Documentation ¶
Overview ¶
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
- Copyright (c) IBAX. All rights reserved.
- See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------
Index ¶
- Variables
- func Address(pubKey []byte) int64
- func CalcChecksum(input []byte) uint64
- func CutPub(pubKey []byte) []byte
- func DoubleHash(msg []byte) []byte
- func GenHexKeys() (string, string, error)
- func GenKeyPair() ([]byte, []byte, error)
- func GetHMAC(secret string, message string) ([]byte, error)
- func GetWalletIDByPublicKey(publicKey []byte) (int64, error)
- func Hash(msg []byte) []byte
- func HashHex(input []byte) string
- func HexToPub(pub string) ([]byte, error)
- func InitAsymAlgo(s string)
- func InitHashAlgo(s string)
- func KeyToAddress(pubKey []byte) string
- func PrivateToPublic(key []byte) ([]byte, error)
- func PubToHex(pub []byte) string
- func RandSeq(n int) string
- func RepeatPrefixed(input string) []byte
- func Sign(privateKey, data []byte) ([]byte, error)
- func SignString(privateKeyHex, data string) ([]byte, error)
- func Verify(public, data, signature []byte) (bool, error)
- type AsymAlgo
- type AsymProvider
- type HashAlgo
- type HashProvider
- type SymAlgo
Constants ¶
This section is empty.
Variables ¶
var AsymAlgo_name = map[int32]string{
0: "ECC_P256",
1: "ECC_Secp256k1",
2: "SM2",
3: "ECC_P512",
}
var AsymAlgo_value = map[string]int32{
"ECC_P256": 0,
"ECC_Secp256k1": 1,
"SM2": 2,
"ECC_P512": 3,
}
var HashAlgo_name = map[int32]string{
0: "SHA256",
1: "KECCAK256",
2: "SM3",
3: "SHA3_256",
}
var HashAlgo_value = map[string]int32{
"SHA256": 0,
"KECCAK256": 1,
"SM3": 2,
"SHA3_256": 3,
}
var SymAlgo_name = map[int32]string{
0: "AES",
1: "SM4",
}
var SymAlgo_value = map[string]int32{
"AES": 0,
"SM4": 1,
}
Functions ¶
func CalcChecksum ¶
CalcChecksum is calculates checksum, returns crc64 sum.
func DoubleHash ¶
func GenHexKeys ¶
GenHexKeys generates a random pair of private and public hex keys.
func GenKeyPair ¶
GenKeyPair generates a random pair of private and public binary keys.
func GetWalletIDByPublicKey ¶
GetWalletIDByPublicKey converts public key to wallet id
func InitAsymAlgo ¶
func InitAsymAlgo(s string)
func InitHashAlgo ¶
func InitHashAlgo(s string)
func KeyToAddress ¶
KeyToAddress converts a public key to chain address XXXX-...-XXXX.
func PrivateToPublic ¶
PrivateToPublic returns the public key for the specified private key.
func RepeatPrefixed ¶
func SignString ¶
Types ¶
type AsymAlgo ¶
type AsymAlgo int32
AsymAlgo is asymmetric algorithms
func (AsymAlgo) EnumDescriptor ¶
type AsymProvider ¶
type AsymProvider interface { GenKeyPair() ([]byte, []byte, error) Sign(privateKey, hash []byte) ([]byte, error) // Verify checks if forSign has been signed with corresponding to public the private key Verify(public, hash, sign []byte) (bool, error) PrivateToPublic(key []byte) ([]byte, error) }
func GetAsymProvider ¶
func GetAsymProvider() AsymProvider
func NewAsymAlgo ¶
func NewAsymAlgo(a AsymAlgo) AsymProvider
type HashProvider ¶
type HashProvider interface { // GetHMAC returns HMAC hash GetHMAC(secret string, msg string) ([]byte, error) // GetHash returns hash of passed bytes GetHash(msg []byte) []byte // DoubleHash returns double hash of passed bytes DoubleHash(msg []byte) []byte }
func GetHashProvider ¶
func GetHashProvider() HashProvider
func NewHashAlgo ¶
func NewHashAlgo(a HashAlgo) HashProvider