Skip to content

Commit

Permalink
not need to refer ffi library
Browse files Browse the repository at this point in the history
  • Loading branch information
hunjixin committed Nov 4, 2021
1 parent e921598 commit 8d6614c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 4 additions & 0 deletions pkg/crypto/sigs.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ const (
SigTypeBLS = crypto.SigTypeBLS
)

const (
BLSSignatureBytes = 96
)

// Sign takes in signature type, private key and message. Returns a signature for that message.
// Valid sigTypes are: "secp256k1" and "bls"
func Sign(msg []byte, privkey []byte, sigType SigType) (*crypto.Signature, error) {
Expand Down
4 changes: 1 addition & 3 deletions pkg/messagepool/messagepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
lps "github.com/whyrusleeping/pubsub"
"golang.org/x/xerrors"

ffi "github.com/filecoin-project/filecoin-ffi"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
Expand Down Expand Up @@ -843,12 +842,11 @@ func (mp *MessagePool) Add(ctx context.Context, m *types.SignedMessage) error {
func sigCacheKey(m *types.SignedMessage) (string, error) {
switch m.Signature.Type {
case crypto.SigTypeBLS:
if len(m.Signature.Data) != ffi.SignatureBytes {
if len(m.Signature.Data) != crypto2.BLSSignatureBytes {
return "", fmt.Errorf("bls signature incorrectly sized")
}

hashCache := blake2b.Sum256(append(m.Cid().Bytes(), m.Signature.Data...))

return string(hashCache[:]), nil
case crypto.SigTypeSecp256k1:
return string(m.Cid().Bytes()), nil
Expand Down

0 comments on commit 8d6614c

Please sign in to comment.