我很抱歉,如果这是显而易见的,但事实是,我对此感到困惑。
我正在研究用于Ed25519的RFC 8032测试向量,我对该文件第7.1节中提供的信息有一些疑问。在本节的顶部,可以找到以下数据:
SECRET KEY:
9d61b19deffd5a60ba844af492ec2cc4
4449c5697b326919703bac031cae7f60
PUBLIC KEY:
d75a980182b10ab7d54bfed3c964073a
0ee172f3daa62325af021a68f707511a我的理解是,密钥是一个随机生成的64个字节的字符串,其中的前32个字节将被进一步操作。根据RFC中描述的一些规则,结果字符串被解释为整数,然后通过将秘密密钥指定的次数添加到自己中的选定基点来获取公钥。
我的问题如下:
要以不同的方式提出上述两个问题,公钥是否通过向自身添加基点0x9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60时间来获得?
发布于 2021-02-03 00:32:28
因此,您有需要使用SHA-512散列的32字节私钥。
1. Prune the buffer: The lowest three bits of the first octet are cleared, the highest bit of the last octet is cleared, and the second highest bit of the last octet is set.这是用于SHA-512的较低的32字节输出。
1. Interpret the buffer as the little-endian integer, forming a secret scalar s. Perform a fixed-base scalar multiplication [s]B. # Points are represented as tuples (X, Y, Z, T) of extended
# coordinates, with x = X/Z, y = Y/Z, x*y = T/Z
def point_compress(P):
zinv = modp_inv(P[2])
x = P[0] * zinv % p
y = P[1] * zinv % p
return int.to_bytes(y | ((x & 1) << 255), 32, "little")
def point_decompress(s):
if len(s) != 32:
raise Exception("Invalid input length for decompression")
y = int.from_bytes(s, "little")
sign = y >> 255
y &= (1 << 255) - 1
x = recover_x(y, sign)
if x is None:
return None
else:
return (x, y, 1, x*y % p)
## These are functions for manipulating the private key.
def secret_expand(secret):
if len(secret) != 32:
raise Exception("Bad size of private key")
h = sha512(secret)
a = int.from_bytes(h[:32], "little")
a &= (1 << 254) - 8
a |= (1 << 254)
return (a, h[32:])
def secret_to_public(secret):
(a, dummy) = secret_expand(secret)
return point_compress(point_mul(a, G))https://crypto.stackexchange.com/questions/87960
复制相似问题