vrf

package
v0.10.8 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const OnChainResponseLength = ProofLength + 32

OnChainResponseLength is the length of the MarshaledOnChainResponse. The extra 32 bytes are for blocknumber (as a uint256), which goes at the end. The seed is rewritten with the preSeed. (See MarshalForVRFCoordinator and ProofResponse#ActualProof.)

View Source
const ProofLength = 64 +
	64 +
	32 +
	32 +
	32 +
	32 +
	64 +
	64 +

	32 // zInv  (Leave Output out, because that can be efficiently calculated)

Length of marshaled proof, in bytes

Variables

View Source
var (
	ErrKeyNotSet = errors.New("key not set")
)

Functions

func FinalSeed added in v0.8.12

func FinalSeed(s PreSeedData) (finalSeed *big.Int)

FinalSeed is the seed which is actually passed to the VRF proof generator, given the pre-seed and the hash of the block in which the VRFCoordinator emitted the log for the request this is responding to.

func UnmarshalSolidityProof added in v0.8.2

func UnmarshalSolidityProof(proof []byte) (rv vrfkey.Proof, err error)

func ValidatedVRFSpec added in v0.10.8

func ValidatedVRFSpec(tomlString string) (job.Job, error)

Types

type Config added in v0.10.8

type Config interface {
	MinIncomingConfirmations() uint32
	EthGasLimitDefault() uint64
}

type Delegate added in v0.10.8

type Delegate struct {
	// contains filtered or unexported fields
}

func NewDelegate added in v0.10.8

func NewDelegate(
	db *gorm.DB,
	txm bulletprooftxmanager.TxManager,
	ks *keystore.Master,
	pr pipeline.Runner,
	porm pipeline.ORM,
	lb log.Broadcaster,
	ec eth.Client,
	cfg Config) *Delegate

func (*Delegate) JobType added in v0.10.8

func (d *Delegate) JobType() job.Type

func (*Delegate) OnJobCreated added in v0.10.8

func (d *Delegate) OnJobCreated(spec job.Job)

func (*Delegate) OnJobDeleted added in v0.10.8

func (d *Delegate) OnJobDeleted(spec job.Job)

func (*Delegate) ServicesForSpec added in v0.10.8

func (d *Delegate) ServicesForSpec(jb job.Job) ([]job.Service, error)

type GethKeyStore added in v0.10.8

type GethKeyStore interface {
	GetRoundRobinAddress(addresses ...common.Address) (common.Address, error)
}

type MarshaledOnChainResponse added in v0.8.12

type MarshaledOnChainResponse [OnChainResponseLength]byte

MarshaledOnChainResponse is the flat bytes which are sent back to the VRFCoordinator.

func GenerateProofResponse added in v0.8.12

func GenerateProofResponse(keystore *keystore.VRF, key secp256k1.PublicKey, s PreSeedData) (
	MarshaledOnChainResponse, error)

type MarshaledProof added in v0.8.2

type MarshaledProof [ProofLength]byte

MarshaledProof contains a VRF proof for randomValueFromVRFProof.

NB: when passing one of these to randomValueFromVRFProof via the geth blockchain simulator, it must be passed as a slice ("proof[:]"). Passing it as-is sends hundreds of single bytes, each padded to their own 32-byte word.

func MarshalForSolidityVerifier added in v0.10.8

func MarshalForSolidityVerifier(p *vrfkey.Proof) (MarshaledProof, error)

MarshalForSolidityVerifier renders p as required by randomValueFromVRFProof

func (MarshaledProof) String added in v0.8.2

func (m MarshaledProof) String() string

String returns m as 0x-hex bytes

type PreSeedData added in v0.8.12

type PreSeedData struct {
	PreSeed   Seed        // Seed to be mixed with hash of containing block
	BlockHash common.Hash // Hash of block containing VRF request
	BlockNum  uint64      // Cardinal number of block containing VRF request
}

PreSeedData contains the data the VRF provider needs to compute the final VRF output and marshal the proof for transmission to the VRFCoordinator contract.

func TestXXXSeedData added in v0.10.8

func TestXXXSeedData(t *testing.T, preSeed *big.Int, blockHash common.Hash,
	blockNum int) PreSeedData

type ProofResponse added in v0.8.12

type ProofResponse struct {
	// Approximately the proof which will be checked on-chain. Note that this
	// contains the pre-seed in place of the final seed. That should be computed
	// as in FinalSeed.
	P        vrfkey.Proof
	PreSeed  Seed   // Seed received during VRF request
	BlockNum uint64 // Height of the block in which tihs request was made
}

ProofResponse is the data which is sent back to the VRFCoordinator, so that it can verify that the seed the oracle finally used is correct.

func UnmarshalProofResponse added in v0.8.12

func UnmarshalProofResponse(m MarshaledOnChainResponse) (*ProofResponse, error)

UnmarshalProofResponse returns the ProofResponse represented by the bytes in m

func (ProofResponse) CryptoProof added in v0.8.12

func (p ProofResponse) CryptoProof(s PreSeedData) (vrfkey.Proof, error)

CryptoProof returns the proof implied by p, with the correct seed

func (*ProofResponse) MarshalForVRFCoordinator added in v0.8.12

func (p *ProofResponse) MarshalForVRFCoordinator() (
	response MarshaledOnChainResponse, err error)

MarshalForVRFCoordinator constructs the flat bytes which are sent to the VRFCoordinator.

type Seed added in v0.8.12

type Seed [32]byte

Seed represents a VRF seed as a serialized uint256

func BigToSeed added in v0.8.12

func BigToSeed(x *big.Int) (Seed, error)

BigToSeed returns seed x represented as a Seed, or an error if x is too big

func BytesToSeed added in v0.8.12

func BytesToSeed(b []byte) (*Seed, error)

BytesToSeed returns the Seed corresponding to b, or an error if b is too long

func (*Seed) Big added in v0.8.12

func (s *Seed) Big() *big.Int

Big returns the uint256 seed represented by s

type SolidityProof added in v0.8.2

type SolidityProof struct {
	P                           *vrfkey.Proof  // The core proof
	UWitness                    common.Address // Address of P.C*P.PK+P.S*G
	CGammaWitness, SHashWitness kyber.Point    // P.C*P.Gamma, P.S*HashToCurve(P.Seed)
	ZInv                        *big.Int       // Inverse of Z coord from ProjectiveECAdd(CGammaWitness, SHashWitness)
}

SolidityProof contains precalculations which VRF.sol needs to verifiy proofs

func SolidityPrecalculations added in v0.10.8

func SolidityPrecalculations(p *vrfkey.Proof) (*SolidityProof, error)

SolidityPrecalculations returns the precomputed values needed by the solidity verifier, or an error on failure.

func (*SolidityProof) MarshalForSolidityVerifier added in v0.8.2

func (p *SolidityProof) MarshalForSolidityVerifier() (proof MarshaledProof)

MarshalForSolidityVerifier renders p as required by randomValueFromVRFProof

func (*SolidityProof) String added in v0.8.2

func (p *SolidityProof) String() string

String returns the values in p, in hexadecimal format

type VRFInputs added in v0.10.8

type VRFInputs struct {
	// contains filtered or unexported fields
}

func GetVRFInputs added in v0.10.8

Check the key hash against the spec's pubkey

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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