Skip to content

Commit 7bc1cb3

Browse files
committed
accounts/scwallet: fix public key confirmation regression
1 parent 75a8608 commit 7bc1cb3

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

‎accounts/scwallet/wallet.go‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -982,12 +982,10 @@ func (s *Session) derive(path accounts.DerivationPath) (accounts.Account, error)
982982
copy(sig[32-len(rbytes):32], rbytes)
983983
copy(sig[64-len(sbytes):64], sbytes)
984984

985-
pubkey, err := determinePublicKey(sig, sigdata.PublicKey)
986-
if err != nil {
985+
if err := confirmPublicKey(sig, sigdata.PublicKey); err != nil {
987986
return accounts.Account{}, err
988987
}
989-
990-
pub, err := crypto.UnmarshalPubkey(pubkey)
988+
pub, err := crypto.UnmarshalPubkey(sigdata.PublicKey)
991989
if err != nil {
992990
return accounts.Account{}, err
993991
}
@@ -1057,10 +1055,10 @@ func (s *Session) sign(path accounts.DerivationPath, hash []byte) ([]byte, error
10571055
return sig, nil
10581056
}
10591057

1060-
// determinePublicKey uses a signature and the X component of a public key to
1061-
// recover the entire public key.
1062-
func determinePublicKey(sig, pubkeyX []byte) ([]byte, error) {
1063-
return makeRecoverableSignature(DerivationSignatureHash[:], sig, pubkeyX)
1058+
// confirmPublicKey confirms that the given signature belongs to the specified key.
1059+
func confirmPublicKey(sig, pubkey []byte) error {
1060+
_, err := makeRecoverableSignature(DerivationSignatureHash[:], sig, pubkey)
1061+
return err
10641062
}
10651063

10661064
// makeRecoverableSignature uses a signature and an expected public key to

0 commit comments

Comments
 (0)