From 6b94b9efcdfc103adcfeac681f3e1a9a0723bba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A8Jeff?= <¨burdges@gnunet.org¨> Date: Tue, 28 Nov 2023 13:36:19 +0100 Subject: [PATCH] EcVrfSigner trait support consumable preproofs --- bandersnatch_vrfs/src/lib.rs | 6 +++--- dleq_vrf/src/thin.rs | 6 +++--- dleq_vrf/src/traits.rs | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bandersnatch_vrfs/src/lib.rs b/bandersnatch_vrfs/src/lib.rs index a766957e..a7267c51 100644 --- a/bandersnatch_vrfs/src/lib.rs +++ b/bandersnatch_vrfs/src/lib.rs @@ -218,12 +218,12 @@ impl<'a> EcVrfSigner for RingProver<'a> { type Error = (); type Secret = SecretKey; fn vrf_sign_detached( - &self, + self, t: impl IntoTranscript, ios: &[VrfInOut] ) -> Result { - let RingProver { ring_prover, secret } = *self; + let RingProver { ring_prover, secret } = self; let secret_blinding = None; // TODO: Set this first so we can hash the ring proof let (dleq_proof,secret_blinding) = pedersen_vrf().sign_pedersen_vrf(t, ios, secret_blinding, secret); let ring_proof = ring_prover.prove(secret_blinding.0[0]); @@ -233,7 +233,7 @@ impl<'a> EcVrfSigner for RingProver<'a> { impl<'a> RingProver<'a> { pub fn sign_ring_vrf( - &self, + self, t: impl IntoTranscript, ios: &[VrfInOut; N], ) -> RingVrfSignature diff --git a/dleq_vrf/src/thin.rs b/dleq_vrf/src/thin.rs index 69fa43df..8ab21dfa 100644 --- a/dleq_vrf/src/thin.rs +++ b/dleq_vrf/src/thin.rs @@ -245,12 +245,12 @@ impl PublicKey { } } -impl EcVrfSigner for SecretKey { +impl EcVrfSigner for &SecretKey { type Proof = ThinVrfProof; type Error = (); - type Secret = Self; + type Secret = SecretKey; fn vrf_sign_detached( - &self, + self, t: impl IntoTranscript, ios: &[VrfInOut] ) -> Result diff --git a/dleq_vrf/src/traits.rs b/dleq_vrf/src/traits.rs index d3c1d958..362cda7e 100644 --- a/dleq_vrf/src/traits.rs +++ b/dleq_vrf/src/traits.rs @@ -261,7 +261,7 @@ pub trait EcVrfVerifier { /// /// Inherent methods and other traits being used here: /// `IntoTranscript`, `vrf::{VrfInOut, VrfPreOut}` -pub trait EcVrfSigner: Borrow { +pub trait EcVrfSigner: Sized+Borrow { /// Detached signature aka proof type created by the VRF type Proof: EcVrfProof; @@ -273,14 +273,14 @@ pub trait EcVrfSigner: Borrow { type Secret: EcVrfSecret>; fn vrf_sign_detached( - &self, + self, t: impl IntoTranscript, ios: &[IO] ) -> Result; /// VRF signature for a fixed number of input-output pairs fn vrf_sign( - &self, + self, t: impl IntoTranscript, ios: &[IO; N] ) -> Result,Self::Error> @@ -296,7 +296,7 @@ pub trait EcVrfSigner: Borrow { /// more for pedagogy than for convenience. It demonstrates choosing /// whether we sign the VRF, and what else we sign in its transcript, /// after examining the VRF output. - fn vrf_sign_one(&self, input: I, mut check: F) -> Result,Self::Error> + fn vrf_sign_one(self, input: I, mut check: F) -> Result,Self::Error> where I: IntoVrfInput>, T: IntoTranscript, @@ -309,7 +309,7 @@ pub trait EcVrfSigner: Borrow { /// VRF signature for a variable number of input-output pairs. fn vrf_sign_vec( - &self, + self, t: impl IntoTranscript, ios: &[IO] ) -> Result,Self::Error>