account

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: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 不同语言标准不一样,这里用const直接定义值还是好一些
	//	_ = iota
	// 低
	StrengthEasy = 1
	// 中
	StrengthMiddle = 2
	// 高
	StrengthHard = 3
)

定义助记词的强度类型

View Source
const (
	// 不同语言标准不一样,这里用const直接定义值还是好一些
	//	_ = iota
	// 美国Federal Information Processing Standards的椭圆曲线
	EccFIPS = iota
	// 国密椭圆曲线
	EccGM
)

定义密码算法的类型

Variables

View Source
var (
	TooSmallNumOfkeysError         = errors.New("The total num of keys should be greater than one")
	CurveParamNilError             = errors.New("curve input param is nil")
	NotExactTheSameCurveInputError = errors.New("the curve is not same as curve of members")
	KeyParamNotMatchError          = errors.New("key param not match")
)
View Source
var (
	// 1111 - 11个1,当一个大的bigint和它进行“And”比特运算的时候,就会获得大的bigint最右边4位的比特位
	Last4BitsMask = big.NewInt(15)
	// 10000 - 乘以这个带有4个0的数等于左移4个比特位,除以这个带有4个0的数等于右移4个比特位,
	Shift4BitsFactor = big.NewInt(16)
)
View Source
var (
	// 助记词的强度暂未被支持
	// Strength required for generating Mnemonic has not been supported yet.
	ErrStrengthNotSupported = fmt.Errorf("This strength has not been supported yet.")

	// 密码学算法暂未被支持
	// Cryptography required for generating Mnemonic has not been supported yet.
	ErrCryptographyNotSupported = fmt.Errorf("This cryptography has not been supported yet.")

	// 语言暂未被支持
	// ReservedType required for generating Mnemonic has not been supported yet.
	ErrReservedTypeNotSupported = fmt.Errorf("This ReservedType has not been supported yet.")
)

Functions

func CheckAddressFormat

func CheckAddressFormat(address string) (bool, uint8)

验证钱包地址是否是合法的格式 如果成功,返回true和对应的密码学标记位;如果失败,返回false和默认的密码学标记位0

func CreateNewAccountWithMnemonic

func CreateNewAccountWithMnemonic(language int, strength uint8, cryptography uint8) (*account.ECDSAAccount, error)

参数字段:版本号、语言、强度 返回的字段:助记词、私钥的json、公钥的json、钱包地址、错误信息

func ExportNewAccount

func ExportNewAccount(path string, privateKey *ecdsa.PrivateKey) error

func ExportNewAccountWithMnemonic

func ExportNewAccountWithMnemonic(path string, language int, strength uint8, cryptography uint8) error

func GenerateAccountByMnemonic

func GenerateAccountByMnemonic(mnemonic string, language int) (*account.ECDSAAccount, error)

通过助记词来产生/恢复钱包账户

func GetAddressFromPublicKey

func GetAddressFromPublicKey(pub *ecdsa.PublicKey) (string, error)

返回33位长度的地址

func GetAddressFromPublicKeys

func GetAddressFromPublicKeys(keys []*ecdsa.PublicKey) (string, error)

generate address for multi-signature / ring-signature algorithm 为多个公钥生成地址,比如环签名地址,多重签名地址

func GetCryptoByteFromMnemonic

func GetCryptoByteFromMnemonic(mnemonic string, language int) (uint8, error)

func GetEcdsaPrivateKeyFromFile

func GetEcdsaPrivateKeyFromFile(filename string) (*ecdsa.PrivateKey, error)

func GetEcdsaPrivateKeyFromJson

func GetEcdsaPrivateKeyFromJson(jsonContent []byte) (*ecdsa.PrivateKey, error)

func GetEcdsaPrivateKeyJsonFormat

func GetEcdsaPrivateKeyJsonFormat(k *ecdsa.PrivateKey) (string, error)

获得私钥所对应的的json

func GetEcdsaPublicKeyFromFile

func GetEcdsaPublicKeyFromFile(filename string) (*ecdsa.PublicKey, error)

func GetEcdsaPublicKeyFromJson

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

func GetEcdsaPublicKeyJsonFormat

func GetEcdsaPublicKeyJsonFormat(k *ecdsa.PrivateKey) (string, error)

获得公钥所对应的的json

func GetEcdsaPublicKeyJsonFormatFromPublicKey

func GetEcdsaPublicKeyJsonFormatFromPublicKey(k *ecdsa.PublicKey) (string, error)

获得公钥所对应的的json

func RetrievePrivateKeyByShares

func RetrievePrivateKeyByShares(strEncodeComplexShareGroup []string) (string, error)

RetrievePrivateKeyByShares 私钥恢复

func SplitPrivateKey

func SplitPrivateKey(jsonPrivKey string, totalShareNumber, minimumShareNumber int) ([]string, error)

SplitPrivateKey 私钥分割

func VerifyAddressUsingPublicKey

func VerifyAddressUsingPublicKey(address string, pub *ecdsa.PublicKey) (bool, uint8)

验证钱包地址是否和指定的公钥match 如果成功,返回true和对应的密码学标记位;如果失败,返回false和默认的密码学标记位0

func VerifyAddressUsingPublicKeys

func VerifyAddressUsingPublicKeys(address string, pubs []*ecdsa.PublicKey) (bool, uint8)

验证钱包地址是否和指定的公钥数组match 如果成功,返回true和对应的密码学标记位;如果失败,返回false和默认的密码学标记位0

Types

type ECDSAPrivateKey

type ECDSAPrivateKey struct {
	Curvname string
	X, Y, D  *big.Int
}

通过这个数据结构来生成私钥的json

type ECDSAPublicKey

type ECDSAPublicKey struct {
	Curvname string
	X, Y     *big.Int
}

通过这个数据结构来生成公钥的json

type PrivateKeyShare

type PrivateKeyShare struct {
	Index         int
	ComplexShares ShareGroup
}

PrivateKeyShare 私钥片段

type ShareGroup

type ShareGroup []*big.Int

ShareGroup 密码学切分后的密钥片段簇

Jump to

Keyboard shortcuts

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