Skip to content
This repository has been archived by the owner on Nov 15, 2024. It is now read-only.

Sourcery refactored master branch #13

Merged
merged 1 commit into from
Nov 27, 2023
Merged

Sourcery refactored master branch #13

merged 1 commit into from
Nov 27, 2023

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Nov 27, 2023

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:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from daedalus November 27, 2023 18:34
Comment on lines -45 to +55
# 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"
)
Copy link
Author

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:

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).

Comment on lines -78 to +81
a = "0" + a
res = base58_encode(int("0x" + a, 16))
a = f"0{a}"
res = base58_encode(int(f"0x{a}", 16))
Copy link
Author

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:

Comment on lines -102 to +104
string = binary[i + 2 : end]
return string
return binary[i + 2 : end]
Copy link
Author

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:

Comment on lines -112 to +113
string = binary[i + 2 : end]
return string
return binary[i + 2 : end]
Copy link
Author

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:

Comment on lines -122 to +126
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
Copy link
Author

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:

Comment on lines -146 to +148
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}")
Copy link
Author

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:

Comment on lines -158 to +156
print("%s: %s" % (param, params[param]))
print(f"{param}: {params[param]}")
Copy link
Author

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:

Comment on lines -171 to -173
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)))
Copy link
Author

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:

Comment on lines -199 to +196
privkey = [
return [
Copy link
Author

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:

Comment on lines -243 to +238
privkey = derivate_privkey_fast(p, r1, s1, s2, z1, z2)
return privkey
return derivate_privkey_fast(p, r1, s1, s2, z1, z2)
Copy link
Author

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:

@daedalus daedalus merged commit 79ad1d0 into master Nov 27, 2023
2 of 4 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant