key

package
v0.0.0-...-60962e5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2023 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ED25519算法
	ED25519 = iota + 1
	// SM2算法
	SM2

	// 加密类型关键字
	ED25519_VALUE = 'e'
	SM2_VALUE     = 'z'
	// 字符编码类型关键字
	BASE_58_VALUE = 'f'
)

Variables

This section is empty.

Functions

func AESDecrypt

func AESDecrypt(key []byte, cryptoText string) string

AESDecrypt Decrypt from base64 to decrypted string

func AESEncrypt

func AESEncrypt(key []byte, text string) (string, string)

func DecipherKeyStore

func DecipherKeyStore(keyStore KeyStore, password string) string

func EncPublicKey

func EncPublicKey(rawPublicKey []byte, keyType int) string

EncPublicKey 原生公钥转星火公钥

func GetEncAddress

func GetEncAddress(rawPublicKey []byte, chainCode string, keyType int) string

GetEncAddress 获取地址

func GetEncPrivateKey

func GetEncPrivateKey(privateKey []byte, keyType int) string

GetEncPrivateKey 原生私钥转星火私钥

func GetEncPublicKey

func GetEncPublicKey(encPrivateKey []byte) (string, error)

GetEncPublicKey 星火私钥获取星火公钥

func GetRawPrivateKey

func GetRawPrivateKey(encPrivateKey []byte) (int, []byte, error)

GetRawPrivateKey 星火私钥转原生私钥

func GetRawPublicKey

func GetRawPublicKey(encPublicKey []byte) []byte

GetRawPublicKey 星火公钥获取原生公钥

func IsAddressValid

func IsAddressValid(encAddress string) bool

IsAddressValid check address

func Sign

func Sign(encPrivate []byte, message []byte) ([]byte, error)

func Verify

func Verify(encPublicKey []byte, msg []byte, signMsg []byte) bool

Types

type KeyPairEntity

type KeyPairEntity struct {
	EncAddress    string
	EncPublicKey  string
	EncPrivateKey string
	RawPrivateKey []byte
	RawPublicKey  []byte
}

func GetBidAndKeyPair

func GetBidAndKeyPair() (*KeyPairEntity, error)

func GetBidAndKeyPairBySM2

func GetBidAndKeyPairBySM2() (*KeyPairEntity, error)

func (*KeyPairEntity) GetEncAddress

func (k *KeyPairEntity) GetEncAddress() string

func (*KeyPairEntity) GetEncPrivateKey

func (k *KeyPairEntity) GetEncPrivateKey() string

func (*KeyPairEntity) GetEncPublicKey

func (k *KeyPairEntity) GetEncPublicKey() string

func (*KeyPairEntity) GetRawPrivateKey

func (k *KeyPairEntity) GetRawPrivateKey() []byte

func (*KeyPairEntity) GetRawPublicKey

func (k *KeyPairEntity) GetRawPublicKey() []byte

type KeyStore

type KeyStore struct {
	Address    string
	AesctrIv   string
	CypherText string
	ScryptParams
	Version int
}

func GenerateKeyStore

func GenerateKeyStore(encPrivateKey string, password string, n int, r int, p int, version int) (string, KeyStore)

type PrivateKeyManager

type PrivateKeyManager struct {
	EncPrivateKey string // 星火私钥
	RawPrivateKey []byte // 原生私钥
	RawPublicKey  []byte // 原生公钥
	TypeKey       string // 加密类型
}

func GetPrivateKeyManager

func GetPrivateKeyManager(keyType int) (*PrivateKeyManager, error)

func GetPrivateKeyManagerByPrivateKey

func GetPrivateKeyManagerByPrivateKey(encPrivateKey string) (*PrivateKeyManager, error)

GetPrivateKeyManagerByPrivateKey 根据星火私钥获取私钥对象

func GetPrivateKeyManagerByRand

func GetPrivateKeyManagerByRand(seed []byte, keyType int) (*PrivateKeyManager, error)

type PublicKeyManager

type PublicKeyManager struct {
	EncAddress   string
	EncPublicKey string
	RawPublicKey []byte
}

func GetPublicKeyManager

func GetPublicKeyManager(encPrivateKey []byte, keyType int) (*PublicKeyManager, error)

func GetPublicKeyManagerByPublicKey

func GetPublicKeyManagerByPublicKey(encPublicKey string) (*PublicKeyManager, error)

GetPublicKeyManagerByPublicKey

type ScryptParams

type ScryptParams struct {
	N    int
	P    int
	R    int
	Salt string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL