Documentation ¶
Overview ¶
Provides low-level functions and types to work with different cryptographic schemes with a unified interface and provide cryptographic operations.
Index ¶
- Constants
- func IsMnemonicValid(mnemonic string) bool
- func Sha3Sum256(data string) string
- type BlsSigner
- type ED255190chainScheme
- func (ed *ED255190chainScheme) Add(signature, msg string) (string, error)
- func (ed *ED255190chainScheme) GenerateKeys() (*Wallet, error)
- func (ed *ED255190chainScheme) GenerateKeysWithEth(mnemonic, password string) (*Wallet, error)
- func (ed *ED255190chainScheme) GetID() string
- func (b0 *ED255190chainScheme) GetMnemonic() string
- func (ed *ED255190chainScheme) GetPrivateKey() string
- func (ed *ED255190chainScheme) GetPrivateKeyAsByteArray() ([]byte, error)
- func (ed *ED255190chainScheme) GetPublicKey() string
- func (ed *ED255190chainScheme) RecoverKeys(mnemonic string) (*Wallet, error)
- func (ed *ED255190chainScheme) SetID(id string) error
- func (ed *ED255190chainScheme) SetPrivateKey(privateKey string) error
- func (ed *ED255190chainScheme) SetPublicKey(publicKey string) error
- func (ed *ED255190chainScheme) Sign(hash string) (string, error)
- func (b0 *ED255190chainScheme) SplitKeys(numSplits int) (*Wallet, error)
- func (ed *ED255190chainScheme) Verify(signature, msg string) (bool, error)
- type Fr
- type HerumiScheme
- func (b0 *HerumiScheme) Add(signature, msg string) (string, error)
- func (b0 *HerumiScheme) GenerateKeys() (*Wallet, error)
- func (b0 *HerumiScheme) GenerateKeysWithEth(mnemonic, password string) (*Wallet, error)
- func (b0 *HerumiScheme) GetID() string
- func (b0 *HerumiScheme) GetMnemonic() string
- func (b0 *HerumiScheme) GetPrivateKey() string
- func (b0 *HerumiScheme) GetPrivateKeyAsByteArray() ([]byte, error)
- func (b0 *HerumiScheme) GetPublicKey() string
- func (b0 *HerumiScheme) RecoverKeys(mnemonic string) (*Wallet, error)
- func (b0 *HerumiScheme) SetID(id string) error
- func (b0 *HerumiScheme) SetPrivateKey(privateKey string) error
- func (b0 *HerumiScheme) SetPublicKey(publicKey string) error
- func (b0 *HerumiScheme) Sign(hash string) (string, error)
- func (b0 *HerumiScheme) SplitKeys(numSplits int) (*Wallet, error)
- func (b0 *HerumiScheme) Verify(signature, msg string) (bool, error)
- type ID
- type KeyPair
- type PublicKey
- type SecretKey
- type Signature
- type SignatureScheme
- type Wallet
Constants ¶
const CryptoVersion = "1.0"
CryptoVersion - version of the crypto library
Variables ¶
This section is empty.
Functions ¶
func IsMnemonicValid ¶
func Sha3Sum256 ¶
Types ¶
type BlsSigner ¶ added in v1.3.5
type BlsSigner interface { SetRandFunc(randReader io.Reader) FrSub(out Fr, x Fr, y Fr) NewFr() Fr NewSecretKey() SecretKey NewPublicKey() PublicKey NewSignature() Signature NewID() ID }
var BlsSignerInstance BlsSigner
type ED255190chainScheme ¶
type ED255190chainScheme struct {
// contains filtered or unexported fields
}
ED255190chainScheme - a signature scheme based on ED25519
func NewED255190chainScheme ¶
func NewED255190chainScheme() *ED255190chainScheme
NewED255190chainScheme - create a ED255190chainScheme object
func (*ED255190chainScheme) Add ¶
func (ed *ED255190chainScheme) Add(signature, msg string) (string, error)
func (*ED255190chainScheme) GenerateKeys ¶
func (ed *ED255190chainScheme) GenerateKeys() (*Wallet, error)
GenerateKeys - implement interface
func (*ED255190chainScheme) GenerateKeysWithEth ¶
func (ed *ED255190chainScheme) GenerateKeysWithEth(mnemonic, password string) (*Wallet, error)
GenerateKeysWithEth - not implemented
func (*ED255190chainScheme) GetID ¶ added in v1.3.1
func (ed *ED255190chainScheme) GetID() string
GetID gets ID in hex string format
func (*ED255190chainScheme) GetMnemonic ¶ added in v1.3.1
func (b0 *ED255190chainScheme) GetMnemonic() string
func (*ED255190chainScheme) GetPrivateKey ¶
func (ed *ED255190chainScheme) GetPrivateKey() string
GetPrivateKey - implement interface
func (*ED255190chainScheme) GetPrivateKeyAsByteArray ¶ added in v1.3.1
func (ed *ED255190chainScheme) GetPrivateKeyAsByteArray() ([]byte, error)
GetPrivateKeyAsByteArray - converts private key into byte array
func (*ED255190chainScheme) GetPublicKey ¶
func (ed *ED255190chainScheme) GetPublicKey() string
GetPublicKey - implement interface
func (*ED255190chainScheme) RecoverKeys ¶
func (ed *ED255190chainScheme) RecoverKeys(mnemonic string) (*Wallet, error)
func (*ED255190chainScheme) SetID ¶ added in v1.3.1
func (ed *ED255190chainScheme) SetID(id string) error
SetID sets ID in HexString format
func (*ED255190chainScheme) SetPrivateKey ¶
func (ed *ED255190chainScheme) SetPrivateKey(privateKey string) error
func (*ED255190chainScheme) SetPublicKey ¶
func (ed *ED255190chainScheme) SetPublicKey(publicKey string) error
type HerumiScheme ¶ added in v1.3.5
type HerumiScheme struct { PublicKey string `json:"public_key"` PrivateKey string `json:"private_key"` Mnemonic string `json:"mnemonic"` Ids string `json:"threshold_scheme_id"` // contains filtered or unexported fields }
HerumiScheme - a signature scheme for BLS0Chain Signature
func NewHerumiScheme ¶ added in v1.3.5
func NewHerumiScheme() *HerumiScheme
NewHerumiScheme - create a MiraclScheme object
func (*HerumiScheme) Add ¶ added in v1.3.5
func (b0 *HerumiScheme) Add(signature, msg string) (string, error)
func (*HerumiScheme) GenerateKeys ¶ added in v1.3.5
func (b0 *HerumiScheme) GenerateKeys() (*Wallet, error)
GenerateKeys generate fresh keys
func (*HerumiScheme) GenerateKeysWithEth ¶ added in v1.3.5
func (b0 *HerumiScheme) GenerateKeysWithEth(mnemonic, password string) (*Wallet, error)
GenerateKeysWithEth generate fresh keys based on eth wallet
func (*HerumiScheme) GetID ¶ added in v1.3.5
func (b0 *HerumiScheme) GetID() string
GetID gets ID in hex string format
func (*HerumiScheme) GetMnemonic ¶ added in v1.3.5
func (b0 *HerumiScheme) GetMnemonic() string
func (*HerumiScheme) GetPrivateKey ¶ added in v1.3.5
func (b0 *HerumiScheme) GetPrivateKey() string
func (*HerumiScheme) GetPrivateKeyAsByteArray ¶ added in v1.3.5
func (b0 *HerumiScheme) GetPrivateKeyAsByteArray() ([]byte, error)
GetPrivateKeyAsByteArray - converts private key into byte array
func (*HerumiScheme) GetPublicKey ¶ added in v1.3.5
func (b0 *HerumiScheme) GetPublicKey() string
GetPublicKey - implement interface
func (*HerumiScheme) RecoverKeys ¶ added in v1.3.5
func (b0 *HerumiScheme) RecoverKeys(mnemonic string) (*Wallet, error)
RecoverKeys recovery keys from mnemonic
func (*HerumiScheme) SetID ¶ added in v1.3.5
func (b0 *HerumiScheme) SetID(id string) error
SetID sets ID in HexString format
func (*HerumiScheme) SetPrivateKey ¶ added in v1.3.5
func (b0 *HerumiScheme) SetPrivateKey(privateKey string) error
SetPrivateKey set private key to sign
func (*HerumiScheme) SetPublicKey ¶ added in v1.3.5
func (b0 *HerumiScheme) SetPublicKey(publicKey string) error
SetPublicKey - implement interface
func (*HerumiScheme) Sign ¶ added in v1.3.5
func (b0 *HerumiScheme) Sign(hash string) (string, error)
Sign sign message
type SecretKey ¶ added in v1.3.5
type SecretKey interface { SerializeToHexStr() string DeserializeHexStr(s string) error Serialize() []byte GetLittleEndian() []byte SetLittleEndian(buf []byte) error SetByCSPRNG() GetPublicKey() PublicKey Sign(m string) Signature Add(rhs SecretKey) GetMasterSecretKey(k int) (msk []SecretKey, err error) Set(msk []SecretKey, id ID) error }
type SignatureScheme ¶
type SignatureScheme interface { // Generate fresh keys GenerateKeys() (*Wallet, error) // Generate fresh keys based on eth wallet GenerateKeysWithEth(mnemonic, password string) (*Wallet, error) // Generate keys from mnemonic for recovery RecoverKeys(mnemonic string) (*Wallet, error) GetMnemonic() string // Signing - Set private key to sign SetPrivateKey(privateKey string) error Sign(hash string) (string, error) // Signature verification - Set public key to verify SetPublicKey(publicKey string) error GetPublicKey() string GetPrivateKey() string Verify(signature string, msg string) (bool, error) // Combine signature for schemes BLS Add(signature, msg string) (string, error) SplitKeys(numSplits int) (*Wallet, error) GetPrivateKeyAsByteArray() ([]byte, error) SetID(id string) error GetID() string }
SignatureScheme - an encryption scheme for signing and verifying messages
func GenerateThresholdKeyShares ¶ added in v1.3.1
func GenerateThresholdKeyShares(t, n int, originalKey SignatureScheme) ([]SignatureScheme, error)
GenerateThresholdKeyShares given a signature scheme will generate threshold sig keys
func NewSignatureScheme ¶
func NewSignatureScheme(sigScheme string) SignatureScheme
NewSignatureScheme creates an instance for using signature functions
- sigScheme signature scheme to be used
func UnmarshalSignatureSchemes ¶ added in v1.3.5
func UnmarshalSignatureSchemes(sigScheme string, obj interface{}) ([]SignatureScheme, error)
UnmarshalSignatureSchemes unmarshal SignatureScheme from json string
type Wallet ¶
type Wallet struct { ClientID string `json:"client_id"` ClientKey string `json:"client_key"` PeerPublicKey string `json:"peer_public_key"` // Peer public key exists only in split wallet Keys []KeyPair `json:"keys"` Mnemonic string `json:"mnemonics"` Version string `json:"version"` DateCreated string `json:"date_created"` Nonce int64 `json:"nonce"` IsSplit bool `json:"is_split"` }
Wallet represents client wallet information
func (*Wallet) SetSplitKeys ¶ added in v1.17.0
SetSplitKeys sets split keys and wipes out mnemonic and original primary keys