// GeneratePrivateKey creates a private key and stores it in keystorePath
GeneratePrivateKey creates a private key and stores it in keystorePath
// GeneratePrivateKey creates a private key and stores it in keystorePath
func GeneratePrivateKey(keystorePath string) (bccsp.Key,
	crypto.Signer, error) {
	var err error
	var priv bccsp.Key
	var s crypto.Signer
	opts := &factory.FactoryOpts{
		ProviderName: "SW",
		SwOpts: &factory.SwOpts{
			HashFamily: "SHA2",
			SecLevel:   256,
			FileKeystore: &factory.FileKeystoreOpts{
				KeyStorePath: keystorePath,
			},
		},
	}
	csp, err := factory.GetBCCSPFromOpts(opts)
	if err == nil {
		priv, err = csp.KeyGen(&bccsp.SM2KeyGenOpts{Temporary: false})
		if err == nil {
			s, err = signer.New(csp, priv)
		}
	}
	return priv, s, err
}
func GeneratePrivateKey ( keystorePath string ) ( bccsp . Key , crypto . Signer , error ) { var err error var priv bccsp . Key var s crypto . Signer opts := & factory . FactoryOpts { ProviderName : " " , SwOpts : & factory . SwOpts { HashFamily : " " , SecLevel : 256 , FileKeystore : & factory . FileKeystoreOpts { KeyStorePath : keystorePath , } , } , } csp , err := factory . GetBCCSPFromOpts ( opts ) if err == nil { priv , err = csp . KeyGen ( & bccsp . SM2KeyGenOpts { Temporary : false } ) if err == nil { s , err = signer . New ( csp , priv ) } } return priv , s , err }
GeneratePrivateKey creates a private key and stores it in keystorePath
GeneratePrivateKey creates a private key and stores it in keystorePath
// generate a key // create a crypto.Signer