vrf

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

README

VRF

VRF implementation is set by func init() with build option

Interface

  • package/file
    • PikeEcosystem/tendermintvrf/crypto/vrf
      • var defaultVrf vrfEd25519
      • vrf.go
      • vrf_test.go
type vrfEd25519 interface {
	Prove(privateKey []byte, message []byte) (Proof, error)
	Verify(publicKey []byte, proof Proof, message []byte) (bool, error)
	ProofToHash(proof Proof) (Output, error)

Implementations

Use func init() with build option

  • package/file
    • PikeEcosystem/tendermintvrf/crypto/vrf
      • (r2ishiguro = default)
        • //go:build libsodium
        • // +build !libsodium,!coniks
        • func init() { defaultVrf = newVrfEd25519r2ishiguro() }
        • const ProofSize = 81
        • vrf_r2ishiguro.go
      • (coniks)
        • //go:build coniks
        • // +build coniks
        • func init() { defaultVrf = newVrfEd25519coniks() }
        • const ProofSize = 96
        • vrf_coniks.go
        • vrf_coniks_test.go
      • (libsodium)
        • //go:build libsodium
        • // +build libsodium
        • func init() { defaultVrf = newVrfEd25519libsodium() }
        • const ProofSize = int(libsodium.PROOFBYTES)
        • vrf_libsodium.go
        • vrf_libsodium_test.go
Status
impl available memo
r2ishiguro o (default)
coniks x no compatibility between crypto ED25519 and coniks ED25519 (See TestProveAndVerify_ConiksByCryptoED25519)
libsodium o need to build libsodium (See libsodium task of Makefile)
Attention
  • There is no compatibility between r2ishiguro.Prove/libsodium.Verify and libsodium.Prove/r2ishiguro.Verify (See TestProveAndVerifyCompatibilityLibsodium)
  • tendermintvrf Network should use r2ishiguro or libsodium (Can't use both at the same time in tendermintvrf Network)
libsodium (bind C implementations)
  • package/file
    • PikeEcosystem/tendermintvrf/crypto/vrf/internal/vrf
      • // +build libsodium
      • vrf.go
      • vrf_test.go
      • libsodium: submodule (See .gitmodule)
      • sodium: libs (See libsodium task of Makefile)

How to test

# r2ishiguro
go test github.com/PikeEcosystem/tendermintvrf/crypto/vrf -tags r2ishiguro
# libsodium
go test github.com/PikeEcosystem/tendermintvrf/crypto/vrf -tags libsodium
# internal libsodium only
go test github.com/PikeEcosystem/tendermintvrf/crypto/vrf/internal/vrf -v -tags libsodium

# coniks is not available, but if you want to do, you can see no-compatibility
go test github.com/PikeEcosystem/tendermintvrf/crypto/vrf -tags coniks

How to benchmark

# r2ishiguro
go test -bench Benchmark github.com/PikeEcosystem/tendermintvrf/crypto/vrf -run ^$ -benchtime=1000x -count 10 -benchmem -v
# libsodium
go test -bench Benchmark github.com/PikeEcosystem/tendermintvrf/crypto/vrf -run ^$ -benchtime=1000x -count 10 -benchmem -v -tags libsodium

How to build

# r2ishiguro
make build
# libsodium
LIBSODIUM=1 make build

Documentation

Index

Constants

View Source
const (
	ProofSize  int = 81
	OutputSize int = 32
)

Variables

This section is empty.

Functions

func Verify

func Verify(publicKey []byte, proof Proof, message []byte) (bool, error)

Types

type Output

type Output []byte

func ProofToHash

func ProofToHash(proof Proof) (Output, error)

func (Output) ToInt

func (op Output) ToInt() *big.Int

type Proof

type Proof []byte

func Prove

func Prove(privateKey []byte, message []byte) (Proof, error)

Jump to

Keyboard shortcuts

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