diff options
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/crypto.go | 13 | ||||
-rw-r--r-- | crypto/key_store_plain.go | 5 | ||||
-rw-r--r-- | crypto/secp256k1/README.md | 5 | ||||
-rw-r--r-- | crypto/secp256k1/secp256.go | 2 |
4 files changed, 21 insertions, 4 deletions
diff --git a/crypto/crypto.go b/crypto/crypto.go index 89423e0c4..3c5783014 100644 --- a/crypto/crypto.go +++ b/crypto/crypto.go @@ -179,6 +179,19 @@ func Decrypt(prv *ecdsa.PrivateKey, ct []byte) ([]byte, error) { return key.Decrypt(rand.Reader, ct, nil, nil) } +// Used only by block tests. +func ImportBlockTestKey(privKeyBytes []byte) error { + ks := NewKeyStorePassphrase(common.DefaultDataDir() + "/keys") + ecKey := ToECDSA(privKeyBytes) + key := &Key{ + Id: uuid.NewRandom(), + Address: PubkeyToAddress(ecKey.PublicKey), + PrivateKey: ecKey, + } + err := ks.StoreKey(key, "") + return err +} + // creates a Key and stores that in the given KeyStore by decrypting a presale key JSON func ImportPreSaleKey(keyStore KeyStore2, keyJSON []byte, password string) (*Key, error) { key, err := decryptPreSaleKey(keyJSON, password) diff --git a/crypto/key_store_plain.go b/crypto/key_store_plain.go index 338a4a2c3..9bbaf1c15 100644 --- a/crypto/key_store_plain.go +++ b/crypto/key_store_plain.go @@ -117,13 +117,12 @@ func GetKeyAddresses(keysDirPath string) (addresses [][]byte, err error) { if err != nil { return nil, err } - addresses = make([][]byte, len(fileInfos)) - for i, fileInfo := range fileInfos { + for _, fileInfo := range fileInfos { address, err := hex.DecodeString(fileInfo.Name()) if err != nil { continue } - addresses[i] = address + addresses = append(addresses, address) } return addresses, err } diff --git a/crypto/secp256k1/README.md b/crypto/secp256k1/README.md index 79cdccb38..5a86147d4 100644 --- a/crypto/secp256k1/README.md +++ b/crypto/secp256k1/README.md @@ -7,8 +7,11 @@ Implements cryptographic operations for the secp256k1 ECDSA curve used by Bitcoi Installing === + +GMP library headers are required to build. On Debian-based systems, the package is called `libgmp-dev`. + ``` -sudo apt-get install gmp-dev +sudo apt-get install libgmp-dev ``` Now compiles with cgo! diff --git a/crypto/secp256k1/secp256.go b/crypto/secp256k1/secp256.go index 6eafea2fa..f8cc60e82 100644 --- a/crypto/secp256k1/secp256.go +++ b/crypto/secp256k1/secp256.go @@ -5,8 +5,10 @@ package secp256k1 /* #cgo CFLAGS: -I./secp256k1 #cgo darwin CFLAGS: -I/usr/local/include +#cgo linux,arm CFLAGS: -I/usr/local/arm/include #cgo LDFLAGS: -lgmp #cgo darwin LDFLAGS: -L/usr/local/lib +#cgo linux,arm LDFLAGS: -L/usr/local/arm/lib #define USE_NUM_GMP #define USE_FIELD_10X26 #define USE_FIELD_INV_BUILTIN |