Unverified Commit f4226bc5 authored by Sofia Celi's avatar Sofia Celi

Remove unused code that refers to cofactor of 8 on ristretto

parent a21e1fcf
......@@ -147,7 +147,6 @@ class RistrettoPoint(QuotientEdwardsPoint):
def encodeSpec(self):
"""Unoptimized specification for encoding"""
x,y = self
if self.cofactor==8 and (negative(x*y) or y==0): (x,y) = self.torque()
if y == -1: y = 1 # Avoid divide by 0; doesn't affect impl
if negative(x): x,y = -x,-y
......@@ -163,9 +162,6 @@ class RistrettoPoint(QuotientEdwardsPoint):
x = xsqrt(4*s^2 / (a*d*(1+a*s^2)^2 - (1-a*s^2)^2))
y = (1+a*s^2) / (1-a*s^2)
if cls.cofactor==8 and (negative(x*y) or y==0):
raise InvalidEncodingException("x*y has high bit")
return cls(x,y)
@optimized_version_of("encodeSpec")
......@@ -215,9 +211,6 @@ class RistrettoPoint(QuotientEdwardsPoint):
if negative(x): x = -x
y = ynum * yden_inv
if cls.cofactor==8 and (negative(x*y) or y==0):
raise InvalidEncodingException("x*y is invalid: %d, %d" % (x,y))
return cls(x,y)
@classmethod
......@@ -262,7 +255,6 @@ class RistrettoPoint(QuotientEdwardsPoint):
if negative(s) == iss: s = -s
return cls.fromJacobiQuartic(s,t)
class Decaf_1_1_Point(QuotientEdwardsPoint):
"""Like current decaf but tweaked for simplicity"""
def encodeSpec(self):
......@@ -271,9 +263,6 @@ class Decaf_1_1_Point(QuotientEdwardsPoint):
x,y = self
if x==0 or y==0: return(self.gfToBytes(0))
if self.cofactor==8 and negative(x*y*self.isoMagic):
x,y = self.torque()
sr = xsqrt(1-a*x^2)
altx = x*y*self.isoMagic / sr
if negative(altx): s = (1+sr)/x
......@@ -294,9 +283,6 @@ class Decaf_1_1_Point(QuotientEdwardsPoint):
x = 2*s / (1+a*s^2)
y = (1-a*s^2) / t
if cls.cofactor==8 and (negative(x*y*cls.isoMagic) or y==0):
raise InvalidEncodingException("x*y is invalid: %d, %d" % (x,y))
return cls(x,y)
def toJacobiQuartic(self,toggle_rotation=False,toggle_altx=False,toggle_s=False):
......@@ -332,7 +318,7 @@ class Decaf_1_1_Point(QuotientEdwardsPoint):
rets = []
tr = [False,True] if self.cofactor == 8 else [False]
tr = [False,True] if self.cofactor != 4 else [False]
for toggle_rotation in tr:
for toggle_altx in [False,True]:
for toggle_s in [False,True]:
......@@ -344,7 +330,6 @@ class Decaf_1_1_Point(QuotientEdwardsPoint):
#print m1
#print m12
if self == self.__class__():
if self.cofactor == 4:
# Hacks for identity!
......@@ -402,9 +387,6 @@ class Decaf_1_1_Point(QuotientEdwardsPoint):
x = 2*s *isr^2*den*num
y = (1-a*s^2) * isr*den
if cls.cofactor==8 and (negative(x*y*cls.isoMagic) or y==0):
raise InvalidEncodingException("x*y is invalid: %d, %d" % (x,y))
return cls(x,y)
@classmethod
......@@ -567,7 +549,6 @@ def test(cls,n):
except NotOnCurveException: pass
except InvalidEncodingException: pass
P = cls.base()
Q = cls()
for i in xrange(n):
......@@ -582,8 +563,6 @@ def test(cls,n):
ss = cls.gfToBytes(1/s,mustBePositive=True)
try:
QN = cls.decode(ss)
if cls.cofactor == 8:
raise TestFailedException("1/s shouldnt work for cofactor 8")
if QN != -Q:
raise TestFailedException("s -> 1/s should negate point for cofactor 4")
except InvalidEncodingException as e:
......@@ -671,6 +650,7 @@ def testDoubleAndEncode(cls,n):
testDoubleAndEncode(IsoEd448Point,100)
testDoubleAndEncode(TwistedEd448GoldilocksPoint,100)
# uncomment to see it work, but it is wip
#test(IsoEd448Point,100)
#test(TwistedEd448GoldilocksPoint,100)
#test(Ed448GoldilocksPoint,100)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment