key

package
v0.0.0-...-05508b9 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// 参数错误
	ErrParam = errors.New("param is illegal")
)

Functions

func CreateAndSaveSecretKey

func CreateAndSaveSecretKey(path string, language int, strength uint8, password string, cryptography uint8) (*account.ECDSAInfo, error)

生成并保存私钥

func CreateAndSaveSecretKeyWithMnemonic

func CreateAndSaveSecretKeyWithMnemonic(path string, language int, mnemonic string, password string) (*account.ECDSAInfo, error)

通过助记词来恢复并保存私钥 这里不应该再需要知道指定曲线了,也不需要知道版本号了,这个功能应该由助记词中的标记位来判断

func DecryptByKey

func DecryptByKey(cipherInfo string, key string) (string, error)

DecryptByKey 解密

func EciesDecryptByJsonPrivateKey

func EciesDecryptByJsonPrivateKey(privateKey string, cipherInfo string) (string, error)

EciesDecryptByJsonPublicKey 使用字符串私钥进行ecies解密

func EciesEncryptByJsonPublicKey

func EciesEncryptByJsonPublicKey(publicKey string, msg string) (string, error)

EciesEncryptByJsonPublicKey 使用字符串公钥进行ecies加密

func EncryptAccount

func EncryptAccount(info *account.ECDSAAccount, password string) (*account.ECDSAAccountToCloud, error)

使用支付密码加密账户信息

func EncryptByKey

func EncryptByKey(info string, key string) (string, error)

EncryptByKey 加密

func GetAccountFromLocal

func GetAccountFromLocal(path string) (*account.ECDSAAccountToCloud, error)

GetAccountFromLocal 读取本地文件获取账户信息

func GetBinaryEcdsaPrivateKeyFromFile

func GetBinaryEcdsaPrivateKeyFromFile(path string, password string) ([]byte, error)

func GetBinaryEcdsaPrivateKeyFromString

func GetBinaryEcdsaPrivateKeyFromString(encryptPrivateKey string, password string) ([]byte, error)

GetBinaryEcdsaPrivateKeyFromString通过二进制字符串获取真实私钥的字节数组

func GetEcdsaPrivateKeyFromFile

func GetEcdsaPrivateKeyFromFile(path string, password string) (*ecdsa.PrivateKey, error)

func GetEcdsaPrivateKeyFromString

func GetEcdsaPrivateKeyFromString(encryptPrivateKey string, password string) (*ecdsa.PrivateKey, error)

GetEcdsaPrivateKeyFromString通过二进制字符串获取真实私钥

func GetEcdsaPublicKeyFromJson

func GetEcdsaPublicKeyFromJson(jsonContent []byte) (*ecdsa.PublicKey, error)

func GetEncryptedPrivateKeyFromFile

func GetEncryptedPrivateKeyFromFile(path string) (string, error)

func GetPublicKeyByPrivateKey

func GetPublicKeyByPrivateKey(binaryPrivateKey string) (string, error)

GetPublicKeyByPrivateKey通过私钥获取公钥

func SaveAccountFile

func SaveAccountFile(account *account.ECDSAAccountToCloud, path string) error

保存账户信息到文件,只需要保存address 和 privateKey

Types

type AccountInfo

type AccountInfo struct {
	Address           string
	PrivateKey        []byte
	PublicKey         []byte
	Mnemonic          []byte
	EncryptPrivateKey []byte
	EncryptPublicKey  []byte
	EncryptMnemonic   []byte
}

Jump to

Keyboard shortcuts

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