Lux Proposals
← All proposals
LP-0131Finalevmprecompilevrfrandomness

LP-131: ECVRF Precompile

Abstract

VRF verification precompile per RFC 9381. Enables on-chain randomness beacons, leader election, and lottery protocols with ~40x gas savings over Solidity implementations.

Motivation

Verifiable Random Functions produce randomness that is:

On-chain VRF verification in Solidity requires explicit elliptic curve arithmetic over Edwards25519 -- approximately 800,000 gas. A native precompile at 20,000 gas is a 40x improvement.

Specification

Operations

OpVerify (0x01)

Verifies a VRF proof and returns the verifiable random output.

Input: opcode(1) || pk(32) || alpha_len(2 big-endian) || alpha(variable) || proof(80)

Output: beta_string(64) on success, empty bytes on verification failure.

The proof is 80 bytes: Gamma(32) || c(16) || s(32) where Gamma is a compressed Edwards25519 point, c is a 16-byte challenge scalar (little-endian, zero-padded to 32 bytes internally), and s is a 32-byte scalar.

Verification follows RFC 9381 section 5.3:

1. Decode public key Y from pk bytes

2. Decode proof into (Gamma, c, s)

3. Compute H = hash_to_curve(pk, alpha) using Elligator2

4. Compute U = s*B - c*Y

5. Compute V = s*H - c*Gamma

6. Derive c' = challenge_generation(Y, H, Gamma, U, V)

7. Accept iff c == c'

8. Return beta = proof_to_hash(Gamma)

Gas: 20,000

OpProofToHash (0x02)

Extracts the verifiable random output from a proof without re-verifying. Useful when the proof has already been verified (e.g., stored on-chain after a prior verify call).

Input: opcode(1) || proof(80)

Output: beta_string(64)

Computes SHA-512(suite_string || 0x03 || cofactor*Gamma || 0x00).

Gas: 1,000

Cryptographic Details

Security Properties

Use Cases

Implementation

Source: github.com/luxfi/precompile/vrf/

Files:

Dependencies: filippo.io/edwards25519 (already in go.mod), crypto/sha512 (stdlib).

No external VRF library is used. The implementation follows RFC 9381 sections 5.1-5.4 directly using the edwards25519 point and scalar arithmetic from filippo.io.