I want to compute the multiplicative inverse of 0x2
over $GF(2^{233})$ in hardware.
To do so, I compute $a^{-1} = (a^{2^{m-1}-1})^{2}$. Here's the result of that computation:
0x10000000000000000000000000000000000000002000000000000000000
(where the left-most 1 is bit index 233, not 232).
I verify that I get 1
by multiplying it with the initial number using a binary Karatsuba multiplier.
I'm also able to verify that I can perform a point multiplication over SECT233R1
against this python library.
Here's my question. The result of point multiplication on my hardware is coherent with that of the python library (point multiplication $Q = k*G$), but the result of just the inverse sub-module isn't.
For example, if I use the hazmat math library, I get the inverse of 0x2
to be 0x800000000000000000000000000009f4ba7397c53491018e9301e7f06c
.
(the left-most 1 is in 0x8 which is 0b0100 which is the 232th bit)
Here's how I do that:
value_S = 0x2
object_S = ec.derive_private_key(value_S, ec.SECT233R1(), default_backend())
object_SINV = ops.BN_MOD_INVERSE(object_S)
vals = object_SINV.private_numbers()
print (f"SINV value: {hex(vals.private_value)}.")
My question is why I don't see the same value for $s^{-1}$ in my hardware, and in the python library, when they both give the same result for point multiplication.
Can someone please help me understand what I'm missing? Thanks in advance!