aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/key.go
diff options
context:
space:
mode:
authorGustav Simonsson <gustav.simonsson@gmail.com>2015-01-21 06:55:13 +0800
committerGustav Simonsson <gustav.simonsson@gmail.com>2015-01-21 23:35:43 +0800
commit1f8290ca44df31cc4c4b68b30eef412476ed24e0 (patch)
treed3cef09eedffc76848b43e8f339593578156545c /crypto/key.go
parent4df2e1ef5c20ebd7004a595de7e6a032699106ad (diff)
downloadgo-tangerine-1f8290ca44df31cc4c4b68b30eef412476ed24e0.tar.gz
go-tangerine-1f8290ca44df31cc4c4b68b30eef412476ed24e0.tar.zst
go-tangerine-1f8290ca44df31cc4c4b68b30eef412476ed24e0.zip
Add ImportPreSaleKey
* ImportPreSaleKey takes a KeyStore, a presale key JSON (e.g. file content) and a password string. It stores the key in the given key store. * Refactored common AES decryption and moved some functions to crypto.go
Diffstat (limited to 'crypto/key.go')
-rw-r--r--crypto/key.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/crypto/key.go b/crypto/key.go
index d371ad4dc..ca29b691f 100644
--- a/crypto/key.go
+++ b/crypto/key.go
@@ -57,7 +57,7 @@ type encryptedKeyJSON struct {
func (k *Key) Address() []byte {
pubBytes := FromECDSAPub(&k.PrivateKey.PublicKey)
- return Sha3(pubBytes)[12:]
+ return Sha3(pubBytes[1:])[12:]
}
func (k *Key) MarshalJSON() (j []byte, err error) {
@@ -99,9 +99,10 @@ func NewKey(rand io.Reader) *Key {
privateKeyMarshalled := elliptic.Marshal(S256(), x, y)
privateKeyECDSA := ToECDSA(privateKeyMarshalled)
- key := new(Key)
id := uuid.NewRandom()
- key.Id = &id
- key.PrivateKey = privateKeyECDSA
+ key := &Key{
+ Id: &id,
+ PrivateKey: privateKeyECDSA,
+ }
return key
}