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

refactor: remove low S check from util-crypto #938

Merged

Conversation

jjyr
Copy link
Contributor

@jjyr jjyr commented Jun 3, 2019

Cause we already use witness, the low S rule for signature is unnecessary.

See https://github.com/bitcoin/bips/blob/master/bip-0062.mediawiki#new-rules

@jjyr jjyr requested a review from a team June 3, 2019 07:30
@nervos-bot
Copy link

nervos-bot bot commented Jun 3, 2019

@quake is assigned as the chief reviewer

@jjyr jjyr requested a review from zhangsoledad June 3, 2019 07:30
@@ -74,7 +65,7 @@ impl Signature {
return false;
}
};
self.v() <= 1 && h_r < N && h_r >= ONE && h_s < N && h_s >= ONE
self.v() < 4 && h_r < N && h_r >= ONE && h_s < N && h_s >= ONE
Copy link
Member

Choose a reason for hiding this comment

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

why is this change needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After checking the source code of secp256k1 and peter wullies's answer, it seems in practice the v is only considered either 0 or 1.

I'll rollback this.

https://github.com/bitcoin-core/secp256k1/blob/544435fc90a5672d862e2a51f44c10251893b97d/src/ecdsa_impl.h#L298

https://bitcoin.stackexchange.com/questions/38351/ecdsa-v-r-s-what-is-v

@jjyr jjyr force-pushed the remove-low_s-verify-from-util-crypto branch from b252adf to 468b881 Compare June 3, 2019 14:00
@jjyr jjyr merged commit 53bdf31 into nervosnetwork:develop Jun 4, 2019
@jjyr jjyr deleted the remove-low_s-verify-from-util-crypto branch June 4, 2019 00:57
This was referenced Jun 21, 2019
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.

None yet

4 participants