Skip to content
Yuxiang LIU edited this page Jul 30, 2020 · 14 revisions
  • Fabric:bccsp

    • 接口定义于
    • bccsp接口方法解析
      • KeyGen(opts KeyGenOpts) (k Key, err error)

        • 暂时只用于idemix
      • KeyDeriv(k Key, opts KeyDerivOpts) (dk Key, err error)

        • 暂时只用于idemix
      • KeyImport(raw interface{}, opts KeyImportOpts) (k Key, err error)

        • 将key从原始的表达形式导入并生成Key对象
      • GetKey(ski []byte) (k Key, err error)

        • 根据SKI获取Key,通常情况用于从KeyStore中获取已保存的Key
      • Hash(msg []byte, opts HashOpts) (hash []byte, err error)

        • 进行哈希计算
      • GetHash(opts HashOpts) (h hash.Hash, err error)

        • 获取用于哈希计算的函数
      • Sign(k Key, digest []byte, opts SignerOpts) (signature []byte, err error)

        • 注意,当需要对哈希进行签名时,调用者需要自己先进行哈希计算,将结果作为digest传入
      • Verify(k Key, signature, digest []byte, opts SignerOpts) (valid bool, err error)

      • Encrypt(k Key, plaintext []byte, opts EncrypterOpts) (ciphertext []byte, err error)

      • Decrypt(k Key, ciphertext []byte, opts DecrypterOpts) (plaintext []byte, err error)

    • Key接口方法: SKI() []byte // 返回该Key对应的subject key identifier
      • SKI生成方式可考虑使用基础库中SM3对Key Bytes进行哈希计算
  • 接口实现导入方式

    • 源码import + Conditional Build
    • 替换vendor
  • Switch hardcode: 通过map pattern改写

    • csp.KeyImporters[reflect.TypeOf(opts)]
  • 多次配置

    msp:"crypto_config": { "identity_identifier_hash_function": "SHA256", "signature_hash_family": "SHA2" }, "HashingAlgorithm": { "mod_policy": "Admins", "value": { "name": "SHA256" }, "version": "0" },

    peer 节点的bccsp