Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

### Changed

- Compute KZG openings for up to 128 nonzero scalars using a sparse quotient
and fixed public unit-polynomial openings. Preserve dense behavior above the
threshold, exact proof bytes, checked primitive Prove and receiver verification.
- Compute CPU KZG openings at every occupancy using a sparse quotient
and fixed public unit-polynomial openings. This preserves exact proof bytes,
checked primitive Prove and receiver verification.
Generate and verify the additional writer-only table from the pinned setup;
no query-time precomputation, new setup ceremony or profile change is needed.

Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,10 @@ and generated-evidence reuse; proof order and serialized bytes do not depend on
scheduling. The built-in KZG and IPA arithmetic also follows the process's Go
scheduler budget. Applications may schedule independent ArcSet proofs separately.

The built-in KZG prover uses a sparse quotient calculation for vectors with at
most 128 nonzero scalars. Its fixed unit-polynomial opening table is generated
from the pinned public setup and loaded with the writer key; queries require
no table precomputation. Higher occupancy uses the full-vector calculation.
Both paths emit identical proof bytes and use the same verifier. Writers retain
The built-in CPU KZG prover uses a sparse quotient calculation at every
occupancy. It loads a fixed unit-polynomial opening table with the writer key.
The table is generated from the pinned public setup before queries run.
The resulting proofs match the full-vector calculation byte for byte. Writers retain
an additional 384 KiB embedded table plus 384 KiB of decoded points per process;
portable verifiers do not load or link either.

Expand Down
9 changes: 1 addition & 8 deletions auth/commitment/kzg/sparse.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ import (
gokzg4844 "github.com/crate-crypto/go-kzg-4844"
)

// Sparse openings use at most occupancy+2 MSM terms instead of MaxValues.
// Keep the existing full-vector algorithm for higher occupancy.
const sparseOpeningLimit = 128

func provePolynomialAtIndex(key *kzgWriterKey, domain *kzgDomain, polynomial []blsfr.Element, index uint64) (gokzg4844.KZGProof, gokzg4844.Scalar, error) {
if key == nil || len(key.lagrangeG1) != MaxValues || len(key.unitProofs) != MaxValues {
return gokzg4844.KZGProof{}, gokzg4844.Scalar{}, fmt.Errorf("KZG writer parameters are incomplete")
Expand All @@ -22,12 +18,9 @@ func provePolynomialAtIndex(key *kzgWriterKey, domain *kzgDomain, polynomial []b
if len(polynomial) != MaxValues || index >= MaxValues {
return gokzg4844.KZGProof{}, gokzg4844.Scalar{}, fmt.Errorf("invalid KZG opening index %d", index)
}
indices := make([]int, 0, sparseOpeningLimit)
indices := make([]int, 0, 128)
for i := range polynomial {
if !polynomial[i].IsZero() {
if len(indices) == sparseOpeningLimit {
return provePolynomialAtIndexDense(key, domain, polynomial, index)
}
indices = append(indices, i)
}
}
Expand Down
4 changes: 2 additions & 2 deletions auth/commitment/kzg/sparse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ func TestSparseOpeningsEqualDenseQuotients(t *testing.T) {
if err != nil {
t.Fatal(err)
}
// Include zero and occupied targets, both ends of the domain, and both
// sides of the dispatch boundary. Dense outputs are the byte-level oracle.
// Compare empty and occupied targets against the dense reference,
// including both ends of the domain and a fully populated vector.
for _, occupancy := range []int{0, 1, 2, 32, 127, 128, 129, 1024, MaxValues} {
t.Run(fmt.Sprint(occupancy), func(t *testing.T) {
polynomial := make([]blsfr.Element, MaxValues)
Expand Down
5 changes: 2 additions & 3 deletions docs/spec/commitment-proof-encoding.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ point `domain[i]`.

### Opening Computation

The CPU prover selects a sparse computation when at most 128 evaluations are
nonzero; higher occupancy uses the full 4096-element quotient. This is an
implementation choice and does not change KZG4096 parameters or proof bytes.
The CPU prover uses the sparse quotient computation at every occupancy,
including a fully populated 4096-element vector.

Let `L_j` be the Lagrange basis for the index domain, `omega_i` the opening
point, and `p_j` the supplied evaluations. The writer embeds one public point
Expand Down
Loading