github.com/devwanda/aphelion-staking@v0.33.9/crypto/secp256k1/secp256k1_cgo.go (about)

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