Skip to content

ChaChaPoly: prove the Poly1305 bound and instantiate with RFC 8439 - #1237

Open
bgregoir wants to merge 2 commits into
pocklingtonfrom
poly1305
Open

bgregoir wants to merge 2 commits into
pocklingtonfrom
poly1305

Conversation

@bgregoir

@bgregoir bgregoir commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #1233 (Pocklington, itself on #1238), and depends on #1232 (root counting in Poly.ec), whose commit is included here until it is merged; only the last commit is new.

Replaces the Poly1305 axioms of the ChaCha20-Poly1305 example by proofs.

examples/ChaChaPoly/poly1305_prime.ec, poly1305_field.ec, poly1305_msg.ec (moved from #1233)

  • prime_p1305 : prime (2^130 - 5), as a chain of 9 Pocklington certificates checked by cbv delta hint +powmod +gcd;
  • Z/(2^130 - 5) and its polynomial ring;
  • the RFC 8439 message polynomial (MAC input with padding and little-endian lengths, 16-byte blocks, coefficients le(b) + 2^128), its degree, and its injectivity (topol_inj) for lengths < 2^64.

examples/ChaChaPoly/poly1305_clamp.ec (abstract theory Clamp, parameterised by a byte distribution with mu1 = 1/256)

  • RFC 8439 clamping of r; each clamped value has probability at most 2^-106 (dr1E).
  • pr_topol_diff: for distinct (a, c) of valid sizes, Pr_r[P2(r) - P1(r) = t] <= max(nblocks)/2^106 (via mu_root_le).
  • pr_tag_diff: the same difference modulo 2^128 is hit with probability at most 8 * max(nblocks)/2^106.

examples/ChaChaPoly/chacha_poly_rfc.ec

  • Clones chacha_poly.ec with the polynomial over Z/(2^130 - 5), tags modulo 2^128, a 32-bit counter, and maximal sizes max_ad / max_cipher for the associated data and the ciphertext, as parameters within the RFC 8439 limits (max_ad_rg, max_cipher_rg); the bound grows linearly with them.
  • Proves topol_inj, pr_zeropol_spec, ge0_pr_zeropol and the four poly_out_* axioms; pr_zeropol = 8 * max_nblocks / 2^106 and pr1_poly_out = 2^-128.
  • Bytes stay abstract (to be linked with concrete implementations), with three axioms: to_uint_rg, to_uint_inj, of_uintK; the finite type of bytes is built from them (enum defined, enum_spec proved).
  • Final theorem chacha_poly_rfc_security: for a nonce-respecting adversary,
    |Pr[real] - Pr[IdealAEAD]| <= |Pr[ChaCha20] - Pr[random function]| + qdec * 8 * max_nblocks / 2^106 + qdec / 2^128.

examples/ChaChaPoly/chacha_poly.ec

  • The ge0_poly_size axiom of the TPoly clone is now realized (its proof clause was silently dropped because of the rename, see clone: proof clause on a renamed axiom is checked but the axiom remains #1236).
  • IdealAEAD: the ideal oracles as a single module (random ciphertexts and tags, decryption only of the ciphertexts returned by encryption), equal to CCA_CPA_Adv around EncRnd (CCA_CPA_IdealAEAD); conclusion_ideal restates conclusion with it.
  • conclusion_ideal_abs: the same bound on the absolute value of the advantage, by applying conclusion_ideal to the adversary that negates its output (with losslessness of the four games).

@bgregoir
bgregoir marked this pull request as draft November 10, 2026 18:08
…ting

Following mathcomp (algebra/poly.v), with `peval` for `horner` and `deg`
(degree + 1) for `size`:
- PolyComRing: evaluation lemmas (pevalC, pevalD, pevalM, peval_exp,
  pevalXsubC, ...), the remainder theorem (peval_factor), root lemmas
  (root0, rootC, rootX, rootN, root_XsubC), factor_theorem, divisibility
  of polynomials (clone of Ideal.IdealComRing) and root_factor_theorem;
- Poly (integral domain): rootM, rootZ, factor_theorem_deg, roots_finite,
  max_poly_roots, and the probability that a nonzero polynomial vanishes
  at a sampled point (mu_root_le, mu_root_uni).

PolyReduce reuses the divisibility clone inherited from PolyComRing
instead of its own copy.
…FC 8439

poly1305_prime.ec: 2^130 - 5 is prime, by a chain of Pocklington
certificates. poly1305_field.ec: polynomials over Z/(2^130 - 5).
poly1305_msg.ec: the Poly1305 message polynomial of RFC 8439 and its
injectivity.

poly1305_clamp.ec: for r made of 16 uniform bytes and clamped as in
RFC 8439, each value of r has probability at most 2^-106 (dr1E). For
distinct (a, c) of valid sizes, the difference of the two message
polynomials evaluated at r hits a given field element with probability
at most max(nblocks)/2^106 (pr_topol_diff), and a given difference
modulo 2^128 with probability at most 8 * max(nblocks)/2^106
(pr_tag_diff).

chacha_poly_rfc.ec clones chacha_poly.ec with the Poly1305 polynomial
over Z/(2^130 - 5), tags modulo 2^128 and the RFC 8439 sizes, and proves
the axioms topol_inj, pr_zeropol_spec, ge0_pr_zeropol and poly_out_*.
Bytes stay abstract, with to_uint/of_uint and three axioms.

chacha_poly.ec: the proof clause of the TPoly clone named the axiom
before renaming and was dropped, leaving ge0_poly_size an axiom
(EasyCrypt issue #1236); realize it after the clone instead.
@bgregoir
bgregoir marked this pull request as ready for review November 11, 2026 07:11
@fdupress
fdupress added this pull request to stack #1239 November 11, 2026 19:02
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.

1 participant