From 4037853be879c0049506c4e7c66b9d5361c6ab48 Mon Sep 17 00:00:00 2001 From: Brian Lawrence Date: Mon, 30 Sep 2024 15:44:27 -0700 Subject: [PATCH] Make trait SignatureVerifierBuilder --- src/mod65537.rs | 2 -- src/schnorr_prover.rs | 28 +++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/mod65537.rs b/src/mod65537.rs index 84ac9e5..d901b02 100644 --- a/src/mod65537.rs +++ b/src/mod65537.rs @@ -19,8 +19,6 @@ use crate::schnorr::{SchnorrPublicKey, SchnorrSignature}; type GoldF = GoldilocksField; - - #[derive(Debug, Default)] pub struct Mod65537Generator { a: Target, diff --git a/src/schnorr_prover.rs b/src/schnorr_prover.rs index 16dbe75..6fc8139 100644 --- a/src/schnorr_prover.rs +++ b/src/schnorr_prover.rs @@ -78,8 +78,30 @@ impl SchnorrPublicKeyTarget { pub struct SchnorrBuilder {} -impl SchnorrBuilder { - pub fn constrain_sig < +pub trait SignatureVerifierBuilder { + fn constrain_sig < + C: GenericConfig<2, F = GoldF>, + > ( + &self, + builder: &mut CircuitBuilder::, + sig: &SchnorrSignatureTarget, + msg: &MessageTarget, + pk: &SchnorrPublicKeyTarget, + ); + + fn verify_sig < + C: GenericConfig<2, F = GoldF>, + > ( + &self, + builder: &mut CircuitBuilder::, + sig: &SchnorrSignatureTarget, + msg: &MessageTarget, + pk: &SchnorrPublicKeyTarget, + ) -> BoolTarget; +} + +impl SignatureVerifierBuilder for SchnorrBuilder { + fn constrain_sig < C: GenericConfig<2, F = GoldF>, > ( &self, @@ -93,7 +115,7 @@ impl SchnorrBuilder { builder.connect(verification_output.target, true_target.target); } - pub fn verify_sig < + fn verify_sig < C: GenericConfig<2, F = GoldF>, > ( &self,