Documentation ¶
Index ¶
- Constants
- func CreateAddress(b common.Address, nonce uint64) common.Address
- func Decrypt(prv *ecdsa.PrivateKey, ct []byte) ([]byte, error)
- func Ecrecover(hash, sig []byte) ([]byte, error)
- func Encrypt(pub *ecdsa.PublicKey, message []byte) ([]byte, error)
- func EncryptKey(key *Key, auth string, scryptN, scryptP int) ([]byte, error)
- func FromECDSA(prv *ecdsa.PrivateKey) []byte
- func FromECDSAPub(pub *ecdsa.PublicKey) []byte
- func GenerateKey() (*ecdsa.PrivateKey, error)
- func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error)
- func ImportBlockTestKey(privKeyBytes []byte) error
- func Keccak256(data ...[]byte) []byte
- func Keccak256Hash(data ...[]byte) (h common.Hash)
- func LoadECDSA(file string) (*ecdsa.PrivateKey, error)
- 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) []bytedeprecated
- func Sha3Hash(data ...[]byte) 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, homestead bool) bool
- type Key
- func DecryptKey(keyjson []byte, auth string) (*Key, error)
- func GenerateNewKeyDefault(ks KeyStore, rand io.Reader, auth string) (key *Key, err error)
- func ImportPreSaleKey(keyStore KeyStore, keyJSON []byte, password string) (*Key, error)
- func NewKey(rand io.Reader) *Key
- func NewKeyForDirectICAP(rand io.Reader) *Key
- func NewKeyFromECDSA(privateKeyECDSA *ecdsa.PrivateKey) *Key
- type KeyStore
Constants ¶
const ( // n,r,p = 2^18, 8, 1 uses 256MB memory and approx 1s CPU time on a modern CPU. StandardScryptN = 1 << 18 StandardScryptP = 1 // n,r,p = 2^12, 8, 6 uses 4MB memory and approx 100ms CPU time on a modern CPU. LightScryptN = 1 << 12 LightScryptP = 6 )
Variables ¶
This section is empty.
Functions ¶
func CreateAddress ¶
Creates an ethereum address given the bytes and the nonce
func EncryptKey ¶
EncryptKey encrypts a key using the specified scrypt parameters into a json blob that can be decrypted later on.
func FromECDSA ¶
func FromECDSA(prv *ecdsa.PrivateKey) []byte
func FromECDSAPub ¶
func GenerateKey ¶
func GenerateKey() (*ecdsa.PrivateKey, error)
func HexToECDSA ¶
func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error)
HexToECDSA parses a secp256k1 private key.
func ImportBlockTestKey ¶
Used only by block tests.
func Keccak256Hash ¶
func LoadECDSA ¶
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 SaveECDSA ¶
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 ¶
Types ¶
type Key ¶
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 DecryptKey ¶
DecryptKey decrypts a key from a json blob, returning the private key itself.
func GenerateNewKeyDefault ¶
func ImportPreSaleKey ¶
creates a Key and stores that in the given KeyStore by decrypting a presale key JSON
func NewKeyForDirectICAP ¶
generate key whose address fits into < 155 bits so it can fit into the Direct ICAP spec. for simplicity and easier compatibility with other libs, we retry until the first byte is 0.
func NewKeyFromECDSA ¶
func NewKeyFromECDSA(privateKeyECDSA *ecdsa.PrivateKey) *Key
func (*Key) MarshalJSON ¶
func (*Key) UnmarshalJSON ¶
type KeyStore ¶
type KeyStore 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) // get 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 Cleanup(keyAddr common.Address) (err error) }
func NewKeyStorePassphrase ¶
func NewKeyStorePlain ¶
Directories ¶
Path | Synopsis |
---|---|
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
|
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202. |