Make trait SignatureVerifierBuilder

This commit is contained in:
Brian Lawrence
2024-09-30 15:44:27 -07:00
parent 8e25c44603
commit 4037853be8
2 changed files with 25 additions and 5 deletions

View File

@@ -19,8 +19,6 @@ use crate::schnorr::{SchnorrPublicKey, SchnorrSignature};
type GoldF = GoldilocksField; type GoldF = GoldilocksField;
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct Mod65537Generator { pub struct Mod65537Generator {
a: Target, a: Target,

View File

@@ -78,8 +78,30 @@ impl SchnorrPublicKeyTarget {
pub struct SchnorrBuilder {} pub struct SchnorrBuilder {}
impl SchnorrBuilder { pub trait SignatureVerifierBuilder {
pub fn constrain_sig < fn constrain_sig <
C: GenericConfig<2, F = GoldF>,
> (
&self,
builder: &mut CircuitBuilder::<GoldF, 2>,
sig: &SchnorrSignatureTarget,
msg: &MessageTarget,
pk: &SchnorrPublicKeyTarget,
);
fn verify_sig <
C: GenericConfig<2, F = GoldF>,
> (
&self,
builder: &mut CircuitBuilder::<GoldF, 2>,
sig: &SchnorrSignatureTarget,
msg: &MessageTarget,
pk: &SchnorrPublicKeyTarget,
) -> BoolTarget;
}
impl SignatureVerifierBuilder for SchnorrBuilder {
fn constrain_sig <
C: GenericConfig<2, F = GoldF>, C: GenericConfig<2, F = GoldF>,
> ( > (
&self, &self,
@@ -93,7 +115,7 @@ impl SchnorrBuilder {
builder.connect(verification_output.target, true_target.target); builder.connect(verification_output.target, true_target.target);
} }
pub fn verify_sig < fn verify_sig <
C: GenericConfig<2, F = GoldF>, C: GenericConfig<2, F = GoldF>,
> ( > (
&self, &self,