func (sv Ed25519SignatureVerifier) Verify(pubKey *PublicKey, msg, signature []byte) error {
	value := pubKey.Value
	if pubKey.JWK != nil {
		var ok bool
		value, ok = pubKey.JWK.Public().Key.(ed25519.PublicKey)
		if !ok {
			return fmt.Errorf("public key not ed25519.VerificationMethod")
		}
	}
	if len(value) != ed25519.PublicKeySize {
		return errors.New("ed25519: invalid key")
	}
	verified := ed25519.Verify(value, msg, signature)
	if !verified {
		return errors.New("ed25519: invalid signature")
	}
	return nil
}
Verify verifies the signature.
package verifier
import (
	"crypto"
	"crypto/ecdsa"
	"crypto/ed25519"
	"crypto/elliptic"
	"crypto/rsa"
	"crypto/x509"
	"errors"
	"fmt"
	"math/big"
	"strings"
	"github.com/btcsuite/btcd/btcec"
	gojose "github.com/square/go-jose/v3"
	"github.com/hyperledger/aries-framework-go/pkg/crypto/primitive/bbs12381g2pub"
	"github.com/hyperledger/aries-framework-go/pkg/doc/jose/jwk"
)
type PublicKeyVerifier struct {
	exactType      string
	singleVerifier SignatureVerifier
	verifiers      []SignatureVerifier
}
type PublicKeyVerifierOpt func(opts *PublicKeyVerifier)
func NewPublicKeyVerifier(sigAlg SignatureVerifier, opts ...PublicKeyVerifierOpt) *PublicKeyVerifier {
	v := &PublicKeyVerifier{
		singleVerifier: sigAlg,
	}
	for _, opt := range opts {
		opt(v)
	}
	return v
}
func NewCompositePublicKeyVerifier(verifiers []SignatureVerifier, opts ...PublicKeyVerifierOpt) *PublicKeyVerifier {
	v := &PublicKeyVerifier{
		verifiers: verifiers,
	}
	for _, opt := range opts {
		opt(v)
	}
	return v
}
func (pkv *PublicKeyVerifier) Verify(pubKey *PublicKey, msg, signature []byte) error {
	if pkv.exactType != "" {
		if pubKey.Type != pkv.exactType {
			return fmt.Errorf("a type of public key is not '%s'", pkv.exactType)
		}
	}
	if pkv.singleVerifier != nil {
		if pubKey.JWK != nil && !pkv.matchVerifier(pkv.singleVerifier, pubKey.JWK) {
			return errors.New("verifier does not match JSON Web Key")
		}
		return pkv.singleVerifier.Verify(pubKey, msg, signature)
	}
	for _, v := range pkv.verifiers {
		if pkv.matchVerifier(v, pubKey.JWK) {
			return v.Verify(pubKey, msg, signature)
		}
	}
	return errors.New("no matching verifier found")
}
func (pkv *PublicKeyVerifier) matchVerifier(verifier SignatureVerifier, j *jwk.JWK) bool {
	if verifier.KeyType() != j.Kty {
		return false
	}
	if j.Crv != "" && verifier.Curve() != j.Crv {
		return false
	}
	if j.Algorithm != "" && verifier.Algorithm() != j.Algorithm {
		return false
	}
	return true
}
func WithExactPublicKeyType(jwkType string) PublicKeyVerifierOpt {
	return func(opts *PublicKeyVerifier) {
		opts.exactType = jwkType
	}
}
type SignatureVerifier interface {
	KeyType() string
	Curve() string
	Algorithm() string
	Verify(pubKey *PublicKey, msg, signature []byte) error
}
type baseSignatureVerifier struct {
	keyType   string
	curve     string
	algorithm string
}
func (sv baseSignatureVerifier) KeyType() string {
	return sv.keyType
}
func (sv baseSignatureVerifier) Curve() string {
	return sv.curve
}
func (sv baseSignatureVerifier) Algorithm() string {
	return sv.algorithm
}
type Ed25519SignatureVerifier struct {
	baseSignatureVerifier
}
func NewEd25519SignatureVerifier() *Ed25519SignatureVerifier {
	return &Ed25519SignatureVerifier{
		baseSignatureVerifier: baseSignatureVerifier{
			keyType:   "OKP",
			curve:     "Ed25519",
			algorithm: "EdDSA",
		},
	}
}