Documentation ¶
Index ¶
- func CreateAddress(addr common.Address, nonce uint64) common.Address
- func CreateAddress2(b common.Address, salt common.Hash, inithash []byte) common.Address
- func Ecrecover(hash, sig []byte) ([]byte, error)
- func FromECDSA(priv *ecdsa.PrivateKey) []byte
- func FromECDSAPub(pub *ecdsa.PublicKey) []byte
- func GenerateKey() (*ecdsa.PrivateKey, error)
- func GenerateKeyPair() (*common.Address, *ecdsa.PrivateKey, error)
- func GenerateRandomAddress() (*common.Address, error)
- func GetAddress(key *ecdsa.PublicKey) *common.Address
- func HashBytes(data ...[]byte) common.Hash
- func Keccak256(data ...[]byte) []byte
- func Keccak256Hash(data ...[]byte) common.Hash
- func Keccak512(data ...[]byte) []byte
- func LoadECDSAFromString(ecStr string) (*ecdsa.PrivateKey, error)
- func MustGenerateKeyPairNotShard(shard uint) (*common.Address, *ecdsa.PrivateKey)
- func MustGenerateRandomAddress() *common.Address
- func MustGenerateShardAddress(shardNum uint) *common.Address
- func MustGenerateShardKeyPair(shard uint) (*common.Address, *ecdsa.PrivateKey)
- func MustHash(v interface{}) common.Hash
- func PubkeyToAddress(key ecdsa.PublicKey) common.Address
- func PubkeyToString(pub *ecdsa.PublicKey) string
- func S256() elliptic.Curve
- func SigToPub(hash, sig []byte) (*ecdsa.PublicKey, error)
- func ToECDSA(d []byte) (*ecdsa.PrivateKey, error)
- func ToECDSAPub(pub []byte) *ecdsa.PublicKey
- func ValidateSignatureValues(v byte, r, s *big.Int, homestead bool) bool
- type Signature
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateAddress ¶
CreateAddress creates a new address with the specified address and nonce. Generally, it's used to create a new contract address based on the account address and nonce. Note, the new created contract address and the account address are in the same shard.
func CreateAddress2 ¶
CreateAddress2 creates an ethereum address given the address bytes, initial contract code hash and a salt.
func FromECDSA ¶
func FromECDSA(priv *ecdsa.PrivateKey) []byte
FromECDSA exports a private key into a binary dump.
func FromECDSAPub ¶
FromECDSAPub marshals and returns the byte array of the specified ECDSA public key.
func GenerateKey ¶
func GenerateKey() (*ecdsa.PrivateKey, error)
GenerateKey generates and returns an ECDSA private key.
func GenerateKeyPair ¶
func GenerateKeyPair() (*common.Address, *ecdsa.PrivateKey, error)
GenerateKeyPair generates public key and private key
func GenerateRandomAddress ¶
GenerateRandomAddress generates and returns a random address.
func GetAddress ¶
GetAddress gets an address from the given public key
func Keccak256Hash ¶
Keccak256Hash calculates and returns the Keccak256 hash of the input data, converting it to an internal Hash data structure.
func LoadECDSAFromString ¶
func LoadECDSAFromString(ecStr string) (*ecdsa.PrivateKey, error)
LoadECDSAFromString creates ecdsa private key from the given string. ecStr should start with 0x or 0X
func MustGenerateKeyPairNotShard ¶
func MustGenerateKeyPairNotShard(shard uint) (*common.Address, *ecdsa.PrivateKey)
MustGenerateKeyPairNotShard generates and returns a random address and key. Panic on any error.
func MustGenerateRandomAddress ¶
MustGenerateRandomAddress generates and returns a random address. Panic on any error.
func MustGenerateShardAddress ¶
MustGenerateShardAddress generates and returns a random address that match the specified shard number. Panic on any error.
func MustGenerateShardKeyPair ¶
func MustGenerateShardKeyPair(shard uint) (*common.Address, *ecdsa.PrivateKey)
MustGenerateShardKeyPair generates and returns a random address and key. Panic on any error.
func MustHash ¶
MustHash returns the hash of the specified value. Panic on any error, e.g. unsupported data type for encoding.
func PubkeyToAddress ¶
PubkeyToAddress add this method for istanbul BFT integration
func PubkeyToString ¶
PubkeyToString returns the string of the given public key, with prefix 0x
func ToECDSA ¶
func ToECDSA(d []byte) (*ecdsa.PrivateKey, error)
ToECDSA creates a private key with the given D value.
func ToECDSAPub ¶
ToECDSAPub creates ecdsa.PublicKey object by the given byte array. Pubkey length derived from ecdsa is 65, with constant prefix 4 in the first byte. So if pubkey length equals 64, we insert one byte in front
Types ¶
type Signature ¶
type Signature struct {
Sig []byte // [R || S || V] format signature in 65 bytes.
}
Signature is a wrapper for the signed message and it is serializable.
func MustSign ¶
func MustSign(privKey *ecdsa.PrivateKey, hash []byte) *Signature
MustSign signs the specified hash with private key and returns a signature. Panic if failed to sign the hash.
Directories ¶
Path | Synopsis |
---|---|
Package bn256 implements the Optimal Ate pairing over a 256-bit Barreto-Naehrig curve.
|
Package bn256 implements the Optimal Ate pairing over a 256-bit Barreto-Naehrig curve. |
cloudflare
Package bn256 implements a particular bilinear group at the 128-bit security level.
|
Package bn256 implements a particular bilinear group at the 128-bit security level. |
google
Package bn256 implements a particular bilinear group.
|
Package bn256 implements a particular bilinear group. |
Package secp256k1 wraps the bitcoin secp256k1 C library.
|
Package secp256k1 wraps the bitcoin secp256k1 C library. |
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. |