Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
cforeman-cqc committed Dec 24, 2023
1 parent bc9c008 commit e7d3547
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions cryptomite/circulant.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def from_params(
The Circulant extractor.
"""
if log2_error >= 0:
raise Exception('''Cannot extract with these parameters.
log2_error must be < 0.''')
raise Exception("""Cannot extract with these parameters.
log2_error must be < 0.""")
input_length = closest_prime((input_length1 + input_length2)//2)
if input_length1 > input_length - 1:
min_entropy1 -= input_length1 - input_length
Expand All @@ -115,9 +115,9 @@ def from_params(
- input_length + 8 * log2_error
+ 8 - 4 * log2(3)))
if output_length <= 0:
raise Exception('''Cannot extract with these parameters.
raise Exception("""Cannot extract with these parameters.
Increase min_entropy1 and/or min_entropy2
and/or log2_error.''')
and/or log2_error.""")
if verbose:
print('Min entropy1: ', min_entropy1,
'Min entropy2: ', min_entropy2,
Expand Down
8 changes: 4 additions & 4 deletions cryptomite/dodis.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ def from_params(
The Dodis extractor.
"""
if log2_error >= 0:
raise Exception('''Cannot extract with these parameters.
log2_error must be < 0.''')
raise Exception("""Cannot extract with these parameters.
log2_error must be < 0.""")
input_length = closest_na_set((input_length1 + input_length2)//2)
if input_length1 > input_length:
min_entropy1 -= input_length1 - input_length
Expand All @@ -113,9 +113,9 @@ def from_params(
- input_length + 8 * log2_error
+ 9 - 4 * log2(3)))
if output_length <= 0:
raise Exception('''Cannot extract with these parameters.
raise Exception("""Cannot extract with these parameters.
Increase min_entropy1 and/or min_entropy2
and/or log2_error.''')
and/or log2_error.""")
if verbose:
print('Min entropy1: ', min_entropy1,
'Min entropy2: ', min_entropy2,
Expand Down
12 changes: 6 additions & 6 deletions cryptomite/toeplitz.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ def from_params(
The Toeplitz extractor.
"""
if log2_error > 0:
raise Exception('''Cannot extract with these parameters.
log2_error must be < 0.''')
raise Exception("""Cannot extract with these parameters.
log2_error must be < 0.""")
if input_length2 <= input_length1:
raise Exception('''Cannot extract with these parameters.
raise Exception("""Cannot extract with these parameters.
Increase the seed length (input_length2).
The seed must be longer than the input.''')
The seed must be longer than the input.""")
if min_entropy2 >= input_length2:
output_length = min_entropy1 + 2 * log2_error
if input_length2 >= output_length + input_length1 - 1:
Expand Down Expand Up @@ -134,9 +134,9 @@ def from_params(
while input_length2 < output_length + input_length1 - 1:
output_length -= 1
if output_length <= 0:
raise Exception('''Cannot extract with these parameters.
raise Exception("""Cannot extract with these parameters.
Increase min_entropy1 and/or min_entropy2
and/or log2_error.''')
and/or log2_error.""")
if verbose:
print('Min entropy1: ', min_entropy1,
'Min entropy2: ', min_entropy2,
Expand Down
20 changes: 10 additions & 10 deletions cryptomite/trevisan.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ def from_params(
The Trevisan extractor.
"""
if log2_error > 0:
raise Exception('''Cannot extract with these parameters.
log2_error must be < 0.''')
raise Exception("""Cannot extract with these parameters.
log2_error must be < 0.""")
if min_entropy2 != input_length2:
raise Exception('''Cannot calcuate with these parameters.
Set min_entropy2 = input_length2.''')
raise Exception("""Cannot calcuate with these parameters.
Set min_entropy2 = input_length2.""")
r = 2 * exp(1)
m = min_entropy1 + 4 * log2_error - 6
output_length = floor(min_entropy1 + 4 * log2_error
Expand All @@ -116,17 +116,17 @@ def from_params(
a = max(1, ceil((log(output_length - r) - log(t - r))
/ (log(r) - log(r-1))))
if markov_q_proof:
m = (1/7) * (min_entropy1 + 6 - 6 * log2(3) +
12 * log2_error)
output_length = floor((1/7) * (min_entropy1 + 6 - 6 * log2(3) +
12 * log2_error - 12 * log2(m)))
m = (1/7) * (min_entropy1 + 6 - 6 * log2(3)
+ 12 * log2_error)
output_length = floor((1/7) * (min_entropy1 + 6 - 6 * log2(3)
+ 12 * log2_error - 12 * log2(m)))
t = 2 * ceil(log2(input_length1) + 1
- 2 * log2_error + 2 * log2(2 * output_length))
a = max(1, ceil((log(output_length - r) - log(t - r))
/ (log(r) - log(r-1))))
if input_length2 < 4 * a * t**2:
raise Exception('''Cannot extract with these parameters.
Increase input_length2.''')
raise Exception("""Cannot extract with these parameters.
Increase input_length2.""")
input_length2 = 4 * a * t**2
if verbose:
print('Min entropy1: ', min_entropy1,
Expand Down

0 comments on commit e7d3547

Please sign in to comment.