diff --git a/noir_stdlib/src/schnorr.nr b/noir_stdlib/src/schnorr.nr index e24aabf3cda..0623f116dea 100644 --- a/noir_stdlib/src/schnorr.nr +++ b/noir_stdlib/src/schnorr.nr @@ -41,6 +41,8 @@ pub fn verify_signature_noir( for i in 0..32 { is_ok &= result[i] == signature[32 + i]; } + } else { + is_ok = false; } is_ok } @@ -92,3 +94,12 @@ fn calculate_signature_challenge( let result = crate::hash::blake2s(hash_input); (r.is_infinite, result) } + +#[test] +fn test_zero_signature() { + let public_key: EmbeddedCurvePoint = EmbeddedCurvePoint { x: 1, y: 17631683881184975370165255887551781615748388533673675138860, is_infinite: false }; + let signature: [u8; 64] = [0; 64]; + let message: [u8; _] = [2; 64]; // every message + let verified = verify_signature_noir(public_key, signature, message); + assert(!verified); +}