1+ use alloy:: rpc:: types:: beacon:: constants:: BLS_DST_SIG ;
12pub use alloy:: rpc:: types:: beacon:: BlsSignature ;
2- use alloy:: rpc:: types:: beacon:: { constants:: BLS_DST_SIG , BlsPublicKey as BlsPublicKeyInner } ;
33use blst:: BLST_ERROR ;
4- use derive_more:: derive:: { Deref , Display , From , Into } ;
5- use serde:: { Deserialize , Serialize } ;
64use tree_hash:: TreeHash ;
7- use tree_hash_derive:: TreeHash ;
85
96use crate :: {
107 error:: BlstErrorWrapper , signature:: sign_commit_boost_root, types:: Chain ,
118 utils:: blst_pubkey_to_alloy,
129} ;
1310
1411pub type BlsSecretKey = blst:: min_pk:: SecretKey ;
15-
16- // TODO(David):
17- // This wrapper type is potentially a temporary solution, merely to implement
18- // `TreeHash`. Remove when progress is made on this issue (https://github.com/sigp/tree_hash/issues/22)
19- // or refine the boundaries between our wrapper `BlsPublicKey` type
20- // and alloy's `BlsPublicKey` if we stick with it
21-
22- // std traits
23- #[ derive( Debug , Clone , Copy , Display , PartialEq , Eq , Hash , Default ) ]
24- // serde, ssz, tree_hash
25- #[ derive( Serialize , Deserialize , TreeHash ) ]
26- #[ serde( transparent) ]
27- // derive_more
28- #[ derive( Deref , From , Into ) ]
29- pub struct BlsPublicKey {
30- inner : BlsPublicKeyInner ,
31- }
32-
33- impl AsRef < [ u8 ] > for BlsPublicKey {
34- fn as_ref ( & self ) -> & [ u8 ] {
35- self . as_slice ( )
36- }
37- }
38-
39- impl TryFrom < & [ u8 ] > for BlsPublicKey {
40- type Error = core:: array:: TryFromSliceError ;
41-
42- fn try_from ( value : & [ u8 ] ) -> Result < Self , Self :: Error > {
43- Ok ( Self { inner : value. try_into ( ) ? } )
44- }
45- }
12+ pub type BlsPublicKey = alloy:: rpc:: types:: beacon:: BlsPublicKey ;
4613
4714#[ derive( Clone ) ]
4815pub enum BlsSigner {
@@ -61,7 +28,7 @@ impl BlsSigner {
6128
6229 pub fn pubkey ( & self ) -> BlsPublicKey {
6330 match self {
64- BlsSigner :: Local ( secret) => blst_pubkey_to_alloy ( & secret. sk_to_pk ( ) ) . into ( ) ,
31+ BlsSigner :: Local ( secret) => blst_pubkey_to_alloy ( & secret. sk_to_pk ( ) ) ,
6532 }
6633 }
6734
@@ -97,7 +64,7 @@ pub fn random_secret() -> BlsSecretKey {
9764}
9865
9966pub fn verify_bls_signature (
100- pubkey : & BlsPublicKeyInner ,
67+ pubkey : & BlsPublicKey ,
10168 msg : & [ u8 ] ,
10269 signature : & BlsSignature ,
10370) -> Result < ( ) , BlstErrorWrapper > {
0 commit comments