Documentation ¶
Index ¶
- 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 FromECDSA(prv *ecdsa.PrivateKey) []byte
- func FromECDSAPub(pub *ecdsa.PublicKey) []byte
- func GenerateKey() (*ecdsa.PrivateKey, error)
- func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error)
- func Keccak256(data ...[]byte) []byte
- func Keccak256Hash(data ...[]byte) (h common.Hash)
- func LoadECDSA(file string) (*ecdsa.PrivateKey, error)
- 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(data []byte, prv *ecdsa.PrivateKey) (sig []byte, err error)
- func SignEthereum(data []byte, prv *ecdsa.PrivateKey) ([]byte, error)
- func ToECDSA(prv []byte) *ecdsa.PrivateKey
- func ToECDSAPub(pub []byte) *ecdsa.PublicKey
- func ValidateSignatureValues(v byte, r, s *big.Int, homestead bool) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateAddress ¶
Creates an ethereum address given the bytes and the nonce
func Ecrecover ¶
Ecrecover returns the public key for the private key that was used to calculate the signature.
Note: secp256k1 expects the recover id to be either 0, 1. Ethereum signatures have a recover id with an offset of 27. Callers must take this into account and if "recovering" from an Ethereum signature adjust.
func FromECDSA ¶
func FromECDSA(prv *ecdsa.PrivateKey) []byte
func FromECDSAPub ¶
func GenerateKey ¶
func GenerateKey() (*ecdsa.PrivateKey, error)
func HexToECDSA ¶ added in v0.9.22
func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error)
HexToECDSA parses a secp256k1 private key.
func Keccak256Hash ¶ added in v1.4.0
func LoadECDSA ¶ added in v0.9.22
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 ¶ added in v0.9.22
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 Sign ¶
func Sign(data []byte, prv *ecdsa.PrivateKey) (sig []byte, err error)
Sign calculates an ECDSA signature. This function is susceptible to choosen plaintext attacks that can leak information about the private key that is used for signing. Callers must be aware that the given hash cannot be choosen by an adversery. Common solution is to hash any input before calculating the signature.
Note: the calculated signature is not Ethereum compliant. The yellow paper dictates Ethereum singature to have a V value with and offset of 27 v in [27,28]. Use SignEthereum to get an Ethereum compliant signature.
func SignEthereum ¶ added in v1.5.0
func SignEthereum(data []byte, prv *ecdsa.PrivateKey) ([]byte, error)
SignEthereum calculates an Ethereum ECDSA signature. This function is susceptible to choosen plaintext attacks that can leak information about the private key that is used for signing. Callers must be aware that the given hash cannot be freely choosen by an adversery. Common solution is to hash the message before calculating the signature.
func ToECDSA ¶
func ToECDSA(prv []byte) *ecdsa.PrivateKey
New methods using proper ecdsa keys from the stdlib
func ToECDSAPub ¶
Types ¶
This section is empty.
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. |