区块链加密服务商 (Blockchain Cryptographic Service Provider, BCCSP)
1. 介绍
bccsp
是fabric总结的概念,我在这一节主要就是介绍fabric
里的bccsp
开发细节,供所有区块链爱好者学习交流。
另外,我在GitHub上创建了一个仓库,专门用来学习fabric-2.3.0,欢迎大家多多⭐️。
2. bccsp包的内部细节
尽量详细的介绍fabric
项目中bccsp
包里代码的设计思路。
2.1 实现BCCSP需要实现哪些接口?
要想实现BCCSP
的功能,那么我们需要实现以下给出的接口:
type BCCSP interface {
KeyGen(opts KeyGenOpts) (key Key, err error)
KeyDerive(key Key, opts KeyDeriveOpts) (dk Key, err error)
KeyImport(raw interface{}, opts KeyImportOpts) (key Key, err error)
GetKey(ski []byte) (key Key, err error)
Hash(msg []byte, opts HashOpts) ([]byte, error)
GetHash(opts HashOpts) (hash hash.Hash, err error)
Sign(key Key, digest []byte, opts SignerOpts) (signature []byte, err error)
Verify(key Key, digest []byte, opts SignerOpts) (valid bool, err error)
Encrypt(key Key, plaintext []byte, opts EncrypterOpts) (ciphertext []byte, err error)
Decrypt(key Key, ciphertext []byte, opts DecrypterOpts) (plaintext []byte, err error)
}