github.com/okex/exchain@v1.8.0/libs/tendermint/crypto/secp256k1/secp256k1_cgo.go (about)

     1  //go:build libsecp256k1
     2  // +build libsecp256k1
     3  
     4  package secp256k1
     5  
     6  import (
     7  	"github.com/okex/exchain/libs/tendermint/crypto"
     8  	"github.com/okex/exchain/libs/tendermint/crypto/secp256k1/internal/secp256k1"
     9  )
    10  
    11  // Sign creates an ECDSA signature on curve Secp256k1, using SHA256 on the msg.
    12  func (privKey PrivKeySecp256k1) Sign(msg []byte) ([]byte, error) {
    13  	rsv, err := secp256k1.Sign(crypto.Sha256(msg), privKey[:])
    14  	if err != nil {
    15  		return nil, err
    16  	}
    17  	// we do not need v  in r||s||v:
    18  	rs := rsv[:len(rsv)-1]
    19  	return rs, nil
    20  }
    21  
    22  func (pubKey PubKeySecp256k1) VerifyBytes(msg []byte, sig []byte) bool {
    23  	return secp256k1.VerifySignature(pubKey[:], crypto.Sha256(msg), sig)
    24  }