@@ -4,9 +4,9 @@ extern crate bincode;
44extern crate secp256k1;
55extern crate serde_cbor;
66
7+ use secp256k1:: { musig, PublicKey , SecretKey , XOnlyPublicKey } ;
78#[ cfg( feature = "global-context" ) ]
89use secp256k1:: { Keypair , Secp256k1 } ;
9- use secp256k1:: { PublicKey , SecretKey , XOnlyPublicKey } ;
1010
1111// Arbitrary key data.
1212
@@ -35,6 +35,43 @@ static XONLY_PK_BYTES: [u8; 32] = [
3535 0x4a , 0xc8 , 0x87 , 0xfe , 0x91 , 0xdd , 0xd1 , 0x66 ,
3636] ;
3737
38+ #[ rustfmt:: skip]
39+ static MUSIG_PUBLIC_NONCE_BYTES : [ u8 ; 74 ] = [
40+ 0x42 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
41+ 0x03 , 0xf4 , 0xa3 , 0x61 , 0xab , 0xd3 , 0xd5 , 0x05 ,
42+ 0x35 , 0xbe , 0x08 , 0x42 , 0x1d , 0xbc , 0x73 , 0xb0 ,
43+ 0xa8 , 0xf5 , 0x95 , 0x65 , 0x4a , 0xe3 , 0x23 , 0x8a ,
44+ 0xfc , 0xaf , 0x25 , 0x99 , 0xf9 , 0x4e , 0x25 , 0x20 ,
45+ 0x4c , 0x03 , 0x6b , 0xa1 , 0x74 , 0x21 , 0x44 , 0x33 ,
46+ 0xe2 , 0x1f , 0x5c , 0xd0 , 0xfc , 0xb1 , 0x4b , 0x03 ,
47+ 0x8e , 0xb4 , 0x0b , 0x05 , 0xb7 , 0xe7 , 0xc8 , 0x20 ,
48+ 0xdd , 0x21 , 0xaa , 0x56 , 0x8f , 0xdb , 0x0a , 0x9d ,
49+ 0xe4 , 0xd7 ,
50+ ] ;
51+
52+ #[ rustfmt:: skip]
53+ static MUSIG_AGGREGATED_NONCE_BYTES : [ u8 ; 74 ] = [
54+ 0x42 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
55+ 0x02 , 0x18 , 0xc3 , 0x0f , 0xe0 , 0xf5 , 0x67 , 0xa4 ,
56+ 0xa9 , 0xc0 , 0x5e , 0xb4 , 0x83 , 0x5e , 0x27 , 0x35 ,
57+ 0x41 , 0x9c , 0xf3 , 0x0f , 0x83 , 0x4c , 0x9c , 0xe2 ,
58+ 0xfe , 0x34 , 0x30 , 0xf0 , 0x21 , 0xba , 0x4e , 0xac ,
59+ 0xd5 , 0x03 , 0x11 , 0x2e , 0x97 , 0xbc , 0xf6 , 0xa0 ,
60+ 0x22 , 0xd2 , 0x36 , 0xd7 , 0x1a , 0x93 , 0x57 , 0x82 ,
61+ 0x4a , 0x2b , 0x19 , 0x51 , 0x5f , 0x98 , 0x01 , 0x31 ,
62+ 0xb3 , 0x97 , 0x0b , 0x08 , 0x7c , 0xad , 0xf9 , 0x4c ,
63+ 0xc4 , 0xa7 ,
64+ ] ;
65+
66+ #[ rustfmt:: skip]
67+ static MUSIG_PARTIAL_SIG_BYTES : [ u8 ; 40 ] = [
68+ 0x20 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
69+ 0x28 , 0x9e , 0xeb , 0x2f , 0x5e , 0xfc , 0x31 , 0x4a ,
70+ 0xa6 , 0xd8 , 0x7b , 0xf5 , 0x81 , 0x25 , 0x04 , 0x3c ,
71+ 0x96 , 0xd1 , 0x5a , 0x00 , 0x7d , 0xb4 , 0xb6 , 0xaa ,
72+ 0xaa , 0xc7 , 0xd1 , 0x80 , 0x86 , 0xf4 , 0x9a , 0x99 ,
73+ ] ;
74+
3875fn secret_key ( ) -> SecretKey {
3976 SecretKey :: from_slice ( & SK_BYTES ) . expect ( "failed to create sk from slice" )
4077}
@@ -85,3 +122,23 @@ fn cbor() {
85122 // It also adds a 1-byte length prefix and a byte of metadata for the whole vector.
86123 assert_eq ! ( e. len( ) , 54 ) ;
87124}
125+
126+ #[ test]
127+ fn musig ( ) {
128+ let public_nonce: musig:: PublicNonce = bincode:: deserialize ( & MUSIG_PUBLIC_NONCE_BYTES ) . unwrap ( ) ;
129+ let ser = bincode:: serialize ( & public_nonce) . unwrap ( ) ;
130+
131+ assert_eq ! ( ser, MUSIG_PUBLIC_NONCE_BYTES ) ;
132+
133+ let aggregated_nonce: musig:: AggregatedNonce =
134+ bincode:: deserialize ( & MUSIG_AGGREGATED_NONCE_BYTES ) . unwrap ( ) ;
135+ let ser = bincode:: serialize ( & aggregated_nonce) . unwrap ( ) ;
136+
137+ assert_eq ! ( ser, MUSIG_AGGREGATED_NONCE_BYTES ) ;
138+
139+ let partial_sig: musig:: PartialSignature =
140+ bincode:: deserialize ( & MUSIG_PARTIAL_SIG_BYTES ) . unwrap ( ) ;
141+ let ser = bincode:: serialize ( & partial_sig) . unwrap ( ) ;
142+
143+ assert_eq ! ( ser, MUSIG_PARTIAL_SIG_BYTES ) ;
144+ }
0 commit comments