mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-08 22:28:12 -05:00
calculate function divisor for adding 2 points
This commit is contained in:
@@ -26,6 +26,7 @@ def degree(D):
|
||||
def neg(D):
|
||||
return tuple((-order, pnt) for order, pnt in D)
|
||||
|
||||
# This means D1 ~ D2 because D1 - D2 ∈ Pic(E)
|
||||
D = D1 + neg(D2)
|
||||
assert degree(D) == 0
|
||||
assert dsum(D) == inf
|
||||
|
||||
31
script/research/ec/pairing/3.1.3-divlines.sage
Normal file
31
script/research/ec/pairing/3.1.3-divlines.sage
Normal file
@@ -0,0 +1,31 @@
|
||||
q = 47
|
||||
Fq = GF(q)
|
||||
E = EllipticCurve(Fq, (0, 5))
|
||||
|
||||
R.<x, y> = PolynomialRing(Fq)
|
||||
|
||||
def add(P, Q):
|
||||
Px, Py = P[0], P[1]
|
||||
Qx, Qy = Q[0], Q[1]
|
||||
# We don't handle this case yet :p
|
||||
assert Px != Qx
|
||||
gradient = (Qy - Py) / (Qx - Px)
|
||||
intersect = Py - gradient * Px
|
||||
f = y - gradient * x - intersect
|
||||
assert f(Px, Py) == 0
|
||||
assert f(Qx, Qy) == 0
|
||||
R = P + Q
|
||||
Rx, Ry = R[0], R[1]
|
||||
assert f(Rx, -Ry) == 0
|
||||
g = x - Rx
|
||||
assert g(Rx, Ry) == g(Rx, -Ry) == 0
|
||||
return f / g
|
||||
|
||||
P = E(33, 9)
|
||||
Q = E(34, 39)
|
||||
# div(f) = [P] + [Q] - [P + Q] - [∞] ∈ Pic(E)
|
||||
# = ([P] + [Q] - 2[∞]) - ([P + Q] - [∞])
|
||||
# => [P] + [Q] - 2[∞] ~ [P + Q] - [∞]
|
||||
f = add(P, Q)
|
||||
print(f)
|
||||
|
||||
Reference in New Issue
Block a user