Skip to content

Commit

Permalink
fix: check for Schnorr null signature (#6226)
Browse files Browse the repository at this point in the history
# Description

## Problem\*

Resolves #6218 

## Summary\*
return false when signature is null


## Additional Context



## Documentation\*

Check one:
- [X] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [X] I have tested the changes locally.
- [X] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
guipublic authored Oct 4, 2024
1 parent c3cb38a commit 2430920
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions noir_stdlib/src/schnorr.nr
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ pub fn verify_signature_noir<let N: u32>(
for i in 0..32 {
is_ok &= result[i] == signature[32 + i];
}
} else {
is_ok = false;
}
is_ok
}
Expand Down Expand Up @@ -92,3 +94,12 @@ fn calculate_signature_challenge<let N: u32>(
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);
}

0 comments on commit 2430920

Please sign in to comment.