good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit 7bc1cb36 authored by Péter Szilágyi's avatar Péter Szilágyi
Browse files

accounts/scwallet: fix public key confirmation regression

parent 75a86088
No related branches found
No related tags found
No related merge requests found
...@@ -982,12 +982,10 @@ func (s *Session) derive(path accounts.DerivationPath) (accounts.Account, error) ...@@ -982,12 +982,10 @@ func (s *Session) derive(path accounts.DerivationPath) (accounts.Account, error)
copy(sig[32-len(rbytes):32], rbytes) copy(sig[32-len(rbytes):32], rbytes)
copy(sig[64-len(sbytes):64], sbytes) copy(sig[64-len(sbytes):64], sbytes)
pubkey, err := determinePublicKey(sig, sigdata.PublicKey) if err := confirmPublicKey(sig, sigdata.PublicKey); err != nil {
if err != nil {
return accounts.Account{}, err return accounts.Account{}, err
} }
pub, err := crypto.UnmarshalPubkey(sigdata.PublicKey)
pub, err := crypto.UnmarshalPubkey(pubkey)
if err != nil { if err != nil {
return accounts.Account{}, err return accounts.Account{}, err
} }
...@@ -1057,10 +1055,10 @@ func (s *Session) sign(path accounts.DerivationPath, hash []byte) ([]byte, error ...@@ -1057,10 +1055,10 @@ func (s *Session) sign(path accounts.DerivationPath, hash []byte) ([]byte, error
return sig, nil return sig, nil
} }
// determinePublicKey uses a signature and the X component of a public key to // confirmPublicKey confirms that the given signature belongs to the specified key.
// recover the entire public key. func confirmPublicKey(sig, pubkey []byte) error {
func determinePublicKey(sig, pubkeyX []byte) ([]byte, error) { _, err := makeRecoverableSignature(DerivationSignatureHash[:], sig, pubkey)
return makeRecoverableSignature(DerivationSignatureHash[:], sig, pubkeyX) return err
} }
// makeRecoverableSignature uses a signature and an expected public key to // makeRecoverableSignature uses a signature and an expected public key to
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment