crypto

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SHA3256LEN is the length for hash value of sha3 256
	SHA3256LEN = 32
)

Variables

This section is empty.

Functions

func CalculateDigest

func CalculateDigest(pre *protos.PreOrder) (string, error)

CalculateDigest is used to calculate the digest

func CheckDigest

func CheckDigest(pre *protos.PreOrder) error

CheckDigest is used to check the correctness of digest

func HashToID

func HashToID(hash []byte) types.Identifier

func IDToByte

func IDToByte(id types.Identifier) []byte

func MakeID

func MakeID(payload []byte) types.Identifier

MakeID creates an ID from the hash of encoded data.

func PrivSign

func PrivSign(hash types.Hash, nodeID int) (*protos.Certification, error)

PrivSign is used to generate signature with private key

func PubVerify

func PubVerify(cert *protos.Certification, hash types.Hash, nodeID int) error

PubVerify is used to verify the signature with the provided public key

func SetKeys

func SetKeys() error

SetKeys is used to init the public/private keys for validator

func VerifyProofCerts

func VerifyProofCerts(digest types.Hash, pc *protos.QuorumCert, quorum int) error

VerifyProofCerts is used to verify the validation of proof-certs

Types

type Hasher

type Hasher interface {
	// ComputeHash returns the hash output regardless of the hash state
	ComputeHash([]byte) types.Hash
}

Hasher interface

func NewSHA3256

func NewSHA3256() Hasher

NewSHA3256 returns a new instance of SHA3-256 hasher

type PrivateKey

type PrivateKey interface {
	// Algorithm returns the signing algorithm related to the private key.
	Algorithm() string

	// Sign generates a signature using the provided hasher.
	Sign(types.Hash) (*protos.Certification, error)

	// PublicKey returns the public key.
	PublicKey() PublicKey
}

PrivateKey is an unspecified signature scheme private key

type PublicKey

type PublicKey interface {
	// Algorithm returns the signing algorithm related to the public key.
	Algorithm() string

	// Verify verifies a signature of an input message using the provided hasher.
	Verify(*protos.Certification, types.Hash) error
}

PublicKey is an unspecified signature scheme public key.

type StaticRand

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

func (*StaticRand) Read

func (sr *StaticRand) Read(x []byte) (int, error)

Jump to

Keyboard shortcuts

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