aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2019-05-27 22:27:18 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-05-27 22:29:02 +0800
commit7bc1cb3677ba18b83fa094799de4a4e8589a4eac (patch)
treee9981e8d7fa301312a2eb84fb18d4d54e8fdba2b
parent75a860880cfc88cc515ef91301aea0f7df4c17bc (diff)
downloadgo-tangerine-7bc1cb3677ba18b83fa094799de4a4e8589a4eac.tar
go-tangerine-7bc1cb3677ba18b83fa094799de4a4e8589a4eac.tar.gz
go-tangerine-7bc1cb3677ba18b83fa094799de4a4e8589a4eac.tar.bz2
go-tangerine-7bc1cb3677ba18b83fa094799de4a4e8589a4eac.tar.lz
go-tangerine-7bc1cb3677ba18b83fa094799de4a4e8589a4eac.tar.xz
go-tangerine-7bc1cb3677ba18b83fa094799de4a4e8589a4eac.tar.zst
go-tangerine-7bc1cb3677ba18b83fa094799de4a4e8589a4eac.zip
accounts/scwallet: fix public key confirmation regression
-rw-r--r--accounts/scwallet/wallet.go14
1 files changed, 6 insertions, 8 deletions
diff --git a/accounts/scwallet/wallet.go b/accounts/scwallet/wallet.go
index c48028281..57b597706 100644
--- a/accounts/scwallet/wallet.go
+++ b/accounts/scwallet/wallet.go
@@ -982,12 +982,10 @@ func (s *Session) derive(path accounts.DerivationPath) (accounts.Account, error)
copy(sig[32-len(rbytes):32], rbytes)
copy(sig[64-len(sbytes):64], sbytes)
- pubkey, err := determinePublicKey(sig, sigdata.PublicKey)
- if err != nil {
+ if err := confirmPublicKey(sig, sigdata.PublicKey); err != nil {
return accounts.Account{}, err
}
-
- pub, err := crypto.UnmarshalPubkey(pubkey)
+ pub, err := crypto.UnmarshalPubkey(sigdata.PublicKey)
if err != nil {
return accounts.Account{}, err
}
@@ -1057,10 +1055,10 @@ func (s *Session) sign(path accounts.DerivationPath, hash []byte) ([]byte, error
return sig, nil
}
-// determinePublicKey uses a signature and the X component of a public key to
-// recover the entire public key.
-func determinePublicKey(sig, pubkeyX []byte) ([]byte, error) {
- return makeRecoverableSignature(DerivationSignatureHash[:], sig, pubkeyX)
+// confirmPublicKey confirms that the given signature belongs to the specified key.
+func confirmPublicKey(sig, pubkey []byte) error {
+ _, err := makeRecoverableSignature(DerivationSignatureHash[:], sig, pubkey)
+ return err
}
// makeRecoverableSignature uses a signature and an expected public key to