mirror of
https://github.com/luxfi/precompile.git
synced 2026-07-27 03:33:45 +00:00
fix: corona GenerateKeys->GenerateKeysTrustedDealer (KAT dump) + pq go.sum + dealerless deps
Co-authored-by: Hanzo Dev <dev@hanzo.ai>
This commit is contained in:
@@ -124,7 +124,7 @@ func magnetarKAT() katOut {
|
||||
//
|
||||
// c || z[N] || Delta[M] || A[M][N] || bTilde[M], each poly = N()*8 bytes BE.
|
||||
func coronaKAT(t, n uint32) katOut {
|
||||
shares, groupKey, err := cthr.GenerateKeys(int(t), int(n), rand.Reader)
|
||||
shares, groupKey, err := cthr.GenerateKeysTrustedDealer(int(t), int(n), rand.Reader)
|
||||
must(err)
|
||||
|
||||
prfKey := make([]byte, csign.KeySize)
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
package curves
|
||||
|
||||
import (
|
||||
"github.com/luxfi/precompile/bls12381"
|
||||
"github.com/luxfi/precompile/examples"
|
||||
)
|
||||
|
||||
// BLS12381Demo exercises all 7 BLS12-381 precompiles (EIP-2537).
|
||||
func BLS12381Demo() []examples.Result {
|
||||
var results []examples.Result
|
||||
|
||||
// BLS12-381 G1 generator in EIP-2537 format (128 bytes):
|
||||
g1Gen := make([]byte, 128)
|
||||
copy(g1Gen[16:64], examples.HexDecode("17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"))
|
||||
copy(g1Gen[80:128], examples.HexDecode("08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"))
|
||||
|
||||
// G1Add: G + G = 2G
|
||||
g1AddInput := make([]byte, 256)
|
||||
copy(g1AddInput[0:128], g1Gen)
|
||||
copy(g1AddInput[128:256], g1Gen)
|
||||
results = append(results, examples.CallPrecompileResult(
|
||||
"BLS12-381 G1Add",
|
||||
bls12381.G1AddModule.Contract,
|
||||
bls12381.G1AddAddress,
|
||||
g1AddInput,
|
||||
func(out []byte) bool { return len(out) == 128 && examples.IsNonZero(out) },
|
||||
))
|
||||
|
||||
// G1Mul: G * 2
|
||||
g1MulInput := make([]byte, 160)
|
||||
copy(g1MulInput[0:128], g1Gen)
|
||||
g1MulInput[159] = 2
|
||||
results = append(results, examples.CallPrecompileResult(
|
||||
"BLS12-381 G1Mul",
|
||||
bls12381.G1MulModule.Contract,
|
||||
bls12381.G1MulAddress,
|
||||
g1MulInput,
|
||||
func(out []byte) bool { return len(out) == 128 && examples.IsNonZero(out) },
|
||||
))
|
||||
|
||||
// G1MSM: 1 pair (G, scalar=3)
|
||||
g1MSMInput := make([]byte, 160)
|
||||
copy(g1MSMInput[0:128], g1Gen)
|
||||
g1MSMInput[159] = 3
|
||||
results = append(results, examples.CallPrecompileResult(
|
||||
"BLS12-381 G1MSM",
|
||||
bls12381.G1MSMModule.Contract,
|
||||
bls12381.G1MSMAddress,
|
||||
g1MSMInput,
|
||||
func(out []byte) bool { return len(out) == 128 && examples.IsNonZero(out) },
|
||||
))
|
||||
|
||||
// G2 generator in EIP-2537 format (256 bytes):
|
||||
g2Gen := make([]byte, 256)
|
||||
copy(g2Gen[16:64], examples.HexDecode("13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e"))
|
||||
copy(g2Gen[80:128], examples.HexDecode("024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"))
|
||||
copy(g2Gen[144:192], examples.HexDecode("0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be"))
|
||||
copy(g2Gen[208:256], examples.HexDecode("0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"))
|
||||
|
||||
// G2Add
|
||||
g2AddInput := make([]byte, 512)
|
||||
copy(g2AddInput[0:256], g2Gen)
|
||||
copy(g2AddInput[256:512], g2Gen)
|
||||
results = append(results, examples.CallPrecompileResult(
|
||||
"BLS12-381 G2Add",
|
||||
bls12381.G2AddModule.Contract,
|
||||
bls12381.G2AddAddress,
|
||||
g2AddInput,
|
||||
func(out []byte) bool { return len(out) == 256 && examples.IsNonZero(out) },
|
||||
))
|
||||
|
||||
// G2Mul
|
||||
g2MulInput := make([]byte, 288)
|
||||
copy(g2MulInput[0:256], g2Gen)
|
||||
g2MulInput[287] = 2
|
||||
results = append(results, examples.CallPrecompileResult(
|
||||
"BLS12-381 G2Mul",
|
||||
bls12381.G2MulModule.Contract,
|
||||
bls12381.G2MulAddress,
|
||||
g2MulInput,
|
||||
func(out []byte) bool { return len(out) == 256 && examples.IsNonZero(out) },
|
||||
))
|
||||
|
||||
// G2MSM
|
||||
g2MSMInput := make([]byte, 288)
|
||||
copy(g2MSMInput[0:256], g2Gen)
|
||||
g2MSMInput[287] = 3
|
||||
results = append(results, examples.CallPrecompileResult(
|
||||
"BLS12-381 G2MSM",
|
||||
bls12381.G2MSMModule.Contract,
|
||||
bls12381.G2MSMAddress,
|
||||
g2MSMInput,
|
||||
func(out []byte) bool { return len(out) == 256 && examples.IsNonZero(out) },
|
||||
))
|
||||
|
||||
// Pairing: e(0, G2) * e(0, G2) = identity pairing (trivially true)
|
||||
pairingInput := make([]byte, 2*(128+256))
|
||||
copy(pairingInput[128:128+256], g2Gen)
|
||||
copy(pairingInput[128+256+128:], g2Gen)
|
||||
results = append(results, examples.CallPrecompileResult(
|
||||
"BLS12-381 Pairing",
|
||||
bls12381.PairingModule.Contract,
|
||||
bls12381.PairingAddress,
|
||||
pairingInput,
|
||||
func(out []byte) bool { return examples.LastByte32IsOne(out) },
|
||||
))
|
||||
|
||||
return results
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// Package curves demonstrates BLS12-381, Ed25519, secp256r1, and SR25519 precompiles.
|
||||
package curves
|
||||
|
||||
import "github.com/luxfi/precompile/examples"
|
||||
|
||||
// AllCurveDemos runs all curve precompile demos.
|
||||
type AllCurveDemos struct{}
|
||||
|
||||
func (d AllCurveDemos) Name() string { return "curves" }
|
||||
|
||||
func (d AllCurveDemos) Run() []examples.Result {
|
||||
var all []examples.Result
|
||||
all = append(all, BLS12381Demo()...)
|
||||
all = append(all, Ed25519Demo()...)
|
||||
all = append(all, Secp256r1Demo()...)
|
||||
all = append(all, SR25519Demo()...)
|
||||
return all
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package curves
|
||||
|
||||
import (
|
||||
"crypto/ed25519"
|
||||
"crypto/sha256"
|
||||
|
||||
"github.com/luxfi/geth/common"
|
||||
ed "github.com/luxfi/precompile/ed25519"
|
||||
"github.com/luxfi/precompile/examples"
|
||||
)
|
||||
|
||||
// Ed25519Demo exercises the Ed25519 verify precompile (0x3211).
|
||||
func Ed25519Demo() []examples.Result {
|
||||
// Generate a key pair and sign a message
|
||||
pub, priv, _ := ed25519.GenerateKey(nil)
|
||||
msg := []byte("Lux precompile Ed25519 demo")
|
||||
sig := ed25519.Sign(priv, msg)
|
||||
|
||||
// The precompile expects: hash(32) + sig(64) + pubkey(32) = 128 bytes
|
||||
hash := sha256.Sum256(msg)
|
||||
|
||||
input := make([]byte, 128)
|
||||
copy(input[0:32], hash[:])
|
||||
copy(input[32:96], sig)
|
||||
copy(input[96:128], pub)
|
||||
|
||||
// We need to sign the hash, not the raw message, for the precompile
|
||||
sigOfHash := ed25519.Sign(priv, hash[:])
|
||||
copy(input[32:96], sigOfHash)
|
||||
|
||||
return []examples.Result{
|
||||
examples.CallPrecompileResult(
|
||||
"Ed25519 Verify",
|
||||
ed.Ed25519VerifyPrecompile,
|
||||
ed.ContractAddress,
|
||||
input,
|
||||
func(out []byte) bool { return examples.LastByte32IsOne(out) },
|
||||
),
|
||||
// Invalid signature test
|
||||
func() examples.Result {
|
||||
bad := make([]byte, 128)
|
||||
copy(bad, input)
|
||||
bad[32] ^= 0xFF // corrupt first byte of signature
|
||||
return examples.CallPrecompileResult(
|
||||
"Ed25519 Verify (invalid sig)",
|
||||
ed.Ed25519VerifyPrecompile,
|
||||
ed.ContractAddress,
|
||||
bad,
|
||||
func(out []byte) bool { return len(out) == 0 }, // should return empty
|
||||
)
|
||||
}(),
|
||||
// Wrong length test
|
||||
examples.CallPrecompileResult(
|
||||
"Ed25519 Verify (bad length)",
|
||||
ed.Ed25519VerifyPrecompile,
|
||||
common.HexToAddress("0x3211000000000000000000000000000000000000"),
|
||||
[]byte{0x01, 0x02, 0x03}, // too short
|
||||
func(out []byte) bool { return len(out) == 0 },
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package curves
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"crypto/elliptic"
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
|
||||
"github.com/luxfi/geth/common"
|
||||
"github.com/luxfi/precompile/examples"
|
||||
"github.com/luxfi/precompile/secp256r1"
|
||||
)
|
||||
|
||||
// Secp256r1Demo exercises the P-256 verify precompile (EIP-7212, 0x0100).
|
||||
func Secp256r1Demo() []examples.Result {
|
||||
// Generate P-256 key pair
|
||||
priv, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
||||
pub := &priv.PublicKey
|
||||
|
||||
msg := []byte("Lux precompile secp256r1 demo")
|
||||
hash := sha256.Sum256(msg)
|
||||
|
||||
r, s, _ := ecdsa.Sign(rand.Reader, priv, hash[:])
|
||||
|
||||
// Input: hash(32) + r(32) + s(32) + x(32) + y(32) = 160 bytes
|
||||
input := make([]byte, 160)
|
||||
copy(input[0:32], hash[:])
|
||||
copy(input[32:64], examples.PadLeft(r.Bytes(), 32))
|
||||
copy(input[64:96], examples.PadLeft(s.Bytes(), 32))
|
||||
copy(input[96:128], examples.PadLeft(pub.X.Bytes(), 32))
|
||||
copy(input[128:160], examples.PadLeft(pub.Y.Bytes(), 32))
|
||||
|
||||
// secp256r1 uses a different Run signature (not StatefulPrecompiledContract)
|
||||
// It has Run(input) ([]byte, error) -- call it directly
|
||||
c := &secp256r1.Contract{}
|
||||
out, err := c.Run(input)
|
||||
pass := err == nil && examples.LastByte32IsOne(out)
|
||||
gasUsed := uint64(secp256r1.P256VerifyGas)
|
||||
|
||||
return []examples.Result{
|
||||
{
|
||||
Name: "secp256r1 (P-256) Verify",
|
||||
Address: common.HexToAddress(secp256r1.P256VerifyAddress),
|
||||
Calldata: input,
|
||||
Output: out,
|
||||
GasUsed: gasUsed,
|
||||
Pass: pass,
|
||||
Error: err,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package curves
|
||||
|
||||
import (
|
||||
schnorrkel "github.com/ChainSafe/go-schnorrkel"
|
||||
"github.com/luxfi/precompile/examples"
|
||||
"github.com/luxfi/precompile/sr25519"
|
||||
)
|
||||
|
||||
// SR25519Demo exercises the SR25519 verify precompile (0x0A00).
|
||||
func SR25519Demo() []examples.Result {
|
||||
// Generate SR25519 key pair using go-schnorrkel
|
||||
priv, pub, _ := schnorrkel.GenerateKeypair()
|
||||
|
||||
msg := []byte("Lux precompile sr25519 demo")
|
||||
|
||||
// Sign with "substrate" context (the default)
|
||||
transcript := schnorrkel.NewSigningContext([]byte("substrate"), msg)
|
||||
sig, _ := priv.Sign(transcript)
|
||||
|
||||
// Input: pubkey(32) + sig(64) + message(variable)
|
||||
pubBytes := pub.Encode()
|
||||
sigBytes := sig.Encode()
|
||||
|
||||
input := make([]byte, 0, 32+64+len(msg))
|
||||
input = append(input, pubBytes[:]...)
|
||||
input = append(input, sigBytes[:]...)
|
||||
input = append(input, msg...)
|
||||
|
||||
return []examples.Result{
|
||||
examples.CallPrecompileResult(
|
||||
"SR25519 Verify",
|
||||
sr25519.SR25519VerifyPrecompile,
|
||||
sr25519.ContractAddress,
|
||||
input,
|
||||
func(out []byte) bool { return examples.LastByte32IsOne(out) },
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
// Package dex demonstrates DEX (Uniswap v4-style) and StableSwap precompiles.
|
||||
package dex
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"math/big"
|
||||
|
||||
"github.com/luxfi/precompile/examples"
|
||||
"github.com/luxfi/precompile/stableswap"
|
||||
)
|
||||
|
||||
type AllDEXDemos struct{}
|
||||
|
||||
func (d AllDEXDemos) Name() string { return "dex" }
|
||||
|
||||
func (d AllDEXDemos) Run() []examples.Result {
|
||||
var all []examples.Result
|
||||
all = append(all, StableSwapDemo()...)
|
||||
return all
|
||||
}
|
||||
|
||||
// StableSwapDemo exercises the Curve-style StableSwap AMM precompile (0x0400..60).
|
||||
func StableSwapDemo() []examples.Result {
|
||||
// OpGetD (0x04): compute invariant D from balances and amplification
|
||||
// Format: op(1) + numTokens(1) + balances(n * 32) + amp(32)
|
||||
numTokens := byte(2)
|
||||
balance1 := examples.PadLeft(new(big.Int).SetUint64(1_000_000).Bytes(), 32) // 1M
|
||||
balance2 := examples.PadLeft(new(big.Int).SetUint64(1_000_000).Bytes(), 32) // 1M
|
||||
amp := examples.PadLeft(new(big.Int).SetUint64(100).Bytes(), 32) // A=100
|
||||
|
||||
getDInput := make([]byte, 0, 1+1+64+32)
|
||||
getDInput = append(getDInput, stableswap.OpGetD)
|
||||
getDInput = append(getDInput, numTokens)
|
||||
getDInput = append(getDInput, balance1...)
|
||||
getDInput = append(getDInput, balance2...)
|
||||
getDInput = append(getDInput, amp...)
|
||||
|
||||
// OpGetDy (0x01): compute output amount for swap i->j
|
||||
// Format: op(1) + i(1) + j(1) + dx(32) + numTokens(1) + balances(n*32) + amp(32)
|
||||
dx := examples.PadLeft(new(big.Int).SetUint64(1000).Bytes(), 32)
|
||||
|
||||
getDyInput := make([]byte, 0, 1+1+1+32+1+64+32)
|
||||
getDyInput = append(getDyInput, stableswap.OpGetDy)
|
||||
getDyInput = append(getDyInput, 0) // i = token 0
|
||||
getDyInput = append(getDyInput, 1) // j = token 1
|
||||
getDyInput = append(getDyInput, dx...) // swap 1000
|
||||
getDyInput = append(getDyInput, numTokens)
|
||||
getDyInput = append(getDyInput, balance1...)
|
||||
getDyInput = append(getDyInput, balance2...)
|
||||
getDyInput = append(getDyInput, amp...)
|
||||
|
||||
_ = binary.BigEndian // suppress unused import
|
||||
|
||||
return []examples.Result{
|
||||
examples.CallPrecompileResult(
|
||||
"StableSwap GetD",
|
||||
stableswap.Precompile,
|
||||
stableswap.ContractAddress,
|
||||
getDInput,
|
||||
func(out []byte) bool { return len(out) == 32 && examples.IsNonZero(out) },
|
||||
),
|
||||
examples.CallPrecompileResult(
|
||||
"StableSwap GetDy (swap)",
|
||||
stableswap.Precompile,
|
||||
stableswap.ContractAddress,
|
||||
getDyInput,
|
||||
func(out []byte) bool { return len(out) == 32 && examples.IsNonZero(out) },
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
module github.com/luxfi/precompile/examples
|
||||
|
||||
go 1.26.1
|
||||
|
||||
require (
|
||||
github.com/ChainSafe/go-schnorrkel v1.1.0
|
||||
github.com/cloudflare/circl v1.6.3
|
||||
github.com/consensys/gnark-crypto v0.20.1
|
||||
github.com/luxfi/geth v1.16.77
|
||||
github.com/luxfi/precompile v0.4.7
|
||||
github.com/zeebo/blake3 v0.2.4
|
||||
)
|
||||
|
||||
require (
|
||||
filippo.io/edwards25519 v1.2.0 // indirect
|
||||
github.com/ALTree/bigfloat v0.2.0 // indirect
|
||||
github.com/Microsoft/go-winio v0.6.2 // indirect
|
||||
github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20260311194731-d5b7577c683d // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bits-and-blooms/bitset v1.24.4 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/cosmos/go-bip39 v1.0.0 // indirect
|
||||
github.com/crate-crypto/go-eth-kzg v1.5.0 // indirect
|
||||
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect
|
||||
github.com/cronokirby/saferith v0.33.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.1 // indirect
|
||||
github.com/ethereum/c-kzg-4844/v2 v2.1.7 // indirect
|
||||
github.com/ethereum/go-verkle v0.2.2 // indirect
|
||||
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
|
||||
github.com/google/go-cmp v0.7.0 // indirect
|
||||
github.com/gorilla/rpc v1.2.1 // indirect
|
||||
github.com/gtank/merlin v0.1.1 // indirect
|
||||
github.com/gtank/ristretto255 v0.2.0 // indirect
|
||||
github.com/holiman/uint256 v1.3.2 // indirect
|
||||
github.com/klauspost/compress v1.18.4 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||
github.com/luxfi/accel v1.0.7 // indirect
|
||||
github.com/luxfi/atomic v1.0.0 // indirect
|
||||
github.com/luxfi/cache v1.2.1 // indirect
|
||||
github.com/luxfi/codec v1.1.4 // indirect
|
||||
github.com/luxfi/compress v0.0.5 // indirect
|
||||
github.com/luxfi/concurrent v0.0.3 // indirect
|
||||
github.com/luxfi/consensus v1.22.69 // indirect
|
||||
github.com/luxfi/constants v1.4.4 // indirect
|
||||
github.com/luxfi/container v0.0.4 // indirect
|
||||
github.com/luxfi/crypto v1.17.43 // indirect
|
||||
github.com/luxfi/database v1.17.43 // indirect
|
||||
github.com/luxfi/ids v1.2.9 // indirect
|
||||
github.com/luxfi/lattice/v7 v7.0.0 // indirect
|
||||
github.com/luxfi/log v1.4.1 // indirect
|
||||
github.com/luxfi/math v1.2.4 // indirect
|
||||
github.com/luxfi/math/big v0.1.0 // indirect
|
||||
github.com/luxfi/metric v1.5.1 // indirect
|
||||
github.com/luxfi/mock v0.1.1 // indirect
|
||||
github.com/luxfi/p2p v1.19.2 // indirect
|
||||
github.com/luxfi/corona v0.2.0 // indirect
|
||||
github.com/luxfi/runtime v1.0.1 // indirect
|
||||
github.com/luxfi/sampler v1.0.0 // indirect
|
||||
github.com/luxfi/threshold v1.5.5 // indirect
|
||||
github.com/luxfi/utils v1.1.4 // indirect
|
||||
github.com/luxfi/validators v1.0.0 // indirect
|
||||
github.com/luxfi/version v1.0.1 // indirect
|
||||
github.com/luxfi/vm v1.0.40 // indirect
|
||||
github.com/luxfi/warp v1.18.5 // indirect
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b // indirect
|
||||
github.com/montanaflynn/stats v0.8.2 // indirect
|
||||
github.com/mr-tron/base58 v1.2.0 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/prometheus/client_golang v1.23.2 // indirect
|
||||
github.com/prometheus/client_model v0.6.2 // indirect
|
||||
github.com/prometheus/common v0.67.5 // indirect
|
||||
github.com/prometheus/procfs v0.20.1 // indirect
|
||||
github.com/stretchr/testify v1.11.1 // indirect
|
||||
github.com/supranational/blst v0.3.16 // indirect
|
||||
github.com/x448/float16 v0.8.4 // indirect
|
||||
go.uber.org/mock v0.6.0 // indirect
|
||||
go.yaml.in/yaml/v2 v2.4.4 // indirect
|
||||
golang.org/x/crypto v0.49.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20260312153236-7ab1446f8b90 // indirect
|
||||
golang.org/x/sync v0.20.0 // indirect
|
||||
golang.org/x/sys v0.42.0 // indirect
|
||||
gonum.org/v1/gonum v0.17.0 // indirect
|
||||
google.golang.org/protobuf v1.36.11 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
replace github.com/luxfi/precompile => ../
|
||||
+220
@@ -0,0 +1,220 @@
|
||||
filippo.io/edwards25519 v1.2.0 h1:crnVqOiS4jqYleHd9vaKZ+HKtHfllngJIiOpNpoJsjo=
|
||||
filippo.io/edwards25519 v1.2.0/go.mod h1:xzAOLCNug/yB62zG1bQ8uziwrIqIuxhctzJT18Q77mc=
|
||||
github.com/ALTree/bigfloat v0.2.0 h1:AwNzawrpFuw55/YDVlcPw0F0cmmXrmngBHhVrvdXPvM=
|
||||
github.com/ALTree/bigfloat v0.2.0/go.mod h1:+NaH2gLeY6RPBPPQf4aRotPPStg+eXc8f9ZaE4vRfD4=
|
||||
github.com/ChainSafe/go-schnorrkel v1.1.0 h1:rZ6EU+CZFCjB4sHUE1jIu8VDoB/wRKZxoe1tkcO71Wk=
|
||||
github.com/ChainSafe/go-schnorrkel v1.1.0/go.mod h1:ABkENxiP+cvjFiByMIZ9LYbRoNNLeBLiakC1XeTFxfE=
|
||||
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
||||
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
||||
github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20260311194731-d5b7577c683d h1:EA+kZ8mxGb1W/ewiIBMzb/1gg5BiW1Fvr3r4qCUBJEg=
|
||||
github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20260311194731-d5b7577c683d/go.mod h1:ioLG6R+5bUSO1oeGSDxOV3FADARuMoytZCSX6MEMQkI=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bits-and-blooms/bitset v1.24.4 h1:95H15Og1clikBrKr/DuzMXkQzECs1M6hhoGXLwLQOZE=
|
||||
github.com/bits-and-blooms/bitset v1.24.4/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cloudflare/circl v1.6.3 h1:9GPOhQGF9MCYUeXyMYlqTR6a5gTrgR/fBLXvUgtVcg8=
|
||||
github.com/cloudflare/circl v1.6.3/go.mod h1:2eXP6Qfat4O/Yhh8BznvKnJ+uzEoTQ6jVKJRn81BiS4=
|
||||
github.com/consensys/gnark-crypto v0.20.1 h1:PXDUBvk8AzhvWowHLWBEAfUQcV1/aZgWIqD6eMpXmDg=
|
||||
github.com/consensys/gnark-crypto v0.20.1/go.mod h1:RBWrSgy+IDbGR69RRV313th3M/aZU1ubk2om+qHuTSc=
|
||||
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
|
||||
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
|
||||
github.com/crate-crypto/go-eth-kzg v1.5.0 h1:FYRiJMJG2iv+2Dy3fi14SVGjcPteZ5HAAUe4YWlJygc=
|
||||
github.com/crate-crypto/go-eth-kzg v1.5.0/go.mod h1:J9/u5sWfznSObptgfa92Jq8rTswn6ahQWEuiLHOjCUI=
|
||||
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a h1:W8mUrRp6NOVl3J+MYp5kPMoUZPp7aOYHtaua31lwRHg=
|
||||
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a/go.mod h1:sTwzHBvIzm2RfVCGNEBZgRyjwK40bVoun3ZnGOCafNM=
|
||||
github.com/cronokirby/saferith v0.33.0 h1:TgoQlfsD4LIwx71+ChfRcIpjkw+RPOapDEVxa+LhwLo=
|
||||
github.com/cronokirby/saferith v0.33.0/go.mod h1:QKJhjoqUtBsXCAVEjw38mFqoi7DebT7kthcD7UzbnoA=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.1.0 h1:zPMNGQCm0g4QTY27fOCorQW7EryeQ/U0x++OzVrdms8=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.1.0/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.1 h1:5RVFMOWjMyRy8cARdy79nAmgYw3hK/4HUq48LQ6Wwqo=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.1/go.mod h1:ZXNYxsqcloTdSy/rNShjYzMhyjf0LaoftYK0p+A3h40=
|
||||
github.com/emicklei/dot v1.11.0 h1:zsrhCuFHAJge/aZIC4N4LdHy5tqYu4tWEaUzIwdYj4Y=
|
||||
github.com/emicklei/dot v1.11.0/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s=
|
||||
github.com/ethereum/c-kzg-4844/v2 v2.1.7 h1:aat3CuITdDbPC6pmEGRT0zJ5eOxzrZj8TJT5z7Xk//M=
|
||||
github.com/ethereum/c-kzg-4844/v2 v2.1.7/go.mod h1:8HMkUZ5JRv4hpw/XUrYWSQNAUzhHMg2UDb/U+5m+XNw=
|
||||
github.com/ethereum/go-verkle v0.2.2 h1:I2W0WjnrFUIzzVPwm8ykY+7pL2d4VhlsePn4j7cnFk8=
|
||||
github.com/ethereum/go-verkle v0.2.2/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk=
|
||||
github.com/ferranbt/fastssz v1.0.0 h1:9EXXYsracSqQRBQiHeaVsG/KQeYblPf40hsQPb9Dzk8=
|
||||
github.com/ferranbt/fastssz v1.0.0/go.mod h1:Ea3+oeoRGGLGm5shYAeDgu6PGUlcvQhE2fILyD9+tGg=
|
||||
github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM=
|
||||
github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
|
||||
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
|
||||
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
|
||||
github.com/gofrs/flock v0.13.0 h1:95JolYOvGMqeH31+FC7D2+uULf6mG61mEZ/A8dRYMzw=
|
||||
github.com/gofrs/flock v0.13.0/go.mod h1:jxeyy9R1auM5S6JYDBhDt+E2TCo7DkratH4Pgi8P+Z0=
|
||||
github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs=
|
||||
github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
|
||||
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/gorilla/rpc v1.2.1 h1:yC+LMV5esttgpVvNORL/xX4jvTTEUE30UZhZ5JF7K9k=
|
||||
github.com/gorilla/rpc v1.2.1/go.mod h1:uNpOihAlF5xRFLuTYhfR0yfCTm0WTQSQttkMSptRfGk=
|
||||
github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is=
|
||||
github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s=
|
||||
github.com/gtank/ristretto255 v0.2.0 h1:LeOuWr6giplWkkMizx2emfG03SRPJqKt1nfIHLVHQ/0=
|
||||
github.com/gtank/ristretto255 v0.2.0/go.mod h1:OJ1ox/dWcp7sJ5grYDcZ+kkHYuj5nelW5aaL7ESVXBw=
|
||||
github.com/holiman/uint256 v1.3.2 h1:a9EgMPSC1AAaj1SZL5zIQD3WbwTuHrMGOerLjGmM/TA=
|
||||
github.com/holiman/uint256 v1.3.2/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E=
|
||||
github.com/klauspost/compress v1.18.4 h1:RPhnKRAQ4Fh8zU2FY/6ZFDwTVTxgJ/EMydqSTzE9a2c=
|
||||
github.com/klauspost/compress v1.18.4/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
||||
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/leanovate/gopter v0.2.11 h1:vRjThO1EKPb/1NsDXuDrzldR28RLkBflWYcU9CvzWu4=
|
||||
github.com/leanovate/gopter v0.2.11/go.mod h1:aK3tzZP/C+p1m3SPRE4SYZFGP7jjkuSI4f7Xvpt0S9c=
|
||||
github.com/luxfi/accel v1.0.7 h1:ksHieAp50umwqxqgyHk9WiOmXM54kia3IEDb5H7FsM8=
|
||||
github.com/luxfi/accel v1.0.7/go.mod h1:iZD3oxffiMEIT/KvzD8bgwC/cBn4AYlMW3QJpbRa4RE=
|
||||
github.com/luxfi/atomic v1.0.0 h1:xUV60MuzRvXngaQ1sM0yVC2v4TRoLlUGkkH7M9PS4yw=
|
||||
github.com/luxfi/atomic v1.0.0/go.mod h1:0G2mTlQ6TXWHICUHrUUPu1/qAiIyR4gSZ2tva9ci/bI=
|
||||
github.com/luxfi/cache v1.2.1 h1:kAzOS55/hmYeNKR+0HAKv4ma48Y6JjkI8UQeqdZ8bfI=
|
||||
github.com/luxfi/cache v1.2.1/go.mod h1:co7JTxZZHpKT31Yh01LFp5aZOxmoUg157FhBLQdQHVU=
|
||||
github.com/luxfi/codec v1.1.4 h1:Yl8ZalMNkqo7cD6R9AjczAajkLOmsjyZ9+DASVYHrvg=
|
||||
github.com/luxfi/codec v1.1.4/go.mod h1:oGQ3j6E8c2P0pL0irYtWkrB1hmDUFIE0puXHK4gV5KI=
|
||||
github.com/luxfi/compress v0.0.5 h1:4tEUHw5MK1bu5UOjfYCt4OKMiH7yykIgmGPRA/BfJTM=
|
||||
github.com/luxfi/compress v0.0.5/go.mod h1:Cc1yxD2pfzrvpO32W2GDwLKff+CylHEvzZh2Ko8RSIU=
|
||||
github.com/luxfi/concurrent v0.0.3 h1:eJyv1fhaC0jMLMw6+QS774cUmp7GK+ouMgvLCqnC7cc=
|
||||
github.com/luxfi/concurrent v0.0.3/go.mod h1:Aj/FR5NpM0cB2P4Nt3+tz9+dV6V+LUW4HuMgSjwq5hw=
|
||||
github.com/luxfi/consensus v1.22.69 h1:f9udx1mOj5lB4HiDju+Z+hoCkl+FoHJw/fjLVc8ePuw=
|
||||
github.com/luxfi/consensus v1.22.69/go.mod h1:cYnIxzIuRR+gpNXMyI07HlgYBwwhgO1PCP6/XinU+2E=
|
||||
github.com/luxfi/constants v1.4.4 h1:R5MaZkQs70eHceZx+2LS9G2gmG7OcLF98BSkJol3OJE=
|
||||
github.com/luxfi/constants v1.4.4/go.mod h1:ENkJ121cmDEkwQPDiKK4QhnTnW9u37PGpepbrdVcAmc=
|
||||
github.com/luxfi/container v0.0.4 h1:BXhF82WyfqVP5mjlNcr7tP0Fcnvl0Ap1rkiu+rq5XuM=
|
||||
github.com/luxfi/container v0.0.4/go.mod h1:Z3SpmMF5d4t77MM0nHYXURpn+EMVaeu1fhbd/3BGaek=
|
||||
github.com/luxfi/crypto v1.17.43 h1:dDSJ7DNHB49V25WWofjtuQCPPowCuogO2ZPW+IgfvdQ=
|
||||
github.com/luxfi/crypto v1.17.43/go.mod h1:1M6uQ8I/7dzQwf5RdnKtqOWr0+iXRW0D9WfnMV+Cb1s=
|
||||
github.com/luxfi/database v1.17.43 h1:AuW2IDc/nofuqfdspqCn0P6FsP6uBcx8RMgJr2bDRU8=
|
||||
github.com/luxfi/database v1.17.43/go.mod h1:87bOpi6u0WAiHzBxPyxS/+pN1LJGqOY7QkyEZcI+7Kk=
|
||||
github.com/luxfi/geth v1.16.77 h1:bFbSV6C0KCqU6bFtq+I8hJw9bWAj2hCZXyx0fJPIUfo=
|
||||
github.com/luxfi/geth v1.16.77/go.mod h1:al8oFHXxsVly+Y3fcRHIhNhBSgAFNRR5Ey6YKemEDUs=
|
||||
github.com/luxfi/ids v1.2.9 h1:+yjdhXW99drnd2Zlp1u/p8k3G23W3/1btJQ4ogHawUI=
|
||||
github.com/luxfi/ids v1.2.9/go.mod h1:khJOEdOPxd22yn0jcVrnbX1ADa0GHn5Y74gvCzN5BYc=
|
||||
github.com/luxfi/lattice/v7 v7.0.0 h1:d1vgan6mlb2KtwYfPc1g69uxVYaoVYZmlrIm4aCO88w=
|
||||
github.com/luxfi/lattice/v7 v7.0.0/go.mod h1:PFDdOkuGTQ0cbJMbKojzEJMGWUQmZW+wK9/wJ9F9fOs=
|
||||
github.com/luxfi/log v1.4.1 h1:rIfFRodb9jrD/w7KayaUk0Oc+37PaQQdKEEMJCjR8gw=
|
||||
github.com/luxfi/log v1.4.1/go.mod h1:64IE3xRMJcpkQwnPUfJw3pDj7wU0kRS7BZ9wM7R72jk=
|
||||
github.com/luxfi/math v1.2.4 h1:iVz7s0gToCNUU/2cLT8gUa8MLzc0YRp4jBmeXBeKdXk=
|
||||
github.com/luxfi/math v1.2.4/go.mod h1:i+Am9YvFsqDE75ZW8MPE62XCXGukXNiN/7mD9SKxxZY=
|
||||
github.com/luxfi/math/big v0.1.0 h1:Vz4c0RsZVPdIKPsHPgAJChH/R3p15WHRUz7LkLf+NIQ=
|
||||
github.com/luxfi/math/big v0.1.0/go.mod h1:BuxSu22RbO93xBLk5Eam5nldFponoJ73xDFz4uJ3Huk=
|
||||
github.com/luxfi/metric v1.5.1 h1:6tVarXMnNR3Xzud8FYUHjtXabTll3HI/OEqG0tgLAcI=
|
||||
github.com/luxfi/metric v1.5.1/go.mod h1:PkD4D4JoGuyKtfUkqPNYkrg9xKrJeNVZFdW/5XvAe/A=
|
||||
github.com/luxfi/mock v0.1.1 h1:0HEtIjg1J6CWz+IUyP6rsGqNWTcmxjFnSQIhaDuARwY=
|
||||
github.com/luxfi/mock v0.1.1/go.mod h1:jo35akl3Vtd8LbzDts8VJ0jmSVycrd1/eBi6g6t5hKU=
|
||||
github.com/luxfi/p2p v1.19.2 h1:uqZq7ofmEDbXlTkv1QThtci01Q+dmDkNmAPeORIyP8E=
|
||||
github.com/luxfi/p2p v1.19.2/go.mod h1:tI9Bt1R0ouvVtJvXG4e20GlGeV4AR230k4mFF9Vglzk=
|
||||
github.com/luxfi/corona v0.2.0 h1:DbLMZmE//2T2wXXS/gEkKZrTbre9LD+7EE/tz5SQszU=
|
||||
github.com/luxfi/corona v0.2.0/go.mod h1:SZ+aDLUdfSAtaTRaaYzeDZ5DNQiLaOCelSaIGjL21R0=
|
||||
github.com/luxfi/runtime v1.0.1 h1:cii3OsRiVSIl9jzfWFM6++62T1r6ZSGP+/3F0Ezhpqw=
|
||||
github.com/luxfi/runtime v1.0.1/go.mod h1:2hBKjzbEeE4dzrhUKH8dqkRgLEyiXz6GmuVusy3vJMs=
|
||||
github.com/luxfi/sampler v1.0.0 h1:k8Sf6otW83w4pQp0jXLA+g3J/joB7w7SqXQsWmNTOV0=
|
||||
github.com/luxfi/sampler v1.0.0/go.mod h1:f96/ozlj9vFfZj+akLtrHn4VpulQahwB+MQQhpeIekk=
|
||||
github.com/luxfi/threshold v1.5.5 h1:MgPMrHf7dryztiaOYaG+Z+Cqqfa79oyblp5EowDFJw4=
|
||||
github.com/luxfi/threshold v1.5.5/go.mod h1:JEnYrKvCRDwGUeuCsMJSO2FeokuZGVaOml1XD/L1Vgs=
|
||||
github.com/luxfi/utils v1.1.4 h1:8OY0jXCkpp6OotN1Y++6DATJkvtEwzq2k0p56imJlAk=
|
||||
github.com/luxfi/utils v1.1.4/go.mod h1:c3yz1RjzrB+cs5GZm+q1T3/2cCKElO9vxm9yRRtgSEM=
|
||||
github.com/luxfi/validators v1.0.0 h1:zE1HJM1lfvC+v1Lalg+MUgkKBGFWnwTfOOmXraiNnpE=
|
||||
github.com/luxfi/validators v1.0.0/go.mod h1:QGppjtI/gqprbplWc10J+4OIK8UYWpv+53mfH2aKhy4=
|
||||
github.com/luxfi/version v1.0.1 h1:T/1KYWEMmsrNQk7pN7PFPAwh/7XbeX7cFAKLBqI37Sk=
|
||||
github.com/luxfi/version v1.0.1/go.mod h1:Y5fPkQ2DB0XRBCxgSPXp4ISzL1/jptKnmFknShRJCyg=
|
||||
github.com/luxfi/vm v1.0.40 h1:kA0V/9p1VdC88EjgbljWb8t+fl9qz5bCyF3IxnV20yg=
|
||||
github.com/luxfi/vm v1.0.40/go.mod h1:Y5WUKhT76PR6HnbUykHBWI2f5sjssrm5BL6/o7b6IfQ=
|
||||
github.com/luxfi/warp v1.18.5 h1:yXFCT+lnvzJHs8nVvfUCQ9wNvhtgbDGaXJkJeiwgKf4=
|
||||
github.com/luxfi/warp v1.18.5/go.mod h1:SFyC529HDvbP/TWRAdYQSyJUliMa5JKFRtBrTLEElp4=
|
||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM=
|
||||
github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b h1:QrHweqAtyJ9EwCaGHBu1fghwxIPiopAHV06JlXrMHjk=
|
||||
github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b/go.mod h1:xxLb2ip6sSUts3g1irPVHyk/DGslwQsNOo9I7smJfNU=
|
||||
github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM=
|
||||
github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8=
|
||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/montanaflynn/stats v0.8.2 h1:52wnefTJnPI5FoHif1DQh2soKRw0yYs+4AVyvtcZCH0=
|
||||
github.com/montanaflynn/stats v0.8.2/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
|
||||
github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
|
||||
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o=
|
||||
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
|
||||
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
|
||||
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
|
||||
github.com/prometheus/common v0.67.5 h1:pIgK94WWlQt1WLwAC5j2ynLaBRDiinoAb86HZHTUGI4=
|
||||
github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw=
|
||||
github.com/prometheus/procfs v0.20.1 h1:XwbrGOIplXW/AU3YhIhLODXMJYyC1isLFfYCsTEycfc=
|
||||
github.com/prometheus/procfs v0.20.1/go.mod h1:o9EMBZGRyvDrSPH1RqdxhojkuXstoe4UlK79eF5TGGo=
|
||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
|
||||
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/supranational/blst v0.3.16 h1:bTDadT+3fK497EvLdWRQEjiGnUtzJ7jjIUMF0jqwYhE=
|
||||
github.com/supranational/blst v0.3.16/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
|
||||
github.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA=
|
||||
github.com/tklauser/go-sysconf v0.3.16/go.mod h1:/qNL9xxDhc7tx3HSRsLWNnuzbVfh3e7gh/BmM179nYI=
|
||||
github.com/tklauser/numcpus v0.11.0 h1:nSTwhKH5e1dMNsCdVBukSZrURJRoHbSEQjdEbY+9RXw=
|
||||
github.com/tklauser/numcpus v0.11.0/go.mod h1:z+LwcLq54uWZTX0u/bGobaV34u6V7KNlTZejzM6/3MQ=
|
||||
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
|
||||
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
|
||||
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
|
||||
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||
github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
|
||||
github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
|
||||
github.com/zeebo/blake3 v0.2.4 h1:KYQPkhpRtcqh0ssGYcKLG1JYvddkEA8QwCM/yBqhaZI=
|
||||
github.com/zeebo/blake3 v0.2.4/go.mod h1:7eeQ6d2iXWRGF6npfaxl2CU+xy2Fjo2gxeyZGCRUjcE=
|
||||
github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo=
|
||||
github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
|
||||
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
||||
go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ=
|
||||
go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.49.0 h1:+Ng2ULVvLHnJ/ZFEq4KdcDd/cfjrrjjNSXNzxg0Y4U4=
|
||||
golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA=
|
||||
golang.org/x/exp v0.0.0-20260312153236-7ab1446f8b90 h1:jiDhWWeC7jfWqR9c/uplMOqJ0sbNlNWv0UkzE0vX1MA=
|
||||
golang.org/x/exp v0.0.0-20260312153236-7ab1446f8b90/go.mod h1:xE1HEv6b+1SCZ5/uscMRjUBKtIxworgEcEi+/n9NQDQ=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
|
||||
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
|
||||
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
|
||||
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
|
||||
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
||||
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
@@ -0,0 +1,61 @@
|
||||
package hashing_zk
|
||||
|
||||
import (
|
||||
"github.com/consensys/gnark-crypto/ecc/bn254/twistededwards"
|
||||
"github.com/luxfi/precompile/babyjubjub"
|
||||
"github.com/luxfi/precompile/examples"
|
||||
)
|
||||
|
||||
// BabyJubJubDemo exercises the Baby Jubjub curve precompile (0x0500..07).
|
||||
func BabyJubJubDemo() []examples.Result {
|
||||
// Get the curve generator
|
||||
curve := twistededwards.GetEdwardsCurve()
|
||||
|
||||
// Encode generator as 64 bytes: x(32) + y(32)
|
||||
genPoint := make([]byte, 64)
|
||||
xBytes := curve.Base.X.Bytes()
|
||||
yBytes := curve.Base.Y.Bytes()
|
||||
copy(genPoint[0:32], xBytes[:])
|
||||
copy(genPoint[32:64], yBytes[:])
|
||||
|
||||
// OpPointAdd: G + G = 2G
|
||||
addInput := make([]byte, 0, 1+128)
|
||||
addInput = append(addInput, babyjubjub.OpPointAdd)
|
||||
addInput = append(addInput, genPoint...)
|
||||
addInput = append(addInput, genPoint...)
|
||||
|
||||
// OpScalarMul: G * 2
|
||||
mulInput := make([]byte, 0, 1+64+32)
|
||||
mulInput = append(mulInput, babyjubjub.OpScalarMul)
|
||||
mulInput = append(mulInput, genPoint...)
|
||||
mulInput = append(mulInput, examples.PadLeft([]byte{2}, 32)...)
|
||||
|
||||
// OpInCurve: check generator is on curve
|
||||
curveInput := make([]byte, 0, 1+64)
|
||||
curveInput = append(curveInput, babyjubjub.OpInCurve)
|
||||
curveInput = append(curveInput, genPoint...)
|
||||
|
||||
return []examples.Result{
|
||||
examples.CallPrecompileResult(
|
||||
"BabyJubJub PointAdd",
|
||||
babyjubjub.BabyJubJubPrecompile,
|
||||
babyjubjub.ContractAddress,
|
||||
addInput,
|
||||
func(out []byte) bool { return len(out) == 64 && examples.IsNonZero(out) },
|
||||
),
|
||||
examples.CallPrecompileResult(
|
||||
"BabyJubJub ScalarMul",
|
||||
babyjubjub.BabyJubJubPrecompile,
|
||||
babyjubjub.ContractAddress,
|
||||
mulInput,
|
||||
func(out []byte) bool { return len(out) == 64 && examples.IsNonZero(out) },
|
||||
),
|
||||
examples.CallPrecompileResult(
|
||||
"BabyJubJub InCurve",
|
||||
babyjubjub.BabyJubJubPrecompile,
|
||||
babyjubjub.ContractAddress,
|
||||
curveInput,
|
||||
func(out []byte) bool { return examples.LastByte32IsOne(out) },
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package hashing_zk
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
zblake3 "github.com/zeebo/blake3"
|
||||
|
||||
"github.com/luxfi/precompile/blake3"
|
||||
"github.com/luxfi/precompile/examples"
|
||||
)
|
||||
|
||||
// Blake3Demo exercises the Blake3 hash precompile (0x0500..04).
|
||||
func Blake3Demo() []examples.Result {
|
||||
msg := []byte("Lux precompile Blake3 demo")
|
||||
|
||||
// OpHash256: op(1) + data
|
||||
input256 := make([]byte, 0, 1+len(msg))
|
||||
input256 = append(input256, blake3.OpHash256)
|
||||
input256 = append(input256, msg...)
|
||||
|
||||
// Compute reference hash
|
||||
h := zblake3.New()
|
||||
h.Write(msg)
|
||||
ref := make([]byte, 32)
|
||||
h.Digest().Read(ref)
|
||||
|
||||
return []examples.Result{
|
||||
examples.CallPrecompileResult(
|
||||
"Blake3 Hash256",
|
||||
blake3.Blake3Precompile,
|
||||
blake3.ContractAddress,
|
||||
input256,
|
||||
func(out []byte) bool { return bytes.Equal(out, ref) },
|
||||
),
|
||||
func() examples.Result {
|
||||
// OpHash512
|
||||
input := append([]byte{blake3.OpHash512}, msg...)
|
||||
return examples.CallPrecompileResult(
|
||||
"Blake3 Hash512",
|
||||
blake3.Blake3Precompile,
|
||||
blake3.ContractAddress,
|
||||
input,
|
||||
func(out []byte) bool { return len(out) == 64 && examples.IsNonZero(out) },
|
||||
)
|
||||
}(),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// Package hashing_zk demonstrates Blake3, Poseidon, Pedersen, BabyJubJub, and Pasta precompiles.
|
||||
package hashing_zk
|
||||
|
||||
import "github.com/luxfi/precompile/examples"
|
||||
|
||||
type AllHashingZKDemos struct{}
|
||||
|
||||
func (d AllHashingZKDemos) Name() string { return "hashing_zk" }
|
||||
|
||||
func (d AllHashingZKDemos) Run() []examples.Result {
|
||||
var all []examples.Result
|
||||
all = append(all, Blake3Demo()...)
|
||||
all = append(all, PoseidonDemo()...)
|
||||
all = append(all, PedersenDemo()...)
|
||||
all = append(all, BabyJubJubDemo()...)
|
||||
all = append(all, PastaDemo()...)
|
||||
return all
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package hashing_zk
|
||||
|
||||
import (
|
||||
"github.com/luxfi/precompile/examples"
|
||||
"github.com/luxfi/precompile/pasta"
|
||||
)
|
||||
|
||||
// PastaDemo exercises the Pasta curves precompile (0x0500..08).
|
||||
// Pasta = Pallas + Vesta curves, used in Halo2 proofs.
|
||||
func PastaDemo() []examples.Result {
|
||||
// OpPallasAdd (0x01): add two Pallas points
|
||||
// Pallas generator: x,y each 32 bytes
|
||||
// Use identity points (zeros) for a simple test that exercises the dispatch path
|
||||
// Actually use the Pallas generator from gnark-crypto
|
||||
genX := examples.PadLeft([]byte{1}, 32) // x = 1 is not on Pallas, so use a known test vector
|
||||
genY := examples.PadLeft([]byte{2}, 32)
|
||||
|
||||
// For a clean test, use the basepoint multiplication path
|
||||
// OpPallasBaseMul (0x03): scalar(32) -> point(64)
|
||||
scalarInput := make([]byte, 0, 1+32)
|
||||
scalarInput = append(scalarInput, 0x03) // OpPallasBaseMul
|
||||
scalarInput = append(scalarInput, examples.PadLeft([]byte{7}, 32)...)
|
||||
|
||||
_ = genX
|
||||
_ = genY
|
||||
|
||||
return []examples.Result{
|
||||
examples.CallPrecompileResult(
|
||||
"Pasta Pallas BaseMul",
|
||||
pasta.PastaPrecompile,
|
||||
pasta.ContractAddress,
|
||||
scalarInput,
|
||||
func(out []byte) bool { return len(out) == 64 && examples.IsNonZero(out) },
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package hashing_zk
|
||||
|
||||
import (
|
||||
"github.com/luxfi/precompile/examples"
|
||||
"github.com/luxfi/precompile/pedersen"
|
||||
)
|
||||
|
||||
// PedersenDemo exercises the Pedersen commitment precompile (0x0500..06).
|
||||
func PedersenDemo() []examples.Result {
|
||||
// OpCommit: value(32) + blinding(32) -> commitment(32)
|
||||
value := examples.PadLeft([]byte{42}, 32)
|
||||
blinding := examples.PadLeft([]byte{7}, 32)
|
||||
|
||||
commitInput := make([]byte, 0, 1+64)
|
||||
commitInput = append(commitInput, pedersen.OpCommit)
|
||||
commitInput = append(commitInput, value...)
|
||||
commitInput = append(commitInput, blinding...)
|
||||
|
||||
return []examples.Result{
|
||||
examples.CallPrecompileResult(
|
||||
"Pedersen Commit",
|
||||
pedersen.PedersenPrecompile,
|
||||
pedersen.ContractAddress,
|
||||
commitInput,
|
||||
func(out []byte) bool { return len(out) == 32 && examples.IsNonZero(out) },
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package hashing_zk
|
||||
|
||||
import (
|
||||
"github.com/luxfi/precompile/examples"
|
||||
"github.com/luxfi/precompile/poseidon"
|
||||
)
|
||||
|
||||
// PoseidonDemo exercises the Poseidon2 ZK-friendly hash precompile (0x0500..05).
|
||||
func PoseidonDemo() []examples.Result {
|
||||
// OpHash: hash 2 field elements (each 32 bytes, BN254 scalar field)
|
||||
elem1 := examples.PadLeft([]byte{1}, 32)
|
||||
elem2 := examples.PadLeft([]byte{2}, 32)
|
||||
|
||||
input := make([]byte, 0, 1+64)
|
||||
input = append(input, poseidon.OpHash)
|
||||
input = append(input, elem1...)
|
||||
input = append(input, elem2...)
|
||||
|
||||
// OpHashPair: optimized 2-element hash
|
||||
pairInput := make([]byte, 0, 1+64)
|
||||
pairInput = append(pairInput, poseidon.OpHashPair)
|
||||
pairInput = append(pairInput, elem1...)
|
||||
pairInput = append(pairInput, elem2...)
|
||||
|
||||
return []examples.Result{
|
||||
examples.CallPrecompileResult(
|
||||
"Poseidon2 Hash (2 elements)",
|
||||
poseidon.PoseidonPrecompile,
|
||||
poseidon.ContractAddress,
|
||||
input,
|
||||
func(out []byte) bool { return len(out) == 32 && examples.IsNonZero(out) },
|
||||
),
|
||||
examples.CallPrecompileResult(
|
||||
"Poseidon2 HashPair",
|
||||
poseidon.PoseidonPrecompile,
|
||||
poseidon.ContractAddress,
|
||||
pairInput,
|
||||
func(out []byte) bool { return len(out) == 32 && examples.IsNonZero(out) },
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package pq
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
|
||||
"github.com/luxfi/precompile/examples"
|
||||
rt "github.com/luxfi/precompile/corona"
|
||||
)
|
||||
|
||||
// CoronaDemo exercises the Corona lattice threshold precompile (0x0200..0B).
|
||||
// Corona requires a full threshold signing ceremony which is heavy to set up
|
||||
// in a demo context. We test the input parsing and gas calculation path.
|
||||
func CoronaDemo() []examples.Result {
|
||||
// Build minimal input: threshold(4) + totalParties(4) + messageHash(32) + signature
|
||||
// With threshold=2, totalParties=3
|
||||
hash := sha256.Sum256([]byte("Lux precompile Corona demo"))
|
||||
|
||||
input := make([]byte, 0, 4+4+32)
|
||||
input = append(input, examples.Uint32BE(2)...) // threshold
|
||||
input = append(input, examples.Uint32BE(3)...) // total parties
|
||||
input = append(input, hash[:]...) // message hash
|
||||
|
||||
// This will fail with "invalid input length" since we don't have a real
|
||||
// Corona signature, but it exercises the precompile dispatch and gas calc
|
||||
r := examples.CallPrecompileResult(
|
||||
"Corona Threshold (parse test)",
|
||||
rt.CoronaThresholdPrecompile,
|
||||
rt.ContractCoronaThresholdAddress,
|
||||
input,
|
||||
func(out []byte) bool {
|
||||
// Expected to fail validation but not panic
|
||||
return true
|
||||
},
|
||||
)
|
||||
// This is a parse/gas test -- it will error but that is expected
|
||||
r.Pass = r.Error != nil // we EXPECT an error (short input)
|
||||
r.Error = nil // clear the expected error for display
|
||||
|
||||
return []examples.Result{r}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package pq
|
||||
|
||||
import (
|
||||
"github.com/cloudflare/circl/sign/mldsa/mldsa65"
|
||||
"github.com/luxfi/precompile/examples"
|
||||
"github.com/luxfi/precompile/mldsa"
|
||||
)
|
||||
|
||||
// MLDSADemo exercises the ML-DSA verify precompile (0x0200..06).
|
||||
func MLDSADemo() []examples.Result {
|
||||
// Generate ML-DSA-65 key pair
|
||||
pub, priv, _ := mldsa65.GenerateKey(nil)
|
||||
|
||||
msg := []byte("Lux precompile ML-DSA-65 demo")
|
||||
sig := mldsa65.Sign(priv, msg, nil)
|
||||
|
||||
pubBytes, _ := pub.MarshalBinary()
|
||||
sigBytes := sig
|
||||
|
||||
// Input format: mode(1) + pubkey + msglen(32) + sig + msg
|
||||
input := make([]byte, 0, 1+len(pubBytes)+32+len(sigBytes)+len(msg))
|
||||
input = append(input, mldsa.ModeMLDSA65) // mode byte
|
||||
input = append(input, pubBytes...) // public key
|
||||
input = append(input, examples.Uint256(uint64(len(msg)))...)
|
||||
input = append(input, sigBytes...)
|
||||
input = append(input, msg...)
|
||||
|
||||
return []examples.Result{
|
||||
examples.CallPrecompileResult(
|
||||
"ML-DSA-65 Verify",
|
||||
mldsa.MLDSAVerifyPrecompile,
|
||||
mldsa.ContractMLDSAVerifyAddress,
|
||||
input,
|
||||
func(out []byte) bool { return examples.LastByte32IsOne(out) },
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package pq
|
||||
|
||||
import (
|
||||
circl768 "github.com/cloudflare/circl/kem/mlkem/mlkem768"
|
||||
"github.com/luxfi/precompile/examples"
|
||||
"github.com/luxfi/precompile/mlkem"
|
||||
)
|
||||
|
||||
// MLKEMDemo exercises the ML-KEM encapsulate precompile (0x0200..07).
|
||||
func MLKEMDemo() []examples.Result {
|
||||
// Generate ML-KEM-768 key pair
|
||||
_, pub, _ := circl768.GenerateKeyPair(nil)
|
||||
pubBytes, _ := pub.MarshalBinary()
|
||||
|
||||
// Input: op(1) + mode(1) + pubkey
|
||||
input := make([]byte, 0, 2+len(pubBytes))
|
||||
input = append(input, mlkem.OpEncapsulate)
|
||||
input = append(input, mlkem.ModeMLKEM768)
|
||||
input = append(input, pubBytes...)
|
||||
|
||||
return []examples.Result{
|
||||
examples.CallPrecompileResult(
|
||||
"ML-KEM-768 Encapsulate",
|
||||
mlkem.MLKEMPrecompile,
|
||||
mlkem.ContractAddress,
|
||||
input,
|
||||
func(out []byte) bool {
|
||||
// Output: ciphertext(1088) + shared_secret(32) = 1120 bytes
|
||||
return len(out) == 1088+32 && examples.IsNonZero(out)
|
||||
},
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// Package pq demonstrates post-quantum precompiles: ML-DSA, ML-KEM, SLH-DSA, Corona, X-Wing.
|
||||
package pq
|
||||
|
||||
import "github.com/luxfi/precompile/examples"
|
||||
|
||||
type AllPQDemos struct{}
|
||||
|
||||
func (d AllPQDemos) Name() string { return "pq" }
|
||||
|
||||
func (d AllPQDemos) Run() []examples.Result {
|
||||
var all []examples.Result
|
||||
all = append(all, MLDSADemo()...)
|
||||
all = append(all, MLKEMDemo()...)
|
||||
all = append(all, SLHDSADemo()...)
|
||||
all = append(all, CoronaDemo()...)
|
||||
all = append(all, XWingDemo()...)
|
||||
return all
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package pq
|
||||
|
||||
import (
|
||||
"github.com/cloudflare/circl/sign/slhdsa"
|
||||
"github.com/luxfi/precompile/examples"
|
||||
slh "github.com/luxfi/precompile/slhdsa"
|
||||
)
|
||||
|
||||
// SLHDSADemo exercises the SLH-DSA verify precompile (0x0600..01).
|
||||
func SLHDSADemo() []examples.Result {
|
||||
// Generate SLH-DSA-SHA2-128s key pair (smallest, fastest for demo)
|
||||
pub, priv, _ := slhdsa.GenerateKey(nil, slhdsa.ParamIDSHA2Small128)
|
||||
|
||||
msg := []byte("Lux precompile SLH-DSA demo")
|
||||
sig := slhdsa.Sign(priv, msg, nil, false)
|
||||
|
||||
pubBytes, _ := pub.MarshalBinary()
|
||||
|
||||
// Input format: mode(1) + pubkeylen(2) + pubkey + msglen(2) + msg + sig
|
||||
input := make([]byte, 0, 1+2+len(pubBytes)+2+len(msg)+len(sig))
|
||||
input = append(input, slh.ModeSHA2_128s)
|
||||
input = append(input, examples.Uint16BE(uint16(len(pubBytes)))...)
|
||||
input = append(input, pubBytes...)
|
||||
input = append(input, examples.Uint16BE(uint16(len(msg)))...)
|
||||
input = append(input, msg...)
|
||||
input = append(input, sig...)
|
||||
|
||||
return []examples.Result{
|
||||
examples.CallPrecompileResult(
|
||||
"SLH-DSA-SHA2-128s Verify",
|
||||
slh.SLHDSAVerifyPrecompile,
|
||||
slh.ContractSLHDSAVerifyAddress,
|
||||
input,
|
||||
func(out []byte) bool { return examples.LastByte32IsOne(out) },
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package pq
|
||||
|
||||
import (
|
||||
"github.com/cloudflare/circl/kem/xwing"
|
||||
"github.com/luxfi/precompile/examples"
|
||||
xw "github.com/luxfi/precompile/xwing"
|
||||
)
|
||||
|
||||
// XWingDemo exercises the X-Wing hybrid KEM precompile (0x2221).
|
||||
func XWingDemo() []examples.Result {
|
||||
// Generate X-Wing key pair (X25519 + ML-KEM-768)
|
||||
pub, _, _ := xwing.Scheme().GenerateKeyPair()
|
||||
pubBytes, _ := pub.MarshalBinary()
|
||||
|
||||
// Input: op(1) + pubkey
|
||||
input := make([]byte, 0, 1+len(pubBytes))
|
||||
input = append(input, xw.OpEncapsulate)
|
||||
input = append(input, pubBytes...)
|
||||
|
||||
return []examples.Result{
|
||||
examples.CallPrecompileResult(
|
||||
"X-Wing Encapsulate",
|
||||
xw.XWingPrecompile,
|
||||
xw.ContractAddress,
|
||||
input,
|
||||
func(out []byte) bool {
|
||||
// X-Wing ct + shared secret -- non-empty output means success
|
||||
return len(out) > 32 && examples.IsNonZero(out)
|
||||
},
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
// Package examples provides demo programs for all 33 Lux EVM precompiles.
|
||||
//
|
||||
// This is a separate Go module to avoid polluting the main precompile module
|
||||
// with demo-only dependencies. Each subdirectory exercises one precompile
|
||||
// family and can be run standalone or via the cmd/demo orchestrator.
|
||||
package examples
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"strings"
|
||||
|
||||
"github.com/luxfi/geth/common"
|
||||
)
|
||||
|
||||
// Result captures a single precompile demo execution.
|
||||
type Result struct {
|
||||
Name string // Human name (e.g. "BLS12-381 G1Add")
|
||||
Address common.Address
|
||||
Calldata []byte
|
||||
Output []byte
|
||||
GasUsed uint64
|
||||
Pass bool
|
||||
Error error
|
||||
}
|
||||
|
||||
// Print renders a Result to stdout.
|
||||
func (r *Result) Print() {
|
||||
status := "PASS"
|
||||
if !r.Pass {
|
||||
status = "FAIL"
|
||||
}
|
||||
addrShort := strings.TrimLeft(r.Address.Hex(), "0x0")
|
||||
if addrShort == "" {
|
||||
addrShort = "0"
|
||||
}
|
||||
fmt.Printf(" [%s] %-35s addr=0x%s gas=%d\n", status, r.Name, addrShort, r.GasUsed)
|
||||
if r.Error != nil {
|
||||
fmt.Printf(" error: %v\n", r.Error)
|
||||
}
|
||||
}
|
||||
|
||||
// Demo is the interface each precompile demo implements.
|
||||
type Demo interface {
|
||||
// Name returns the category (e.g. "curves", "pq").
|
||||
Name() string
|
||||
// Run executes all demos in this category and returns results.
|
||||
Run() []Result
|
||||
}
|
||||
|
||||
// HexDecode is a helper that panics on invalid hex (test vectors only).
|
||||
func HexDecode(s string) []byte {
|
||||
s = strings.TrimPrefix(s, "0x")
|
||||
b, err := hex.DecodeString(s)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("bad hex: %s: %v", s, err))
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// PadLeft pads b to n bytes on the left with zeros.
|
||||
func PadLeft(b []byte, n int) []byte {
|
||||
if len(b) >= n {
|
||||
return b[:n]
|
||||
}
|
||||
out := make([]byte, n)
|
||||
copy(out[n-len(b):], b)
|
||||
return out
|
||||
}
|
||||
|
||||
// Uint256 encodes a uint64 as a 32-byte big-endian uint256.
|
||||
func Uint256(v uint64) []byte {
|
||||
return PadLeft(new(big.Int).SetUint64(v).Bytes(), 32)
|
||||
}
|
||||
|
||||
// Uint32BE encodes a uint32 as 4 bytes big-endian.
|
||||
func Uint32BE(v uint32) []byte {
|
||||
b := make([]byte, 4)
|
||||
b[0] = byte(v >> 24)
|
||||
b[1] = byte(v >> 16)
|
||||
b[2] = byte(v >> 8)
|
||||
b[3] = byte(v)
|
||||
return b
|
||||
}
|
||||
|
||||
// Uint16BE encodes a uint16 as 2 bytes big-endian.
|
||||
func Uint16BE(v uint16) []byte {
|
||||
return []byte{byte(v >> 8), byte(v)}
|
||||
}
|
||||
|
||||
// IsNonZero returns true if any byte in b is non-zero.
|
||||
func IsNonZero(b []byte) bool {
|
||||
for _, v := range b {
|
||||
if v != 0 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// LastByte32IsOne checks if the last byte of a 32-byte result is 1 (common success pattern).
|
||||
func LastByte32IsOne(b []byte) bool {
|
||||
if len(b) != 32 {
|
||||
return false
|
||||
}
|
||||
for i := 0; i < 31; i++ {
|
||||
if b[i] != 0 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return b[31] == 1
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
// Package privacy demonstrates HPKE, Ring, X25519, and Curve25519 precompiles.
|
||||
package privacy
|
||||
|
||||
import (
|
||||
"github.com/luxfi/precompile/curve25519"
|
||||
"github.com/luxfi/precompile/examples"
|
||||
"github.com/luxfi/precompile/x25519"
|
||||
)
|
||||
|
||||
type AllPrivacyDemos struct{}
|
||||
|
||||
func (d AllPrivacyDemos) Name() string { return "privacy" }
|
||||
|
||||
func (d AllPrivacyDemos) Run() []examples.Result {
|
||||
var all []examples.Result
|
||||
all = append(all, X25519Demo()...)
|
||||
all = append(all, Curve25519Demo()...)
|
||||
return all
|
||||
}
|
||||
|
||||
// X25519Demo exercises the X25519 Diffie-Hellman precompile (0x9203).
|
||||
func X25519Demo() []examples.Result {
|
||||
// OpBasepoint (0x02): scalar(32) -> public key(32)
|
||||
scalar := make([]byte, 32)
|
||||
scalar[0] = 7 // use scalar = 7
|
||||
|
||||
bpInput := make([]byte, 0, 1+32)
|
||||
bpInput = append(bpInput, x25519.OpBasepoint)
|
||||
bpInput = append(bpInput, scalar...)
|
||||
|
||||
return []examples.Result{
|
||||
examples.CallPrecompileResult(
|
||||
"X25519 Basepoint Mul",
|
||||
x25519.X25519Precompile,
|
||||
x25519.ContractAddress,
|
||||
bpInput,
|
||||
func(out []byte) bool { return len(out) == 32 && examples.IsNonZero(out) },
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// Curve25519Demo exercises the Edwards25519 point ops precompile (0x9204).
|
||||
func Curve25519Demo() []examples.Result {
|
||||
// OpBasepointMul (0x03): scalar(32) -> compressed point(32)
|
||||
scalar := make([]byte, 32)
|
||||
scalar[0] = 5
|
||||
|
||||
bpInput := make([]byte, 0, 1+32)
|
||||
bpInput = append(bpInput, curve25519.OpBasepointMul)
|
||||
bpInput = append(bpInput, scalar...)
|
||||
|
||||
return []examples.Result{
|
||||
examples.CallPrecompileResult(
|
||||
"Edwards25519 BasepointMul",
|
||||
curve25519.Curve25519Precompile,
|
||||
curve25519.ContractAddress,
|
||||
bpInput,
|
||||
func(out []byte) bool { return len(out) == 32 && examples.IsNonZero(out) },
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// Package quasar demonstrates Quasar consensus verification precompiles.
|
||||
package quasar
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
|
||||
"github.com/luxfi/geth/common"
|
||||
"github.com/luxfi/precompile/examples"
|
||||
q "github.com/luxfi/precompile/quasar"
|
||||
)
|
||||
|
||||
type QuasarDemo struct{}
|
||||
|
||||
func (d QuasarDemo) Name() string { return "quasar" }
|
||||
|
||||
func (d QuasarDemo) Run() []examples.Result {
|
||||
// VerkleVerify: commitment(32) + proof(32) + threshold_met(1)
|
||||
commitment := sha256.Sum256([]byte("Lux Quasar Verkle commitment"))
|
||||
proof := sha256.Sum256([]byte("Lux Quasar Verkle proof"))
|
||||
|
||||
verkleInput := make([]byte, 0, 65)
|
||||
verkleInput = append(verkleInput, commitment[:]...)
|
||||
verkleInput = append(verkleInput, proof[:]...)
|
||||
verkleInput = append(verkleInput, 1) // threshold_met = true
|
||||
|
||||
return []examples.Result{
|
||||
examples.CallPrecompileResult(
|
||||
"Quasar VerkleVerify",
|
||||
q.VerklePrecompile,
|
||||
common.HexToAddress(q.VerkleVerifyAddress),
|
||||
verkleInput,
|
||||
func(out []byte) bool { return len(out) > 0 && out[0] == 1 },
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package examples
|
||||
|
||||
import (
|
||||
"github.com/luxfi/geth/common"
|
||||
"github.com/luxfi/precompile/contract"
|
||||
)
|
||||
|
||||
// maxGas is the gas budget for each demo call.
|
||||
const maxGas = 10_000_000
|
||||
|
||||
// CallPrecompile invokes a StatefulPrecompiledContract directly (no EVM, no RPC).
|
||||
// This is the fastest way to exercise a precompile in tests and demos.
|
||||
func CallPrecompile(
|
||||
p contract.StatefulPrecompiledContract,
|
||||
addr common.Address,
|
||||
input []byte,
|
||||
readOnly bool,
|
||||
) (output []byte, gasUsed uint64, err error) {
|
||||
gas := uint64(maxGas)
|
||||
out, remaining, err := p.Run(nil, common.Address{}, addr, input, gas, readOnly)
|
||||
return out, gas - remaining, err
|
||||
}
|
||||
|
||||
// CallPrecompileResult is a convenience wrapper that builds a Result.
|
||||
func CallPrecompileResult(
|
||||
name string,
|
||||
p contract.StatefulPrecompiledContract,
|
||||
addr common.Address,
|
||||
input []byte,
|
||||
validate func(output []byte) bool,
|
||||
) Result {
|
||||
out, gasUsed, err := CallPrecompile(p, addr, input, true)
|
||||
pass := err == nil && validate(out)
|
||||
return Result{
|
||||
Name: name,
|
||||
Address: addr,
|
||||
Calldata: input,
|
||||
Output: out,
|
||||
GasUsed: gasUsed,
|
||||
Pass: pass,
|
||||
Error: err,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
// Package threshold demonstrates CGGMP21 and FROST threshold signature precompiles.
|
||||
package threshold
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"crypto/elliptic"
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
|
||||
"github.com/luxfi/geth/common"
|
||||
"github.com/luxfi/precompile/cggmp21"
|
||||
"github.com/luxfi/precompile/examples"
|
||||
"github.com/luxfi/precompile/frost"
|
||||
)
|
||||
|
||||
type AllThresholdDemos struct{}
|
||||
|
||||
func (d AllThresholdDemos) Name() string { return "threshold" }
|
||||
|
||||
func (d AllThresholdDemos) Run() []examples.Result {
|
||||
var all []examples.Result
|
||||
all = append(all, CGGMP21Demo()...)
|
||||
all = append(all, FROSTDemo()...)
|
||||
return all
|
||||
}
|
||||
|
||||
// CGGMP21Demo exercises the CGGMP21 ECDSA threshold verify precompile (0x0800..03).
|
||||
func CGGMP21Demo() []examples.Result {
|
||||
// Generate a standard ECDSA key pair -- CGGMP21 verification is standard ECDSA
|
||||
priv, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
||||
pub := &priv.PublicKey
|
||||
|
||||
msg := []byte("Lux precompile CGGMP21 demo")
|
||||
hash := sha256.Sum256(msg)
|
||||
|
||||
r, s, _ := ecdsa.Sign(rand.Reader, priv, hash[:])
|
||||
|
||||
// Uncompressed public key: 0x04 || x(32) || y(32) = 65 bytes
|
||||
pubKey := make([]byte, 65)
|
||||
pubKey[0] = 0x04
|
||||
copy(pubKey[1:33], examples.PadLeft(pub.X.Bytes(), 32))
|
||||
copy(pubKey[33:65], examples.PadLeft(pub.Y.Bytes(), 32))
|
||||
|
||||
// Signature: r(32) || s(32) || v(1) = 65 bytes
|
||||
sig := make([]byte, 65)
|
||||
copy(sig[0:32], examples.PadLeft(r.Bytes(), 32))
|
||||
copy(sig[32:64], examples.PadLeft(s.Bytes(), 32))
|
||||
sig[64] = 0 // v = 0
|
||||
|
||||
// Input: threshold(4) + totalSigners(4) + pubkey(65) + hash(32) + sig(65)
|
||||
input := make([]byte, 0, 4+4+65+32+65)
|
||||
input = append(input, examples.Uint32BE(2)...) // threshold = 2
|
||||
input = append(input, examples.Uint32BE(3)...) // total signers = 3
|
||||
input = append(input, pubKey...)
|
||||
input = append(input, hash[:]...)
|
||||
input = append(input, sig...)
|
||||
|
||||
return []examples.Result{
|
||||
examples.CallPrecompileResult(
|
||||
"CGGMP21 ECDSA Threshold Verify",
|
||||
cggmp21.CGGMP21VerifyPrecompile,
|
||||
cggmp21.ContractCGGMP21VerifyAddress,
|
||||
input,
|
||||
func(out []byte) bool { return examples.LastByte32IsOne(out) },
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// FROSTDemo exercises the FROST EdDSA threshold verify precompile (0x0800..02).
|
||||
func FROSTDemo() []examples.Result {
|
||||
// FROST verification is Schnorr on Ed25519.
|
||||
// We use the precompile's input format but with minimal viable data.
|
||||
// Full FROST signing ceremony is complex -- test input parsing.
|
||||
hash := sha256.Sum256([]byte("Lux precompile FROST demo"))
|
||||
|
||||
// Construct minimal input that will reach the verification path
|
||||
input := make([]byte, 0, frost.MinInputSize)
|
||||
input = append(input, examples.Uint32BE(2)...) // threshold
|
||||
input = append(input, examples.Uint32BE(3)...) // total signers
|
||||
input = append(input, make([]byte, 32)...) // pubkey (zeros = will fail verify)
|
||||
input = append(input, hash[:]...) // message hash
|
||||
input = append(input, make([]byte, 64)...) // signature (zeros)
|
||||
|
||||
r := examples.CallPrecompileResult(
|
||||
"FROST Schnorr Threshold (parse)",
|
||||
frost.FROSTVerifyPrecompile,
|
||||
common.HexToAddress("0x0800000000000000000000000000000000000002"),
|
||||
input,
|
||||
func(out []byte) bool { return true }, // expect error or fail result
|
||||
)
|
||||
// FROST with zero pubkey will fail verification, not crash
|
||||
if r.Error != nil || !examples.LastByte32IsOne(r.Output) {
|
||||
r.Pass = true // expected: invalid sig gives non-1 result
|
||||
r.Error = nil
|
||||
}
|
||||
|
||||
return []examples.Result{r}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// Package vrf demonstrates the ECVRF precompile (RFC 9381).
|
||||
package vrf
|
||||
|
||||
import (
|
||||
"github.com/luxfi/precompile/examples"
|
||||
vrfpc "github.com/luxfi/precompile/vrf"
|
||||
)
|
||||
|
||||
type VRFDemo struct{}
|
||||
|
||||
func (d VRFDemo) Name() string { return "vrf" }
|
||||
|
||||
func (d VRFDemo) Run() []examples.Result {
|
||||
// OpProofToHash (0x02): extract beta from a proof without verification.
|
||||
// We use a known proof structure: Gamma(32) + c(16) + s(32) = 80 bytes.
|
||||
// Gamma = identity point will fail gracefully, but we test the dispatch.
|
||||
proof := make([]byte, 80)
|
||||
// Set Gamma to the Ed25519 identity (which will fail proofToHash since it checks for identity)
|
||||
// Use a non-identity point: the Ed25519 basepoint compressed
|
||||
copy(proof[0:32], examples.HexDecode("5866666666666666666666666666666666666666666666666666666666666666"))
|
||||
// c and s = small valid scalars
|
||||
proof[32] = 1 // c = 1 (little-endian, first 16 bytes)
|
||||
proof[48] = 1 // s = 1 (little-endian, first 32 bytes)
|
||||
|
||||
input := make([]byte, 0, 1+80)
|
||||
input = append(input, vrfpc.OpProofToHash)
|
||||
input = append(input, proof...)
|
||||
|
||||
return []examples.Result{
|
||||
examples.CallPrecompileResult(
|
||||
"ECVRF ProofToHash",
|
||||
vrfpc.VRFPrecompile,
|
||||
vrfpc.ContractAddress,
|
||||
input,
|
||||
func(out []byte) bool {
|
||||
// proofToHash returns 64-byte SHA-512 output (beta_string)
|
||||
return len(out) == 64 && examples.IsNonZero(out)
|
||||
},
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ require (
|
||||
github.com/luxfi/accel v1.2.4
|
||||
github.com/luxfi/ai v0.1.0
|
||||
github.com/luxfi/chains v1.3.18
|
||||
github.com/luxfi/corona v0.7.9
|
||||
github.com/luxfi/corona v0.10.3
|
||||
github.com/luxfi/crypto v1.19.26
|
||||
github.com/luxfi/database v1.20.4
|
||||
github.com/luxfi/dex v1.5.20
|
||||
@@ -85,6 +85,7 @@ require (
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/luxfi/age v1.5.0 // indirect
|
||||
github.com/luxfi/mdns v0.1.1 // indirect
|
||||
github.com/luxfi/mlwe v0.2.1 // indirect
|
||||
github.com/luxfi/node v1.30.6 // indirect
|
||||
github.com/luxfi/timer v1.0.2 // indirect
|
||||
github.com/luxfi/zap v0.8.10 // indirect
|
||||
|
||||
@@ -224,6 +224,8 @@ github.com/luxfi/container v0.0.4 h1:BXhF82WyfqVP5mjlNcr7tP0Fcnvl0Ap1rkiu+rq5XuM
|
||||
github.com/luxfi/container v0.0.4/go.mod h1:Z3SpmMF5d4t77MM0nHYXURpn+EMVaeu1fhbd/3BGaek=
|
||||
github.com/luxfi/corona v0.7.9 h1:NQe9V/80CdKLvbaVRE2uepxvxg9KHbWfcGRKWrzLSHc=
|
||||
github.com/luxfi/corona v0.7.9/go.mod h1:SfS7xo/k4uoteEYwYy+QCMPzTU8EIEbLnbWKx5ENVCw=
|
||||
github.com/luxfi/corona v0.10.3 h1:Yi1oAkW0HEsf5fvst/tUN0AjRVg6DoNHB/IC0qrFWZE=
|
||||
github.com/luxfi/corona v0.10.3/go.mod h1:xe5qRir0p+FA6eETpyGDv4LjYySg1zVB13kmHpy9x94=
|
||||
github.com/luxfi/crypto v1.19.26 h1:+aHn/L479ak2ih7s/DkBZojjuhcyHBLqu3nYT81vcrU=
|
||||
github.com/luxfi/crypto v1.19.26/go.mod h1:0DCU62kX8+zhYU2qeM07A4pifJyPkPujnUOfgc8TOFQ=
|
||||
github.com/luxfi/crypto/ipa v1.2.4 h1:6xfwhI9/HrcDkF3Ti5/NxsNQIWbwYDJmRSNIHRQ/xfU=
|
||||
@@ -254,13 +256,15 @@ github.com/luxfi/mdns v0.1.1 h1:g2eRr9AXcziPkkcd24M+Qu9ApEpoKKjfI79QSNqv0rQ=
|
||||
github.com/luxfi/mdns v0.1.1/go.mod h1:dbp5f3h3aE7CGzwbaWzBM9cwdcekhmSrWhQevgYhhNA=
|
||||
github.com/luxfi/metric v1.5.9 h1:UAgXMNZf5oN/XJwwuKorf8iMaCj3nyP6thHPCwkUwY4=
|
||||
github.com/luxfi/metric v1.5.9/go.mod h1:ux+w3RZQCfF1zM8MO0wAWyNj/CsDlPd2mwTGshB9vY0=
|
||||
github.com/luxfi/mlwe v0.2.1 h1:pRwTjNUUtzUxRIlMbUPpeh9DE2/NdqfS17hfdogazp4=
|
||||
github.com/luxfi/mlwe v0.2.1/go.mod h1:DD9EHTeiyh/y0KGGeqL+q9S4n8raeGiGdaG/BQPAvT0=
|
||||
github.com/luxfi/mock v0.1.1 h1:0HEtIjg1J6CWz+IUyP6rsGqNWTcmxjFnSQIhaDuARwY=
|
||||
github.com/luxfi/mock v0.1.1/go.mod h1:jo35akl3Vtd8LbzDts8VJ0jmSVycrd1/eBi6g6t5hKU=
|
||||
github.com/luxfi/node v1.30.6 h1:pyuxUjWFvydlBcYrGq5uBPLwZOtu18y6MVb550npiYY=
|
||||
github.com/luxfi/node v1.30.6/go.mod h1:lWXDp8RQXEPdRvhu4iwTdf7CHm20b2CBZVbeq1maVAU=
|
||||
github.com/luxfi/p2p v1.21.1 h1:gmz1JMDhzHIL3dQlhwIDvR4OlFuhNVfnWUl/ipYhAIo=
|
||||
github.com/luxfi/p2p v1.21.1/go.mod h1:SsNPR5fPGWWNem9plGWhSmRqyDoysJ3kPAN0zG0g3iw=
|
||||
github.com/luxfi/pq v1.0.3 h1:pFlQm1+5FuKTDUh2y/23bXWkN4I2Rc5iuxJypwDFFMs=
|
||||
github.com/luxfi/pq v1.0.3 h1:ksw1dmfTR0dqqNMRS7BjGcprCO2Fhc+3Iiq2/NMuONw=
|
||||
github.com/luxfi/pq v1.0.3/go.mod h1:8bppZcRElfrVt0n3nYCZW3iX1TvhvzNbdjNdK1irgIE=
|
||||
github.com/luxfi/runtime v1.1.3 h1:6Yp/PKwQCohjXmBR9GA+gamdSAp+xA2rdN6J/74Y4aw=
|
||||
github.com/luxfi/runtime v1.1.3/go.mod h1:r1uonDnxRCnPz6N6WYwaC72HW95KbFIAyChnJyxePGs=
|
||||
|
||||
Reference in New Issue
Block a user