From 7e7f5c8748a2796b949f2b866e3bd5c8e486c3e4 Mon Sep 17 00:00:00 2001 From: Moreno Ambrosin Date: Tue, 10 Sep 2024 04:07:12 -0700 Subject: [PATCH] Add missing `Variant()` method to `ed25519.Parameters` #tinkApiChange PiperOrigin-RevId: 672897691 Change-Id: Iba5ac1802c6a38b8e4416c2a7a97d5e849c0500e --- signature/ed25519/key.go | 3 +++ signature/ed25519/key_test.go | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/signature/ed25519/key.go b/signature/ed25519/key.go index 0fd2f8b..8f61cac 100644 --- a/signature/ed25519/key.go +++ b/signature/ed25519/key.go @@ -76,6 +76,9 @@ func NewParameters(variant Variant) (Parameters, error) { return Parameters{variant: variant}, nil } +// Variant returns the prefix variant of the parameters. +func (p *Parameters) Variant() Variant { return p.variant } + // HasIDRequirement returns true if the key has an ID requirement. func (p *Parameters) HasIDRequirement() bool { return p.variant != VariantNoPrefix } diff --git a/signature/ed25519/key_test.go b/signature/ed25519/key_test.go index a18f6b0..72a7ab9 100644 --- a/signature/ed25519/key_test.go +++ b/signature/ed25519/key_test.go @@ -43,10 +43,13 @@ func TestNewParameters(t *testing.T) { }, } { t.Run(tc.name, func(t *testing.T) { - _, err := ed25519.NewParameters(tc.variant) + params, err := ed25519.NewParameters(tc.variant) if err != nil { t.Errorf("ed25519.NewParameters(%v) err = %v, want nil", tc.variant, err) } + if got := params.Variant(); got != tc.variant { + t.Errorf("params.Variant() = %v, want %v", got, tc.variant) + } }) } t.Run("unknown", func(t *testing.T) {