Documentation
¶
Index ¶
- func GenerateKey() (*ecdsa.PrivateKey, error)
- func NewKeyFromHexString(key string) (*ecdsa.PrivateKey, error)
- func PrivateKeyToBytes(key *ecdsa.PrivateKey) ([]byte, error)
- func PrivateKeyToHexString(key *ecdsa.PrivateKey) (string, error)
- func Sign(toSign []byte, key *ecdsa.PrivateKey) ([]byte, error)
- func Zero(byt []byte)
- func ZeroKey(key *ecdsa.PrivateKey)
- type Account
- type Address
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateKey ¶
func GenerateKey() (*ecdsa.PrivateKey, error)
GenerateKey generates a new random secp256k1 key
func NewKeyFromHexString ¶
func NewKeyFromHexString(key string) (*ecdsa.PrivateKey, error)
NewKeyFromHexString creates a new PrivateKey from the provided hex string-representation. The hex key can be with/without the '0x' prefix. This function should not be used with direct user input as it performs minimal validation. Auto-generated input should be used (i.e. generated keys retrieved direct from Vault) or user-input from Quorum that should have been validated at the Quorum-level. Be careful if using direct user input as valid hex may not result in a valid ethereum private key.
func PrivateKeyToBytes ¶
func PrivateKeyToBytes(key *ecdsa.PrivateKey) ([]byte, error)
PrivateKeyToBytes returns the bytes for the private component of the key, and if necessary, left-0 pads them to 32 bytes.
As outlined in https://github.com/openethereum/openethereum/issues/2263, 256 bit secp256k1 can generate valid keys that are shorter than 32 bytes. To protect against potential issues with variable lengths, key bytes should be left-0 padded.
common/math.PaddedBigBytes accomplishes this using bitwise operations for maximal performance. Given the additional HTTP overhead already introduced when using Vault, and to improve code-readability, standard slice functions have been used here.
func PrivateKeyToHexString ¶
func PrivateKeyToHexString(key *ecdsa.PrivateKey) (string, error)
PrivateKeyToHexString encodes the provided key as a hex string
Types ¶
type Address ¶
type Address [addressLength]byte
Address is the Quorum account address
func NewAddress ¶
NewAddress creates a new Address from the provided bytes. Minimal validation is performed.
func NewAddressFromHexString ¶
NewAddressFromHexString creates a new Address from the provided hex string-representation. The hexAddr can be with/without the '0x' prefix.
func PrivateKeyToAddress ¶
func PrivateKeyToAddress(key *ecdsa.PrivateKey) (Address, error)
PrivateKeyToAddress derives the valid 20-byte Quorum address from the provided private key
func (Address) ToHexString ¶
ToHexString encodes the Address as a hex string without the '0x' prefix