@@ -12,10 +12,9 @@ use core::convert::TryFrom;
1212use core:: ops:: Add ;
1313
1414use derive_where:: derive_where;
15- use digest:: core_api:: BlockSizeUser ;
16- use digest:: { Digest , Output , OutputSizeUser } ;
15+ use digest:: { Digest , Output } ;
1716use generic_array:: sequence:: Concat ;
18- use generic_array:: typenum:: { IsLess , IsLessOrEqual , Unsigned , U2 , U256 , U9 } ;
17+ use generic_array:: typenum:: { IsLess , Unsigned , U2 , U256 , U9 } ;
1918use generic_array:: { ArrayLength , GenericArray } ;
2019use rand_core:: { CryptoRng , RngCore } ;
2120use subtle:: ConstantTimeEq ;
@@ -79,10 +78,7 @@ impl Mode {
7978pub struct BlindedElement < CS : CipherSuite > (
8079 #[ cfg_attr( feature = "serde" , serde( with = "Element::<CS::Group>" ) ) ]
8180 pub ( crate ) <CS :: Group as Group >:: Elem ,
82- )
83- where
84- <CS :: Hash as OutputSizeUser >:: OutputSize :
85- IsLess < U256 > + IsLessOrEqual < <CS :: Hash as BlockSizeUser >:: BlockSize > ;
81+ ) ;
8682
8783/// The server's response to the [BlindedElement] message from a client (either
8884/// verifiable or not) to a server (either verifiable or not).
9692pub struct EvaluationElement < CS : CipherSuite > (
9793 #[ cfg_attr( feature = "serde" , serde( with = "Element::<CS::Group>" ) ) ]
9894 pub ( crate ) <CS :: Group as Group >:: Elem ,
99- )
100- where
101- <CS :: Hash as OutputSizeUser >:: OutputSize :
102- IsLess < U256 > + IsLessOrEqual < <CS :: Hash as BlockSizeUser >:: BlockSize > ;
95+ ) ;
10396
10497/// Contains prepared [`EvaluationElement`]s by a server batch evaluate
10598/// preparation.
@@ -110,10 +103,7 @@ where
110103 derive( serde:: Deserialize , serde:: Serialize ) ,
111104 serde( bound = "" )
112105) ]
113- pub struct PreparedEvaluationElement < CS : CipherSuite > ( pub ( crate ) EvaluationElement < CS > )
114- where
115- <CS :: Hash as OutputSizeUser >:: OutputSize :
116- IsLess < U256 > + IsLessOrEqual < <CS :: Hash as BlockSizeUser >:: BlockSize > ;
106+ pub struct PreparedEvaluationElement < CS : CipherSuite > ( pub ( crate ) EvaluationElement < CS > ) ;
117107
118108/// A proof produced by a server that the OPRF output matches against a server
119109/// public key.
@@ -124,11 +114,7 @@ where
124114 derive( serde:: Deserialize , serde:: Serialize ) ,
125115 serde( bound = "" )
126116) ]
127- pub struct Proof < CS : CipherSuite >
128- where
129- <CS :: Hash as OutputSizeUser >:: OutputSize :
130- IsLess < U256 > + IsLessOrEqual < <CS :: Hash as BlockSizeUser >:: BlockSize > ,
131- {
117+ pub struct Proof < CS : CipherSuite > {
132118 #[ cfg_attr( feature = "serde" , serde( with = "Scalar::<CS::Group>" ) ) ]
133119 pub ( crate ) c_scalar : <CS :: Group as Group >:: Scalar ,
134120 #[ cfg_attr( feature = "serde" , serde( with = "Scalar::<CS::Group>" ) ) ]
@@ -147,14 +133,10 @@ pub(crate) fn generate_proof<CS: CipherSuite, R: RngCore + CryptoRng>(
147133 k : <CS :: Group as Group >:: Scalar ,
148134 a : <CS :: Group as Group >:: Elem ,
149135 b : <CS :: Group as Group >:: Elem ,
150- cs : impl Iterator < Item = <CS :: Group as Group >:: Elem > + ExactSizeIterator ,
151- ds : impl Iterator < Item = <CS :: Group as Group >:: Elem > + ExactSizeIterator ,
136+ cs : impl ExactSizeIterator < Item = <CS :: Group as Group >:: Elem > ,
137+ ds : impl ExactSizeIterator < Item = <CS :: Group as Group >:: Elem > ,
152138 mode : Mode ,
153- ) -> Result < Proof < CS > >
154- where
155- <CS :: Hash as OutputSizeUser >:: OutputSize :
156- IsLess < U256 > + IsLessOrEqual < <CS :: Hash as BlockSizeUser >:: BlockSize > ,
157- {
139+ ) -> Result < Proof < CS > > {
158140 // https://www.rfc-editor.org/rfc/rfc9497#section-2.2.1
159141
160142 let ( m, z) = compute_composites :: < CS , _ , _ > ( Some ( k) , b, cs, ds, mode) ?;
@@ -209,15 +191,11 @@ where
209191pub ( crate ) fn verify_proof < CS : CipherSuite > (
210192 a : <CS :: Group as Group >:: Elem ,
211193 b : <CS :: Group as Group >:: Elem ,
212- cs : impl Iterator < Item = <CS :: Group as Group >:: Elem > + ExactSizeIterator ,
213- ds : impl Iterator < Item = <CS :: Group as Group >:: Elem > + ExactSizeIterator ,
194+ cs : impl ExactSizeIterator < Item = <CS :: Group as Group >:: Elem > ,
195+ ds : impl ExactSizeIterator < Item = <CS :: Group as Group >:: Elem > ,
214196 proof : & Proof < CS > ,
215197 mode : Mode ,
216- ) -> Result < ( ) >
217- where
218- <CS :: Hash as OutputSizeUser >:: OutputSize :
219- IsLess < U256 > + IsLessOrEqual < <CS :: Hash as BlockSizeUser >:: BlockSize > ,
220- {
198+ ) -> Result < ( ) > {
221199 // https://www.rfc-editor.org/rfc/rfc9497#section-2.2.2
222200 let ( m, z) = compute_composites :: < CS , _ , _ > ( None , b, cs, ds, mode) ?;
223201 let t2 = ( a * & proof. s_scalar ) + & ( b * & proof. c_scalar ) ;
@@ -282,11 +260,7 @@ fn compute_composites<
282260 c_slice : IC ,
283261 d_slice : ID ,
284262 mode : Mode ,
285- ) -> Result < ComputeCompositesResult < CS > >
286- where
287- <CS :: Hash as OutputSizeUser >:: OutputSize :
288- IsLess < U256 > + IsLessOrEqual < <CS :: Hash as BlockSizeUser >:: BlockSize > ,
289- {
263+ ) -> Result < ComputeCompositesResult < CS > > {
290264 // https://www.rfc-editor.org/rfc/rfc9497#section-2.2.1
291265
292266 let elem_len = <CS :: Group as Group >:: ElemLen :: U16 . to_be_bytes ( ) ;
@@ -362,11 +336,7 @@ pub(crate) fn derive_key_internal<CS: CipherSuite>(
362336 seed : & [ u8 ] ,
363337 info : & [ u8 ] ,
364338 mode : Mode ,
365- ) -> Result < <CS :: Group as Group >:: Scalar , Error >
366- where
367- <CS :: Hash as OutputSizeUser >:: OutputSize :
368- IsLess < U256 > + IsLessOrEqual < <CS :: Hash as BlockSizeUser >:: BlockSize > ,
369- {
339+ ) -> Result < <CS :: Group as Group >:: Scalar , Error > {
370340 let dst = Dst :: new :: < CS , _ , _ > ( STR_DERIVE_KEYPAIR , mode) ;
371341
372342 let info_len = i2osp_2 ( info. len ( ) ) . map_err ( |_| Error :: DeriveKeyPair ) ?;
@@ -400,11 +370,7 @@ pub fn derive_key<CS: CipherSuite>(
400370 seed : & [ u8 ] ,
401371 info : & [ u8 ] ,
402372 mode : Mode ,
403- ) -> Result < <CS :: Group as Group >:: Scalar , Error >
404- where
405- <CS :: Hash as OutputSizeUser >:: OutputSize :
406- IsLess < U256 > + IsLessOrEqual < <CS :: Hash as BlockSizeUser >:: BlockSize > ,
407- {
373+ ) -> Result < <CS :: Group as Group >:: Scalar , Error > {
408374 derive_key_internal :: < CS > ( seed, info, mode)
409375}
410376
@@ -418,11 +384,7 @@ pub(crate) fn derive_keypair<CS: CipherSuite>(
418384 seed : & [ u8 ] ,
419385 info : & [ u8 ] ,
420386 mode : Mode ,
421- ) -> Result < DeriveKeypairResult < CS > , Error >
422- where
423- <CS :: Hash as OutputSizeUser >:: OutputSize :
424- IsLess < U256 > + IsLessOrEqual < <CS :: Hash as BlockSizeUser >:: BlockSize > ,
425- {
387+ ) -> Result < DeriveKeypairResult < CS > , Error > {
426388 let sk_s = derive_key_internal :: < CS > ( seed, info, mode) ?;
427389 let pk_s = CS :: Group :: base_elem ( ) * & sk_s;
428390
@@ -438,11 +400,7 @@ pub(crate) fn deterministic_blind_unchecked<CS: CipherSuite>(
438400 input : & [ u8 ] ,
439401 blind : & <CS :: Group as Group >:: Scalar ,
440402 mode : Mode ,
441- ) -> Result < <CS :: Group as Group >:: Elem >
442- where
443- <CS :: Hash as OutputSizeUser >:: OutputSize :
444- IsLess < U256 > + IsLessOrEqual < <CS :: Hash as BlockSizeUser >:: BlockSize > ,
445- {
403+ ) -> Result < <CS :: Group as Group >:: Elem > {
446404 let hashed_point = hash_to_group :: < CS > ( input, mode) ?;
447405 Ok ( hashed_point * blind)
448406}
@@ -451,11 +409,7 @@ where
451409pub ( crate ) fn hash_to_group < CS : CipherSuite > (
452410 input : & [ u8 ] ,
453411 mode : Mode ,
454- ) -> Result < <CS :: Group as Group >:: Elem >
455- where
456- <CS :: Hash as OutputSizeUser >:: OutputSize :
457- IsLess < U256 > + IsLessOrEqual < <CS :: Hash as BlockSizeUser >:: BlockSize > ,
458- {
412+ ) -> Result < <CS :: Group as Group >:: Elem > {
459413 let dst = Dst :: new :: < CS , _ , _ > ( STR_HASH_TO_GROUP , mode) ;
460414 CS :: Group :: hash_to_curve :: < CS :: Hash > ( & [ input] , & dst. as_dst ( ) ) . map_err ( |_| Error :: Input )
461415}
@@ -466,11 +420,7 @@ pub(crate) fn server_evaluate_hash_input<CS: CipherSuite>(
466420 input : & [ u8 ] ,
467421 info : Option < & [ u8 ] > ,
468422 issued_element : GenericArray < u8 , <<CS as CipherSuite >:: Group as Group >:: ElemLen > ,
469- ) -> Result < Output < CS :: Hash > >
470- where
471- <CS :: Hash as OutputSizeUser >:: OutputSize :
472- IsLess < U256 > + IsLessOrEqual < <CS :: Hash as BlockSizeUser >:: BlockSize > ,
473- {
423+ ) -> Result < Output < CS :: Hash > > {
474424 // OPRF & VOPRF
475425 // hashInput = I2OSP(len(input), 2) || input ||
476426 // I2OSP(len(issuedElement), 2) || issuedElement ||
@@ -504,12 +454,11 @@ pub(crate) struct Dst<L: ArrayLength<u8>> {
504454}
505455
506456impl < L : ArrayLength < u8 > > Dst < L > {
507- pub ( crate ) fn new < CS : CipherSuite , T , TL : ArrayLength < u8 > > ( par_1 : T , mode : Mode ) -> Self
457+ pub ( crate ) fn new < CS , T , TL > ( par_1 : T , mode : Mode ) -> Self
508458 where
459+ CS : CipherSuite ,
509460 T : Into < GenericArray < u8 , TL > > ,
510- TL : Add < U9 , Output = L > ,
511- <CS :: Hash as OutputSizeUser >:: OutputSize :
512- IsLess < U256 > + IsLessOrEqual < <CS :: Hash as BlockSizeUser >:: BlockSize > ,
461+ TL : ArrayLength < u8 > + Add < U9 , Output = L > ,
513462 {
514463 let par_1 = par_1. into ( ) ;
515464 // Generates the contextString parameter as defined in
0 commit comments