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

Could the sdk use catch_unwind to catch panic instead of throwing it to caller program directly? #13

Open
berryjam opened this issue Mar 13, 2024 · 0 comments

Comments

@berryjam
Copy link

Hi,I develop a Java app that call the sdk to verify signature.However,the app will crash when calling the sdk with some wrong inputs.
The error looks like:

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Custom { kind: InvalidInput, error: "y is not in field" }', zks-crypto-c/src/[utils.rs:228](http://utils.rs:228/):75
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5 
...

And I found that the sdk will unwrap the result and panic if the signature is wrong.

fn into_signature(signature: &[u8], params: &AltJubjubBn256) -> Signature<Engine> {
    let r: Point<Engine, Unknown> = Point::read(&signature[..32], params).unwrap(); //  the wrong signature will panic and crash the caller program
    let mut s_repr = <Fs as PrimeField>::Repr::default();
    s_repr.read_le(&signature[32..]).unwrap();
    let s = Fs::from_repr(s_repr).unwrap();

    Signature { r, s }
}

Could the sdk return an false instead of panic when calling the function 'verify_musig_rescue'?

@berryjam berryjam changed the title Could sdk use catch_unwind to catch panic instead of throwing it to caller program directly? Could the sdk use catch_unwind to catch panic instead of throwing it to caller program directly? Mar 13, 2024
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

1 participant