orchard_vesta.py: Undo renaming of p and q.
This commit is contained in:
parent
4cbfddd566
commit
35fbc5d7b2
|
@ -5,15 +5,15 @@ import sys; assert sys.version_info[0] >= 3, "Python 3 required."
|
||||||
from sapling_jubjub import FieldElement
|
from sapling_jubjub import FieldElement
|
||||||
from utils import leos2ip
|
from utils import leos2ip
|
||||||
|
|
||||||
p = 0x40000000000000000000000000000000224698fc0994a8dd8c46eb2100000001
|
q = 0x40000000000000000000000000000000224698fc0994a8dd8c46eb2100000001
|
||||||
q = 0x40000000000000000000000000000000224698fc094cf91b992d30ed00000001
|
p = 0x40000000000000000000000000000000224698fc094cf91b992d30ed00000001
|
||||||
|
|
||||||
pm1d2 = 0x2000000000000000000000000000000011234c7e04ca546ec623759080000000
|
qm1d2 = 0x2000000000000000000000000000000011234c7e04ca546ec623759080000000
|
||||||
assert (p - 1) // 2 == pm1d2
|
assert (q - 1) // 2 == qm1d2
|
||||||
|
|
||||||
S = 32
|
S = 32
|
||||||
T = 0x40000000000000000000000000000000224698fc0994a8dd8c46eb21
|
T = 0x40000000000000000000000000000000224698fc0994a8dd8c46eb21
|
||||||
assert (p - 1) == (1 << S) * T
|
assert (q - 1) == (1 << S) * T
|
||||||
|
|
||||||
tm1d2 = 0x2000000000000000000000000000000011234c7e04ca546ec6237590
|
tm1d2 = 0x2000000000000000000000000000000011234c7e04ca546ec6237590
|
||||||
assert (T - 1) // 2 == tm1d2
|
assert (T - 1) // 2 == tm1d2
|
||||||
|
@ -39,7 +39,7 @@ class Fq(FieldElement):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def __init__(self, s, strict=False):
|
def __init__(self, s, strict=False):
|
||||||
FieldElement.__init__(self, Fq, s, p, strict=strict)
|
FieldElement.__init__(self, Fq, s, q, strict=strict)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return 'Fq(%s)' % self.s
|
return 'Fq(%s)' % self.s
|
||||||
|
@ -51,7 +51,7 @@ class Fq(FieldElement):
|
||||||
def sqrt(self):
|
def sqrt(self):
|
||||||
# Tonelli-Shank's algorithm for p mod 16 = 1
|
# Tonelli-Shank's algorithm for p mod 16 = 1
|
||||||
# https://eprint.iacr.org/2012/685.pdf (page 12, algorithm 5)
|
# https://eprint.iacr.org/2012/685.pdf (page 12, algorithm 5)
|
||||||
a = self.exp(pm1d2)
|
a = self.exp(qm1d2)
|
||||||
if a == self.ONE:
|
if a == self.ONE:
|
||||||
# z <- c^t
|
# z <- c^t
|
||||||
c = Fq(ROOT_OF_UNITY)
|
c = Fq(ROOT_OF_UNITY)
|
||||||
|
@ -92,7 +92,7 @@ class Fq(FieldElement):
|
||||||
|
|
||||||
class Scalar(FieldElement):
|
class Scalar(FieldElement):
|
||||||
def __init__(self, s, strict=False):
|
def __init__(self, s, strict=False):
|
||||||
FieldElement.__init__(self, Scalar, s, q, strict=strict)
|
FieldElement.__init__(self, Scalar, s, p, strict=strict)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return 'Scalar(%s)' % self.s
|
return 'Scalar(%s)' % self.s
|
||||||
|
|
Loading…
Reference in New Issue