Skip to content

common: keep only what the verifiers use - #27

Open
SamDelaney wants to merge 2 commits into
mainfrom
sam/common-cleanup
Open

SamDelaney wants to merge 2 commits into
mainfrom
sam/common-cleanup

Conversation

@SamDelaney

Copy link
Copy Markdown
Collaborator

Catalyst completion roadmap task 1.1: the last of the review issues. common.ak is cut down to what the package uses, plus a small docs correction.

Fixes #20.

Changes

Commit Change
aee099c #20: common/common.ak keeps only the two BLS12-381 constants, concat_and_keccak_256, scalar_sum and g1_sum. The rest, about 1,000 lines of broken curve, pairing and field code that no verifier called, is deleted. The READMEs and reports stop describing it as legacy code kept for reference.
625e949 Docs: the root README said 79 tests and the PLONK report 82 (the package has 89), and the PLONK report still compared against the Bulletproofs cost that 1aab9e6 (#25) found was the whole test and over the 10B CPU limit.

What was removed

Everything in the issue: pairing_check (true for empty lists), the placeholder miller_loop and final_exponentiation, point and field arithmetic mod r instead of p, the broken deserialize_field, bls12_381_h = 1, and validate_g1_point without a subgroup check. Also the types and helpers that only that code used (Field, G1Point, G2Point, VerificationKey, Proof, the compress, serialize and hash-to-curve routines, concat_and_blake2b_224, scalar_rt_*).

The issue suggested moving the used helpers into a new small module. Keeping them in common/common.ak makes that module the small one, so no import changes: blst_affine, plonk/proofs, plonk/verifier and the tests import the same names from the same path. plonk/raw.ak was already retired in #22.

Nothing outside common.ak referred to any removed name (checked with git grep over zkp/).

Checks

  • aiken check -D: 89 tests, all pass, no warnings (the same 89 as main; common_tests already covered the five kept items)
  • aiken build passes
  • aiken fmt is clean on the committed files

SamDelaney and others added 2 commits November 18, 2026 22:37
common.ak looked like a BLS12-381 library, but most of it was broken
and nothing called it: pairing_check([], []) returned True, miller_loop
and final_exponentiation were hash placeholders, point and field
arithmetic reduced mod r instead of p, deserialize_field had its foldl
arguments swapped, bls12_381_h was 1, and validate_g1_point skipped the
subgroup check. Leaving it public invited someone to build on it.

The module now holds only the five things the package uses: the two
BLS12-381 constants (blst_affine and the point tests),
concat_and_keccak_256 (the PLONK transcript), and scalar_sum and g1_sum
(the PLONK verifier). They keep their names and module path, so no
import changes, and common_tests already covers all five. Everything
else, about 1,000 lines, is deleted.

The READMEs and the three reports no longer describe common.ak as
legacy scaffolding kept for reference.

Fixes #20

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The root README said 79 tests and the PLONK report 82; the package has
89, as the three reports' own headers already say.

The PLONK report compared its 8.11B CPU against "Bulletproofs' range
proof at ~5.2M mem / 14.2B cpu", the figure the Bulletproofs report
dropped in 1aab9e6: it was the whole range_proof_valid test, and 14.2B
is over the 10B limit, so PLONK couldn't have been both the most
expensive verifier and the one with less headroom than Bulletproofs. It
now compares against verify's own cost at n = 8 with setup called in
the validator (3.16M memory, 7.81B CPU) and names the limits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the unused cryptographic code removal and related documentation updates.

No open issues 🎉

What changed in this PR

Addresses #20 by reducing common/common.ak to the constants and helpers used by the verifiers, removing unused, defective cryptographic implementations while preserving existing imports and retained behavior.

Changes:

  • Removes roughly 1,000 lines of unused curve, pairing, field, and serialization code, keeping two constants and three helpers.
  • Updates documentation and test-header comments to reflect the smaller shared module.
  • Refreshes documented test totals to 89 and corrects the PLONK report’s Bulletproofs cost comparison.
File Description
zkp/​README.md Describes the current shared modules instead of legacy scaffolding.
zkp/​lib/​tests/​common_tests.ak Updates header comments; test behavior is unchanged.
zkp/​lib/​common/​common.ak Removes unused implementations and documents the five retained definitions.
zkp/​docs/​plonk-implementation-report.md Updates shared-module descriptions, test totals, and execution-cost comparisons.
zkp/​docs/​groth16-implementation-report.md Removes references to deleted arithmetic and clarifies native builtin usage.
zkp/​docs/​bulletproofs-implementation-report.md Updates the shared-module description.
README.md Updates the test total and lists the retained common helpers.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

common.ak: legacy curve, pairing and field code is broken (unused by the verifiers)

2 participants