diff options
author | zelig <viktor.tron@gmail.com> | 2015-08-18 07:25:04 +0800 |
---|---|---|
committer | zelig <viktor.tron@gmail.com> | 2015-08-18 07:25:04 +0800 |
commit | d4da2f630ee16411fe41fc7c50b10a59c696503e (patch) | |
tree | 15af61dd3461f196a72e6162ccf831a821db3023 /crypto/keypair.go | |
parent | e1da1244157741b9aa17c67ef48f37d07484e905 (diff) | |
download | go-tangerine-d4da2f630ee16411fe41fc7c50b10a59c696503e.tar go-tangerine-d4da2f630ee16411fe41fc7c50b10a59c696503e.tar.gz go-tangerine-d4da2f630ee16411fe41fc7c50b10a59c696503e.tar.bz2 go-tangerine-d4da2f630ee16411fe41fc7c50b10a59c696503e.tar.lz go-tangerine-d4da2f630ee16411fe41fc7c50b10a59c696503e.tar.xz go-tangerine-d4da2f630ee16411fe41fc7c50b10a59c696503e.tar.zst go-tangerine-d4da2f630ee16411fe41fc7c50b10a59c696503e.zip |
crypto: remove obsolete key files
Diffstat (limited to 'crypto/keypair.go')
-rw-r--r-- | crypto/keypair.go | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/crypto/keypair.go b/crypto/keypair.go deleted file mode 100644 index e070f292f..000000000 --- a/crypto/keypair.go +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2014 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. - -package crypto - -import ( - "strings" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto/secp256k1" -) - -type KeyPair struct { - PrivateKey []byte - PublicKey []byte - address []byte - mnemonic string - // The associated account - // account *StateObject -} - -func GenerateNewKeyPair() *KeyPair { - _, prv := secp256k1.GenerateKeyPair() - keyPair, _ := NewKeyPairFromSec(prv) // swallow error, this one cannot err - return keyPair -} - -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 (k *KeyPair) Address() []byte { - if k.address == nil { - k.address = Sha3(k.PublicKey[1:])[12:] - } - return k.address -} - -func (k *KeyPair) Mnemonic() string { - if k.mnemonic == "" { - k.mnemonic = strings.Join(MnemonicEncode(common.Bytes2Hex(k.PrivateKey)), " ") - } - return k.mnemonic -} - -func (k *KeyPair) AsStrings() (string, string, string, string) { - return k.Mnemonic(), common.Bytes2Hex(k.Address()), common.Bytes2Hex(k.PrivateKey), common.Bytes2Hex(k.PublicKey) -} |