Documentation ¶
Index ¶
- Variables
- func CreateAddress(b common.Address, nonce uint64) common.Address
- func Decrypt(prv *ecdsa.PrivateKey, ct []byte) ([]byte, error)
- func DecryptKey(ks keyStorePassphrase, keyAddr common.Address, auth string) (keyBytes []byte, keyId []byte, err error)
- func Ecrecover(hash, sig []byte) ([]byte, error)
- func Encrypt(pub *ecdsa.PublicKey, message []byte) ([]byte, error)
- func FromECDSA(prv *ecdsa.PrivateKey) []byte
- func FromECDSAPub(pub *ecdsa.PublicKey) []byte
- func GenerateKey() (*ecdsa.PrivateKey, error)
- func GetKeyAddresses(keysDirPath string) (addresses []common.Address, err error)
- func GetKeyFile(keysDirPath string, keyAddr common.Address) (fileContent []byte, err error)
- func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error)
- func ImportBlockTestKey(privKeyBytes []byte) error
- func IndexOf(slice []string, value string) int64
- func LoadECDSA(file string) (*ecdsa.PrivateKey, error)
- func MnemonicDecode(wordsar []string) string
- func MnemonicEncode(message string) []string
- func PKCS7Pad(in []byte) []byte
- func PKCS7Unpad(in []byte) []byte
- func PubkeyToAddress(p ecdsa.PublicKey) common.Address
- func Ripemd160(data []byte) []byte
- func SaveECDSA(file string, key *ecdsa.PrivateKey) error
- func Sha256(data []byte) []byte
- func Sha3(data ...[]byte) []byte
- func Sha3Hash(data ...[]byte) (h common.Hash)
- func SigToPub(hash, sig []byte) (*ecdsa.PublicKey, error)
- func Sign(hash []byte, prv *ecdsa.PrivateKey) (sig []byte, err error)
- func ToECDSA(prv []byte) *ecdsa.PrivateKey
- func ToECDSAPub(pub []byte) *ecdsa.PublicKey
- func ValidateSignatureValues(v byte, r, s *big.Int) bool
- func WriteKeyFile(addr common.Address, keysDirPath string, content []byte) (err error)
- type BitCurve
- func (BitCurve *BitCurve) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)
- func (BitCurve *BitCurve) Double(x1, y1 *big.Int) (*big.Int, *big.Int)
- func (BitCurve *BitCurve) GenerateKey(rand io.Reader) (priv []byte, x, y *big.Int, err error)
- func (BitCurve *BitCurve) IsOnCurve(x, y *big.Int) bool
- func (BitCurve *BitCurve) Marshal(x, y *big.Int) []byte
- func (BitCurve *BitCurve) Params() *elliptic.CurveParams
- func (BitCurve *BitCurve) ScalarBaseMult(k []byte) (*big.Int, *big.Int)
- func (BitCurve *BitCurve) ScalarMult(Bx, By *big.Int, k []byte) (*big.Int, *big.Int)
- func (BitCurve *BitCurve) Unmarshal(data []byte) (x, y *big.Int)
- type Key
- type KeyPair
- type KeyStore2
Constants ¶
This section is empty.
Variables ¶
var MnemonicWords []string = []string{}/* 1626 elements not displayed */
Functions ¶
func CreateAddress ¶
Creates an ethereum address given the bytes and the nonce
func DecryptKey ¶ added in v0.8.4
func FromECDSA ¶
func FromECDSA(prv *ecdsa.PrivateKey) []byte
func FromECDSAPub ¶
func GenerateKey ¶
func GenerateKey() (*ecdsa.PrivateKey, error)
func GetKeyAddresses ¶ added in v0.8.4
func GetKeyFile ¶ added in v0.8.4
func HexToECDSA ¶ added in v0.8.4
func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error)
HexToECDSA parses a secp256k1 private key.
func ImportBlockTestKey ¶ added in v0.9.17
Used only by block tests.
func IndexOf ¶
TODO: See if we can refactor this into a shared util lib if we need it multiple times
func LoadECDSA ¶ added in v0.8.4
func LoadECDSA(file string) (*ecdsa.PrivateKey, error)
LoadECDSA loads a secp256k1 private key from the given file. The key data is expected to be hex-encoded.
func MnemonicDecode ¶
func MnemonicEncode ¶
func PKCS7Pad ¶ added in v0.8.4
From https://leanpub.com/gocrypto/read#leanpub-auto-block-cipher-modes
func PKCS7Unpad ¶ added in v0.8.4
func SaveECDSA ¶ added in v0.9.17
func SaveECDSA(file string, key *ecdsa.PrivateKey) error
SaveECDSA saves a secp256k1 private key to the given file with restrictive permissions. The key data is saved hex-encoded.
func ToECDSA ¶
func ToECDSA(prv []byte) *ecdsa.PrivateKey
New methods using proper ecdsa keys from the stdlib
func ToECDSAPub ¶
func ValidateSignatureValues ¶ added in v0.9.28
Types ¶
type BitCurve ¶
type BitCurve struct { P *big.Int // the order of the underlying field N *big.Int // the order of the base point B *big.Int // the constant of the BitCurve equation Gx, Gy *big.Int // (x,y) of the base point BitSize int // the size of the underlying field }
A BitCurve represents a Koblitz Curve with a=0. See http://www.hyperelliptic.org/EFD/g1p/auto-shortw.html
func S160 ¶
func S160() *BitCurve
S160 returns a BitCurve which implements secp160k1 (see SEC 2 section 2.4.1)
func S192 ¶
func S192() *BitCurve
S192 returns a BitCurve which implements secp192k1 (see SEC 2 section 2.5.1)
func S224 ¶
func S224() *BitCurve
S224 returns a BitCurve which implements secp224k1 (see SEC 2 section 2.6.1)
func S256 ¶
func S256() *BitCurve
S256 returns a BitCurve which implements secp256k1 (see SEC 2 section 2.7.1)
func (*BitCurve) GenerateKey ¶
TODO: double check if it is okay GenerateKey returns a public/private key pair. The private key is generated using the given reader, which must return random data.
func (*BitCurve) Marshal ¶
Marshal converts a point into the form specified in section 4.3.6 of ANSI X9.62.
func (*BitCurve) Params ¶
func (BitCurve *BitCurve) Params() *elliptic.CurveParams
func (*BitCurve) ScalarBaseMult ¶
ScalarBaseMult returns k*G, where G is the base point of the group and k is an integer in big-endian form.
func (*BitCurve) ScalarMult ¶
TODO: double check if it is okay ScalarMult returns k*(Bx,By) where k is a number in big-endian form.
type Key ¶ added in v0.8.4
type Key struct { Id uuid.UUID // Version 4 "random" for unique id not derived from key data // to simplify lookups we also store the address Address common.Address // we only store privkey as pubkey/address can be derived from it // privkey in this struct is always in plaintext PrivateKey *ecdsa.PrivateKey }
func GenerateNewKeyDefault ¶ added in v0.8.4
func ImportPreSaleKey ¶ added in v0.8.4
creates a Key and stores that in the given KeyStore by decrypting a presale key JSON
func NewKeyFromECDSA ¶ added in v0.9.17
func NewKeyFromECDSA(privateKeyECDSA *ecdsa.PrivateKey) *Key
func (*Key) MarshalJSON ¶ added in v0.8.4
func (*Key) UnmarshalJSON ¶ added in v0.8.4
type KeyPair ¶
type KeyPair struct { PrivateKey []byte PublicKey []byte // contains filtered or unexported fields }
func GenerateNewKeyPair ¶
func GenerateNewKeyPair() *KeyPair
func NewKeyPairFromSec ¶
type KeyStore2 ¶ added in v0.8.4
type KeyStore2 interface { // create new key using io.Reader entropy source and optionally using auth string GenerateNewKey(io.Reader, string) (*Key, error) GetKey(common.Address, string) (*Key, error) // key from addr and auth string GetKeyAddresses() ([]common.Address, error) // get all addresses StoreKey(*Key, string) error // store key optionally using auth string DeleteKey(common.Address, string) error // delete key by addr and auth string }
TODO: rename to KeyStore when replacing existing KeyStore
func NewKeyStorePassphrase ¶ added in v0.8.4
func NewKeyStorePlain ¶ added in v0.8.4
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package sha3 implements the SHA3 hash algorithm (formerly called Keccak) chosen by NIST in 2012.
|
Package sha3 implements the SHA3 hash algorithm (formerly called Keccak) chosen by NIST in 2012. |