ed25519

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	PrivKeyName = "tendermint/PrivKeyEd25519"
	PubKeyName  = "tendermint/PubKeyEd25519"
	// PubKeySize is is the size, in bytes, of public keys as used in this package.
	PubKeySize = 32
	// PrivateKeySize is the size, in bytes, of private keys as used in this package.
	PrivateKeySize = 64
	// SignatureSize of an Edwards25519 signature. Namely the size of a compressed
	// Edwards25519 point, and a field element. Both of which are 32 bytes.
	SignatureSize = 64
	// SeedSize is the size, in bytes, of private key seeds. These are the
	// private key representations used by RFC 8032.
	SeedSize = 32

	KeyType = "ed25519"
)

Variables

This section is empty.

Functions

func ProofToHash added in v1.1.1

func ProofToHash(proof []byte) ([]byte, error)

func VRFVerify added in v1.1.1

func VRFVerify(pubKey ed25519.PublicKey, proof []byte, message []byte) (bool, []byte)

func ValidateProof added in v1.1.1

func ValidateProof(h []byte) error

ValidateProof returns an error if the proof is not empty, but its size != vrf.ProofSize.

Types

type PrivKey

type PrivKey []byte

PrivKey implements crypto.PrivKey.

func GenPrivKey

func GenPrivKey() PrivKey

GenPrivKey generates a new ed25519 private key. It uses OS randomness in conjunction with the current global random seed in ostracon/libs/common to generate the private key.

func GenPrivKeyFromSecret

func GenPrivKeyFromSecret(secret []byte) PrivKey

GenPrivKeyFromSecret hashes the secret with SHA2, and uses that 32 byte output to create the private key. NOTE: secret should be the output of a KDF like bcrypt, if it's derived from user input.

func (PrivKey) Bytes

func (privKey PrivKey) Bytes() []byte

Bytes returns the privkey byte format.

func (PrivKey) Equals

func (privKey PrivKey) Equals(other crypto.PrivKey) bool

Equals - you probably don't need to use this. Runs in constant time based on length of the keys.

func (PrivKey) PubKey

func (privKey PrivKey) PubKey() crypto.PubKey

PubKey gets the corresponding public key from the private key.

Panics if the private key is not initialized.

func (PrivKey) Sign

func (privKey PrivKey) Sign(msg []byte) ([]byte, error)

Sign produces a signature on the provided message. This assumes the privkey is wellformed in the golang format. The first 32 bytes should be random, corresponding to the normal ed25519 private key. The latter 32 bytes should be the compressed public key. If these conditions aren't met, Sign will panic or produce an incorrect signature.

func (PrivKey) Type

func (privKey PrivKey) Type() string

func (PrivKey) VRFProve

func (privKey PrivKey) VRFProve(message []byte) (crypto.Proof, error)

VRFProve generates a VRF Proof for given message to generate a verifiable random.

type PubKey

type PubKey []byte

PubKeyEd25519 implements crypto.PubKey for the Ed25519 signature scheme.

func (PubKey) Address

func (pubKey PubKey) Address() crypto.Address

Address is the SHA256-20 of the raw pubkey bytes.

func (PubKey) Bytes

func (pubKey PubKey) Bytes() []byte

Bytes returns the PubKey byte format.

func (PubKey) Equals

func (pubKey PubKey) Equals(other crypto.PubKey) bool

func (PubKey) String

func (pubKey PubKey) String() string

func (PubKey) Type

func (pubKey PubKey) Type() string

func (PubKey) VRFVerify

func (pubKey PubKey) VRFVerify(proof []byte, message []byte) (crypto.Output, error)

VRFVerify guarantees that the public key is validated such that the "full uniqueness" and "full collision" properties are satisfied. The internal function of VRFVerify is implemented based on the IETF draft. See sections 3.1 and 3.2 here https://datatracker.ietf.org/doc/draft-irtf-cfrg-vrf/.

func (PubKey) VerifySignature

func (pubKey PubKey) VerifySignature(msg []byte, sig []byte) bool

type VrfNoProve added in v1.1.1

type VrfNoProve interface {
	Verify(pubKey ed25519.PublicKey, proof []byte, message []byte) (bool, []byte)
	ProofToHash(proof []byte) ([]byte, error)
}

vrf w/o prove vrf Prove() MUST use its latest implementation, while this allows to verify the old blocks.

func NewVersionedVrfNoProve added in v1.1.1

func NewVersionedVrfNoProve() VrfNoProve

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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