From 2e8e42b09a1b2c7bd8e3557fd286a969a2fa0caf Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Tue, 23 Feb 2021 12:07:34 +0100 Subject: reordered functions --- types/namespace.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'types/namespace.go') diff --git a/types/namespace.go b/types/namespace.go index 3c6b90a..376ebcd 100644 --- a/types/namespace.go +++ b/types/namespace.go @@ -62,6 +62,19 @@ func (n *Namespace) Fingerprint() (*[NamespaceFingerprintSize]byte, error) { } } +// Verify checks that signature is valid over message for this namespace +func (ns *Namespace) Verify(message, signature []byte) error { + switch ns.Format { + case NamespaceFormatEd25519V1: + if !ed25519.Verify(ed25519.PublicKey(ns.Ed25519V1.Namespace[:]), message, signature) { + return fmt.Errorf("ed25519 signature verification failed") + } + default: + return fmt.Errorf("namespace not supported: %v", ns.Format) + } + return nil +} + // NewNamespaceEd25519V1 returns an new Ed25519V1 namespace based on a // verification key. func NewNamespaceEd25519V1(vk []byte) (*Namespace, error) { @@ -76,16 +89,3 @@ func NewNamespaceEd25519V1(vk []byte) (*Namespace, error) { Ed25519V1: &ed25519v1, }, nil } - -// Verify checks that signature is valid over message for this namespace -func (ns *Namespace) Verify(message, signature []byte) error { - switch ns.Format { - case NamespaceFormatEd25519V1: - if !ed25519.Verify(ed25519.PublicKey(ns.Ed25519V1.Namespace[:]), message, signature) { - return fmt.Errorf("ed25519 signature verification failed") - } - default: - return fmt.Errorf("namespace not supported: %v", ns.Format) - } - return nil -} -- cgit v1.2.3