github.com/quantosnetwork/Quantos@v0.0.0-20220306172517-e20b28c5a29a/crypto/signature.go (about)

     1  package crypto
     2  
     3  import (
     4  	"encoding/hex"
     5  	"go.dedis.ch/kyber/v3/sign/schnorr"
     6  )
     7  
     8  func (h *HardenedKeys) Sign(msg []byte) []byte {
     9  	sign, err := schnorr.Sign(h.Suite, h.PrivKey, msg)
    10  	if err != nil {
    11  		return nil
    12  	}
    13  	return sign
    14  }
    15  
    16  type Signature []byte
    17  
    18  func (hs Signature) String() string {
    19  	return hex.EncodeToString(hs)
    20  }
    21  
    22  func (h *HardenedKeys) VerifySignature(msg, signature []byte) bool {
    23  	err := schnorr.Verify(h.Suite, h.PubKey, msg, signature)
    24  	if err != nil {
    25  		return false
    26  	}
    27  	return true
    28  }