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

BIP-0340 Schnorr-compatible signature invalidly uses NonZeroScalar #925

Open
kayabaNerve opened this issue Sep 2, 2023 · 1 comment
Open

Comments

@kayabaNerve
Copy link
Contributor

kayabaNerve commented Sep 2, 2023

BIP-0340's validator criteria doesn't require s is non-zero. While it does require R isn't identity, meaning s will be only be 0 for non-trivial cases, finding a valid signature with an s of 0 is reducible to the birthday problem AFAICT. Accordingly, it wouldn't have 2**128 complexity to find a valid signature such that s == 0, though I'm unsure how significantly reduced the complexity is.

The signature should match BIP-0340 and use Scalar, not NonZeroScalar.

This was commented on by the recent NCC Group audit, though they didn't follow up. (though I'm unsure why). Perhaps they didn't realize the likelihood of a BIP-0340 compliant signature which k256 would rejected was less than 2**128.

References:

/// Taproot Schnorr signature as defined in [BIP340].
///
/// [BIP340]: https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki
#[derive(Copy, Clone)]
pub struct Signature {
r: FieldElement,
s: NonZeroScalar,
}

https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki#verification


Edited to strikeout my misinformed thoughts. While this is the birthday problem, I don't believe an efficient algorithm for solving it exists given how the challenge is binding, meaning this would only break with 2**128 computational complexity AFAIK. Regardless, it's still a spec break...

@tarcieri
Copy link
Member

tarcieri commented Sep 3, 2023

The accessor(s) for s all return NonZeroScalar, so fixing this will require breaking changes.

We can do it as part of the next breaking release.

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

No branches or pull requests

3 participants
@tarcieri @kayabaNerve and others