diff options
author | obscuren <geffobscura@gmail.com> | 2014-05-02 18:11:55 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-05-02 18:11:55 +0800 |
commit | 70c8656640a861d93ac40181c6c0bdd8faef856b (patch) | |
tree | 6babcc228bf72af9381656f2a57821050c85c9d4 /ethchain | |
parent | 17674fb888d3dc2de081f1c781a227b61c961189 (diff) | |
download | go-tangerine-70c8656640a861d93ac40181c6c0bdd8faef856b.tar go-tangerine-70c8656640a861d93ac40181c6c0bdd8faef856b.tar.gz go-tangerine-70c8656640a861d93ac40181c6c0bdd8faef856b.tar.bz2 go-tangerine-70c8656640a861d93ac40181c6c0bdd8faef856b.tar.lz go-tangerine-70c8656640a861d93ac40181c6c0bdd8faef856b.tar.xz go-tangerine-70c8656640a861d93ac40181c6c0bdd8faef856b.tar.zst go-tangerine-70c8656640a861d93ac40181c6c0bdd8faef856b.zip |
Added a KeyPairFromSec function which creates a new keypair based on the given seckey
Diffstat (limited to 'ethchain')
-rw-r--r-- | ethchain/keypair.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ethchain/keypair.go b/ethchain/keypair.go index a5af791d0..0f23bacdf 100644 --- a/ethchain/keypair.go +++ b/ethchain/keypair.go @@ -2,6 +2,7 @@ package ethchain import ( "github.com/ethereum/eth-go/ethutil" + "github.com/obscuren/secp256k1-go" "math/big" ) @@ -14,6 +15,15 @@ type KeyPair struct { state *State } +func NewKeyPairFromSec(seckey []byte) (*KeyPair, error) { + pubkey, err := secp256k1.GeneratePubKey(seckey) + if err != nil { + return nil, err + } + + return &KeyPair{PrivateKey: seckey, PublicKey: pubkey}, nil +} + func NewKeyPairFromValue(val *ethutil.Value) *KeyPair { keyPair := &KeyPair{PrivateKey: val.Get(0).Bytes(), PublicKey: val.Get(1).Bytes()} |