Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Inverse of a number module 2**255 -19

I don't understand this code to solve the inverse of a number:

b = 256;
q = 2**255 - 19

def expmod(b,e,m): 
    if e == 0: return 1
    t = expmod(b,e/2,m)**2 % m
    if e & 1: t = (t*b) % m
    return t

def inv(x):
   return expmod(x,q-2,q)`

Finally, If I want to put: $\frac{2}{3}$ I can to do this: aux=2*inv(3)

What does the variable e mean?

Could you explain me this code, please?

Thank you so much.

Inverse of a number module 2**255 -19

I don't understand this code to solve the inverse of a number:

b = 256;
q = 2**255 - 19

def expmod(b,e,m): 
    if e == 0: return 1
    t = expmod(b,e/2,m)**2 % m
    if e & 1: t = (t*b) % m
    return t

def inv(x):
   return expmod(x,q-2,q)`

Finally, If I want to put: $\frac{2}{3}$ I can to do this: aux=2*inv(3)

What does the variable e mean?

Could you explain me this code, please?

Thank you so much.