我知道我的代数是生锈的,但不是以下的身份操作:将GF的元素乘以字段的基数(模数)?我写了一个程序来验证它,但不能:
from ecpy.curves import Curve, Point # I use Python 2.7
def bin256(num):
"""binary conversion, returns a binary string, MSB first and LSB last"""
return '{:0256b}'.format(num)
def ec_multiply(P, d):
"""double-and-add algo. Index decreasing, same naming as Wikipedia:
P is a point on the curve
d is a long
returns P*d"""
Q = None
for bit in map(int, bin256(d)):
if Q is not None:
Q = Q + Q
if bit:
if Q is None:
Q = P
else:
Q = Q + P
return Q
def main():
"""Picks a random point on secp256k1 and multiply it by the modulus
of secp256k1 and print the result."""
cv = Curve.get_curve('secp256k1')
N = Point(0x65d5b8bf9ab1801c9f168d4815994ad35f1dcb6ae6c7a1a303966b677b813b00,
0xe6b865e529b8ecbf71cf966e900477d49ced5846d7662dd2dd11ccd55c0aff7f, cv)
MODULUS = 2**256 - 2**32 - 2**9 - 2**8 - 2**7 - 2**6 - 2**4 - 1
Q = ec_multiply(N, MODULUS)
print 'Q: %064x %064x' % (Q.x, Q.y)
if __name__ == '__main__':
main()
但我有不同的观点:
Q: d113d66bf911fbf026b2a3e24c96bba45ca2d2b130cbf312a36e584249153090 56cabae3704f1c5a7957cbb1d9e2f6198337c59c02b2974d32fb7501b7e287d2
我期待Q: 65d5b8bf..., e6b865e5...
。
任何想法为什么乘以模数都无法在 secp256k1 中工作?提前致谢。
注意: