pylint
This commit is contained in:
parent
ce7c7cfb39
commit
9df19eb154
|
@ -33,7 +33,7 @@ def find_group_hash(D, M):
|
|||
if p:
|
||||
return p
|
||||
i += 1
|
||||
assert(i < 256)
|
||||
assert i < 256
|
||||
|
||||
|
||||
#
|
||||
|
|
|
@ -5,7 +5,7 @@ q_j = 52435875175126190479447740508185965837690552500527637822603658699938581184
|
|||
r_j = 6554484396890773809930967563523245729705921265872317281365359162392183254199
|
||||
|
||||
qm1d2 = 26217937587563095239723870254092982918845276250263818911301829349969290592256
|
||||
assert((q_j - 1) // 2 == qm1d2)
|
||||
assert (q_j - 1) // 2 == qm1d2
|
||||
|
||||
|
||||
#
|
||||
|
@ -28,7 +28,7 @@ class FieldElement(object):
|
|||
return self.t(self.s * a.s)
|
||||
|
||||
def __truediv__(self, a):
|
||||
assert(a.s != 0)
|
||||
assert a.s != 0
|
||||
return self * a.inv()
|
||||
|
||||
def exp(self, e):
|
||||
|
@ -84,11 +84,11 @@ class Fq(FieldElement):
|
|||
while t2i != self.ONE:
|
||||
t2i = t2i * t2i
|
||||
i += 1
|
||||
assert(i < m)
|
||||
assert i < m
|
||||
|
||||
# 9:
|
||||
# w <- z^(2^(v-k-1))
|
||||
for j in range(0, m - i - 1):
|
||||
for _ in range(0, m - i - 1):
|
||||
c = c * c
|
||||
# b <- bz
|
||||
r = r * c
|
||||
|
@ -98,12 +98,11 @@ class Fq(FieldElement):
|
|||
t = t * c
|
||||
# v <- k
|
||||
m = i
|
||||
assert(r * r == self)
|
||||
assert r * r == self
|
||||
return r
|
||||
elif a == self.MINUS_ONE:
|
||||
return None
|
||||
else:
|
||||
return self.ZERO
|
||||
return self.ZERO
|
||||
|
||||
|
||||
class Fr(FieldElement):
|
||||
|
@ -187,4 +186,4 @@ class Point(object):
|
|||
|
||||
Point.ZERO = Point(Fq.ZERO, Fq.ONE)
|
||||
|
||||
assert(Point.ZERO + Point.ZERO == Point.ZERO)
|
||||
assert Point.ZERO + Point.ZERO == Point.ZERO
|
||||
|
|
|
@ -74,7 +74,7 @@ class SpendingKey(object):
|
|||
if group_hash(b'Zcash_gd', d):
|
||||
return d
|
||||
i += 1
|
||||
assert(i < 256)
|
||||
assert i < 256
|
||||
|
||||
@cached
|
||||
def default_pkd(self):
|
||||
|
@ -127,19 +127,18 @@ def main():
|
|||
%s
|
||||
],
|
||||
},''' % (
|
||||
chunk(hexlify(sk.data)),
|
||||
chunk(hexlify(bytes(sk.ask()))),
|
||||
chunk(hexlify(bytes(sk.nsk()))),
|
||||
chunk(hexlify(sk.ovk())),
|
||||
chunk(hexlify(bytes(sk.ak()))),
|
||||
chunk(hexlify(bytes(sk.nk()))),
|
||||
chunk(hexlify(bytes(sk.ivk()))),
|
||||
chunk(hexlify(sk.default_d())),
|
||||
chunk(hexlify(bytes(sk.default_pkd()))),
|
||||
))
|
||||
chunk(hexlify(sk.data)),
|
||||
chunk(hexlify(bytes(sk.ask()))),
|
||||
chunk(hexlify(bytes(sk.nsk()))),
|
||||
chunk(hexlify(sk.ovk())),
|
||||
chunk(hexlify(bytes(sk.ak()))),
|
||||
chunk(hexlify(bytes(sk.nk()))),
|
||||
chunk(hexlify(bytes(sk.ivk()))),
|
||||
chunk(hexlify(sk.default_d())),
|
||||
chunk(hexlify(bytes(sk.default_pkd()))),
|
||||
))
|
||||
print(' ];')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#!/usr/bin/env python3
|
||||
from sapling_generators import find_group_hash, NOTE_POSITION_BASE, WINDOWED_PEDERSEN_RANDOMNESS_BASE
|
||||
from sapling_generators import (
|
||||
find_group_hash,
|
||||
NOTE_POSITION_BASE,
|
||||
WINDOWED_PEDERSEN_RANDOMNESS_BASE,
|
||||
)
|
||||
from sapling_jubjub import Fr, Point
|
||||
from sapling_utils import cldiv, i2leosp
|
||||
|
||||
|
@ -18,7 +22,7 @@ def encode_chunk(mj):
|
|||
def encode_segment(Mi):
|
||||
ki = len(Mi) // 3
|
||||
Michunks = [Mi[i:i+3] for i in range(0, len(Mi), 3)]
|
||||
assert(len(Michunks) == ki)
|
||||
assert len(Michunks) == ki
|
||||
return Fr(sum([encode_chunk(Michunks[j-1]) * 2**(4*(j-1)) for j in range(1, ki + 1)]))
|
||||
|
||||
c = 63
|
||||
|
@ -26,10 +30,10 @@ c = 63
|
|||
def pedersen_hash_to_point(D, M):
|
||||
# Pad M to a multiple of 3 bits
|
||||
Mdash = M + [0] * ((-len(M)) % 3)
|
||||
assert((len(Mdash) // 3) * 3 == len(Mdash))
|
||||
assert (len(Mdash) // 3) * 3 == len(Mdash)
|
||||
n = cldiv(len(Mdash), 3 * c)
|
||||
Msegs = [Mdash[i:i+(3*c)] for i in range(0, len(Mdash), 3*c)]
|
||||
assert(len(Msegs) == n)
|
||||
assert len(Msegs) == n
|
||||
return sum([I_D_i(D, i) * encode_segment(Msegs[i-1]) for i in range(1, n + 1)], Point.ZERO)
|
||||
|
||||
def pedersen_hash(D, M):
|
||||
|
|
Loading…
Reference in New Issue