ed25519

package
v0.0.0-...-c87a664 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2018 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package ed25519 implements a verifiable random function using the Edwards form of Curve25519, SHA512 and the Elligator map.

E is Curve25519 (in Edwards coordinates), h is SHA512.
f is the elligator map (bytes->E) that covers half of E.
8 is the cofactor of E, the group order is 8*l for prime l.
Setup : the prover publicly commits to a public key (P : E)
H : names -> E
    H(n) = f(h(n))^8
VRF : keys -> names -> vrfs
    VRF_x(n) = h(n, H(n)^x))
Prove : keys -> names -> proofs
    Prove_x(n) = tuple(c=h(n, g^r, H(n)^r), t=r-c*x, ii=H(n)^x)
        where r = h(x, n) is used as a source of randomness
Check : E -> names -> vrfs -> proofs -> bool
    Check(P, n, vrf, (c,t,ii)) = vrf == h(n, ii)
                                && c == h(n, g^t*P^c, H(n)^t*ii^c)

Index

Constants

View Source
const (
	PublicKeySize  = ed25519.PublicKeySize
	PrivateKeySize = ed25519.PrivateKeySize
	Size           = 32

	ProofSize = 32 + 32 + intermediateSize
)

Variables

View Source
var (
	ErrGetPubKey = errors.New("[vrf] Couldn't get corresponding public-key from private-key")
)

Functions

This section is empty.

Types

type PrivateKey

type PrivateKey []byte

func GenerateKey

func GenerateKey(rnd io.Reader) (sk PrivateKey, err error)

GenerateKey creates a public/private key pair using rnd for randomness. If rnd is nil, crypto/rand is used.

func (PrivateKey) Compute

func (sk PrivateKey) Compute(m []byte) []byte

Compute generates the vrf value for the byte slice m using the underlying private key sk.

func (PrivateKey) Prove

func (sk PrivateKey) Prove(m []byte) (vrf, proof []byte)

Prove returns the vrf value and a proof such that Verify(m, vrf, proof) == true. The vrf value is the same as returned by Compute(m).

func (PrivateKey) Public

func (sk PrivateKey) Public() (PublicKey, bool)

Public extracts the public VRF key from the underlying private-key and returns a boolean indicating if the operation was successful.

type PublicKey

type PublicKey []byte

func (PublicKey) Verify

func (pkBytes PublicKey) Verify(m, vrfBytes, proof []byte) bool

Verify returns true iff vrf=Compute(m) for the sk that corresponds to pk.

Jump to

Keyboard shortcuts

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