File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,8 +25,6 @@ pub enum Error {
2525 HandoffMismatch ,
2626 #[ error( "handoff not found" ) ]
2727 HandoffNotFound ,
28- #[ error( "identity decoding failed" ) ]
29- IdentityDecodingFailed ,
3028 #[ error( "invalid bivariate polynomial" ) ]
3129 InvalidBivariatePolynomial ,
3230 #[ error( "invalid data" ) ]
@@ -55,6 +53,8 @@ pub enum Error {
5553 PolynomialDecodingFailed ,
5654 #[ error( "runtime mismatch" ) ]
5755 RuntimeMismatch ,
56+ #[ error( "scalar decoding failed" ) ]
57+ ScalarDecodingFailed ,
5858 #[ error( "shareholder mismatch" ) ]
5959 ShareholderMismatch ,
6060 #[ error( "shareholder not found" ) ]
Original file line number Diff line number Diff line change @@ -237,7 +237,7 @@ where
237237 type Error = Error ;
238238
239239 fn try_from ( encoded : & EncodedSecretShare ) -> Result < Self , Self :: Error > {
240- let x = scalar_from_bytes ( & encoded. x ) . ok_or ( Error :: IdentityDecodingFailed ) ?;
240+ let x = scalar_from_bytes ( & encoded. x ) . ok_or ( Error :: ScalarDecodingFailed ) ?;
241241 let p =
242242 Polynomial :: from_bytes ( & encoded. polynomial ) . ok_or ( Error :: PolynomialDecodingFailed ) ?;
243243 let share = SecretShare :: new ( x, p) ;
@@ -274,14 +274,17 @@ where
274274 type Error = Error ;
275275
276276 fn try_from ( encoded : EncodedEncryptedPoint ) -> Result < Self , Self :: Error > {
277- let x = scalar_from_bytes ( & encoded. x ) . ok_or ( Error :: IdentityDecodingFailed ) ?;
277+ let x = scalar_from_bytes ( & encoded. x ) . ok_or ( Error :: ScalarDecodingFailed ) ?;
278278
279279 let mut repr: G :: Repr = Default :: default ( ) ;
280280 let slice = & mut repr. as_mut ( ) [ ..] ;
281+ if slice. len ( ) != encoded. z . len ( ) {
282+ return Err ( Error :: ScalarDecodingFailed ) ;
283+ }
281284 slice. copy_from_slice ( & encoded. z ) ;
282285
283286 let z = match G :: from_bytes ( & repr) . into ( ) {
284- None => return Err ( Error :: IdentityDecodingFailed ) ,
287+ None => return Err ( Error :: ScalarDecodingFailed ) ,
285288 Some ( z) => z,
286289 } ;
287290
You can’t perform that action at this time.
0 commit comments