@@ -71,11 +71,14 @@ impl<H: Hash32, NG: NonceGen> CertificationScheme for Schnorr<H, NG> {
7171#[ cfg( feature = "vrf_cert_keygen" ) ]
7272pub mod vrf_cert {
7373 use super :: * ;
74+ use secp256kfun:: digest:: core_api:: BlockSizeUser ;
7475 use vrf_fun:: VrfProof ;
7576
7677 /// VRF certification scheme using SSWU VRF
77- #[ derive( Clone , Debug , PartialEq ) ]
78- pub struct VrfCertifier ;
78+ #[ derive( Clone , Copy , Debug , PartialEq , Default ) ]
79+ pub struct VrfCertifier < H > {
80+ hash : core:: marker:: PhantomData < H > ,
81+ }
7982
8083 /// The output from VRF verification containing the gamma point
8184 #[ derive( Clone , Debug , PartialEq ) ]
@@ -85,7 +88,7 @@ pub mod vrf_cert {
8588 }
8689
8790 /// Implement CertificationScheme for VrfCertifier
88- impl CertificationScheme for VrfCertifier {
91+ impl < H : Hash32 + BlockSizeUser > CertificationScheme for VrfCertifier < H > {
8992 type Signature = VrfProof ;
9093 type Output = VrfOutput ;
9194
@@ -96,7 +99,7 @@ pub mod vrf_cert {
9699 ) -> Self :: Signature {
97100 // Use the certification bytes as the VRF input
98101 let cert_bytes = agg_input. cert_bytes ( ) ;
99- vrf_fun:: rfc9381:: sswu:: prove :: < sha2 :: Sha256 > ( keypair, & cert_bytes)
102+ vrf_fun:: rfc9381:: sswu:: prove :: < H > ( keypair, & cert_bytes)
100103 }
101104
102105 fn verify_cert (
@@ -107,11 +110,11 @@ pub mod vrf_cert {
107110 ) -> Option < Self :: Output > {
108111 // Use the certification bytes as the VRF input
109112 let cert_bytes = agg_input. cert_bytes ( ) ;
110- vrf_fun:: rfc9381:: sswu:: verify :: < sha2 :: Sha256 > ( cert_key, & cert_bytes, signature) . map (
111- |output| VrfOutput {
113+ vrf_fun:: rfc9381:: sswu:: verify :: < H > ( cert_key, & cert_bytes, signature) . map ( |output| {
114+ VrfOutput {
112115 gamma : output. gamma ,
113- } ,
114- )
116+ }
117+ } )
115118 }
116119 }
117120}
@@ -277,7 +280,9 @@ impl<S: CertificationScheme> CertifiedKeygen<S> {
277280}
278281
279282#[ cfg( feature = "vrf_cert_keygen" ) ]
280- impl CertifiedKeygen < vrf_cert:: VrfCertifier > {
283+ impl < H : Hash32 + secp256kfun:: digest:: crypto_common:: BlockSizeUser >
284+ CertifiedKeygen < vrf_cert:: VrfCertifier < H > >
285+ {
281286 /// Compute a randomness beacon from the VRF outputs
282287 ///
283288 /// This function hashes all the VRF gamma points together to produce
@@ -303,16 +308,14 @@ impl CertifiedKeygen<vrf_cert::VrfCertifier> {
303308 /// different views of the keygen outcome without detection, achieving similar
304309 /// security to comparing a full 32-byte hash but with better usability.
305310 pub fn compute_randomness_beacon ( & self ) -> [ u8 ; 32 ] {
306- use sha2:: { Digest , Sha256 } ;
307-
308- let mut hasher = Sha256 :: new ( ) ;
311+ let mut hasher = H :: default ( ) ;
309312
310313 // BTreeMap already maintains sorted order by key
311314 for output in self . outputs . values ( ) {
312- hasher. update ( output. gamma . to_bytes ( ) ) ;
315+ hasher. update ( output. gamma . to_bytes ( ) . as_ref ( ) ) ;
313316 }
314317
315- hasher. finalize ( ) . into ( )
318+ hasher. finalize_fixed ( ) . into ( )
316319 }
317320}
318321
@@ -590,7 +593,7 @@ mod test {
590593 use proptest:: test_runner:: { RngAlgorithm , TestRng } ;
591594
592595 let schnorr = crate :: new_with_deterministic_nonces :: < sha2:: Sha256 > ( ) ;
593- let vrf_certifier = vrf_cert:: VrfCertifier ;
596+ let vrf_certifier = vrf_cert:: VrfCertifier :: < sha2 :: Sha256 > :: default ( ) ;
594597 let mut rng = TestRng :: deterministic_rng ( RngAlgorithm :: ChaCha ) ;
595598
596599 let threshold = 2 ;
0 commit comments