Skip to content

Counting interface for the indifferentiability arc - #27

Open
daira wants to merge 7 commits into
mainfrom
indiff-counting
Open

Counting interface for the indifferentiability arc#27
daira wants to merge 7 commits into
mainfrom
indiff-counting

Conversation

@daira

@daira daira commented Aug 13, 2026

Copy link
Copy Markdown
Owner

The counting side of the indifferentiability arc (#25; the game side is zcash/ironwood#198): everything the ironwood-side sampler and single-query lemma consume, with no probability in this repo.

Hashing/FibreBound.lean — the fibre bound

Away from the input u = 0, every point of the target curve has at most 10 preimages under SSWUParams.map, over any field where -1 is a square (both Pasta base fields, q ≡ 1 (mod 4)). Nonzero inputs are never exceptional there — ta = 0 would exhibit the nonsquare Z as -1 times a square — so a preimage of an abscissa is a root of the explicit product polynomial Φ_x combining the two branch equations cleared of their common denominator: nonzero of degree at most 10, because its second factor has degree exactly 6 with leading coefficient -B·Z³. The input u = 0 is excluded rather than counted: the probability analysis prices pairs containing 0 in its zero-repair correction, and the sampler rides the same term. The optimal constant is 4 (oddness pairs ±u across P and -P, and each branch equation is a quadratic in t), recorded in the module doc as a follow-up; the sampler only needs some explicit constant.

The deployed maps, per curve

isSquare_neg_one by Euler's criterion, the generic composition step card_fibre_comp_le (composing with an injective map does not grow fibres), and Pallas/Vesta.card_mapToCurve_fibre_le through iso_map_bijective. The census records both endpoints, whose native leaves are the Tonelli–Shanks validity witnesses and, through the isogeny's bijectivity, the order witnesses.

Hashing/TwoTermUniformity.lean — deviation exports and the transport

sum_abs_prob_dev_le states the L¹ probability deviation unsquared, against any budget whose square dominates the squared bound, so the ℝ≥0∞-side consumer never needs a square root and a concrete budget is checked by squaring, in exact arithmetic. card_dev_ge_le is the Chebyshev-style counting form of the L² bound: regularity does not lower-bound individual fibres, so the rejection sampler's acceptance constant holds only outside a bad set of fibres, whose size this bounds. sum_abs_pairCount_sub_le prices the zero-repair transport: mappings agreeing away from a single input have two-term pair counts within 4·#F - 2 of each other in L¹. sum_abs_prob_dev_transport_le combines the two: a mapping agreeing away from a single input with a Weil-bounded one has regularity distance at most ε + (4·#F − 2)/(#F)² — the composed form the ironwood side consumes at the deployed mapToCurve.

The absorbed ironwood extras

Two commits adopt the content of zcash/ironwood's Zcash/Circuits/Specs/CompEllipticExtras.lean, closing #12. CurveForms/ShortWeierstrass.lean gains the rfl projection lemmas SWPoint.add_x/SWPoint.add_y, y_eq_pm_of_onCurve_x_eq (two points on the curve sharing an x-coordinate have y-coordinates equal up to sign), SWPoint.onCurve_of_ne_zero, and SWPoint.eq_pm_of_x_eq (nonzero representable points sharing an x-coordinate are equal up to sign) — ironwood's y_eq_or_y_eq_neg_of_onCurve and eq_or_eq_neg_of_x_eq, renamed to name the shared-abscissa premiss. The last subsumes the private copy that Isogenies/Homomorphism.lean carried. Its ≠ 0 premisses are necessary at SWCurve generality: only B ≠ 0 is bundled, so a curve whose B is a square has a genuine point (0, √B) sharing x = 0 with the 𝒪 sentinel.

Fields/Pasta.lean gains the Fp/Fq abbreviations under their pasta_curves letters, reversing the "not to move" note in #12. The Pallas-side twins neg_five_not_isCube/no_onCurve_y_zero that #12 also requested were already added by #19. ironwood drops its copies of all of this when it bumps its pin.

Per the parallel-iteration plan, this merges once the ironwood side compiles against it. It now does (zcash/ironwood branch fv/indiff-sampler), consuming the L¹ exports through the transport; card_dev_ge_le and the fibre bound get their consumers in the costed milestone.

🤖 Claude Opus 4.8

Base automatically changed from hashing-style to main August 13, 2026 15:38
@daira
daira marked this pull request as ready for review August 13, 2026 19:05
daira added a commit to daira/ironwood that referenced this pull request Aug 15, 2026
Bump the CompElliptic pin from fd997734 to 23ac3369, the head of the
indiff-counting branch (daira/CompElliptic#27, the milestone-1 counting
interface for the hash-to-curve indifferentiability arc), pinned temporarily
until that PR merges. The new revision also carries the Pallas-side twins
neg_five_not_isCube / no_onCurve_y_zero and the content of
Zcash/Circuits/Specs/CompEllipticExtras.lean (daira/CompElliptic#12), so
ironwood's copies are dropped:

- Delete CompEllipticExtras.lean. Its importers now import the CompElliptic
  modules they use directly, as do MulFixed/Theorems.lean and
  MulFixed/ShortTheorems.lean, which had been reaching CompElliptic through
  transitive imports.
- Delete the Pallas-side twins from Specs/Pallas.lean; CompElliptic proves
  them verbatim, by the same kernel-tier proofs, so the census is unchanged.
- Rename uses of y_eq_or_y_eq_neg_of_onCurve to its upstream name
  y_eq_pm_of_onCurve_x_eq, and prove Point.y_eq_or_neg_of_same_x through it
  instead of repeating the square-difference argument.
- Drop the module from the book's source map.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
daira added a commit to daira/ironwood that referenced this pull request Aug 15, 2026
Bump the CompElliptic pin from fd997734 to 23ac3369, the head of the
indiff-counting branch (daira/CompElliptic#27, the milestone-1 counting
interface for the hash-to-curve indifferentiability arc), pinned temporarily
until that PR merges. The new revision also carries the Pallas-side twins
neg_five_not_isCube / no_onCurve_y_zero and the content of
Zcash/Circuits/Specs/CompEllipticExtras.lean (daira/CompElliptic#12), so
ironwood's copies are dropped:

- Delete CompEllipticExtras.lean. Its importers now import the CompElliptic
  modules they use directly, as do MulFixed/Theorems.lean and
  MulFixed/ShortTheorems.lean, which had been reaching CompElliptic through
  transitive imports.
- Delete the Pallas-side twins from Specs/Pallas.lean; CompElliptic proves
  them verbatim, by the same kernel-tier proofs, so the census is unchanged.
- Rename uses of y_eq_or_y_eq_neg_of_onCurve to its upstream name
  y_eq_pm_of_onCurve_x_eq, and prove Point.y_eq_or_neg_of_same_x through it
  instead of repeating the square-difference argument.
- Drop the module from the book's source map.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
daira and others added 7 commits August 16, 2026 01:30
…oCurve

`mapHashOutputsToCurve` and its `_eq` lemma took the field-to-curve map as
`m`. Ironwood's group-hash development calls that map `f` (`f : F → G`), so
rename the parameter to `f` for cross-repo consistency. Callers are
unaffected — the map is passed positionally.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… 10 elements

The counting fact the indifferentiability arc's rejection sampler consumes
(zcash/ironwood#198, CompElliptic#25). On a field where -1 is a square
(both Pasta base fields), a nonzero input is never exceptional, so a
nonzero preimage of an abscissa x is a root of the explicit product
polynomial combining the two branch equations cleared of their common
denominator: nonzero of degree at most 10, since its second factor has
degree exactly 6 with leading coefficient -B·Z³. The input u = 0 is
excluded rather than counted: the probability analysis prices pairs
containing 0 in its existing zero-repair correction. The optimal constant
is 4, recorded in the module doc as a planned follow-up.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
-1 is a square in both Pasta base fields (q ≡ 1 mod 4, Euler's criterion),
so the generic SSWU fibre bound applies, and the isogeny is injective on
rational points (iso_map_bijective), so it carries through the composition:
at most 10 nonzero preimages per point under the deployed mapToCurve. The
generic composition step is card_fibre_comp_le in FibreBound. The census
records both endpoints; they consume the Tonelli-Shanks validity witnesses
and, through the isogeny's bijectivity, the order witnesses.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
The counting interface the indifferentiability game side consumes
(zcash/ironwood#198, CompElliptic#25), in three statements.
sum_abs_prob_dev_le is the L¹ probability deviation unsquared, stated
against any budget whose square dominates the squared bound, so the
consumer never needs a square root and a concrete budget is checked by
squaring in exact arithmetic. card_dev_ge_le is the Chebyshev-style
counting form of the L² bound: regularity does not lower-bound individual
fibres, so the rejection sampler's acceptance constant holds only outside
a bad set of fibres, whose size this bounds. sum_abs_pairCount_sub_le
prices replacing the zero-repaired mapping by the deployed one: mappings
agreeing away from one input have two-term pair counts within 4·#F - 2 in
L¹, by splitting every pair count at the pairs containing that input.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
…Extras

zcash/ironwood carried Zcash/Circuits/Specs/CompEllipticExtras.lean, written
in CompElliptic's own namespaces as explicit upstreaming candidates. Adopt
the curve lemmas into CurveForms/ShortWeierstrass.lean:

- SWPoint.add_x / SWPoint.add_y: rfl projection lemmas for the coordinates
  of a sum.
- y_eq_pm_of_onCurve_x_eq (was y_eq_or_y_eq_neg_of_onCurve; the rename names
  the shared-abscissa premiss): two points on the curve sharing an
  x-coordinate have y-coordinates equal up to sign.
- SWPoint.onCurve_of_ne_zero: a nonzero representable point is on the curve.
- SWPoint.eq_pm_of_x_eq (was SWPoint.eq_or_eq_neg_of_x_eq): nonzero
  representable points sharing an x-coordinate are equal up to sign. This
  subsumes the private eq_or_eq_neg_of_x_eq in Isogenies/Homomorphism.lean,
  which is removed. The ≠ 0 premisses are necessary at SWCurve generality:
  SWCurve requires only B ≠ 0, so a curve whose B is a square has a genuine
  point (0, √B) sharing x = 0 with the 𝒪 sentinel without being equal to it
  up to sign.

Closes #12.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Consumers refer to the Pallas base and scalar fields by their pasta_curves
letters, Fp and Fq. Host the abbreviations beside the role-named fields they
alias. This reverses the "not to move" assessment of #12:
the letters are pasta_curves' own convention, not Zcash-specific usage.

Fields/Pasta.lean is generated, so the abbreviations are emitted by
scripts/gen_pasta.py and the file regenerated from it (CI checks the
reproduction).

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…apping

sum_abs_prob_dev_transport_le combines sum_abs_prob_dev_le with
sum_abs_pairCount_sub_le: a mapping agreeing away from a single input with
a Weil-bounded one has regularity distance at most ε + (4·#F − 2)/(#F)².
This is the form the ironwood-side single-query bias consumes at the
deployed mapToCurve, whose zero-repaired variant carries the Weil-bound
hypothesis.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

@daira daira left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Self-reACK

daira added a commit to daira/ironwood that referenced this pull request Aug 16, 2026
Bump the CompElliptic pin from fd997734 to a18340e, the head of the
indiff-counting branch (daira/CompElliptic#27, the milestone-1 counting
interface for the hash-to-curve indifferentiability arc), pinned temporarily
until that PR merges. The new revision also carries the Pallas-side twins
neg_five_not_isCube / no_onCurve_y_zero and the content of
Zcash/Circuits/Specs/CompEllipticExtras.lean (daira/CompElliptic#12), so
ironwood's copies are dropped:

- Delete CompEllipticExtras.lean. Its importers now import the CompElliptic
  modules they use directly, as do MulFixed/Theorems.lean and
  MulFixed/ShortTheorems.lean, which had been reaching CompElliptic through
  transitive imports.
- Delete the Pallas-side twins from Specs/Pallas.lean; CompElliptic proves
  them verbatim, by the same kernel-tier proofs, so the census is unchanged.
- Rename uses of y_eq_or_y_eq_neg_of_onCurve to its upstream name
  y_eq_pm_of_onCurve_x_eq, and prove Point.y_eq_or_neg_of_same_x through it
  instead of repeating the square-difference argument.
- Drop the module from the book's source map.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

Upstream ironwood's CompEllipticExtras lemmas and the Pallas curve twins

1 participant