Added a KeyPairFromSec function which creates a new keypair based on the given seckey
This commit is contained in:
parent
17674fb888
commit
70c8656640
@ -2,6 +2,7 @@ package ethchain
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/ethereum/eth-go/ethutil"
|
"github.com/ethereum/eth-go/ethutil"
|
||||||
|
"github.com/obscuren/secp256k1-go"
|
||||||
"math/big"
|
"math/big"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,6 +15,15 @@ type KeyPair struct {
|
|||||||
state *State
|
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 {
|
func NewKeyPairFromValue(val *ethutil.Value) *KeyPair {
|
||||||
keyPair := &KeyPair{PrivateKey: val.Get(0).Bytes(), PublicKey: val.Get(1).Bytes()}
|
keyPair := &KeyPair{PrivateKey: val.Get(0).Bytes(), PublicKey: val.Get(1).Bytes()}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user