mirror of
https://github.com/luxfi/crypto.git
synced 2026-07-27 01:54:50 +00:00
The verkle_test.go file added in 8b78e5c references three symbols
(BatchProof, VerifyBatch, ErrBatchLengthMismatch) plus a Verify entry
point that lived in the old verkle/verkle.go re-export shim. The
subsequent vendoring (1402189) replaced the shim with a full source
vendor but did not carry the batch-verify wrapper forward, so the
package no longer built.
Restore the wrapper in verkle/verkle.go using the now-local Verify
implementation in proof_ipa.go (no upstream go-verkle import). Drop the
"upstream" alias from verkle_test.go and call the package's own New,
MakeVerkleMultiProof, and SerializeProof directly.
Also fix two stale "github.com/luxfi/crypto/ipa/banderwagon" imports in
ipa/batch.go and ipa/batch_test.go that point at a deleted directory;
the canonical home is now github.com/luxfi/crypto/banderwagon. Without
this the verkle package transitively fails to compile.
Tests (GOWORK=off go test ./verkle/...):
TestVerifyBatch_KAT PASS
TestVerifyBatch_TamperDetected PASS
TestVerifyBatch_Empty PASS
TestVerify_SingleSucceeds PASS
TestNodeWidthIs256 PASS
TestVerifyBatch_NilProof PASS
Pre-existing failures (TestParseNodeEoA, TestParseNodeSingleSlot,
TestDelLeaf, TestDeletePrune) are unrelated regressions from the
vendoring + blinded-MSM changes already on main.
54 lines
1.9 KiB
Go
54 lines
1.9 KiB
Go
// Copyright (C) 2025-2026, Lux Industries Inc. All rights reserved.
|
|
//
|
|
// Package verkle hosts the canonical Lux implementation of Verkle trees and
|
|
// the IPA-based proof system. This file exposes the batched verify entry
|
|
// point used by downstream chains and by the GPU-accelerated proof driver.
|
|
//
|
|
// A batched verify takes a slice of (proof, pre-root, post-root, state-diff)
|
|
// tuples and runs each one through the package's Verify function in
|
|
// lockstep. The shape is the contract; the body is what an MSM-batched
|
|
// verifier will replace once the curve arithmetic is in place.
|
|
|
|
package verkle
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
// ErrBatchLengthMismatch is returned by VerifyBatch when called with no
|
|
// proofs. Callers must pass at least one BatchProof; an empty slice is a
|
|
// programmer error, not a successful verification of nothing.
|
|
var ErrBatchLengthMismatch = errors.New("verkle: batch slice length mismatch")
|
|
|
|
// BatchProof bundles a single Verkle proof with the public roots and
|
|
// state diff needed to verify it. A []BatchProof is the canonical input
|
|
// shape for VerifyBatch.
|
|
type BatchProof struct {
|
|
Proof *VerkleProof
|
|
PreStateRoot []byte
|
|
PostStateRoot []byte
|
|
StateDiff StateDiff
|
|
}
|
|
|
|
// VerifyBatch verifies many Verkle proofs in lockstep. Each proof is
|
|
// checked independently with Verify; this is a structural batch (one
|
|
// MSM per proof, no proof-randomized accumulation yet).
|
|
//
|
|
// Returns nil on full success, ErrBatchLengthMismatch on empty input, or
|
|
// a wrapped error from the first failing proof tagged with its index.
|
|
func VerifyBatch(proofs []BatchProof) error {
|
|
if len(proofs) == 0 {
|
|
return ErrBatchLengthMismatch
|
|
}
|
|
for i, p := range proofs {
|
|
if p.Proof == nil {
|
|
return fmt.Errorf("verkle batch[%d]: nil proof", i)
|
|
}
|
|
if err := Verify(p.Proof, p.PreStateRoot, p.PostStateRoot, p.StateDiff); err != nil {
|
|
return fmt.Errorf("verkle batch[%d]: %w", i, err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|