Skip to content

Add NIST GHASH <-> POLYVAL bridge (Gueron Proposition 1)#396

Merged
jargh merged 3 commits into
awslabs:mainfrom
nebeid:ghash-nist-bridge-pr
May 22, 2026
Merged

Add NIST GHASH <-> POLYVAL bridge (Gueron Proposition 1)#396
jargh merged 3 commits into
awslabs:mainfrom
nebeid:ghash-nist-bridge-pr

Conversation

@nebeid
Copy link
Copy Markdown
Contributor

@nebeid nebeid commented Apr 24, 2026

Introduces common/ghash_nist_bridge.ml, the formal bridge between
the NIST SP 800-38D GHASH specification (bit-reflected, mod P(x)) and
the POLYVAL-based computation (natural bit order, mod Q(x)) used by
the AES-GCM assembly implementations.

Key definitions

  • nist_dot a b: the native NIST GHASH "•" operation — bit-reflect
    inputs, carry-less multiply, reduce mod P(x), bit-reflect the result.
  • nist_ghash h acc xs: recursive Horner iteration using nist_dot,
    matching the NIST SP 800-38D specification directly.

Key theorems

  • GUERON_PROP1: the main algebraic bridge —
    bit_reflect128(ghash_reduce(pmul(REF a, REF b))) = polyval_dot a (ghash_twist b).
    This is the formal statement of Gueron's Proposition 1 (CSCML 2023).
  • NIST_DOT_IS_POLYVAL_DOT: nist_dot a b = polyval_dot a (ghash_twist b).
  • NIST_GHASH_IS_POLYVAL: nist_ghash h acc xs = ghash_polyval_acc (ghash_twist h) acc xs.
    Proved non-trivially by list induction via GUERON_PROP1 (not a
    definitional unfolding).
  • NIST_GHASH_NIL, NIST_GHASH_CONS, NIST_GHASH_APPEND.

Proof simplification (commit 3)

The GUERON_PROP1 proof was simplified to eliminate word_ushr from the
ideal-membership witness. The original proof factored x out of
REF(m) (valid since bit 0 (REF m) = F) and used QXP_EQ_XQPMULP
to rewrite Q · (x · p). The simplified proof uses QP_EQ_QPMULP
(Q · p = pmul(Q_word, p), a direct consequence of
POLY_OF_WORD_PMUL_2N) with witness poly(zx(REF m)) directly.
This also removes BOOL_POLY_MUL_VARPOW_COMM and POLY_MUL_VAR_SHIFT.

Dependencies

This PR depends on #394 (common/polyval_ghash.ml), which depends on
#393 (common/polyval.ml structural infrastructure). #392 and #388 are
already merged.

Testing

common/ghash_nist_bridge.ml loads cleanly in HOL Light (~530s).
No CHEAT_TAC or new_axiom in the proofs.

nebeid and others added 2 commits April 4, 2026 03:02
Introduces common/ghash_nist_bridge.ml with the formal proof of
Gueron's Proposition 1 (CSCML 2023): bit-reflecting inputs,
carry-less multiplying, reducing mod P(x), and bit-reflecting back
equals polyval_dot with an x-shifted key.

Key definitions and lemmas:
- bit_reflect128: bit-reflection on 128-bit words (word_reversefields 1)
- BIT_REFLECT128, REFLECT128_INVOLUTION, REFLECT128_XOR
- PMUL_REFLECT128: reflecting both factors reverses the product
- GHASH_POLYVAL_RECIPROCAL: P(x) and Q(x) coefficient reciprocity
- PMUL_GHASH_POLYVAL_REFLECT: the bit-level P-to-Q transport
- GUERON_PROP1: the main theorem

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Define nist_dot (the native NIST GHASH multiply) and nist_ghash
(recursive Horner iteration using nist_dot, matching NIST SP 800-38D).
Prove the bridge theorems connecting them to the POLYVAL layer:

- NIST_DOT_IS_POLYVAL_DOT: nist_dot a b = polyval_dot a (ghash_twist b)
- NIST_GHASH_IS_POLYVAL: by list induction via GUERON_PROP1
- NIST_GHASH_NIL, NIST_GHASH_CONS, NIST_GHASH_APPEND

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@nebeid nebeid changed the title Add NIST GHASH ↔ POLYVAL bridge (Gueron Proposition 1) Add NIST GHASH <-> POLYVAL bridge (Gueron Proposition 1) Apr 24, 2026
@nebeid nebeid force-pushed the ghash-nist-bridge-pr branch 3 times, most recently from c32f41b to 714e26f Compare April 24, 2026 19:29
Replace QXP_EQ_XQPMULP (Q * x * p = x * pmul(Q,p)) with the simpler
QP_EQ_QPMULP (Q * p = pmul(Q,p)), which follows directly from
POLY_OF_WORD_PMUL_2N. This lets the witness be poly(zx(REF m))
instead of x * poly(zx(ushr(REF m, 1))), eliminating word_ushr from
the proof entirely.

Supporting changes:
- BIT_WORD_ZX_USHR_REFLECT -> BIT_WORD_ZX_REFLECT (no precondition)
- PMUL_GHASH_POLYVAL_REFLECT: bijection 127-j instead of 126-j
- RHS_PMUL_BOUND_DIRECT: simpler proof using BIT_POLYVAL_WORD
- Remove BOOL_POLY_MUL_VARPOW_COMM, POLY_MUL_VAR_SHIFT (no longer needed)
- Align all comment closing brackets to column 79

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@jakemas
Copy link
Copy Markdown
Contributor

jakemas commented May 1, 2026

GUERON_PROP1: the main algebraic bridge —
bit_reflect128(ghash_reduce(pmul(REF a, REF b))) = polyval_dot a (ghash_twist b).
This is the formal statement of Gueron's Proposition 1 (CSCML 2023).

nice!

@nebeid nebeid force-pushed the ghash-nist-bridge-pr branch from 10b15a8 to f1eaf2b Compare May 19, 2026 16:01
@jargh jargh self-requested a review May 22, 2026 04:29
Copy link
Copy Markdown
Contributor

@jargh jargh left a comment

Choose a reason for hiding this comment

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

All looks great, thank you! We should eventually be able to simplify it using some of the new HOL Light library material like poly_recip, but all the results seem sound.

@jargh jargh merged commit 7bd7c8c into awslabs:main May 22, 2026
15 of 23 checks passed
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.

3 participants