问题描述
我知道我可以在 hypersdk 中使用 myCore.key
和 myCore.discoveryKey
但如果您只有一个十六进制字符串形式的密钥(例如“778f8d955175c92e4ced5e4f5563f69bfec0c86cc6f670352c457943666fe639”),您将如何获得发现密钥?
超核心协议模块之一中是否有便利功能?
注意,the discovery key is the blake2b-256 hash of the public key。
解决方法
我使用了 hypercore-crypto
模块:
@Override
public void onActivityResult(int requestCode,int resultCode,final Intent data) {
super.onActivityResult(requestCode,resultCode,data);
}
给出一个发现密钥:
const crypto = require('hypercore-crypto')
let publicKey = "778f8d955175c92e4ced5e4f5563f69bfec0c86cc6f670352c457943666fe639"
let discoveryKey = crypto.discoveryKey(Buffer.from(publicKey,'hex')).toString('hex');