diff --git a/go/common/viewingkey/viewing_key.go b/go/common/viewingkey/viewing_key.go index 264e9e8460..79ff803f48 100644 --- a/go/common/viewingkey/viewing_key.go +++ b/go/common/viewingkey/viewing_key.go @@ -4,6 +4,7 @@ import ( "crypto/ecdsa" "encoding/hex" "fmt" + "strings" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/crypto" @@ -103,8 +104,8 @@ func GenerateSignMessage(vkPubKey []byte) string { } // GenerateSignMessageOG creates the message to be signed by Obscuro Gateway (new format) -// format is expected to be "Register for " +// format is expected to be "Register for " (with the account in lowercase) func GenerateSignMessageOG(vkPubKey []byte, addr *gethcommon.Address) string { userID := crypto.Keccak256Hash(vkPubKey).Bytes() - return fmt.Sprintf("Register %s for %s", hex.EncodeToString(userID), addr.Hex()) + return fmt.Sprintf("Register %s for %s", hex.EncodeToString(userID), strings.ToLower(addr.Hex())) } diff --git a/tools/walletextension/common/common.go b/tools/walletextension/common/common.go index 27d7f17e0a..4b2fc51ca0 100644 --- a/tools/walletextension/common/common.go +++ b/tools/walletextension/common/common.go @@ -35,9 +35,8 @@ func BytesToPrivateKey(keyBytes []byte) (*ecies.PrivateKey, error) { } // CalculateUserID calculates userID from public key -func CalculateUserID(pk *ecdsa.PrivateKey) []byte { - viewingPublicKeyBytes := crypto.CompressPubkey(&pk.PublicKey) - return crypto.Keccak256Hash(viewingPublicKeyBytes).Bytes() +func CalculateUserID(publicKeyBytes []byte) []byte { + return crypto.Keccak256Hash(publicKeyBytes).Bytes() } // GetUserIDAndAddressFromMessage checks if message is in correct format and extracts userID and address from it diff --git a/tools/walletextension/wallet_extension.go b/tools/walletextension/wallet_extension.go index 4de5e91912..ede55e8d36 100644 --- a/tools/walletextension/wallet_extension.go +++ b/tools/walletextension/wallet_extension.go @@ -176,7 +176,7 @@ func (w *WalletExtension) GenerateAndStoreNewUser() (string, error) { } // create UserID and store it in the database with the private key - userID := common.CalculateUserID(viewingKeyPrivate) + userID := common.CalculateUserID(common.PublicKeyBytesFromPrivateKey(viewingPrivateKeyEcies)) err = w.storage.AddUser(userID, crypto.FromECDSA(viewingPrivateKeyEcies.ExportECDSA())) if err != nil { w.Logger().Error(fmt.Sprintf("failed to save user to the database: %s", err))