Revert "Add key header to unencrypted key file"

This reverts commit a94d4ba0b53c4558ab838aaed635a2ff66ddfa53.
This commit is contained in:
Gustav Simonsson 2015-04-21 15:52:10 +02:00
parent 8754f2b768
commit 313eec33ad
2 changed files with 8 additions and 16 deletions

View File

@ -45,28 +45,27 @@ type Key struct {
type plainKeyJSON struct { type plainKeyJSON struct {
Id []byte Id []byte
Address []byte Address []byte
KeyHeader keyHeaderJSON
PrivateKey []byte PrivateKey []byte
} }
type encryptedKeyJSON struct { type encryptedKeyJSON struct {
Id []byte Id []byte
Address []byte Address []byte
KeyHeader keyHeaderJSON Crypto cipherJSON
Crypto cipherJSON
} }
type cipherJSON struct { type cipherJSON struct {
MAC []byte MAC []byte
Salt []byte Salt []byte
IV []byte IV []byte
KeyHeader keyHeaderJSON
CipherText []byte CipherText []byte
} }
type keyHeaderJSON struct { type keyHeaderJSON struct {
Version string Version string
Kdf string Kdf string
KdfParams *scryptParamsJSON // TODO: make more generic? KdfParams scryptParamsJSON // TODO: make more generic?
} }
type scryptParamsJSON struct { type scryptParamsJSON struct {
@ -78,15 +77,9 @@ type scryptParamsJSON struct {
} }
func (k *Key) MarshalJSON() (j []byte, err error) { func (k *Key) MarshalJSON() (j []byte, err error) {
keyHeader := keyHeaderJSON{
Version: "1",
Kdf: "",
KdfParams: nil,
}
jStruct := plainKeyJSON{ jStruct := plainKeyJSON{
k.Id, k.Id,
k.Address.Bytes(), k.Address.Bytes(),
keyHeader,
FromECDSA(k.PrivateKey), FromECDSA(k.PrivateKey),
} }
j, err = json.Marshal(jStruct) j, err = json.Marshal(jStruct)

View File

@ -153,7 +153,7 @@ func (ks keyStorePassphrase) StoreKey(key *Key, auth string) (err error) {
keyHeaderJSON := keyHeaderJSON{ keyHeaderJSON := keyHeaderJSON{
Version: keyHeaderVersion, Version: keyHeaderVersion,
Kdf: keyHeaderKDF, Kdf: keyHeaderKDF,
KdfParams: &paramsJSON, KdfParams: paramsJSON,
} }
keyHeaderJSONStr, err := json.Marshal(keyHeaderJSON) keyHeaderJSONStr, err := json.Marshal(keyHeaderJSON)
@ -167,12 +167,12 @@ func (ks keyStorePassphrase) StoreKey(key *Key, auth string) (err error) {
mac, mac,
salt, salt,
iv, iv,
keyHeaderJSON,
cipherText, cipherText,
} }
keyStruct := encryptedKeyJSON{ keyStruct := encryptedKeyJSON{
key.Id, key.Id,
key.Address.Bytes(), key.Address.Bytes(),
keyHeaderJSON,
cipherStruct, cipherStruct,
} }
keyJSON, err := json.Marshal(keyStruct) keyJSON, err := json.Marshal(keyStruct)
@ -204,11 +204,10 @@ func DecryptKey(ks keyStorePassphrase, keyAddr common.Address, auth string) (key
err = json.Unmarshal(fileContent, keyProtected) err = json.Unmarshal(fileContent, keyProtected)
keyId = keyProtected.Id keyId = keyProtected.Id
keyHeader := keyProtected.KeyHeader
mac := keyProtected.Crypto.MAC mac := keyProtected.Crypto.MAC
salt := keyProtected.Crypto.Salt salt := keyProtected.Crypto.Salt
iv := keyProtected.Crypto.IV iv := keyProtected.Crypto.IV
keyHeader := keyProtected.Crypto.KeyHeader
cipherText := keyProtected.Crypto.CipherText cipherText := keyProtected.Crypto.CipherText
// used in MAC // used in MAC