1

让我们考虑以下示例。使用 Python 库 tinyec 我可以编写以下代码:

def compress(pubKey):
     return hex(pubKey.x) + hex(pubKey.y % 2)[2:]


curve = registry.get_curve('brainpoolP256r1')
alicePrivKey = secrets.randbelow(curve.field.n)
alicePubKey = alicePrivKey * curve.g
bobPrivKey = secrets.randbelow(curve.field.n)
bobPubKey = bobPrivKey * curve.g

print("Now exchange the public keys (e.g. through Internet)")

aliceSharedKey = alicePrivKey * bobPubKey
print("Alice shared key:", compress(aliceSharedKey))

bobSharedKey = bobPrivKey * alicePubKey

通过这种方式,Alice 和 Bob 能够通过 Internet 导出共享秘密。现在,我需要知道是否可以对 ed25519 曲线做同样的事情,因为我找不到任何类型的库。

因此,我有兴趣找到一种安全地进行此类操作的方法。我该怎么办?此特定操作的最佳实践是什么?

谢谢

4

0 回答 0