vrf

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package vrf implements a verifiable random function using the Edwards form of Curve25519, SHA3 and the Elligator map. Project URLs: - https://github.com/YahooArchive/coname/tree/master/vrf - https://github.com/coniks-sys/coniks-go/tree/master/crypto/vrf Paper: https://www.usenix.org/system/files/conference/usenixsecurity15/sec15-paper-melara.pdf

E is Curve25519 (in Edwards coordinates), h is SHA3.
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 = 32

	Size = 32

	ProofSize = 32 + 32 + intermediateSize
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PrivateKey

type PrivateKey [64]byte

PrivateKey represents an ed25519 private key

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 GenerateKeyFromPrivateKey

func GenerateKeyFromPrivateKey(key []byte) (sk PrivateKey, err error)

GenerateKeyFromPrivateKey generates a key from a 64 bytes private key

func GenerateKeyFromSeed

func GenerateKeyFromSeed(seed []byte) (sk PrivateKey, err error)

GenerateKeyFromSeed generates a key from a seed

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

PublicKey represents an ed25519 public key

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.

Directories

Path Synopsis
ed25519
edwards25519
Package edwards25519 implements operations in GF(2**255-19) and on an Edwards curve that is isomorphic to curve25519.
Package edwards25519 implements operations in GF(2**255-19) and on an Edwards curve that is isomorphic to curve25519.

Jump to

Keyboard shortcuts

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