-
Notifications
You must be signed in to change notification settings - Fork 82
Conversation
# r1 and s1 are contained in this ECDSA signature encoded in DER (openssl default). | ||
der_sig1 = "3044" | ||
der_sig1 += "0220d47ce4c025c35ec440bc81d99834a624875161a26bf56ef7fdc0f5d52f843ad1" | ||
der_sig1 = ( | ||
"3044" | ||
+ "0220d47ce4c025c35ec440bc81d99834a624875161a26bf56ef7fdc0f5d52f843ad1" | ||
) | ||
der_sig1 += "022044e1ff2dfd8102cf7a47c21d5c9fd5701610d04953c6836596b4fe9dd2f53e3e" | ||
der_sig1 += "01" | ||
|
||
# the same thing with the above line. | ||
der_sig2 = "3044" | ||
der_sig2 += "0220d47ce4c025c35ec440bc81d99834a624875161a26bf56ef7fdc0f5d52f843ad1" | ||
der_sig2 = ( | ||
"3044" | ||
+ "0220d47ce4c025c35ec440bc81d99834a624875161a26bf56ef7fdc0f5d52f843ad1" | ||
) |
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 45-53
refactored with the following changes:
- Replace assignment and augmented assignment with single assignment [×2] (
merge-assign-and-aug-assign
)
This removes the following comments ( why? ):
# the same thing with the above line.
# r1 and s1 are contained in this ECDSA signature encoded in DER (openssl default).
a = "0" + a | ||
res = base58_encode(int("0x" + a, 16)) | ||
a = f"0{a}" | ||
res = base58_encode(int(f"0x{a}", 16)) |
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 base58_encode_padded
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
string = binary[i + 2 : end] | ||
return string | ||
return binary[i + 2 : end] |
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 py2_get_der_field
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
string = binary[i + 2 : end] | ||
return string | ||
return binary[i + 2 : end] |
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 py3_get_der_field
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
if (full_length + 3) == len(binary): | ||
r = py2_get_der_field(2, binary) | ||
s = py2_get_der_field(len(r) + 4, binary) | ||
return r, s | ||
else: | ||
if full_length + 3 != len(binary): | ||
return None | ||
r = py2_get_der_field(2, binary) | ||
s = py2_get_der_field(len(r) + 4, binary) | ||
return r, s |
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 py2_der_decode
refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches
) - Remove unnecessary else after guard condition (
remove-unnecessary-else
)
print("hexPrivkey = %s" % hexprivkey) | ||
print(f"hexPrivkey = {hexprivkey}") | ||
wif = base58_check_encode(binascii.unhexlify(hexprivkey), version=128) | ||
print("bitcoin Privkey (WIF) = %s" % wif) | ||
wif = base58_check_encode(binascii.unhexlify(hexprivkey + "01"), version=128) | ||
print("bitcoin Privkey (WIF compressed) = %s" % wif) | ||
print(f"bitcoin Privkey (WIF) = {wif}") | ||
wif = base58_check_encode(binascii.unhexlify(f"{hexprivkey}01"), version=128) | ||
print(f"bitcoin Privkey (WIF compressed) = {wif}") |
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 show_results
refactored with the following changes:
- Replace interpolated string formatting with f-string [×3] (
replace-interpolation-with-fstring
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
print("%s: %s" % (param, params[param])) | ||
print(f"{param}: {params[param]}") |
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 show_params
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
privkey = [] | ||
privkey = [inverse_mult(((z1 * s2) - (z2 * s1)), (r * (s1 - s2)), p) % int(p)] | ||
|
||
privkey.append((inverse_mult(((z1 * s2) - (z2 * s1)), (r * (s1 - s2)), p) % int(p))) |
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 derivate_privkey
refactored with the following changes:
- Merge append into list declaration (
merge-list-append
)
privkey = [ | ||
return [ |
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 derivate_privkey_fast
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
privkey = derivate_privkey_fast(p, r1, s1, s2, z1, z2) | ||
return privkey | ||
return derivate_privkey_fast(p, r1, s1, s2, z1, z2) |
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 process_signatures
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
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!