func (s *Signature) Verify(hash []byte, signee *PublicKey) bool {
	if BypassSignature {
		return true
	}
	if signee == nil || s == nil {
		return false
	}
	cacheKey := make([]byte, 64+len(hash)+ec.PubKeyBytesLenUncompressed)
	signature := cacheKey[:64]
	copy(signature, utils.PaddedBigBytes(s.R, 32))
	copy(signature[32:], utils.PaddedBigBytes(s.S, 32))
	copy(cacheKey[64:64+len(hash)], hash)
	signeeBytes := (*ec.PublicKey)(signee).SerializeUncompressed()
	copy(cacheKey[64+len(hash):], signeeBytes)
	if _, ok := verifyCache.Get(string(cacheKey)); ok {
		return true
	}
	valid := secp256k1.VerifySignature(signeeBytes, hash, signature)
	if valid {
		verifyCache.Add(string(cacheKey), nil)
	}
	return valid
}
Verify calls ecdsa.Verify to verify the signature of hash using the public key. It returns true
if the signature is valid, false otherwise.
package asymmetric
import (
	"crypto/elliptic"
	"errors"
	"math/big"
	hsp "github.com/SQLess/HashStablePack/marshalhash"
	ec "github.com/btcsuite/btcd/btcec"
	lru "github.com/hashicorp/golang-lru"
	"github.com/SQLess/SQLess/crypto/secp256k1"
	"github.com/SQLess/SQLess/utils"
)
var (
	BypassSignature = false
	bypassS         *Signature
	verifyCache     *lru.Cache
)
func init() {
	priv, _ := ec.NewPrivateKey(ec.S256())
	ss, _ := (*ec.PrivateKey)(priv).Sign(([]byte)("00000000000000000000000000000000"))
	bypassS = (*Signature)(ss)
	verifyCache, _ = lru.New(256)
}
type Signature struct {
	R *big.Int
	S *big.Int
}
func (s *Signature) Serialize() []byte {
	return (*ec.Signature)(s).Serialize()
}
func ParseSignature(sigStr []byte) (*Signature, error) {
	return ParseDERSignature(sigStr, ec.S256())
}
func ParseDERSignature(sigStr []byte, curve elliptic.Curve) (*Signature, error) {
	sig, err := ec.ParseDERSignature(sigStr, curve)
	return (*Signature)(sig), err
}
func (s *Signature) IsEqual(signature *Signature) bool {
	return (*ec.Signature)(s).IsEqual((*ec.Signature)(signature))
}
func (private *PrivateKey) Sign(hash []byte) (*Signature, error) {
	if len(hash) != 32 {
		return nil, errors.New("only hash can be signed")
	}
	if BypassSignature {
		return bypassS, nil
	}
	seckey := utils.PaddedBigBytes(private.D, private.Params().BitSize/8)
	defer zeroBytes(seckey)
	sb, e := secp256k1.Sign(hash, seckey)
	s := &Signature{
		R: new(big.Int).SetBytes(sb[:32]),
		S: new(big.Int).SetBytes(sb[32:64]),
	}
	return (*Signature)(s), e
}