Skip to content

Commit

Permalink
Register proto key parsers and serializers for ED25519
Browse files Browse the repository at this point in the history
As a consequence, all ED25519 keys in a keyset are now parsed as `ed25519.{Private,Public}Key`s. Parsing of invalid private/public keys will fail.

PiperOrigin-RevId: 673417211
Change-Id: I8fcc71d007617a5ce8f6b3c8859f204319e2903b
  • Loading branch information
morambro authored and copybara-github committed Sep 11, 2024
1 parent 05d0165 commit f964471
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions signature/ed25519/ed25519.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/tink-crypto/tink-go/v2/core/registry"
"github.com/tink-crypto/tink-go/v2/internal/internalregistry"
"github.com/tink-crypto/tink-go/v2/internal/protoserialization"
)

func init() {
Expand All @@ -33,4 +34,16 @@ func init() {
if err := registry.RegisterKeyManager(new(verifierKeyManager)); err != nil {
panic(fmt.Sprintf("ed25519.init() failed: %v", err))
}
if err := protoserialization.RegisterKeySerializer[*PublicKey](&publicKeySerializer{}); err != nil {
panic(fmt.Sprintf("ed25519.init() failed: %v", err))
}
if err := protoserialization.RegisterKeyParser(verifierTypeURL, &publicKeyParser{}); err != nil {
panic(fmt.Sprintf("ed25519.init() failed: %v", err))
}
if err := protoserialization.RegisterKeySerializer[*PrivateKey](&privateKeySerializer{}); err != nil {
panic(fmt.Sprintf("ed25519.init() failed: %v", err))
}
if err := protoserialization.RegisterKeyParser(signerTypeURL, &privateKeyParser{}); err != nil {
panic(fmt.Sprintf("ed25519.init() failed: %v", err))
}
}

0 comments on commit f964471

Please sign in to comment.