Documentation
¶
Index ¶
- Constants
- func Bytes2Hex(d []byte) string
- func Encode(b []byte) string
- func FromHex(s string) []byte
- func Hex2Bytes(str string) []byte
- func IsHexAddress(s string) bool
- func VerifyP2pAddrBytes(p2pPubkey []byte, p2pAddr string) bool
- func VerifyP2pSignBytes(p2pPubkey []byte, signature []byte, message []byte) bool
- func VerifyP2pSignString(p2pPubkey []byte, signature []byte, message string) bool
- func VerifyWalletAddr(walletPubkey, walletAddr string) int
- func VerifyWalletAddrBytes(walletPubkey []byte, walletAddr string) int
- func VerifyWalletSign(walletPubkey, signature, message string) bool
- func VerifyWalletSignBytes(walletPubkey []byte, signature []byte, message string) bool
- type AccPrivKey
- type AccPubKey
- type Address
- func (a Address) Big() *big.Int
- func (a Address) Bytes() []byte
- func (a Address) Compare(b Address) int
- func (a Address) Hash() Hash
- func (a Address) Hex() string
- func (a Address) P2pAddressToBech() (string, error)
- func (a Address) P2pPublicKeyToBech() (string, error)
- func (a *Address) SetBytes(b []byte)
- func (a Address) String() string
- func (a Address) ToBech(hrp string) (string, error)
- func (a Address) WalletAddressToBech() (string, error)
- type Hash
- type P2pPrivKey
- type P2pPubKey
Constants ¶
const ( // HashLength is the expected length of the hash HashLength = 32 // AddressLength AddressLength = 20 // AccPublicKeyLength AccPublicKeyLength = 33 // AccPrivateKeyLength AccPrivateKeyLength = 32 // P2pPublicKeyLength P2pPublicKeyLength = 32 // P2pPrivateKeyLength P2pPrivateKeyLength = 64 P2pAddressBech32Length = 44 P2pSignatureLength = 64 )
Lengths of hashes and addresses in bytes.
Variables ¶
This section is empty.
Functions ¶
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".
func IsHexAddress ¶
IsHexAddress verifies whether a string can represent a valid hex-encoded Ethereum address or not.
func VerifyP2pAddrBytes ¶
VerifyP2pAddrBytes verify whether P2P address matches public key
func VerifyP2pSignBytes ¶
VerifyP2pSignBytes verify the signature made by P2P key
func VerifyP2pSignString ¶
VerifyP2pSignString verify the signature made by P2P key
func VerifyWalletAddr ¶
VerifyWalletAddr verify the wallet address and public key match
func VerifyWalletAddrBytes ¶
VerifyWalletAddrBytes []byte version of VerifyWalletKey() for the pubkey format
func VerifyWalletSign ¶
VerifyWalletSign verify the signature by wallet key
Types ¶
type AccPrivKey ¶
type AccPrivKey [AccPrivateKeyLength]byte
AccPrivKey account(wallet) private key
func BytesToAccPriveKey ¶
func BytesToAccPriveKey(b []byte) AccPrivKey
BytesToAccPriveKey sets b to PrivKey. If b is larger than len(h), b will be cropped from the left.
func (AccPrivKey) Bytes ¶
func (p AccPrivKey) Bytes() []byte
Bytes gets the byte representation of the underlying hash.
func (AccPrivKey) PubKeyFromPrivKey ¶
func (p AccPrivKey) PubKeyFromPrivKey() AccPubKey
PubKeyFromPrivKey generate a AccPubKey from the AccPrivKey
func (*AccPrivKey) SetBytes ¶
func (p *AccPrivKey) SetBytes(b []byte)
SetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.
type AccPubKey ¶
type AccPubKey [AccPublicKeyLength]byte
AccPubKey account(wallet) public key
func BytesToAccPubKey ¶
BytesToPubKey sets b to PubKey. If b is larger than len(h), b will be cropped from the left.
func WalletPubkeyFromBech ¶
WalletPubkeyFromBech create an AccPubKey from Bech of wallet pubkey
type Address ¶
type Address [AddressLength]byte
Address
func BigToAddress ¶
BigToAddress returns Address with byte values of b. If b is larger than len(h), b will be cropped from the left.
func BytesToAddress ¶
BytesToAddress returns Address with value b. If b is larger than len(h), b will be cropped from the left.
func HexToAddress ¶
HexToAddress returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left.
func P2pAddressFromBech ¶
func WalletAddressFromBech ¶
func (Address) P2pAddressToBech ¶
func (Address) P2pPublicKeyToBech ¶
func (*Address) SetBytes ¶
SetBytes sets the address to the value of b. If b is larger than len(a) it will panic.
func (Address) WalletAddressToBech ¶
type Hash ¶
type Hash [HashLength]byte
Hash represents the 32 byte Keccak256 hash of arbitrary data.
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, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.
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 P2pPrivKey ¶
type P2pPrivKey [P2pPrivateKeyLength]byte
P2pPrivKey P2P address private key
func BytesToP2pPrivKey ¶
func BytesToP2pPrivKey(b []byte) P2pPrivKey
BytesToAccPriveKey sets b to P2pPrivKey. If b is larger than len(h), b will be cropped from the left.
func (P2pPrivKey) Address ¶
func (p P2pPrivKey) Address() Address
Address generate an Address from a P2pPrivKey
func (P2pPrivKey) Bytes ¶
func (p P2pPrivKey) Bytes() []byte
Bytes gets the byte representation of the underlying hash.
func (P2pPrivKey) PubKey ¶
func (p P2pPrivKey) PubKey() P2pPubKey
PubKey generate a P2pPubKey from a P2pPrivKey
func (*P2pPrivKey) SetBytes ¶
func (p *P2pPrivKey) SetBytes(b []byte)
SetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.
func (P2pPrivKey) Sign ¶
func (p P2pPrivKey) Sign(b []byte) []byte
Sign p2p address uses ed25519 algo
type P2pPubKey ¶
type P2pPubKey [P2pPublicKeyLength]byte
P2pPubKey P2P address public key
func BytesToP2pPubKey ¶
BytesToP2pPubKey sets b to P2pPubKey If b is larger than len(h), b will be cropped from the left.
func P2pPubKeyFromBech ¶
P2pPubKeyFromBech create a P2pPubKey from a Bech-encoded P2P public key