-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery refactored master branch #24
Conversation
from sage.all_cmdline import * | ||
from sage.all_cmdline import * | ||
import gmpy2 | ||
|
||
# order is from secp256k1 curve it can be used any other. | ||
order = int(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141) | ||
order = 115792089237316195423570985008687907852837564279074904382605163141518161494337 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 10-14
refactored with the following changes:
- Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
)
if limit == None: | ||
if limit is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function load_csv
refactored with the following changes:
- Use x is None rather than x == None (
none-compare
)
@@ -76,7 +76,6 @@ def privkeys_from_reduced_matrix(msgs, sigs, pubs, matrix): | |||
keys.append(key) | |||
except Exception as e: | |||
sys.stderr.write(str(e)+"\n") | |||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function privkeys_from_reduced_matrix
refactored with the following changes:
- Remove redundant pass statement (
remove-redundant-pass
)
keys = privkeys_from_reduced_matrix(msgs, sigs, pubs, new_matrix) | ||
else: | ||
new_matrix = matrix.BKZ(early_red=True, use_siegel=True) | ||
keys = privkeys_from_reduced_matrix(msgs, sigs, pubs, new_matrix) | ||
|
||
keys = privkeys_from_reduced_matrix(msgs, sigs, pubs, new_matrix) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function main
refactored with the following changes:
- Hoist repeated code outside conditional statement (
hoist-statement-from-if
)
nonces = [fixed_bits + random.randrange(1, 2 ** bits) for i in range(n)] | ||
nonces = [fixed_bits + random.randrange(1, 2 ** bits) for _ in range(n)] | ||
else: | ||
# generate n least significant bits, nonce must be less than order | ||
nonces = [random.randrange(2 ** bits, order) + fixed_bits for i in range(n)] | ||
nonces = [random.randrange(2 ** bits, order) + fixed_bits for _ in range(n)] | ||
|
||
msgs = [random.randrange(1, order) for i in range(n)] | ||
msgs = [random.randrange(1, order) for _ in range(n)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 22-27
refactored with the following changes:
- Replace unused for index with underscore [×3] (
for-index-underscore
)
tmpstr = hex(i) | ||
hexstr = tmpstr.replace('0x','').replace('L','').zfill(64) | ||
return hexstr | ||
tmpstr = hex(i) | ||
return tmpstr.replace('0x','').replace('L','').zfill(64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function inttohex
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
print("%s,%s,%s,%s,%s" % ("1111",inttohex(sigs[i].r),inttohex(sigs[i].s),inttohex(msgs[i]),"0000")) | ||
print( | ||
f"1111,{inttohex(sigs[i].r)},{inttohex(sigs[i].s)},{inttohex(msgs[i])},0000" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 36-36
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
) - Simplify unnecessary nesting, casting and constant values in f-strings (
simplify-fstring-formatting
)
30b3549
to
47353a3
Compare
Branch
master
refactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run:Help us improve this pull request!