From 313eec33ad7add82bfdd00e3a076091fa990c799 Mon Sep 17 00:00:00 2001
From: Gustav Simonsson <gustav.simonsson@gmail.com>
Date: Tue, 21 Apr 2015 15:52:10 +0200
Subject: [PATCH] Revert "Add key header to unencrypted key file"

This reverts commit a94d4ba0b53c4558ab838aaed635a2ff66ddfa53.
---
 crypto/key.go                  | 17 +++++------------
 crypto/key_store_passphrase.go |  7 +++----
 2 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/crypto/key.go b/crypto/key.go
index 0f36a7f6b..067a5a294 100644
--- a/crypto/key.go
+++ b/crypto/key.go
@@ -45,28 +45,27 @@ type Key struct {
 type plainKeyJSON struct {
 	Id         []byte
 	Address    []byte
-	KeyHeader  keyHeaderJSON
 	PrivateKey []byte
 }
 
 type encryptedKeyJSON struct {
-	Id        []byte
-	Address   []byte
-	KeyHeader keyHeaderJSON
-	Crypto    cipherJSON
+	Id      []byte
+	Address []byte
+	Crypto  cipherJSON
 }
 
 type cipherJSON struct {
 	MAC        []byte
 	Salt       []byte
 	IV         []byte
+	KeyHeader  keyHeaderJSON
 	CipherText []byte
 }
 
 type keyHeaderJSON struct {
 	Version   string
 	Kdf       string
-	KdfParams *scryptParamsJSON // TODO: make more generic?
+	KdfParams scryptParamsJSON // TODO: make more generic?
 }
 
 type scryptParamsJSON struct {
@@ -78,15 +77,9 @@ type scryptParamsJSON struct {
 }
 
 func (k *Key) MarshalJSON() (j []byte, err error) {
-	keyHeader := keyHeaderJSON{
-		Version:   "1",
-		Kdf:       "",
-		KdfParams: nil,
-	}
 	jStruct := plainKeyJSON{
 		k.Id,
 		k.Address.Bytes(),
-		keyHeader,
 		FromECDSA(k.PrivateKey),
 	}
 	j, err = json.Marshal(jStruct)
diff --git a/crypto/key_store_passphrase.go b/crypto/key_store_passphrase.go
index 96227e4d1..00717b5d1 100644
--- a/crypto/key_store_passphrase.go
+++ b/crypto/key_store_passphrase.go
@@ -153,7 +153,7 @@ func (ks keyStorePassphrase) StoreKey(key *Key, auth string) (err error) {
 	keyHeaderJSON := keyHeaderJSON{
 		Version:   keyHeaderVersion,
 		Kdf:       keyHeaderKDF,
-		KdfParams: &paramsJSON,
+		KdfParams: paramsJSON,
 	}
 
 	keyHeaderJSONStr, err := json.Marshal(keyHeaderJSON)
@@ -167,12 +167,12 @@ func (ks keyStorePassphrase) StoreKey(key *Key, auth string) (err error) {
 		mac,
 		salt,
 		iv,
+		keyHeaderJSON,
 		cipherText,
 	}
 	keyStruct := encryptedKeyJSON{
 		key.Id,
 		key.Address.Bytes(),
-		keyHeaderJSON,
 		cipherStruct,
 	}
 	keyJSON, err := json.Marshal(keyStruct)
@@ -204,11 +204,10 @@ func DecryptKey(ks keyStorePassphrase, keyAddr common.Address, auth string) (key
 	err = json.Unmarshal(fileContent, keyProtected)
 
 	keyId = keyProtected.Id
-	keyHeader := keyProtected.KeyHeader
-
 	mac := keyProtected.Crypto.MAC
 	salt := keyProtected.Crypto.Salt
 	iv := keyProtected.Crypto.IV
+	keyHeader := keyProtected.Crypto.KeyHeader
 	cipherText := keyProtected.Crypto.CipherText
 
 	// used in MAC
-- 
GitLab