@@ -16,15 +16,23 @@ use std::{collections::BTreeMap, fmt};
1616
1717/// the list of signature codecs currently supported
1818pub const SIG_CODECS : [ Codec ; 4 ] = [
19- Codec :: Bls12381G1Sig ,
20- Codec :: Bls12381G2Sig ,
21- Codec :: Eddsa ,
22- Codec :: Es256K ] ;
19+ Codec :: Bls12381G1Msig ,
20+ Codec :: Bls12381G2Msig ,
21+ Codec :: EddsaMsig ,
22+ // Codec::Es256Msig,
23+ // Codec::Es384Msig,
24+ // Codec::Es521Msig,
25+ // Codec::Rs256Msig,
26+ Codec :: Es256KMsig //,
27+ //Codec::LamportMsig,
28+ ] ;
2329
2430/// the list of signature share codecs supported
2531pub const SIG_SHARE_CODECS : [ Codec ; 2 ] = [
26- Codec :: Bls12381G1SigShare ,
27- Codec :: Bls12381G2SigShare ] ;
32+ Codec :: Bls12381G1ShareMsig ,
33+ Codec :: Bls12381G2ShareMsig //,
34+ //Codec::LamportShareMsig,
35+ ] ;
2836
2937/// the multisig sigil
3038pub const SIGIL : Codec = Codec :: Multisig ;
@@ -172,53 +180,53 @@ impl Views for Multisig {
172180 /// Provide a read-only view to access the signature attributes
173181 fn attr_view < ' a > ( & ' a self ) -> Result < Box < dyn AttrView + ' a > , Error > {
174182 match self . codec {
175- Codec :: Bls12381G1Sig
176- | Codec :: Bls12381G2Sig
177- | Codec :: Bls12381G1SigShare
178- | Codec :: Bls12381G2SigShare => Ok ( Box :: new ( bls12381:: View :: try_from ( self ) ?) ) ,
179- Codec :: Eddsa => Ok ( Box :: new ( ed25519:: View :: try_from ( self ) ?) ) ,
180- Codec :: Es256K => Ok ( Box :: new ( secp256k1:: View :: try_from ( self ) ?) ) ,
183+ Codec :: Bls12381G1Msig
184+ | Codec :: Bls12381G2Msig
185+ | Codec :: Bls12381G1ShareMsig
186+ | Codec :: Bls12381G2ShareMsig => Ok ( Box :: new ( bls12381:: View :: try_from ( self ) ?) ) ,
187+ Codec :: EddsaMsig => Ok ( Box :: new ( ed25519:: View :: try_from ( self ) ?) ) ,
188+ Codec :: Es256KMsig => Ok ( Box :: new ( secp256k1:: View :: try_from ( self ) ?) ) ,
181189 _ => Err ( AttributesError :: UnsupportedCodec ( self . codec ) . into ( ) ) ,
182190 }
183191 }
184192 /// Provide a read-only view to access signature data
185193 fn data_view < ' a > ( & ' a self ) -> Result < Box < dyn DataView + ' a > , Error > {
186194 match self . codec {
187- Codec :: Bls12381G1Sig
188- | Codec :: Bls12381G2Sig
189- | Codec :: Bls12381G1SigShare
190- | Codec :: Bls12381G2SigShare => Ok ( Box :: new ( bls12381:: View :: try_from ( self ) ?) ) ,
191- Codec :: Eddsa => Ok ( Box :: new ( ed25519:: View :: try_from ( self ) ?) ) ,
192- Codec :: Es256K => Ok ( Box :: new ( secp256k1:: View :: try_from ( self ) ?) ) ,
195+ Codec :: Bls12381G1Msig
196+ | Codec :: Bls12381G2Msig
197+ | Codec :: Bls12381G1ShareMsig
198+ | Codec :: Bls12381G2ShareMsig => Ok ( Box :: new ( bls12381:: View :: try_from ( self ) ?) ) ,
199+ Codec :: EddsaMsig => Ok ( Box :: new ( ed25519:: View :: try_from ( self ) ?) ) ,
200+ Codec :: Es256KMsig => Ok ( Box :: new ( secp256k1:: View :: try_from ( self ) ?) ) ,
193201 _ => Err ( AttributesError :: UnsupportedCodec ( self . codec ) . into ( ) ) ,
194202 }
195203 }
196204 /// Provide a read-only view to access signature data
197205 fn conv_view < ' a > ( & ' a self ) -> Result < Box < dyn ConvView + ' a > , Error > {
198206 match self . codec {
199- Codec :: Bls12381G1Sig
200- | Codec :: Bls12381G2Sig
201- | Codec :: Bls12381G1SigShare
202- | Codec :: Bls12381G2SigShare => Ok ( Box :: new ( bls12381:: View :: try_from ( self ) ?) ) ,
203- Codec :: Eddsa => Ok ( Box :: new ( ed25519:: View :: try_from ( self ) ?) ) ,
204- Codec :: Es256K => Ok ( Box :: new ( secp256k1:: View :: try_from ( self ) ?) ) ,
207+ Codec :: Bls12381G1Msig
208+ | Codec :: Bls12381G2Msig
209+ | Codec :: Bls12381G1ShareMsig
210+ | Codec :: Bls12381G2ShareMsig => Ok ( Box :: new ( bls12381:: View :: try_from ( self ) ?) ) ,
211+ Codec :: EddsaMsig => Ok ( Box :: new ( ed25519:: View :: try_from ( self ) ?) ) ,
212+ Codec :: Es256KMsig => Ok ( Box :: new ( secp256k1:: View :: try_from ( self ) ?) ) ,
205213 _ => Err ( AttributesError :: UnsupportedCodec ( self . codec ) . into ( ) ) ,
206214 }
207215 }
208216 /// Provide a read-only view to access the threshold signature attributes
209217 fn threshold_attr_view < ' a > ( & ' a self ) -> Result < Box < dyn ThresholdAttrView + ' a > , Error > {
210218 match self . codec {
211- Codec :: Bls12381G1Sig
212- | Codec :: Bls12381G2Sig
213- | Codec :: Bls12381G1SigShare
214- | Codec :: Bls12381G2SigShare => Ok ( Box :: new ( bls12381:: View :: try_from ( self ) ?) ) ,
219+ Codec :: Bls12381G1Msig
220+ | Codec :: Bls12381G2Msig
221+ | Codec :: Bls12381G1ShareMsig
222+ | Codec :: Bls12381G2ShareMsig => Ok ( Box :: new ( bls12381:: View :: try_from ( self ) ?) ) ,
215223 _ => Err ( AttributesError :: UnsupportedCodec ( self . codec ) . into ( ) ) ,
216224 }
217225 }
218226 /// Provide the view for adding a share to a multisig
219227 fn threshold_view < ' a > ( & ' a self ) -> Result < Box < dyn ThresholdView + ' a > , Error > {
220228 match self . codec {
221- Codec :: Bls12381G1Sig | Codec :: Bls12381G2Sig => {
229+ Codec :: Bls12381G1Msig | Codec :: Bls12381G2Msig => {
222230 Ok ( Box :: new ( bls12381:: View :: try_from ( self ) ?) )
223231 }
224232 _ => Err ( AttributesError :: UnsupportedCodec ( self . codec ) . into ( ) ) ,
@@ -253,7 +261,7 @@ impl Builder {
253261 Ed25519 => {
254262 attributes. insert ( AttrId :: SigData , sig. as_bytes ( ) . to_vec ( ) ) ;
255263 Ok ( Self {
256- codec : Codec :: Eddsa ,
264+ codec : Codec :: EddsaMsig ,
257265 attributes : Some ( attributes) ,
258266 ..Default :: default ( )
259267 } )
@@ -262,7 +270,7 @@ impl Builder {
262270 secp256k1:: ALGORITHM_NAME => {
263271 attributes. insert ( AttrId :: SigData , sig. as_bytes ( ) . to_vec ( ) ) ;
264272 Ok ( Self {
265- codec : Codec :: Es256K ,
273+ codec : Codec :: Es256KMsig ,
266274 attributes : Some ( attributes) ,
267275 ..Default :: default ( )
268276 } )
@@ -272,7 +280,7 @@ impl Builder {
272280 attributes. insert ( AttrId :: Scheme , sig_combined. 0 . into ( ) ) ;
273281 attributes. insert ( AttrId :: SigData , sig_combined. 1 ) ;
274282 Ok ( Self {
275- codec : Codec :: Bls12381G1Sig ,
283+ codec : Codec :: Bls12381G1Msig ,
276284 attributes : Some ( attributes) ,
277285 ..Default :: default ( )
278286 } )
@@ -282,7 +290,7 @@ impl Builder {
282290 attributes. insert ( AttrId :: Scheme , sig_combined. 0 . into ( ) ) ;
283291 attributes. insert ( AttrId :: SigData , sig_combined. 1 ) ;
284292 Ok ( Self {
285- codec : Codec :: Bls12381G2Sig ,
293+ codec : Codec :: Bls12381G2Msig ,
286294 attributes : Some ( attributes) ,
287295 ..Default :: default ( )
288296 } )
@@ -295,7 +303,7 @@ impl Builder {
295303 attributes. insert ( AttrId :: Scheme , sig_share. 3 . into ( ) ) ;
296304 attributes. insert ( AttrId :: SigData , sig_share. 4 ) ;
297305 Ok ( Self {
298- codec : Codec :: Bls12381G1SigShare ,
306+ codec : Codec :: Bls12381G1ShareMsig ,
299307 attributes : Some ( attributes) ,
300308 ..Default :: default ( )
301309 } )
@@ -308,7 +316,7 @@ impl Builder {
308316 attributes. insert ( AttrId :: Scheme , sig_share. 3 . into ( ) ) ;
309317 attributes. insert ( AttrId :: SigData , sig_share. 4 ) ;
310318 Ok ( Self {
311- codec : Codec :: Bls12381G1SigShare ,
319+ codec : Codec :: Bls12381G1ShareMsig ,
312320 attributes : Some ( attributes) ,
313321 ..Default :: default ( )
314322 } )
@@ -328,8 +336,8 @@ impl Builder {
328336 let sig_bytes: Vec < u8 > = sig. as_raw_value ( ) . to_bytes ( ) . as_ref ( ) . to_vec ( ) ;
329337 println ! ( "signature length: {}" , sig_bytes. len( ) ) ;
330338 let codec = match sig_bytes. len ( ) {
331- 48 => Codec :: Bls12381G1Sig , // G1Projective::to_compressed()
332- 96 => Codec :: Bls12381G2Sig , // G2Projective::to_compressed()
339+ 48 => Codec :: Bls12381G1Msig , // G1Projective::to_compressed()
340+ 96 => Codec :: Bls12381G2Msig , // G2Projective::to_compressed()
333341 _ => {
334342 return Err ( Error :: UnsupportedAlgorithm (
335343 "invalid Bls signature size" . to_string ( ) ,
@@ -361,8 +369,8 @@ impl Builder {
361369 let value = sigshare. value_vec ( ) ;
362370 println ! ( "sigshare len: {}" , value. len( ) ) ;
363371 let codec = match value. len ( ) {
364- 48 => Codec :: Bls12381G1SigShare , // large pubkeys, small signatures
365- 96 => Codec :: Bls12381G2SigShare , // small pubkeys, large signatures
372+ 48 => Codec :: Bls12381G1ShareMsig , // large pubkeys, small signatures
373+ 96 => Codec :: Bls12381G2ShareMsig , // small pubkeys, large signatures
366374 _ => {
367375 return Err ( Error :: UnsupportedAlgorithm (
368376 "invalid Bls signature size" . to_string ( ) ,
@@ -507,7 +515,7 @@ mod tests {
507515
508516 #[ test]
509517 fn test_eddsa ( ) {
510- let ms = Builder :: new ( Codec :: Eddsa )
518+ let ms = Builder :: new ( Codec :: EddsaMsig )
511519 . with_signature_bytes ( & [ 0u8 ; 64 ] )
512520 . try_build ( )
513521 . unwrap ( ) ;
@@ -517,7 +525,7 @@ mod tests {
517525
518526 #[ test]
519527 fn test_es256k ( ) {
520- let ms = Builder :: new ( Codec :: Es256K )
528+ let ms = Builder :: new ( Codec :: Es256KMsig )
521529 . with_signature_bytes ( & [ 0u8 ; 64 ] )
522530 . try_build ( )
523531 . unwrap ( ) ;
@@ -578,7 +586,7 @@ mod tests {
578586 } ) ;
579587
580588 // build a new signature from the parts
581- let mut builder = Builder :: new ( Codec :: Bls12381G2Sig ) ;
589+ let mut builder = Builder :: new ( Codec :: Bls12381G2Msig ) ;
582590 for sig in & sigs {
583591 builder = builder. add_signature_share ( sig) ;
584592 }
@@ -596,7 +604,7 @@ mod tests {
596604
597605 #[ test]
598606 fn test_eddsa_ssh_roundtrip ( ) {
599- let ms1 = Builder :: new ( Codec :: Eddsa )
607+ let ms1 = Builder :: new ( Codec :: EddsaMsig )
600608 . with_signature_bytes ( & [ 0u8 ; 64 ] )
601609 . try_build ( )
602610 . unwrap ( ) ;
@@ -611,7 +619,7 @@ mod tests {
611619
612620 #[ test]
613621 fn test_es256k_ssh_roundtrip ( ) {
614- let ms1 = Builder :: new ( Codec :: Es256K )
622+ let ms1 = Builder :: new ( Codec :: Es256KMsig )
615623 . with_signature_bytes ( & [ 0u8 ; 64 ] )
616624 . try_build ( )
617625 . unwrap ( ) ;
@@ -686,7 +694,7 @@ mod tests {
686694 } ) ;
687695
688696 // build a new signature from the parts
689- let mut builder = Builder :: new ( Codec :: Bls12381G2Sig ) ;
697+ let mut builder = Builder :: new ( Codec :: Bls12381G2Msig ) ;
690698 for sig in & sigs {
691699 let ms = Builder :: new_from_ssh_signature ( sig)
692700 . unwrap ( )
0 commit comments