【问题标题】:Hypercore Protocol: Function to get hypercore discovery key from a public key超核协议:从公钥获取超核发现密钥的功能
【发布时间】:2021-05-26 14:54:51
【问题描述】:

是否有一个方便的函数可以从它的公钥中获取超核的发现密钥?

我知道我可以在hypersdk 中使用myCore.keymyCore.discoveryKey

但如果您只有一个十六进制字符串形式的密钥(例如“778f8d955175c92e4ced5e4f5563f69bfec0c86cc6f670352c457943666fe639”),您将如何获得发现密钥?

其中一个超核协议模块中是否有便利功能?

注意,the discovery key is the blake2b-256 hash of the public key

【问题讨论】:

    标签: javascript node.js hash hypercore-protocol


    【解决方案1】:

    我使用了hypercore-crypto 模块:

    const crypto = require('hypercore-crypto')
    let publicKey = "778f8d955175c92e4ced5e4f5563f69bfec0c86cc6f670352c457943666fe639"
    let discoveryKey = crypto.discoveryKey(Buffer.from(publicKey, 'hex')).toString('hex');
    

    提供以下发现密钥:

    "25a78aa81615847eba00995df29dd41d7ee30f3b01f892209f79b75a57d989e1"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-06
      • 2012-07-13
      相关资源
      最近更新 更多