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

starknet_crypto::ecdsa::verify panics #365

Closed
satoshiotomakan opened this issue Apr 26, 2023 · 1 comment · Fixed by #366
Closed

starknet_crypto::ecdsa::verify panics #365

satoshiotomakan opened this issue Apr 26, 2023 · 1 comment · Fixed by #366

Comments

@satoshiotomakan
Copy link

Got a panic while fuzzing testing starknet_crypto::ecdsa::verify:

called Option::unwrap() on a None value
thread 'starkex::tests::test_verify_panic' panicked at 'called Option::unwrap() on a None value', /path/to/starknet-curve-0.2.1/src/ec_point.rs:28:33
stack backtrace:
0: rust_begin_unwind
at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/panicking.rs:577:5
1: core::panicking::panic_fmt
at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/core/src/panicking.rs:67:14
2: core::panicking::panic
at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/core/src/panicking.rs:117:5
3: core::option::Option::unwrap
at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/core/src/option.rs:952:21
4: starknet_curve::ec_point::AffinePoint::from_x
at /path/to/starknet-curve-0.2.1/src/ec_point.rs:28:16
5: starknet_crypto::ecdsa::verify
at /path/to/starknet-crypto-0.4.3/src/ecdsa.rs:144:27

Example:

let hash = any!();
let public = FieldElement::from_bytes_be(hex::decode("03ee9bffffffffff26ffffffff60ffffffffffffffffffffffffffff004accff").unwrap());
let signature_r = FieldElement::from_bytes_be(hex::decode("06ffffffffffffffffffffffffffffffffffffffffffff06ffff5dffff9bffdf").unwrap());
let signature_s = FieldElement::from_bytes_be(hex::decode("00ffffff9b9b9b9b9b9b9b9bbb9bff9b9bbb9bff9b9b9b9b9b9b9b9b9b9b9b33").unwrap());
assert!(!ecdsa_verify(&public, &hash, &signature_r, &signature_s));
@xJonathanLEI
Copy link
Owner

Thanks for reporting! This is apparently a bug when the supplied public key is invalid by itself. Working on a fix now. A new version of starknet-crypto should be published soon.

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 a pull request may close this issue.

2 participants