zcncrypto

package
v1.2.76 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2021 License: MIT Imports: 10 Imported by: 10

Documentation

Index

Constants

View Source
const CryptoVersion = "1.0"

Variables

This section is empty.

Functions

func IsMnemonicValid

func IsMnemonicValid(mnemonic string) bool

func Sha3Sum256

func Sha3Sum256(data string) string

Types

type BLS0ChainScheme

type BLS0ChainScheme struct {
	PublicKey  string `json:"public_key"`
	PrivateKey string `json:"private_key"`
	Mnemonic   string `json:"mnemonic"`
}

BLS0ChainScheme - a signature scheme for BLS0Chain Signature

func NewBLS0ChainScheme

func NewBLS0ChainScheme() *BLS0ChainScheme

NewBLS0ChainScheme - create a BLS0ChainScheme object

func (*BLS0ChainScheme) Add

func (b0 *BLS0ChainScheme) Add(signature, msg string) (string, error)

func (*BLS0ChainScheme) GenerateKeys

func (b0 *BLS0ChainScheme) GenerateKeys() (*Wallet, error)

GenerateKeys - implement interface

func (*BLS0ChainScheme) GetPrivateKey

func (b0 *BLS0ChainScheme) GetPrivateKey() string

func (*BLS0ChainScheme) GetPrivateKeyAsByteArray

func (b0 *BLS0ChainScheme) GetPrivateKeyAsByteArray() ([]byte, error)

GetPrivateKeyAsByteArray - converts private key into byte array

func (*BLS0ChainScheme) GetPublicKey

func (b0 *BLS0ChainScheme) GetPublicKey() string

GetPublicKey - implement interface

func (*BLS0ChainScheme) RecoverKeys

func (b0 *BLS0ChainScheme) RecoverKeys(mnemonic string) (*Wallet, error)

func (*BLS0ChainScheme) SetPrivateKey

func (b0 *BLS0ChainScheme) SetPrivateKey(privateKey string) error

SetPrivateKey - implement interface

func (*BLS0ChainScheme) SetPublicKey

func (b0 *BLS0ChainScheme) SetPublicKey(publicKey string) error

SetPublicKey - implement interface

func (*BLS0ChainScheme) Sign

func (b0 *BLS0ChainScheme) Sign(hash string) (string, error)

Sign - implement interface

func (*BLS0ChainScheme) SplitKeys

func (b0 *BLS0ChainScheme) SplitKeys(numSplits int) (*Wallet, error)

func (*BLS0ChainScheme) Verify

func (b0 *BLS0ChainScheme) Verify(signature, msg string) (bool, error)

Verify - implement interface

type BLS0ChainThresholdScheme

type BLS0ChainThresholdScheme struct {
	BLS0ChainScheme

	Ids string `json:"threshold_scheme_id"`
	// contains filtered or unexported fields
}

BLS0ChainThresholdScheme - a scheme that can create threshold signature shares for BLS0Chain signature scheme

func BLS0GenerateThresholdKeyShares

func BLS0GenerateThresholdKeyShares(t, n int, originalKey SignatureScheme) ([]BLS0ChainThresholdScheme, error)

BLS0GenerateThresholdKeyShares given a signature scheme will generate threshold sig keys

func NewBLS0ChainThresholdScheme

func NewBLS0ChainThresholdScheme() *BLS0ChainThresholdScheme

NewBLS0ChainThresholdScheme - create a new instance

func (*BLS0ChainThresholdScheme) GetID

func (tss *BLS0ChainThresholdScheme) GetID() string

GetID gets ID in hex string format

func (*BLS0ChainThresholdScheme) SetID

func (tss *BLS0ChainThresholdScheme) SetID(id string) error

SetID sets ID in HexString format

type ED255190chainScheme

type ED255190chainScheme struct {
	// contains filtered or unexported fields
}

ED255190chainScheme - a signature scheme based on ED25519

func NewED255190chainScheme

func NewED255190chainScheme() *ED255190chainScheme

NewED25519Scheme - create a ED255219Scheme 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) GetPrivateKey

func (ed *ED255190chainScheme) GetPrivateKey() string

GetPrivateKey - implement interface

func (*ED255190chainScheme) GetPublicKey

func (ed *ED255190chainScheme) GetPublicKey() string

GetPublicKey - implement interface

func (*ED255190chainScheme) RecoverKeys

func (ed *ED255190chainScheme) RecoverKeys(mnemonic string) (*Wallet, error)

func (*ED255190chainScheme) SetPrivateKey

func (ed *ED255190chainScheme) SetPrivateKey(privateKey string) error

func (*ED255190chainScheme) SetPublicKey

func (ed *ED255190chainScheme) SetPublicKey(publicKey string) error

func (*ED255190chainScheme) Sign

func (ed *ED255190chainScheme) Sign(hash string) (string, error)

func (*ED255190chainScheme) Verify

func (ed *ED255190chainScheme) Verify(signature, msg string) (bool, error)

type KeyPair

type KeyPair struct {
	PublicKey  string `json:"public_key"`
	PrivateKey string `json:"private_key"`
}

KeyPair private and publickey

type SignatureScheme

type SignatureScheme interface {
	// Generate fresh keys
	GenerateKeys() (*Wallet, error)
	// Generate keys from mnemonic for recovery
	RecoverKeys(mnemonic string) (*Wallet, error)

	// 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)
}

SignatureScheme - an encryption scheme for signing and verifying messages

func NewSignatureScheme

func NewSignatureScheme(sigScheme string) SignatureScheme

NewSignatureScheme creates an instance for using signature functions

type SplitSignatureScheme

type SplitSignatureScheme interface {
	SignatureScheme
	SplitKeys(numSplits int) (*Wallet, error)
}

SplitSignatureScheme splits the primary key into number of parts.

type ThresholdSignatureScheme

type ThresholdSignatureScheme interface {
	SignatureScheme

	SetID(id string) error
	GetID() string
}

type Wallet

type Wallet struct {
	ClientID    string    `json:"client_id"`
	ClientKey   string    `json:"client_key"`
	Keys        []KeyPair `json:"keys"`
	Mnemonic    string    `json:"mnemonics"`
	Version     string    `json:"version"`
	DateCreated string    `json:"date_created"`
}

Wallet structure

func (*Wallet) Marshal

func (w *Wallet) Marshal() (string, error)

Marshal returns json string

Jump to

Keyboard shortcuts

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