Skip to content
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

fix R and S may not be 32 bytes #130

Merged
merged 2 commits into from
Apr 2, 2021
Merged

fix R and S may not be 32 bytes #130

merged 2 commits into from
Apr 2, 2021

Conversation

ackratos
Copy link
Collaborator

@ackratos ackratos commented Mar 23, 2021

The R and S might not be less than 32 bytes, if we return such R and S and the client code concatenates these two bytes together, the signature would not be 64 bytes. Such signature would fail for blockchains (for example Ethereum) that check the signature length: https://github.com/ethereum/go-ethereum/blob/master/crypto/secp256k1/secp256.go#L169-L171

@ackratos ackratos self-assigned this Mar 23, 2021

func fillTo32BytesInPlace(src []byte) []byte {
oriLen := len(src)
if oriLen < 32 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really minor : I think it would have been nicer to accept the wanted length as another input parameter to the function.
Besides that I would also rename the function to padToLengthBytesInPlace

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

padToLengthBytesInPlace +1

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx, updated!

omershlo
omershlo previously approved these changes Mar 24, 2021
FitzLu
FitzLu previously approved these changes Mar 25, 2021
@ackratos ackratos dismissed stale reviews from FitzLu and omershlo via 95db485 March 28, 2021 10:20
@ackratos ackratos merged commit 49366aa into master Apr 2, 2021
ackratos added a commit that referenced this pull request Apr 2, 2021
* fix R and S may not be 32 bytes

* refactor according to review comments

(cherry picked from commit 49366aa)

# Conflicts:
#	ecdsa/signing/finalize.go
#	ecdsa/signing/local_party_test.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants