Commit 97649fce authored by suyanlong's avatar suyanlong

update dep and Add register bls package

parent 2c9ea07f
Pipeline #8259 failed with stages
...@@ -30,7 +30,7 @@ require ( ...@@ -30,7 +30,7 @@ require (
github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd
github.com/hashicorp/go-multierror v1.1.0 github.com/hashicorp/go-multierror v1.1.0
github.com/hashicorp/go-plugin v1.3.0 github.com/hashicorp/go-plugin v1.3.0
github.com/herumi/bls-eth-go-binary v0.0.0-20210917013441-d37c07cfda4e github.com/herumi/bls-eth-go-binary v0.0.0-20211108015406-b5186ba08dc7
github.com/huandu/skiplist v1.2.0 github.com/huandu/skiplist v1.2.0
github.com/huandu/xstrings v1.3.2 github.com/huandu/xstrings v1.3.2
github.com/hyperledger/fabric v2.0.1+incompatible github.com/hyperledger/fabric v2.0.1+incompatible
...@@ -195,3 +195,4 @@ require ( ...@@ -195,3 +195,4 @@ require (
) )
replace github.com/libp2p/go-libp2p-core => github.com/libp2p/go-libp2p-core v0.5.6 replace github.com/libp2p/go-libp2p-core => github.com/libp2p/go-libp2p-core v0.5.6
replace github.com/meshplus/bitxhub-kit => github.com/suyanlong/bitxhub-kit v1.2.1-0.20211118095742-332b6c4e4b9f
This diff is collapsed.
package bls package bls
import ( import (
"fmt"
"github.com/herumi/bls-eth-go-binary/bls" "github.com/herumi/bls-eth-go-binary/bls"
"github.com/meshplus/bitxhub-kit/crypto" "github.com/meshplus/bitxhub-kit/crypto"
"github.com/meshplus/bitxhub-kit/crypto/asym"
"github.com/meshplus/bitxhub-kit/crypto/asym/ecdsa" "github.com/meshplus/bitxhub-kit/crypto/asym/ecdsa"
"github.com/meshplus/bitxhub-kit/types" "github.com/meshplus/bitxhub-kit/types"
) )
func init() {
asym.RegisterCrypto1(
BlsEth,
"BlsEth",
GenerateKeyPair,
Verify,
UnmarshalPrivateKey,
)
}
func Verify(opt crypto.KeyType, sig, digest []byte, from types.Address) (bool, error) {
if len(sig) == 0 {
return false, fmt.Errorf("empty sig data")
}
if opt != BlsEth {
return false, fmt.Errorf("not supported %d", opt)
}
return true, nil
}
func UnmarshalPrivateKey(data []byte, opt crypto.KeyType) (crypto.PrivateKey, error) {
if len(data) == 0 {
return nil, fmt.Errorf("empty private key data")
}
if opt != BlsEth {
return nil, fmt.Errorf("not supported %d", opt)
}
pk := &PrivateKey{
curve: BlsEth,
SecretKey: &bls.SecretKey{},
}
err := pk.Deserialize(data)
if err != nil {
return nil, err
}
return pk, nil
}
type Sign = bls.Sign type Sign = bls.Sign
var HashAndMapToSignature = bls.HashAndMapToSignature var HashAndMapToSignature = bls.HashAndMapToSignature
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment