如何解决ed25519共享密协议的python实现
让我们考虑以下示例。使用 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 曲线做同样的事情,因为我找不到任何类型的库。
所以,我有兴趣找到一种安全地进行此类操作的方法。我怎么办?此特定操作的最佳做法是什么?
谢谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。