ed25519

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2019 License: GPL-3.0, LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PublicKeySize is the size, in bytes, of public keys as used in this package.
	PublicKeySize = 32

	// PrivateKeySize is the size, in bytes, of private keys as used in this package.
	PrivateKeySize = 64

	// SignatureSize is the size, in bytes, of signatures generated and verified by this package.
	SignatureSize = 64

	// SeedSize is the size, in bytes, of private key seeds. These are the private key representations used by RFC 8032.
	SeedSize = 32
)
View Source
const (
	// VrfProofSize is the size, in bytes, of VRF proofs
	VrfProofSize = 80

	// VrfOutputSize is the size, in bytes, of VRF outputs
	VrfOutputSize = 64

	// VrfOutputSize256 is the size, in bytes, of VRF outputs in 32 bytes
	VrfOutputSize256 = 32
)
View Source
const (
	ForwardSecureSignatureSize = SignatureSize + PublicKeySize + SignatureSize
)

Variables

This section is empty.

Functions

func ForwardSecureUpdate

func ForwardSecureUpdate(sk *ForwardSecurePrivateKey, offset uint64) (deleted uint64)

func ForwardSecureVerify

func ForwardSecureVerify(pk *ForwardSecurePublicKey, offset uint64, data []byte, sig ForwardSecureSignature) bool

func GenerateForwardSecureKey

func GenerateForwardSecureKey(offset, count uint64) (pk ForwardSecurePublicKey, sk ForwardSecurePrivateKey)

func GenerateKey

func GenerateKey() (publicKey PublicKey, privateKey PrivateKey)

GenerateKey generates a public/private key pair using rand in libsodium.

func GenerateKeyFromSeed

func GenerateKeyFromSeed(seed Seed) (publicKey PublicKey, privateKey PrivateKey)

GenerateKeyFromSeed generates a public/private key pair using seed.

func Verify

func Verify(publicKey *PublicKey, data []byte, sig *Signature) bool

Verify reports whether sig is a valid signature of data by publicKey.

func VrfGenerateKey

func VrfGenerateKey() (publicKey VrfPublicKey, privateKey VrfPrivateKey)

VrfGenerateKey generates a new rand VRF key pair.

func VrfGenerateKeyFromSeed

func VrfGenerateKeyFromSeed(seed Seed) (publicKey VrfPublicKey, privateKey VrfPrivateKey)

VrfGenerateKeyFromSeed generates a new key pair from seed.

Types

type ForwardSecurePrivateKey

type ForwardSecurePrivateKey struct {
	PublicKey ForwardSecurePublicKey
	Start     uint64
	SubKeys   []signedSubKey
}

func (ForwardSecurePrivateKey) ValidOffset

func (key ForwardSecurePrivateKey) ValidOffset(offset uint64) bool

type ForwardSecurePublicKey

type ForwardSecurePublicKey PublicKey

func ForwardSecurePrivateKeyToPublicKey

func ForwardSecurePrivateKeyToPublicKey(sk *ForwardSecurePrivateKey) ForwardSecurePublicKey

type ForwardSecureSignature

type ForwardSecureSignature struct {
	Sig   Signature
	Pk    PublicKey
	PkSig Signature
}

func ForwardSecureSign

func ForwardSecureSign(sk *ForwardSecurePrivateKey, offset uint64, data []byte) ForwardSecureSignature

type PrivateKey

type PrivateKey [PrivateKeySize]byte

type PublicKey

type PublicKey [PublicKeySize]byte

func PrivateKeyToPublicKey

func PrivateKeyToPublicKey(privateKey *PrivateKey) (PublicKey, error)

PrivateKeyToPublicKey derives a public key from a private key. This is very efficient since ed25519 private keys literally contain their public key

type Seed

type Seed [SeedSize]byte

func PrivateKeyToSeed

func PrivateKeyToSeed(privateKey *PrivateKey) (Seed, error)

PrivateKeyToSeed derives the seed from a private key. This is very efficient since ed25519 private keys literally contain their seed

type Signature

type Signature [SignatureSize]byte

func Sign

func Sign(privateKey *PrivateKey, data []byte) (sig Signature)

Sign signs the data with privateKey and returns a signature. It will panic if privateKey is nil

type VrfOutput

type VrfOutput [VrfOutputSize]byte

VrfOutput is a 64-byte pseudorandom value that can be computed from a VrfProof. The VRF scheme guarantees that such output will be unique

func VrfProofToHash

func VrfProofToHash(proof *VrfProof) (hash VrfOutput, ok bool)

VrfProofToHash generates a hash from a proof without verifying the proof.

func VrfVerify

func VrfVerify(publicKey *VrfPublicKey, proof *VrfProof, msg []byte) (ok bool, output VrfOutput)

VrfVerify verifies a VRF proof against publicKey and msg, return true and the VrfOutput if the proof is valid. ok will be false if the proof is invalid.

For a given public key and message, there are potentially multiple valid proofs. However, given a public key and message, all valid proofs will yield the same output. Moreover, the output is indistinguishable from random to anyone without the proof or the secret key.

type VrfOutput256

type VrfOutput256 [VrfOutputSize256]byte

VrfOutput256 is a 32-byte pseudorandom value that can be computed from a VrfProof. The VRF scheme guarantees that such output will be unique

func VrfProofToHash256

func VrfProofToHash256(proof *VrfProof) (hash256 VrfOutput256, ok bool)

VrfProofToHash256 generates a hash256 from a proof without verifying the proof.

func VrfVerify256

func VrfVerify256(publicKey *VrfPublicKey, proof *VrfProof, msg []byte) (ok bool, hash256 VrfOutput256)

type VrfPrivateKey

type VrfPrivateKey PrivateKey

A VrfPrivateKey is a private key used for producing VRF proofs. Specifically, we use a 64-byte ed25519 private key.

type VrfProof

type VrfProof [VrfProofSize]byte

A VrfProof for a message can be generated with a secret key and verified against a public key, like a signature. Proofs are malleable, however, for a given message and public key, the VRF output that can be computed from a proof is unique.

func VrfProve

func VrfProve(privateKey *VrfPrivateKey, msg []byte) (proof VrfProof, ok bool)

VrfProve generates a proof for a given message. ok will be false if the private key is bad.

type VrfPublicKey

type VrfPublicKey PublicKey

A VrfPublicKey is a public key that can be used to verify VRF proofs.

func VrfPrivateKeyToPublicKey

func VrfPrivateKeyToPublicKey(privateKey *VrfPrivateKey) (publicKey VrfPublicKey)

Jump to

Keyboard shortcuts

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