aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/key.go
diff options
context:
space:
mode:
authorGustav Simonsson <gustav.simonsson@gmail.com>2015-04-15 21:47:00 +0800
committerGustav Simonsson <gustav.simonsson@gmail.com>2015-05-12 23:19:39 +0800
commitcd88295f5ac360aaaf63be94ae09f202a4b8630f (patch)
tree09fbc21c5fedcdbe8ea63f2b3a83d98ef204da6c /crypto/key.go
parent29a5a92d13cad45794c6e42cb97260a9ab9900ab (diff)
downloaddexon-cd88295f5ac360aaaf63be94ae09f202a4b8630f.tar.gz
dexon-cd88295f5ac360aaaf63be94ae09f202a4b8630f.tar.zst
dexon-cd88295f5ac360aaaf63be94ae09f202a4b8630f.zip
Add key header to unencrypted key file
Diffstat (limited to 'crypto/key.go')
-rw-r--r--crypto/key.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/crypto/key.go b/crypto/key.go
index 067a5a294..0f36a7f6b 100644
--- a/crypto/key.go
+++ b/crypto/key.go
@@ -45,27 +45,28 @@ type Key struct {
type plainKeyJSON struct {
Id []byte
Address []byte
+ KeyHeader keyHeaderJSON
PrivateKey []byte
}
type encryptedKeyJSON struct {
- Id []byte
- Address []byte
- Crypto cipherJSON
+ Id []byte
+ Address []byte
+ KeyHeader keyHeaderJSON
+ 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 {
@@ -77,9 +78,15 @@ 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)