You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
p521: initial Scalar with fiat-crypto arithmetic (RustCrypto#760)
Adds a scalar field implementation generated by fiat-crypto, run with
the following arguments:
$ ./word_by_word_montgomery --lang Rust --inline p521_scalar 64 '0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409'
The output has been postprocessed by the `fiat-constify` utility, which
rewrites the functions in the fiat-crypto output as `const fn`.
Only a 64-bit implementation has been synthesized. I encountered a stack
overflow when attempting a 32-bit one.
Constants for the `PrimeField` impl were calculated in `sage` as
follows:
sage: p = 0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f7
....: 09a5d03bb5c9b8899c47aebb6fb71e91386409
sage: multiplicative_generator = GF(p).primitive_element()
sage: p_minus_1_bin = (p - 1).binary()
sage: s = len(p_minus_1_bin) - len(p_minus_1_bin.rstrip('0')) # count trailing zeros in binary
sage: t = (p - 1) >> s
sage: root_of_unity = pow(multiplicative_generator,t,p)
sage: delta = pow(multiplicative_generator, 2^s, p)
sage: multiplicative_generator
3
sage: p_minus_1_bin
'11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110100101000110000110100001111000001110111111001011111001011001101011011111111100110000000001010010001111011100001001101001011101000000111011101101011100100110111000100010011001110001000111101011101011101101101111101101110001111010010001001110000110010000001000'
sage: s
3
sage: hex(t)
'0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff4a30d0f077e5f2cd6ff980291ee134ba0776b937113388f5d76df6e3d2270c81'
sage: hex(root_of_unity)
'0x9a0a650d44b28c17f3d708ad2fa8c4fbc7e6000d7c12dafa92fcc5673a3055276d535f79ff391dcdbcd998b7836647d3a72472b3da861ac810a7f9c7b7b63e2205'
sage: delta
6561
0 commit comments