Documentation
¶
Index ¶
- Constants
- Variables
- func CommitteeKeyListToString(keyList []CommitteePublicKey) ([]string, error)
- func ConvertToBase58ShortFormat(strKeyList []string) ([]string, error)
- func ExtractMiningPublickeysFromCommitteeKeyList(keyList []CommitteePublicKey, keyType string) ([]string, error)
- func ExtractPublickeysFromCommitteeKeyList(keyList []CommitteePublicKey, keyType string) ([]string, error)
- func IndexOfCommitteeKey(item CommitteePublicKey, list []CommitteePublicKey) int
- func IsInBase58ShortFormat(strKeyList []string) bool
- func IsOneMiner(keyString1 string, keyString2 string) bool
- func ValidateDataB58(publicKeyInBase58CheckEncode string, signatureInBase58CheckEncode string, ...) error
- type CashecError
- type ChainCommittee
- type CommitteeKeyString
- type CommitteePublicKey
- func CommitteeBase58KeyListToStruct(strKeyList []string) ([]CommitteePublicKey, error)
- func DeepCopy(committeePublicKeys []CommitteePublicKey) []CommitteePublicKey
- func GetValidStakeStructCommitteePublicKey(committees []CommitteePublicKey, stakers []CommitteePublicKey) []CommitteePublicKey
- func InsertCommitteePublicKeyToSlice(list []CommitteePublicKey, value CommitteePublicKey, index int) []CommitteePublicKey
- func NewCommitteeKeyFromSeed(seed, incPubKey []byte) (CommitteePublicKey, error)
- func NewCommitteePublicKey() *CommitteePublicKey
- func (pubKey *CommitteePublicKey) Bytes() ([]byte, error)
- func (pubKey *CommitteePublicKey) CheckSanityData() bool
- func (pubKey *CommitteePublicKey) FromBase58(keyString string) error
- func (pubKey *CommitteePublicKey) FromBytes(keyBytes []byte) error
- func (pubKey *CommitteePublicKey) FromString(keyString string) error
- func (pubKey *CommitteePublicKey) GetIncKeyBase58() string
- func (pubKey *CommitteePublicKey) GetMiningKey(schemeName string) ([]byte, error)
- func (pubKey *CommitteePublicKey) GetMiningKeyBase58(schemeName string) string
- func (pubKey *CommitteePublicKey) GetNormalKey() []byte
- func (committeePublicKey *CommitteePublicKey) IsEqual(target CommitteePublicKey) bool
- func (pubKey *CommitteePublicKey) IsEqualMiningPubKey(consensusName string, k *CommitteePublicKey) bool
- func (committeePublicKey *CommitteePublicKey) IsValid(target CommitteePublicKey) bool
- func (pubKey *CommitteePublicKey) RawBytes() ([]byte, error)
- func (pubKey *CommitteePublicKey) ToBase58() (string, error)
- type KeySet
- func (keySet *KeySet) GenerateKey(seed []byte) *KeySet
- func (keySet KeySet) GetOTASecretKeyInBase58CheckEncode() string
- func (keySet KeySet) GetPublicKeyInBase58CheckEncode() string
- func (keySet KeySet) GetReadOnlyKeyInBase58CheckEncode() string
- func (keySet *KeySet) InitFromPrivateKey(privateKey *key.PrivateKey) error
- func (keySet *KeySet) InitFromPrivateKeyByte(privateKey []byte) error
- func (keySet KeySet) Verify(data, signature []byte) (bool, error)
Constants ¶
const ( InvalidPrivateKeyErr = iota B58DecodePubKeyErr B58DecodeSigErr B58ValidateErr InvalidDataValidateErr SignDataB58Err InvalidDataSignErr InvalidVerificationKeyErr DecodeFromStringErr SignError JSONError )
Variables ¶
var ErrCodeMessage = map[int]struct { Code int Message string }{ InvalidPrivateKeyErr: {-201, "Private key is invalid"}, B58DecodePubKeyErr: {-202, "Base58 decode pub key error"}, B58DecodeSigErr: {-203, "Base58 decode signature error"}, B58ValidateErr: {-204, "Base58 validate data error"}, InvalidDataValidateErr: {-205, "Validated base58 data is invalid"}, SignDataB58Err: {-206, "Signing B58 data error"}, InvalidDataSignErr: {-207, "Signed data is invalid"}, InvalidVerificationKeyErr: {-208, "Verification key is invalid"}, DecodeFromStringErr: {-209, "Decode key set from string error"}, SignError: {-210, "Can not sign data"}, JSONError: {-211, "JSON Marshal, Unmarshal error"}, }
var GetMiningKeyBase58Cache, _ = lru.New(2000)
var ToBase58Cache, _ = lru.New(2000)
Functions ¶
func CommitteeKeyListToString ¶
func CommitteeKeyListToString(keyList []CommitteePublicKey) ([]string, error)
func ExtractMiningPublickeysFromCommitteeKeyList ¶
func ExtractMiningPublickeysFromCommitteeKeyList(keyList []CommitteePublicKey, keyType string) ([]string, error)
func ExtractPublickeysFromCommitteeKeyList ¶
func ExtractPublickeysFromCommitteeKeyList(keyList []CommitteePublicKey, keyType string) ([]string, error)
func IndexOfCommitteeKey ¶
func IndexOfCommitteeKey(item CommitteePublicKey, list []CommitteePublicKey) int
func IsInBase58ShortFormat ¶
func IsOneMiner ¶
func ValidateDataB58 ¶
func ValidateDataB58(publicKeyInBase58CheckEncode string, signatureInBase58CheckEncode string, data []byte) error
ValidateDataB58 receives a data, a base58 check encoded signature (sigB58) and a base58 check encoded public key (pbkB58) It decodes pbkB58 and sigB58 after that, it verifies the given signature is corresponding to data using verification key is pbkB58
Types ¶
type CashecError ¶
func NewCashecError ¶
func NewCashecError(key int, err error) *CashecError
func (CashecError) Error ¶
func (e CashecError) Error() string
func (CashecError) GetCode ¶
func (e CashecError) GetCode() int
type ChainCommittee ¶
type ChainCommittee struct { Epoch uint64 BeaconCommittee []CommitteePublicKey AllShardCommittee map[byte][]CommitteePublicKey AllShardPending map[byte][]CommitteePublicKey }
func ChainCommitteeFromByte ¶
func ChainCommitteeFromByte(data []byte) (*ChainCommittee, error)
func (*ChainCommittee) ToByte ¶
func (cc *ChainCommittee) ToByte() ([]byte, error)
type CommitteeKeyString ¶
func CommitteeKeyListToStringList ¶
func CommitteeKeyListToStringList(keyList []CommitteePublicKey) []CommitteeKeyString
type CommitteePublicKey ¶
func CommitteeBase58KeyListToStruct ¶
func CommitteeBase58KeyListToStruct(strKeyList []string) ([]CommitteePublicKey, error)
func DeepCopy ¶
func DeepCopy(committeePublicKeys []CommitteePublicKey) []CommitteePublicKey
func GetValidStakeStructCommitteePublicKey ¶
func GetValidStakeStructCommitteePublicKey(committees []CommitteePublicKey, stakers []CommitteePublicKey) []CommitteePublicKey
func InsertCommitteePublicKeyToSlice ¶
func InsertCommitteePublicKeyToSlice(list []CommitteePublicKey, value CommitteePublicKey, index int) []CommitteePublicKey
func NewCommitteeKeyFromSeed ¶
func NewCommitteeKeyFromSeed(seed, incPubKey []byte) (CommitteePublicKey, error)
func NewCommitteePublicKey ¶
func NewCommitteePublicKey() *CommitteePublicKey
func (*CommitteePublicKey) Bytes ¶
func (pubKey *CommitteePublicKey) Bytes() ([]byte, error)
func (*CommitteePublicKey) CheckSanityData ¶
func (pubKey *CommitteePublicKey) CheckSanityData() bool
func (*CommitteePublicKey) FromBase58 ¶
func (pubKey *CommitteePublicKey) FromBase58(keyString string) error
func (*CommitteePublicKey) FromBytes ¶
func (pubKey *CommitteePublicKey) FromBytes(keyBytes []byte) error
func (*CommitteePublicKey) FromString ¶
func (pubKey *CommitteePublicKey) FromString(keyString string) error
func (*CommitteePublicKey) GetIncKeyBase58 ¶
func (pubKey *CommitteePublicKey) GetIncKeyBase58() string
func (*CommitteePublicKey) GetMiningKey ¶
func (pubKey *CommitteePublicKey) GetMiningKey(schemeName string) ([]byte, error)
func (*CommitteePublicKey) GetMiningKeyBase58 ¶
func (pubKey *CommitteePublicKey) GetMiningKeyBase58(schemeName string) string
func (*CommitteePublicKey) GetNormalKey ¶
func (pubKey *CommitteePublicKey) GetNormalKey() []byte
func (*CommitteePublicKey) IsEqual ¶
func (committeePublicKey *CommitteePublicKey) IsEqual(target CommitteePublicKey) bool
func (*CommitteePublicKey) IsEqualMiningPubKey ¶
func (pubKey *CommitteePublicKey) IsEqualMiningPubKey(consensusName string, k *CommitteePublicKey) bool
func (*CommitteePublicKey) IsValid ¶
func (committeePublicKey *CommitteePublicKey) IsValid(target CommitteePublicKey) bool
func (*CommitteePublicKey) RawBytes ¶
func (pubKey *CommitteePublicKey) RawBytes() ([]byte, error)
func (*CommitteePublicKey) ToBase58 ¶
func (pubKey *CommitteePublicKey) ToBase58() (string, error)
type KeySet ¶
type KeySet struct { PrivateKey key.PrivateKey //Master Private key PaymentAddress key.PaymentAddress //Payment address for sending coins ReadonlyKey key.ViewingKey //ViewingKey for retrieving the amount of coin (both V1 + V2) as well as the asset tag (V2 ONLY) OTAKey key.OTAKey //OTAKey is for recovering one time addresses: ONLY in V2 }
KeySet is real raw data of wallet account, which user can use to - spend and check double spend coin with private key - receive coin with payment address - read tx data with readonly key
func (*KeySet) GenerateKey ¶
GenerateKey generates key set from seed in byte array
func (KeySet) GetOTASecretKeyInBase58CheckEncode ¶
func (KeySet) GetPublicKeyInBase58CheckEncode ¶
GetPublicKeyInBase58CheckEncode returns the public key which is base58 check encoded
func (KeySet) GetReadOnlyKeyInBase58CheckEncode ¶
func (*KeySet) InitFromPrivateKey ¶
func (keySet *KeySet) InitFromPrivateKey(privateKey *key.PrivateKey) error
InitFromPrivateKey receives private key in PrivateKey type, and regenerates payment address and readonly key returns error if private key is invalid
func (*KeySet) InitFromPrivateKeyByte ¶
InitFromPrivateKeyByte receives private key in bytes array, and regenerates payment address and readonly key returns error if private key is invalid