Пример #1
0
def add(p, q, n):

    a = 1
    lamda = 0

    if p == q:
        lamda = (3 * p[0]**2 + a) * xgcd(2 * p[1], n)[0]
    else:
        lamda = (q[1] - p[1]) * xgcd(q[0] - p[0], n)[0]

    lamda = lamda % n

    x3 = (lamda**2 - p[0] - q[0]) % n
    y3 = (lamda * (p[0] - x3) - p[1]) % n

    return [x3, y3]
Пример #2
0
def add(p,q,n):

	a = 1
	lamda = 0;

	if p == q:
		lamda = (3*p[0]**2 + a) * xgcd(2*p[1],n)[0]
	else: 
		lamda = (q[1] - p[1]) * xgcd(q[0] - p[0],n)[0] 

	lamda = lamda % n

	x3 = (lamda**2 - p[0] - q[0]) % n
	y3 = (lamda*(p[0] - x3) - p[1]) % n

	return [x3,y3]
Пример #3
0
def inv(x,p): return xgcd(x,p)[0];

def log(p,n,alpha,beta,q,c):
Пример #4
0
def inv(x, p):
    return xgcd(x, p)[0]