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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...