1818
1919use bp_header_chain:: { justification:: JustificationVerificationContext , AuthoritySet } ;
2020use codec:: Encode ;
21- use ed25519_dalek:: { Keypair , PublicKey , SecretKey , Signature } ;
21+ use ed25519_dalek:: { Signature , SigningKey , VerifyingKey } ;
2222use finality_grandpa:: voter_set:: VoterSet ;
2323use sp_consensus_grandpa:: { AuthorityId , AuthorityList , AuthorityWeight , SetId } ;
2424use sp_runtime:: RuntimeDebug ;
@@ -37,29 +37,15 @@ pub const FERDIE: Account = Account(5);
3737pub struct Account ( pub u16 ) ;
3838
3939impl Account {
40- pub fn public ( & self ) -> PublicKey {
41- ( & self . secret ( ) ) . into ( )
40+ pub fn public ( & self ) -> VerifyingKey {
41+ self . pair ( ) . verifying_key ( )
4242 }
4343
44- pub fn secret ( & self ) -> SecretKey {
44+ pub fn pair ( & self ) -> SigningKey {
4545 let data = self . 0 . encode ( ) ;
4646 let mut bytes = [ 0_u8 ; 32 ] ;
4747 bytes[ 0 ..data. len ( ) ] . copy_from_slice ( & data) ;
48- SecretKey :: from_bytes ( & bytes)
49- . expect ( "A static array of the correct length is a known good." )
50- }
51-
52- pub fn pair ( & self ) -> Keypair {
53- let mut pair: [ u8 ; 64 ] = [ 0 ; 64 ] ;
54-
55- let secret = self . secret ( ) ;
56- pair[ ..32 ] . copy_from_slice ( & secret. to_bytes ( ) ) ;
57-
58- let public = self . public ( ) ;
59- pair[ 32 ..] . copy_from_slice ( & public. to_bytes ( ) ) ;
60-
61- Keypair :: from_bytes ( & pair)
62- . expect ( "We expect the SecretKey to be good, so this must also be good." )
48+ SigningKey :: from_bytes ( & bytes)
6349 }
6450
6551 pub fn sign ( & self , msg : & [ u8 ] ) -> Signature {
0 commit comments