diff --git a/noir_stdlib/src/eddsa.nr b/noir_stdlib/src/eddsa.nr new file mode 100644 index 00000000000..068712ff838 --- /dev/null +++ b/noir_stdlib/src/eddsa.nr @@ -0,0 +1,70 @@ +use crate::hash::poseidon; +use crate::ec::tecurve::affine::Point as TEPoint; +use crate::ec::tecurve::affine::Curve as AffineCurve; + +fn eddsa_poseidon_verify( + pub_key_x: Field, + pub_key_y: Field, + signature_s: Field, + signature_r8_x: Field, + signature_r8_y: Field, + message: Field, +) -> bool { + // Verifies by testing: + // S * G8 = R8 + H(R8, A, m) * A8 + + // TODO: lift bjj into shared const/config module + // Define Baby Jubjub (ERC-2494) parameters in affine representation + let bjj = AffineCurve::new( + 168700, + 168696, + TEPoint::new( + 995203441582195749578291179787384436505546430278305826713579947235728471134, + 5472060717959818805561601436314318772137091100104008585924551046643952123905 + ), + ); + + let pub_key = TEPoint::new(pub_key_x, pub_key_y); + constrain bjj.contains(pub_key); + + let signature_r8 = TEPoint::new(signature_r8_x, signature_r8_y); + constrain bjj.contains(signature_r8); + + + // Ensure S