Skip to content

Commit

Permalink
fix signature check in wallet_extension
Browse files Browse the repository at this point in the history
  • Loading branch information
zkokelj committed Feb 21, 2024
1 parent 00de93b commit 7ee0d28
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions tools/walletextension/wallet_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,10 @@ func (w *WalletExtension) AddAddressToUser(hexUserID string, address string, sig
requestStartTime := time.Now()
addressFromMessage := gethcommon.HexToAddress(address)
// check if a message was signed by the correct address and if the signature is valid
sigAddrs, err := viewingkey.CheckEIP712Signature(hexUserID, signature, int64(w.config.TenChainID))
if err != nil {
return fmt.Errorf("signature is not valid: %w", err)
}

if sigAddrs.Hex() != address {
return fmt.Errorf("signature is not valid. Signature address %s!=%s ", sigAddrs, address)
isValidAndMatchesAddress := viewingkey.CheckIfSignatureIsValidAndMatchesAddress(hexUserID, signature, int64(w.config.TenChainID), &addressFromMessage)
if !isValidAndMatchesAddress {
return errors.New("signature is not valid or does not match the address in the message")
}

// register the account for that viewing key
Expand Down

0 comments on commit 7ee0d28

Please sign in to comment.