incognitokey

package
v0.0.0-...-7ece11e Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 14 Imported by: 6

README

Incognito Key structure

Incognito key include 3 value;

  • Private Key: use for spending UTXO
  • Payment Address: use for receiving token or PRV
  • ReadonlyKey: use for decrypt data in output of tx if Payment Address output com from owner of readonly key

Payment Address

Payment address includes two keys:

  • Public key: It is derived from private key
  • Transmission key: It is derived from Receiving key and it used to encrypt output's details when creating transactions

Readonly Key

Readonly key includes two keys:

  • Public key: It is derived from private key
  • Receiving key: It is random generated from private key and it used to decrypt output's details when receiving transactions

Documentation

Index

Constants

View Source
const (
	InvalidPrivateKeyErr = iota
	B58DecodePubKeyErr
	B58DecodeSigErr
	B58ValidateErr
	InvalidDataValidateErr
	SignDataB58Err
	InvalidDataSignErr
	InvalidVerificationKeyErr
	DecodeFromStringErr
	SignError
	JSONError
)

Variables

View Source
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"},
}
View Source
var GetMiningKeyBase58Cache, _ = lru.New(2000)
View Source
var ToBase58Cache, _ = lru.New(2000)

Functions

func CommitteeKeyListToString

func CommitteeKeyListToString(keyList []CommitteePublicKey) ([]string, error)

func ConvertToBase58ShortFormat

func ConvertToBase58ShortFormat(strKeyList []string) ([]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 IsInBase58ShortFormat(strKeyList []string) bool

func IsOneMiner

func IsOneMiner(keyString1 string, keyString2 string) bool

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

type CashecError struct {
	Code    int
	Message string
	// contains filtered or unexported fields
}

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

type CommitteeKeyString struct {
	IncPubKey    string
	MiningPubKey map[string]string
}

func CommitteeKeyListToStringList

func CommitteeKeyListToStringList(keyList []CommitteePublicKey) []CommitteeKeyString

type CommitteePublicKey

type CommitteePublicKey struct {
	IncPubKey    key.PublicKey
	MiningPubKey map[string][]byte
}

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

func (keySet *KeySet) GenerateKey(seed []byte) *KeySet

GenerateKey generates key set from seed in byte array

func (KeySet) GetOTASecretKeyInBase58CheckEncode

func (keySet KeySet) GetOTASecretKeyInBase58CheckEncode() string

func (KeySet) GetPublicKeyInBase58CheckEncode

func (keySet KeySet) GetPublicKeyInBase58CheckEncode() string

GetPublicKeyInBase58CheckEncode returns the public key which is base58 check encoded

func (KeySet) GetReadOnlyKeyInBase58CheckEncode

func (keySet KeySet) GetReadOnlyKeyInBase58CheckEncode() string

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

func (keySet *KeySet) InitFromPrivateKeyByte(privateKey []byte) error

InitFromPrivateKeyByte receives private key in bytes array, and regenerates payment address and readonly key returns error if private key is invalid

func (KeySet) Verify

func (keySet KeySet) Verify(data, signature []byte) (bool, error)

Verify receives data and signature It checks whether the given signature is the signature of data and was signed by private key corresponding to public key in keySet or not

Jump to

Keyboard shortcuts

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