1
1
use cosmwasm_schema:: cw_serde;
2
2
use cosmwasm_std:: { HexBinary , StdError } ;
3
- use k256:: ecdsa:: VerifyingKey ;
4
3
use sha2:: { Digest , Sha256 } ;
5
4
6
5
use crate :: {
7
- error:: Error ,
8
6
msg:: { execute:: attested:: HasUserData , HasDomainType } ,
9
7
state:: { Nonce , UserData } ,
10
8
} ;
11
9
12
10
#[ derive( Clone , Debug , PartialEq ) ]
13
11
pub struct SessionSetPubKey {
14
12
nonce : Nonce ,
15
- pub_key : VerifyingKey ,
13
+ pub_key : Vec < u8 > ,
16
14
}
17
15
18
16
impl SessionSetPubKey {
19
- pub fn new ( nonce : Nonce , pub_key : VerifyingKey ) -> Self {
17
+ pub fn new ( nonce : Nonce , pub_key : Vec < u8 > ) -> Self {
20
18
Self { nonce, pub_key }
21
19
}
22
20
23
- pub fn into_tuple ( self ) -> ( Nonce , VerifyingKey ) {
21
+ pub fn into_tuple ( self ) -> ( Nonce , Vec < u8 > ) {
24
22
( self . nonce , self . pub_key )
25
23
}
26
24
}
@@ -42,18 +40,18 @@ impl TryFrom<RawSessionSetPubKey> for SessionSetPubKey {
42
40
43
41
fn try_from ( value : RawSessionSetPubKey ) -> Result < Self , Self :: Error > {
44
42
let nonce = value. nonce . to_array ( ) ?;
45
- let pub_key = VerifyingKey :: from_sec1_bytes ( & value . pub_key )
46
- . map_err ( Error :: from )
47
- . map_err ( |e| StdError :: generic_err ( e . to_string ( ) ) ) ? ;
48
- Ok ( Self { nonce , pub_key } )
43
+ Ok ( Self {
44
+ nonce ,
45
+ pub_key : value . pub_key . into ( ) ,
46
+ } )
49
47
}
50
48
}
51
49
52
50
impl From < SessionSetPubKey > for RawSessionSetPubKey {
53
51
fn from ( value : SessionSetPubKey ) -> Self {
54
52
Self {
55
53
nonce : value. nonce . into ( ) ,
56
- pub_key : value. pub_key . to_sec1_bytes ( ) . into_vec ( ) . into ( ) ,
54
+ pub_key : value. pub_key . into ( ) ,
57
55
}
58
56
}
59
57
}
0 commit comments