1+ use super :: ShareIndex ;
12use secp256kfun:: { poly, prelude:: * } ;
23/// A *[Shamir secret share]*.
34///
@@ -87,8 +88,11 @@ impl SecretShare {
8788 }
8889
8990 /// Get the image of the secret share.
90- pub fn share_image ( & self ) -> Point < NonNormal , Public , Zero > {
91- g ! ( self . share * G )
91+ pub fn share_image ( & self ) -> ShareImage {
92+ ShareImage {
93+ index : self . index ,
94+ image : g ! ( self . share * G ) . normalize ( ) ,
95+ }
9296 }
9397}
9498
@@ -265,12 +269,12 @@ impl PairedSecretShare<Normal> {
265269
266270impl PairedSecretShare < EvenY > {
267271 /// Get the verification for the inner secret share.
268- pub fn verification_share ( & self ) -> VerificationShare < NonNormal > {
269- VerificationShare {
272+ pub fn verification_share ( & self ) -> VerificationShare {
273+ VerificationShare ( ShareImage {
270274 index : self . index ( ) ,
271- share_image : self . secret_share . share_image ( ) ,
272- public_key : self . public_key ,
273- }
275+ // we don't use SecretShare:: share_image because it normalizes which is unecessary here
276+ image : g ! ( self . secret_share . share * G ) ,
277+ } )
274278 }
275279}
276280
@@ -286,14 +290,7 @@ impl PairedSecretShare<EvenY> {
286290///
287291/// [`share_image`]: SecretShare::share_image
288292#[ derive( Clone , Copy , Debug , PartialEq ) ]
289- pub struct VerificationShare < T : PointType > {
290- /// The index of the share in the secret sharing
291- pub index : ShareIndex ,
292- /// The image of the secret share
293- pub share_image : Point < T , Public , Zero > ,
294- /// The public key that this is a share of
295- pub public_key : Point < EvenY > ,
296- }
293+ pub struct VerificationShare ( pub ( crate ) ShareImage < NonNormal > ) ;
297294
298295#[ cfg( feature = "share_backup" ) ]
299296mod share_backup {
@@ -501,7 +498,45 @@ mod share_backup {
501498#[ cfg( feature = "share_backup" ) ]
502499pub use share_backup:: BackupDecodeError ;
503500
504- use super :: ShareIndex ;
501+ /// The public image of a secret share, consisting of an index and the corresponding point.
502+ ///
503+ /// A `ShareImage` represents the public information about a share: the index at
504+ /// which the polynomial was evaluated and the image of the secret share. This
505+ /// can be shared publicly and used to reconstruct the shared public key and the polynomial
506+ /// from a threshold number of share images using [`SharedKey::from_share_images`].
507+ ///
508+ /// [`SharedKey::from_share_images`]: crate::frost::SharedKey::from_share_images
509+ #[ derive( Clone , Copy , Debug ) ]
510+ #[ cfg_attr(
511+ feature = "bincode" ,
512+ derive( bincode:: Encode , bincode:: Decode ) ,
513+ bincode(
514+ encode_bounds = "Point<T, Public, Zero>: bincode::Encode" ,
515+ decode_bounds = "Point<T, Public, Zero>: bincode::Decode<__Context>" ,
516+ borrow_decode_bounds = "Point<T, Public, Zero>: bincode::BorrowDecode<'__de, __Context>"
517+ )
518+ ) ]
519+ #[ cfg_attr(
520+ feature = "serde" ,
521+ derive( crate :: fun:: serde:: Deserialize , crate :: fun:: serde:: Serialize ) ,
522+ serde( crate = "crate::fun::serde" ) ,
523+ serde( bound(
524+ serialize = "Point<T, Public, Zero>: crate::fun::serde::Serialize" ,
525+ deserialize = "Point<T, Public, Zero>: crate::fun::serde::Deserialize<'de>"
526+ ) )
527+ ) ]
528+ pub struct ShareImage < T = Normal > {
529+ /// The index where the polynomial was evaluated
530+ pub index : ShareIndex ,
531+ /// The image of the secret share (G * share_scalar)
532+ pub image : Point < T , Public , Zero > ,
533+ }
534+
535+ impl < T : PointType > PartialEq for ShareImage < T > {
536+ fn eq ( & self , other : & Self ) -> bool {
537+ self . index == other. index && self . image == other. image
538+ }
539+ }
505540
506541#[ cfg( test) ]
507542mod test {
0 commit comments