Documentation
¶
Index ¶
- Constants
- func Bytes2Hex(d []byte) string
- func Bytes2HexWith0x(b []byte) string
- func CopyBytes(b []byte) (copiedBytes []byte)
- func FromECDSAPub(pub *ecdsa.PublicKey) []byte
- func FromHex(s string) []byte
- func Hex2Bytes(str string) []byte
- func Hex2BytesFixed(str string, flen int) []byte
- func Keccak256(data ...[]byte) []byte
- func PubkeyToAddress(p *ecdsa.PublicKey) address.Address
- func RecoverPubkey(hash, sig []byte) (*ecdsa.PublicKey, error)
- type Hash
- type KeccakState
Constants ¶
const ( // HashLength is the expected length of the hash HashLength = 32 // AddressLength is the expected length of the address AddressLength = 20 )
Lengths of hashes and addresses in bytes.
Variables ¶
This section is empty.
Functions ¶
func Bytes2HexWith0x ¶
Bytes2HexWith0x encodes b as a hex string with 0x prefix.
func FromECDSAPub ¶
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".
func Hex2BytesFixed ¶
Hex2BytesFixed returns bytes of a specified fixed length flen.
Types ¶
type Hash ¶
type Hash [HashLength]byte
Hash represents the 32 byte Keccak256 hash of arbitrary data.
func BigToHash ¶
BigToHash sets byte representation of b to hash. If b is larger than len(h), b will be cropped from the left.
func BytesToHash ¶
BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.
func HexToHash ¶
HexToHash sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.
func (Hash) Format ¶
Format implements fmt.Formatter. Hash supports the %v, %s, %q, %x, %X and %d format verbs.
func (*Hash) SetBytes ¶
SetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.
func (Hash) String ¶
String implements the stringer interface and is used also by the logger when doing full logging into a file.
func (Hash) TerminalString ¶
TerminalString implements log.TerminalStringer, formatting a string for console output during logging.
type KeccakState ¶
KeccakState wraps sha3.state. In addition to the usual hash methods, it also supports Read to get a variable amount of data from the hash state. Read is faster than Sum because it doesn't copy the internal state, but also modifies the internal state.