Replies: 2 comments 1 reply
-
You've made a lot of progress! The key insight is that when putting together a secure computation workflow, you cannot have the number of iterations depend on a secret input. This would leak information about the input to the nodes performing the computation (since they know how many iterations occur when they execute a program). Thus, the approach is to rewrite the body of the loop so that the number of iterations is always some fixed, sufficiently large value. However, in that case it is also necessary to perform the assignments inside the body based on a condition (i.e., the original condition from the The Python code below illustrates how you might go about finishing your program:
Good luck! |
Beta Was this translation helpful? Give feedback.
-
In case it may be an option for your problem, Nada works in a prime modular field. In case you can set PRIME_64 = 18446744072637906947
PRIME_128 = 340282366920938463463374607429104828419
PRIME_256 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF98C00003
PRIME = PRIME_64
def public_modular_inverse(
value: Integer | UnsignedInteger, modulo: int
) -> PublicUnsignedInteger | UnsignedInteger:
"""
Calculates the modular inverse of a public value with respect to a prime modulus.
Args:
`value`: The value for which the modular inverse is to be calculated.
`modulo`: The prime modulo with respect to which the modular inverse is to be calculated.
Returns:
The modular inverse of the value with respect to the modulo.
"""
return value ** UnsignedInteger(modulo - 2)
def nada_main():
...
a = UnsignedInteger(16)
a_inv = public_modular_inverse(a)
... |
Beta Was this translation helpful? Give feedback.
-
Need help in calculating Multiplicative inverse of two numbers
Current Progress: I am able to calculate reciprocals in nada using following code
the pseudo code of Extended Euclidean Multiplicative Inverse is
and here is my nada implementation
The Problems:
iterations≈ log ϕ (min(10,3))
but that cannot be computed in nada program.
Beta Was this translation helpful? Give feedback.
All reactions