I have this piece of code:
import (
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric-protos-go/common"
"github.com/hyperledger/fabric-protos-go/peer"
"github.com/hyperledger/fabric-lib-go/bccsp/sw"
mspmgmt "github.com/hyperledger/fabric/msp/mgmt"
)
.....
cryptoProvider, err := sw.NewDefaultSecurityLevelWithKeystore(sw.NewDummyKeyStore())
if err != nil {
log.Fatalf("Failed to create bccsp: %v", err)
}
bccsp := mspmgmt.GetIdentityDeserializer(channelId, cryptoProvider)
if bccsp == nil {
log.Fatalf("could not get msp for channel [%s]", channelId)
}
And I am getting the following error:
> ./signatureValidator.go:30:54: cannot use cryptoProvider (variable of
> type "github.com/hyperledger/fabric-lib-go/bccsp".BCCSP) as
> "github.com/hyperledger/fabric/bccsp".BCCSP value in argument to
> mspmgmt.GetIdentityDeserializer:
> "github.com/hyperledger/fabric-lib-go/bccsp".BCCSP does not implement
> "github.com/hyperledger/fabric/bccsp".BCCSP (wrong type for method
> Decrypt)have Decrypt("github.com/hyperledger/fabric-lib-go/bccsp".Key,
> []byte, "github.com/hyperledger/fabric-lib-go/bccsp".DecrypterOpts)
> ([]byte, error)want Decrypt("github.com/hyperledger/fabric/bccsp".Key,
> []byte, "github.com/hyperledger/fabric/bccsp".DecrypterOpts) ([]byte,
> error)
----------------
Apparently cryptoProvider is an instance of a struct defined in github.com/hyperledger/fabric-lib-go/bccsp but GetIdentityDeserializer is asking for the same struct, but from github.com/hyperledger/fabric/bccsp.
I have tried removing all instances of github.com/hyperledger/fabric so that the program is forced to use the definition in the other repo. However, because I need to use github.com/hyperledger/fabric/msp/mgmt it imports all of /fabric in the go.mod.
I have no idea why the struct is defined twice with different names. Ideally both should use the definition in github.com/hyperledger/fabric-lib-go/bccsp. Does anyone have experience with this type of issue?
The github.com/hyperledger/fabric/bccsp
package was moved to fabric-lib-go in these pull requests:
If you are seeing bccsp in both fabric and fabric-lib-go then you are likely using mismatched versions of those modules.
Please also note that github.com/hyperledger/fabric
is not intended to be used as a library. "Breaking" changes (like the package move above) may occur at any time.