From 666e41811bdd46e24ced8ddd3448243ecb2f45c3 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Tue, 23 Feb 2021 11:07:00 +0100 Subject: added namespace fingerprint --- types/namespace.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'types/namespace.go') diff --git a/types/namespace.go b/types/namespace.go index 8a2ad17..f221960 100644 --- a/types/namespace.go +++ b/types/namespace.go @@ -14,6 +14,8 @@ type NamespaceFormat tls.Enum const ( NamespaceFormatReserved NamespaceFormat = 0 NamespaceFormatEd25519V1 NamespaceFormat = 1 + + NamespaceFingerprintSize = 32 ) // Namespace references a versioned namespace based on a given format specifier @@ -50,6 +52,16 @@ func (n Namespace) String() string { } } +// Fingerprint returns a fixed-size namespace fingerprint that is unique. +func (n *Namespace) Fingerprint() (*[NamespaceFingerprintSize]byte, error) { + switch n.Format { + case NamespaceFormatEd25519V1: + return &n.Ed25519V1.Namespace, nil + default: + return nil, fmt.Errorf("unsupported NamespaceFormat: %v", n.Format) + } +} + // NewNamespaceEd25519V1 returns an new Ed25519V1 namespace based on a // verification key. func NewNamespaceEd25519V1(vk []byte) (*Namespace, error) { -- cgit v1.2.3