You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
637 B

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