Skip to content

Commit

Permalink
fix(ssa refactor): schnorr signature handling (#1727)
Browse files Browse the repository at this point in the history
* fix(ssa refactor): schnorr inputs

* chore(ssa refactor): cp working test
  • Loading branch information
joss-aztec committed Jun 16, 2023
1 parent a1596bc commit 98ecf93
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
message = [0,1,2,3,4,5,6,7,8,9]
pub_key_x = "0x17cbd3ed3151ccfd170efe1d54280a6a4822640bf5c369908ad74ea21518a9c5"
pub_key_y = "0x0e0456e3795c1a31f20035b741cd6158929eeccd320d299cfcac962865a6bc74"
signature = [
5, 202, 31, 146, 81, 242, 246, 69, 43, 107, 249, 153, 198, 44, 14, 111, 191, 121, 137, 166,
160, 103, 18, 181, 243, 233, 226, 95, 67, 16, 37, 128, 85, 76, 19, 253, 30, 77, 192, 53, 138,
205, 69, 33, 236, 163, 83, 194, 84, 137, 184, 221, 176, 121, 179, 27, 63, 70, 54, 16, 176,
250, 39, 239,
]
10 changes: 10 additions & 0 deletions crates/nargo_cli/tests/test_data_ssa_refactor/schnorr/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use dep::std;

// Note: If main has any unsized types, then the verifier will never be able
// to figure out the circuit instance
fn main(message: [u8; 10], pub_key_x: Field, pub_key_y: Field, signature: [u8; 64]) {
// Is there ever a situation where someone would want
// to ensure that a signature was invalid?
let valid_signature = std::schnorr::verify_signature(pub_key_x,pub_key_y,signature, message);
assert(valid_signature);
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ impl GeneratedAcir {
BlackBoxFunc::SchnorrVerify => BlackBoxFuncCall::SchnorrVerify {
public_key_x: inputs[0],
public_key_y: inputs[1],
// Schnorr signature is two field field elements (r,s)
signature: vec![inputs[2], inputs[3]],
message: inputs[4..].to_vec(),
// Schnorr signature is an r & s, 32 bytes each
signature: inputs[2..66].to_vec(),
message: inputs[66..].to_vec(),
output: outputs[0],
},
BlackBoxFunc::Pedersen => BlackBoxFuncCall::Pedersen {
Expand Down

0 comments on commit 98ecf93

Please sign in to comment.