func (EDVerifier) Verify(pub *PublicKey, msg, sig []byte) bool {
	return Verify(pub, msg, sig)
}
Verify that signature matches public key.
package signing
import (
	"bytes"
	"errors"
	"fmt"
	"github.com/spacemeshos/ed25519"
	"github.com/spacemeshos/go-spacemesh/common/util"
	"github.com/spacemeshos/go-spacemesh/log"
)
const shortStringSize = 5
type PublicKey struct {
	pub []byte
}
func NewPublicKey(pub []byte) *PublicKey {
	return &PublicKey{pub}
}
func (p *PublicKey) Field() log.Field {
	return log.String("public_key", p.ShortString())
}
func (p *PublicKey) Bytes() []byte {
	if p != nil {
		return p.pub
	}
	return nil
}
func (p *PublicKey) String() string {
	return util.Bytes2Hex(p.Bytes())
}
func (p *PublicKey) ShortString() string {
	s := p.String()
	if len(s) < shortStringSize {
		return s
	}
	return s[:shortStringSize]
}
func (p *PublicKey) Equals(o *PublicKey) bool {
	return bytes.Equal(p.Bytes(), o.Bytes())
}
var _ Signer = (*EdSigner)(nil)
type EdSigner struct {
	privKey ed25519.PrivateKey  
	pubKey  ed25519.PublicKey   
}
func NewEdSignerFromBuffer(buff []byte) (*EdSigner, error) {
	if len(buff) != ed25519.PrivateKeySize {
		log.Error("Could not create EdSigner from the provided buffer: buffer too small")
		return nil, errors.New("buffer too small")
	}
	sgn := &EdSigner{privKey: buff, pubKey: buff[32:]}
	keyPair := ed25519.NewKeyFromSeed(sgn.privKey[:32])
	if !bytes.Equal(keyPair[32:], sgn.pubKey) {
		log.Error("Public key and private key does not match")
		return nil, errors.New("private and public does not match")
	}
	return sgn, nil
}
func NewEdSigner() *EdSigner {
	pub, priv, err := ed25519.GenerateKey(nil)
	if err != nil {
		log.Panic("Could not generate key pair err=%v", err)
	}
	return &EdSigner{privKey: priv, pubKey: pub}
}
func (es *EdSigner) Sign(m []byte) []byte {
	return ed25519.Sign2(es.privKey, m)
}
func (es *EdSigner) PublicKey() *PublicKey {
	return NewPublicKey(es.pubKey)
}
func (es *EdSigner) LittleEndian() bool {
	return true
}
func (es *EdSigner) ToBuffer() []byte {
	buff := make([]byte, len(es.privKey))
	copy(buff, es.privKey)
	return buff
}
func Verify(pubkey *PublicKey, message []byte, sign []byte) bool {
	return ed25519.Verify2(pubkey.Bytes(), message, sign)
}
type EDVerifier struct{}
func NewEDVerifier() EDVerifier {
	return EDVerifier{}
}
var _ VerifyExtractor = EDVerifier{}