From bd38458817da316ba4ae5a330464c6d71598ea75 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet Date: Fri, 22 Nov 2019 17:11:18 +0100 Subject: [PATCH 1/2] accounts/keystore: fix staticcheck warnings --- accounts/keystore/passphrase.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/accounts/keystore/passphrase.go b/accounts/keystore/passphrase.go index 1ced41e9975b..6daaa5dbd4c4 100644 --- a/accounts/keystore/passphrase.go +++ b/accounts/keystore/passphrase.go @@ -117,7 +117,7 @@ func (ks keyStorePassphrase) StoreKey(filename string, key *Key, auth string) er // Verify that we can decrypt the file with the given password. _, err = ks.GetKey(key.Address, tmpName, auth) if err != nil { - msg := "An error was encountered when saving and verifying the keystore file. \n" + + msg := "an error was encountered when saving and verifying the keystore file. \n" + "This indicates that the keystore is corrupted. \n" + "The corrupted file is stored at \n%v\n" + "Please file a ticket at:\n\n" + @@ -237,7 +237,7 @@ func DecryptKey(keyjson []byte, auth string) (*Key, error) { func DecryptDataV3(cryptoJson CryptoJSON, auth string) ([]byte, error) { if cryptoJson.Cipher != "aes-128-ctr" { - return nil, fmt.Errorf("Cipher not supported: %v", cryptoJson.Cipher) + return nil, fmt.Errorf("cipher not supported: %v", cryptoJson.Cipher) } mac, err := hex.DecodeString(cryptoJson.MAC) if err != nil { @@ -273,7 +273,7 @@ func DecryptDataV3(cryptoJson CryptoJSON, auth string) ([]byte, error) { func decryptKeyV3(keyProtected *encryptedKeyJSONV3, auth string) (keyBytes []byte, keyId []byte, err error) { if keyProtected.Version != version { - return nil, nil, fmt.Errorf("Version not supported: %v", keyProtected.Version) + return nil, nil, fmt.Errorf("version not supported: %v", keyProtected.Version) } keyId = uuid.Parse(keyProtected.Id) plainText, err := DecryptDataV3(keyProtected.Crypto, auth) @@ -335,13 +335,13 @@ func getKDFKey(cryptoJSON CryptoJSON, auth string) ([]byte, error) { c := ensureInt(cryptoJSON.KDFParams["c"]) prf := cryptoJSON.KDFParams["prf"].(string) if prf != "hmac-sha256" { - return nil, fmt.Errorf("Unsupported PBKDF2 PRF: %s", prf) + return nil, fmt.Errorf("unsupported PBKDF2 PRF: %s", prf) } key := pbkdf2.Key(authArray, salt, c, dkLen, sha256.New) return key, nil } - return nil, fmt.Errorf("Unsupported KDF: %s", cryptoJSON.KDF) + return nil, fmt.Errorf("unsupported KDF: %s", cryptoJSON.KDF) } // TODO: can we do without this when unmarshalling dynamic JSON? From 03e033ff54bd9e01ec943aef43c3e36a503bb616 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet Date: Mon, 25 Nov 2019 13:33:18 +0100 Subject: [PATCH 2/2] review feedback --- accounts/keystore/passphrase.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/accounts/keystore/passphrase.go b/accounts/keystore/passphrase.go index 6daaa5dbd4c4..89cdf0bfca14 100644 --- a/accounts/keystore/passphrase.go +++ b/accounts/keystore/passphrase.go @@ -117,12 +117,13 @@ func (ks keyStorePassphrase) StoreKey(filename string, key *Key, auth string) er // Verify that we can decrypt the file with the given password. _, err = ks.GetKey(key.Address, tmpName, auth) if err != nil { - msg := "an error was encountered when saving and verifying the keystore file. \n" + + msg := "An error was encountered when saving and verifying the keystore file. \n" + "This indicates that the keystore is corrupted. \n" + "The corrupted file is stored at \n%v\n" + "Please file a ticket at:\n\n" + "https://github.com/ethereum/go-ethereum/issues." + "The error was : %s" + //lint:ignore ST1005 This is a message for the user return fmt.Errorf(msg, tmpName, err) } }