ed25519

package
v2.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package ed25519 provides ED25519 keys and parameters definitions, and key managers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSigner

func NewSigner(privateKey *PrivateKey, _ internalapi.Token) (tink.Signer, error)

NewSigner creates a new tink.Signer for ED25519.

This is an internal API.

func NewVerifier

func NewVerifier(publicKey *PublicKey, _ internalapi.Token) (tink.Verifier, error)

NewVerifier creates a new tink.Verifier for ED25519.

This is an internal API.

Types

type Parameters

type Parameters struct {
	// contains filtered or unexported fields
}

Parameters represents the parameters of an ED25519 key.

func NewParameters

func NewParameters(variant Variant) (Parameters, error)

NewParameters creates a new Parameters.

func (*Parameters) Equal

func (p *Parameters) Equal(other key.Parameters) bool

Equal returns true if this parameters object is equal to other.

func (*Parameters) HasIDRequirement

func (p *Parameters) HasIDRequirement() bool

HasIDRequirement returns true if the key has an ID requirement.

func (*Parameters) Variant

func (p *Parameters) Variant() Variant

Variant returns the prefix variant of the parameters.

type PrivateKey

type PrivateKey struct {
	// contains filtered or unexported fields
}

PrivateKey represents an ED25519 private key.

func NewPrivateKey

func NewPrivateKey(privateKeyBytes secretdata.Bytes, idRequirement uint32, params Parameters) (*PrivateKey, error)

NewPrivateKey creates a new ED25519 private key from privateKeyBytes, with idRequirement and params.

func NewPrivateKeyWithPublicKey

func NewPrivateKeyWithPublicKey(privateKeyBytes secretdata.Bytes, pubKey *PublicKey) (*PrivateKey, error)

NewPrivateKeyWithPublicKey creates a new ED25519 private key from privateKeyBytes and a PublicKey.

func (*PrivateKey) Equal

func (k *PrivateKey) Equal(other key.Key) bool

Equal returns true if this key is equal to other.

func (*PrivateKey) IDRequirement

func (k *PrivateKey) IDRequirement() (uint32, bool)

IDRequirement returns the ID requirement of the key, and whether it is required.

func (*PrivateKey) OutputPrefix

func (k *PrivateKey) OutputPrefix() []byte

OutputPrefix returns the output prefix of this key.

func (*PrivateKey) Parameters

func (k *PrivateKey) Parameters() key.Parameters

Parameters returns the parameters of the key.

func (*PrivateKey) PrivateKeyBytes

func (k *PrivateKey) PrivateKeyBytes() secretdata.Bytes

PrivateKeyBytes returns the private key bytes.

func (*PrivateKey) PublicKey

func (k *PrivateKey) PublicKey() (key.Key, error)

PublicKey returns the public key of the key.

This implements the privateKey interface defined in handle.go.

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

PublicKey represents an ED25519 public key.

func NewPublicKey

func NewPublicKey(keyBytes []byte, idRequirement uint32, params Parameters) (*PublicKey, error)

NewPublicKey creates a new ED25519 public key.

idRequirement is the ID of the key in the keyset. It must be zero if params doesn't have an ID requirement.

func (*PublicKey) Equal

func (k *PublicKey) Equal(other key.Key) bool

Equal returns true if this key is equal to other.

func (*PublicKey) IDRequirement

func (k *PublicKey) IDRequirement() (uint32, bool)

IDRequirement returns the ID requirement of the key, and whether it is required.

func (*PublicKey) KeyBytes

func (k *PublicKey) KeyBytes() []byte

KeyBytes returns the public key bytes.

func (*PublicKey) OutputPrefix

func (k *PublicKey) OutputPrefix() []byte

OutputPrefix returns the output prefix of this key.

func (*PublicKey) Parameters

func (k *PublicKey) Parameters() key.Parameters

Parameters returns the parameters of the key.

type Variant

type Variant int

Variant is the prefix variant of an ED25519 key.

It describes the format of the signature. For ED25519, there are four options:

  • TINK: prepends '0x01<big endian key id>' to the signature.
  • CRUNCHY: prepends '0x00<big endian key id>' to the signature.
  • LEGACY: appends a 0-byte to the input message before computing the signature, then prepends '0x00<big endian key id>' to the signature.
  • NO_PREFIX: adds no prefix to the signature.
const (
	// VariantUnknown is the default value of Variant.
	VariantUnknown Variant = iota
	// VariantTink prefixes '0x01<big endian key id>' to the signature.
	VariantTink
	// VariantCrunchy prefixes '0x00<big endian key id>' to the signature.
	VariantCrunchy
	// VariantLegacy appends a 0-byte to input message BEFORE computing the signature,
	// signature, then prepends '0x00<big endian key id>' to signature.
	VariantLegacy
	// VariantNoPrefix does not prefix the signature with the key id.
	VariantNoPrefix
)

func (Variant) String

func (variant Variant) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL