Skip to main content

Module montgomery

Module montgomery 

Source
Expand description

Montgomery form conversion for field elements.

The hardware operates in Montgomery domain with R = 2^128. This module provides conversion between standard and Montgomery representations.

In Montgomery form, an element a is represented as aR mod p. Montgomery multiplication: MontMul(aR, bR) = abR mod p.

This reference implementation stores the standard value internally and performs standard arithmetic for correctness. The Montgomery representation is available via MontgomeryElement::to_mont_repr for comparison with hardware outputs.

Structs§

MontgomeryElement
A field element that tracks both standard and Montgomery forms.

Constants§

MONT_BITS 🔒
Number of bits in the Montgomery constant R.

Functions§

halve_mod_p 🔒
Halves a field element modulo p.