更改默认哈希函数以进行块哈希

时间:2018-09-05 22:33:04

标签: hash hyperledger-fabric hyperledger

我对HF非常陌生,我应该为大学项目研究这个平台。分配的第一件事是了解Fabric的来源,尤其是查找在何处创建块,以及以哪种方式可以更改用于块创建的默认哈希函数。

我找到了一些可能是感兴趣的文件,但是我是该平台的新手,我真的不知道从哪里获取此类信息。

我找到了:

  1. https://github.com/hyperledger/fabric/blob/release-1.2/common/ledger/blockledger/util.go CreateNewBlock 函数
  2. https://github.com/hyperledger/fabric/blob/release-1.2/protos/common/block.go

有帮助吗?谢谢。

2 个答案:

答案 0 :(得分:1)

根据文档,当前SHA256是唯一有效的算法。在某些地方进行了硬编码。

但是,您可以做一些实验,下面是您可能要研究的一些配置地方- peerorderer节点以及channel configuration Hashing Algorithm part的BCCSP配置。

BCCSP配置区块链加密服务提供商。

BCCSP:
    # Default specifies the preferred blockchain crypto service provider
    # to use. If the preferred provider is not available, the software
    # based provider ("SW") will be used.
    # Valid providers are:
    #  - SW: a software based crypto provider
    #  - PKCS11: a CA hardware security module crypto provider.
    Default: SW

    # SW configures the software based blockchain crypto provider.
    SW:
        # TODO: The default Hash and Security level needs refactoring to be
        # fully configurable. Changing these defaults requires coordination
        # SHA2 is hardcoded in several places, not only BCCSP
        Hash: SHA2
        Security: 256
        # Location of key store. If this is unset, a location will be
        # chosen using: 'LocalMSPDir'/keystore
        FileKeyStore:
            KeyStore:

答案 1 :(得分:1)

我找到了解决方法。

可以这样做,可以通过替换

中的哈希函数来完成
protos/common/block.go

文件,正如我在帖子中所说的;)

相关问题