From 16a3f20c3b974ad263494466384b2f9461316b5b Mon Sep 17 00:00:00 2001 From: guipublic Date: Fri, 4 Oct 2024 11:59:17 +0000 Subject: [PATCH] check for Schnorr null signature --- noir_stdlib/src/schnorr.nr | 11 +++++++++++ 1 file changed, 11 insertions(+) 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); +}