crypto

package
v0.0.0-...-c69f244 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2022 License: LGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSignatureVerificationFailed = errors.New("failed to verify signature")

Functions

func AppendUint64

func AppendUint64(t *merlin.Transcript, label []byte, n uint64)

AppendUint64 appends a uint64 to the given transcript using the given label

func NewBIP39Mnemonic

func NewBIP39Mnemonic() (string, error)

NewBIP39Mnemonic returns a new BIP39-compatible mnemonic

func PublicAddressToByteArray

func PublicAddressToByteArray(add common.Address) []byte

PublicAddressToByteArray returns []byte address for given PublicKey Address

Types

type KeyType

type KeyType = string

KeyType str

const Ed25519Type KeyType = "ed25519"

Ed25519Type ed25519

const Secp256k1Type KeyType = "secp256k1"

Secp256k1Type secp256k1

const Sr25519Type KeyType = "sr25519"

Sr25519Type sr25519

const UnknownType KeyType = "unknown"

UnknownType is used by the GenericKeystore

type Keypair

type Keypair interface {
	Type() KeyType
	Sign(msg []byte) ([]byte, error)
	Public() PublicKey
	Private() PrivateKey
}

Keypair interface

type PrivateKey

type PrivateKey interface {
	Sign(msg []byte) ([]byte, error)
	Public() (PublicKey, error)
	Encode() []byte
	Decode([]byte) error
	Hex() string
}

PrivateKey interface

type PublicKey

type PublicKey interface {
	Verify(msg, sig []byte) (bool, error)
	Encode() []byte
	Decode([]byte) error
	Address() common.Address
	Hex() string
}

PublicKey interface

type SigVerifyFunc

type SigVerifyFunc func(pubkey, sig, msg []byte) (err error)

SigVerifyFunc verifies a signature given a public key and a message

type SignatureInfo

type SignatureInfo struct {
	PubKey     []byte
	Sign       []byte
	Msg        []byte
	VerifyFunc SigVerifyFunc
}

SignatureInfo ...

type SignatureVerifier

type SignatureVerifier struct {
	sync.RWMutex
	sync.Once
	sync.WaitGroup
	// contains filtered or unexported fields
}

SignatureVerifier ...

func NewSignatureVerifier

func NewSignatureVerifier(logger log.LeveledLogger) *SignatureVerifier

NewSignatureVerifier initialises SignatureVerifier which does background verification of signatures. Start() is called to start the verification process. Finish() is called to stop the verification process. Signatures can be added to the batch using Add().

func (*SignatureVerifier) Add

func (sv *SignatureVerifier) Add(s *SignatureInfo)

Add ...

func (*SignatureVerifier) Finish

func (sv *SignatureVerifier) Finish() bool

Finish waits till batch is finished. Returns true if all the signatures are valid, Otherwise returns false.

func (*SignatureVerifier) Invalid

func (sv *SignatureVerifier) Invalid()

Invalid ...

func (*SignatureVerifier) IsInvalid

func (sv *SignatureVerifier) IsInvalid() bool

IsInvalid ...

func (*SignatureVerifier) IsStarted

func (sv *SignatureVerifier) IsStarted() bool

IsStarted ...

func (*SignatureVerifier) Remove

func (sv *SignatureVerifier) Remove() *SignatureInfo

Remove returns the first signature from the batch. Returns nil if batch is empty.

func (*SignatureVerifier) Reset

func (sv *SignatureVerifier) Reset()

Reset reset the signature verifier for reuse.

func (*SignatureVerifier) Start

func (sv *SignatureVerifier) Start()

Start signature verification in batch.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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