【问题标题】:Offline Transaction Signing with Fabric Node SDK使用 Fabric 节点 SDK 进行离线交易签名
【发布时间】:2021-09-15 21:07:15
【问题描述】:

是否有人使用 Fabric Node SDK 的当前 master(2.2 版)的教程成功实现了离线交易签名? 我正在按照这些教程进行提案构建和提案的离线签名。

v2.2:https://hyperledger.github.io/fabric-sdk-node/master/tutorial-sign-transaction-offline.html https://github.com/BLOCKOTUS/hyperledger-fabric-offline-transaction-signing

我遇到以下错误

2021-09-15T11:37:15.283Z - error: [Endorser]: sendProposal[peer0.org2.example.com:9051] - Received error response from: grpcs://localhost:9051 error: Error: 2 UNKNOWN: error validating proposal: access denied: channel [mychannel] creator org [Org1MSP]
2021-09-15T11:37:15.283Z - error: [Endorser]: sendProposal[peer0.org2.example.com:9051] - rejecting with: Error: 2 UNKNOWN: error validating proposal: access denied: channel [mychannel] creator org [Org1MSP]
2021-09-15T11:37:15.284Z - error: [Endorser]: sendProposal[peer0.org1.example.com:7051] - Received error response from: grpcs://localhost:7051 error: Error: 2 UNKNOWN: error validating proposal: access denied: channel [mychannel] creator org [Org1MSP]
2021-09-15T11:37:15.284Z - error: [Endorser]: sendProposal[peer0.org1.example.com:7051] - rejecting with: Error: 2 UNKNOWN: error validating proposal: access denied: channel [mychannel] creator org [Org1MSP]

并在对等日志中记录以下日志

2021-09-15 11:37:15.282 UTC [endorser] Validate -> WARN 097 access denied: creator's signature over the proposal is not valid: The signature is invalid channel=mychannel txID=1b2ca125 mspID=Org1MSP

感谢任何想法。

【问题讨论】:

    标签: hyperledger-fabric hyperledger hyperledger-fabric-ca


    【解决方案1】:

    您的代码看起来与教程中描述的步骤有些不同。您将哈希生成为:

    const proposalBytes = endorsement.build(idx, build_options);
    const proposalDigest = user.getCryptoSuite().hash(proposalBytes.toString(), { algorithm: 'SHA2' });
    

    您需要确切消息字节的 SHA256 哈希,而不是转换为字符串。所以使用 Node 的 crypto 库,类似于:

    const digest = crypto.createHash('sha256').update(proposalBytes).digest();
    

    elliptic 包的最新版本可以通过指定 canonical 选项来防止您的延展性,例如:

    const curve = new EC('p256');
    const keyPair = curve.keyFromPrivate(prvKeyHex, 'hex');
    const signature = curve.sign(digest, keyPair, { canonical: true });
    const signatureBytes = Buffer.from(signature.toDER());
    

    【讨论】:

      猜你喜欢
      • 2020-04-30
      • 1970-01-01
      • 2023-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多