File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -39,28 +39,29 @@ pub mod scalar {
3939 scalar_poly. iter ( ) . map ( |a| g ! ( a * G ) . normalize ( ) ) . collect ( )
4040 }
4141
42- /// Generate a [`Scalar`] polynomial for key generation
42+ /// Generate a [`Scalar`] polynomial with `length` coefficients.
4343 ///
4444 /// [`Scalar`]: crate::Scalar
45- pub fn generate ( threshold : usize , rng : & mut impl RngCore ) -> Vec < Scalar > {
46- ( 0 ..threshold ) . map ( |_| Scalar :: random ( rng) ) . collect ( )
45+ pub fn generate ( length : usize , rng : & mut impl RngCore ) -> Vec < Scalar > {
46+ ( 0 ..length ) . map ( |_| Scalar :: random ( rng) ) . collect ( )
4747 }
4848
49- /// Generate a [`Scalar`] polynomial for sharing a particular secret scalar.
49+ /// Generate a [`Scalar`] polynomial for sharing a particular `secret` scalar. `length` shares
50+ /// will be needed to reconstruct the secret (or the whole polynomial).
5051 ///
5152 /// ## Panics
5253 ///
53- /// Panics if `threshold ` == 0
54+ /// Panics if `length ` == 0 because the polynomial must have length 1 so the secret can be the first coefficient.
5455 pub fn generate_shamir_sharing_poly < Z : ZeroChoice > (
5556 secret : Scalar < Secret , Z > ,
56- threshold : usize ,
57+ length : usize ,
5758 rng : & mut impl RngCore ,
5859 ) -> Vec < Scalar < Secret , Z > > {
59- if threshold == 0 {
60+ if length == 0 {
6061 panic ! ( "threshold cannot be 0" ) ;
6162 }
6263 core:: iter:: once ( secret)
63- . chain ( ( 1 ..threshold ) . map ( |_| Scalar :: random ( rng) . mark_zero_choice ( ) ) )
64+ . chain ( ( 1 ..length ) . map ( |_| Scalar :: random ( rng) . mark_zero_choice ( ) ) )
6465 . collect ( )
6566 }
6667
You can’t perform that action at this time.
0 commit comments