Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeHexString(s string) (b []byte, err error)
- func LegacyKeccak256Hash(data []byte) string
- func MakeHashKeccak256(obj interface{}, excepts ...string) []byte
- func MakeHashKeccak256Hex(obj interface{}, excepts ...string) string
- func MakeHashSHA256(obj interface{}, excepts ...string) []byte
- func MakeHashSHA256Hex(obj interface{}, excepts ...string) string
- func MakeSignString(obj interface{}, excepts ...string) string
- func MustSignatureFromBase58(in string) solana.Signature
- func PersonalSignHash(data []byte) string
- func PublicKey2Address(strPublicKey string) (string, error)
- func RecoverKeccak256Hash(strHash, strSignature string) (string, error)
- func RecoverKeccak256Msg(strMsg, strSignature string) (string, error)
- func RecoverLegacyKeccak256Hash(strHash, strSignature string) (strPubKey string, err error)
- func RecoverLegacyKeccak256Msg(strMsg, strSignature string) (string, error)
- func VerifyKeccak256(strAddress, strMsg, strSignature string) (bool, error)
- func VerifyLegacyKeccak256(strAddress, strMsg, strSignature string) (bool, error)
- func VerifySignatureSolana(strAddress, strMsg, strSignature string) (bool, error)
- type OpType
- type Wallet
- type WalletEthereum
- func (m *WalletEthereum) Create() Wallet
- func (m *WalletEthereum) GetAddress() string
- func (m *WalletEthereum) GetPhrase() string
- func (m *WalletEthereum) GetPrivateKey() string
- func (m *WalletEthereum) GetPublicKey() string
- func (m *WalletEthereum) MakeHash(data []byte) []byte
- func (m *WalletEthereum) MakeHashString(data []byte) string
- func (m *WalletEthereum) Recover(strPhrase string) Wallet
- func (m *WalletEthereum) SignHash(digestHash []byte) (strSignature string, err error)
- func (m *WalletEthereum) SignText(text []byte) (strMsgHash, strSignature string, err error)
- func (m *WalletEthereum) VerifyHash(digestHash []byte, strSignature string) bool
- func (m *WalletEthereum) VerifyText(text []byte, strSignature string) bool
Constants ¶
View Source
const ( TAG_VALUE_IGNORE = "-" TAG_NAME_JSON = "json" )
View Source
const ( //Number of bytes in a pubkey. PublicKeyLength = 32 //Maximum length of derived pubkey seed. MaxSeedLength = 32 //Maximum number of seeds. MaxSeeds = 16 //Number of bytes in a signature. SignatureLength = 64 //Maximum string length of a base58 encoded pubkey. MaxBase58Length = 44 )
View Source
const (
DefaultBitSize = 128
)
Variables ¶
View Source
var ( DerivationPath0 = "m/44'/60'/0'/0/0" DerivationPath1 = "m/44'/60'/0'/0/1" )
Functions ¶
func DecodeHexString ¶ added in v0.5.0
func LegacyKeccak256Hash ¶ added in v0.8.0
func MakeHashKeccak256 ¶ added in v0.7.0
func MakeHashKeccak256Hex ¶ added in v0.7.0
func MakeHashSHA256 ¶ added in v0.7.0
func MakeHashSHA256Hex ¶ added in v0.7.0
func MakeSignString ¶
MakeSignString make a sign string sort by alpha character
obj can be url.Values, struct with json tag or map[string]interface{}
func MustSignatureFromBase58 ¶ added in v0.9.0
func MustSignatureFromBase58(in string) solana.Signature
func PersonalSignHash ¶ added in v0.8.0
func PublicKey2Address ¶ added in v0.2.0
func RecoverKeccak256Hash ¶ added in v0.8.0
func RecoverKeccak256Msg ¶ added in v0.8.0
RecoverKeccak256Msg for metamask eth_sign signature
func RecoverLegacyKeccak256Hash ¶ added in v0.8.0
func RecoverLegacyKeccak256Msg ¶ added in v0.8.0
func VerifyKeccak256 ¶ added in v0.8.0
VerifyKeccak256 for metamask eth_sign signature verification
func VerifyLegacyKeccak256 ¶ added in v0.8.0
VerifyLegacyKeccak256 for BCOS signature verification
func VerifySignatureSolana ¶ added in v0.9.0
VerifySignatureSolana for Solana phantom signature verification strAddress base58 encoded public key strSignature base58 encoded signature strMsg base64 encoded message
Types ¶
type Wallet ¶
type Wallet interface { Create() Wallet //create a new wallet Recover(strPhrase string) Wallet //recover wallet from phrase SignHash(digestHash []byte) (strSignature string, err error) //sign hash bytes (32bytes) and return a hex signature string VerifyHash(digestHash []byte, strSignature string) bool //verify hash bytes (32bytes) signature from a hex encoded signature MakeHash(data []byte) []byte //make hash (ethereum: legacy keccak256) SignText(text []byte) (strMsgHash, strSignature string, err error) //sign text bytes and return a hex signature string VerifyText(text []byte, strSignature string) bool //verify text bytes signature from a hex encoded signature GetPrivateKey() string //retrieve private key (hex string) GetPublicKey() string //retrieve public key (hex string) GetAddress() string //retrieve address key (hex string) GetPhrase() string //retrieve phrase key (hex string) }
func NewWalletEthereum ¶
type WalletEthereum ¶
type WalletEthereum struct { Address string PrivateKey string PublicKey string Phrase string Seed string }
func (*WalletEthereum) Create ¶
func (m *WalletEthereum) Create() Wallet
func (*WalletEthereum) GetAddress ¶
func (m *WalletEthereum) GetAddress() string
func (*WalletEthereum) GetPhrase ¶
func (m *WalletEthereum) GetPhrase() string
func (*WalletEthereum) GetPrivateKey ¶
func (m *WalletEthereum) GetPrivateKey() string
func (*WalletEthereum) GetPublicKey ¶
func (m *WalletEthereum) GetPublicKey() string
func (*WalletEthereum) MakeHash ¶ added in v0.8.0
func (m *WalletEthereum) MakeHash(data []byte) []byte
MakeHash legacy keccak256 hash algorithm, return [32]byte
func (*WalletEthereum) MakeHashString ¶ added in v0.8.0
func (m *WalletEthereum) MakeHashString(data []byte) string
MakeHashString legacy keccak256 hash algorithm return hex string
func (*WalletEthereum) Recover ¶
func (m *WalletEthereum) Recover(strPhrase string) Wallet
func (*WalletEthereum) SignHash ¶
func (m *WalletEthereum) SignHash(digestHash []byte) (strSignature string, err error)
func (*WalletEthereum) SignText ¶
func (m *WalletEthereum) SignText(text []byte) (strMsgHash, strSignature string, err error)
func (*WalletEthereum) VerifyHash ¶
func (m *WalletEthereum) VerifyHash(digestHash []byte, strSignature string) bool
func (*WalletEthereum) VerifyText ¶
func (m *WalletEthereum) VerifyText(text []byte, strSignature string) bool
Click to show internal directories.
Click to hide internal directories.