crypto

package
v0.0.0-...-2e52d37 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SHA3_224 = "sha3_224"
	SHA3_256 = "sha3_256"
	SHA3_384 = "sha3_384"
	SHA3_512 = "sha3_512"
)
View Source
const (
	HashLenSha3_224 = 32
	HashLenSha3_256 = 32
	HashLenSha3_384 = 32
	HashLenSha3_512 = 32
)
View Source
const (
	// Supported signing algorithms
	//UnknownSigningAlgorithm SigningAlgorithm = iota
	BLS_BLS12381    = "BLS_BLS12381"
	ECDSA_P256      = "ECDSA_P256"
	ECDSA_SECp256k1 = "ECDSA_SECp256k1"
)

Variables

This section is empty.

Functions

func HashesToBytes

func HashesToBytes(hashes []Hash) [][]byte

HashesToBytes converts a slice of hashes to a slice of byte slices.

func IDToByte

func IDToByte(id Identifier) []byte

func PubVerify

func PubVerify(sig Signature, data []byte, nodeID identity.NodeID) (bool, error)

func SetKeys

func SetKeys() error

func VerifyQuorumSignature

func VerifyQuorumSignature(aggregatedSigs AggSig, blockID Identifier, aggSigners []identity.NodeID) (bool, error)

Types

type AggSig

type AggSig []Signature

type ECDSASignature

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

type Hash

type Hash []byte

Hash is the hash algorithms output types

func BytesToHash

func BytesToHash(b []byte) Hash

func (Hash) Equal

func (h Hash) Equal(input Hash) bool

Equal checks if a hash is equal to a given hash

func (Hash) Hex

func (h Hash) Hex() string

Hex returns the hex string representation of the hash.

type Hasher

type Hasher interface {
	// Size returns the hash output length
	Size() int
	// ComputeHash returns the hash output regardless of the hash state
	ComputeHash([]byte) Hash
	// Write([]bytes) (using the io.Writer interface) adds more bytes to the
	// current hash state
	io.Writer
	// SumHash returns the hash output and resets the hash state
	SumHash() Hash
	// Reset resets the hash state
	Reset()
}

Hasher interface

func NewHasher

func NewHasher(hashType string) (Hasher, error)

NewHasher chooses and initializes a hashing algorithm Deprecated and will removed later: use dedicated hash generation functions instead. UPDATE By Ali: This function is used to build a new hasher for a replica

func NewSHA3_224

func NewSHA3_224() Hasher

NewSHA3_224 returns a new instance of SHA3-224 hasher

func NewSHA3_256

func NewSHA3_256() Hasher

NewSHA3_256 returns a new instance of SHA3-256 hasher

func NewSHA3_384

func NewSHA3_384() Hasher

NewSHA3_384 returns a new instance of SHA3-384 hasher

func NewSHA3_512

func NewSHA3_512() Hasher

NewSHA3_512 returns a new instance of SHA3-512 hasher

type Identifier

type Identifier [32]byte

func HashToID

func HashToID(hash []byte) Identifier

func MakeID

func MakeID(body interface{}) Identifier

MakeID creates an ID from the hash of encoded data.

type PrivateKey

type PrivateKey interface {
	// Algorithm returns the signing algorithm related to the private key.
	Algorithm() string
	// KeySize return the key size in bytes.
	// KeySize() int
	// Sign generates a signature using the provided hasher.
	Sign([]byte, Hasher) (Signature, error)
	// PublicKey returns the public key.
	PublicKey() PublicKey
}

PrivateKey is an unspecified signature scheme private key

func GenerateKey

func GenerateKey(signer string, id identity.NodeID) (PrivateKey, error)

type PublicKey

type PublicKey interface {
	// Algorithm returns the signing algorithm related to the public key.
	Algorithm() string
	// KeySize return the key size in bytes.
	//KeySize() int
	// Verify verifies a signature of an input message using the provided hasher.
	Verify(Signature, Hash) (bool, error)
}

PublicKey is an unspecified signature scheme public key.

type Signature

type Signature [][]byte

func PrivSign

func PrivSign(data []byte, nodeID identity.NodeID, hasher Hasher) (Signature, error)

func (*Signature) ToECDSA

func (sig *Signature) ToECDSA() ECDSASignature

TODO: I have to generate an error here

type StaticRand

type StaticRand struct {
	identity.NodeID
}

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