Skip to content

Commit

Permalink
feat: switch to using an external noir implementation of Schnorr (#10330
Browse files Browse the repository at this point in the history
)

This PR replaces usage of the stdlib implementation of schnorr with the
external library https://github.com/noir-lang/schnorr
  • Loading branch information
TomAFrench authored Dec 4, 2024
1 parent 17fa214 commit 6cbd375
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ type = "contract"
[dependencies]
aztec = { path = "../../../aztec-nr/aztec" }
authwit = { path = "../../../aztec-nr/authwit" }
schnorr = { tag = "v0.1.1", git = "https://github.com/noir-lang/schnorr" }
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use dep::aztec::macros::aztec;

#[aztec]
contract SchnorrAccount {
use dep::std;

use dep::authwit::{
account::AccountActions,
auth::{compute_authwit_message_hash, compute_authwit_nullifier},
Expand Down Expand Up @@ -83,7 +81,7 @@ contract SchnorrAccount {
is_infinite: false,
};
// Verify signature of the payload bytes
std::schnorr::verify_signature(pub_key, signature, outer_hash.to_be_bytes::<32>())
schnorr::verify_signature(pub_key, signature, outer_hash.to_be_bytes::<32>())
// docs:end:is_valid_impl
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ type = "contract"
[dependencies]
aztec = { path = "../../../aztec-nr/aztec" }
authwit = { path = "../../../aztec-nr/authwit" }
schnorr = { tag = "v0.1.1", git = "https://github.com/noir-lang/schnorr" }
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ contract SchnorrHardcodedAccount {
}

// Verify signature using hardcoded public key
std::schnorr::verify_signature(public_key, signature, outer_hash.to_be_bytes::<32>())
schnorr::verify_signature(public_key, signature, outer_hash.to_be_bytes::<32>())
}
// docs:end:is-valid
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ type = "contract"
[dependencies]
aztec = { path = "../../../aztec-nr/aztec" }
authwit = { path = "../../../aztec-nr/authwit" }
schnorr = { tag = "v0.1.1", git = "https://github.com/noir-lang/schnorr" }
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::auth_oracle::AuthWitness;
use dep::aztec::prelude::AztecAddress;
use std::{embedded_curve_ops::EmbeddedCurvePoint, schnorr::verify_signature};
use std::embedded_curve_ops::EmbeddedCurvePoint;

pub fn recover_address(message_hash: Field, witness: AuthWitness) -> AztecAddress {
let message_bytes: [u8; 32] = message_hash.to_be_bytes();
Expand All @@ -11,8 +11,7 @@ pub fn recover_address(message_hash: Field, witness: AuthWitness) -> AztecAddres
};

// In a single key account contract we re-used ivpk_m as signing key
let verification = verify_signature(public_key, witness.signature, message_bytes);
assert(verification == true);
schnorr::assert_valid_signature(public_key, witness.signature, message_bytes);

AztecAddress::compute(witness.keys, witness.partial_address)
}

0 comments on commit 6cbd375

Please sign in to comment.