ed25519

package
v2.3.3 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2023 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigPrivKey     = "priv_key"
	ConfigPubKey      = "pub_key"
	ConfigKeyId       = "key_id"
	ConfigKeyPurposes = "key_purposes"
)

Variables

This section is empty.

Functions

func TestSigInfo

func TestSigInfo(t *testing.T, privKey ed25519.PrivateKey, msg []byte, opt ...wrapping.Option) *wrapping.SigInfo

TestSigInfo creates a test SigInfo using the provided ed25519 priv key

func WithPrivKey

func WithPrivKey(k ed25519.PrivateKey) wrapping.Option

WithPrivKey provides a common way to pass in a private key. This local option will override a ConfigMap provide option.

func WithPubKey

func WithPubKey(k ed25519.PublicKey) wrapping.Option

WithPubKey provides a common way to pass in a public key. This local option will override a ConfigMap provide option.

Types

type OptionFunc

type OptionFunc func(*options) error

OptionFunc holds a function with local options

type Signer

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

Signer provides an ed25519 implementation for the wrapping.Signer interface

func NewSigner

func NewSigner(ctx context.Context, opt ...wrapping.Option) (*Signer, error)

NewSigner creates a new Signer. Supported options: WithKeyId, WithKeyPurposes, WithPrivKey, WithConfigMap

Note: options order of precedence is: local options, WithConfigMap provided options and finally wrapping options.

func (*Signer) KeyBytes

func (s *Signer) KeyBytes(context.Context) ([]byte, error)

KeyBytes returns the current key bytes

func (*Signer) SetConfig

func (s *Signer) SetConfig(_ context.Context, opt ...wrapping.Option) (*wrapping.WrapperConfig, error)

SetConfig sets the fields on the Signer

Supported options: wrapping.WithKeyId, wrapping.WithKeyPurposes, wrapping.WithConfigMap and the local WithPrivKey

Note: options order of precedence is: local options, WithConfigMap provided options and finally wrapping options.

wrapping.WithConfigMap supports a ConfigPrivKey to set the Signer priv key along with ConfigKeyId, and ConfigKeyPurposes. ConfigKeyPurposes are a comma delimited list of wrapping.KeyPurpose_name values (for example: "Sign, Verify")

The values in WithConfigMap can also be set via the package's native local options.

func (*Signer) Sign

func (s *Signer) Sign(tx context.Context, msg []byte, _ ...wrapping.Option) (*wrapping.SigInfo, error)

Sign creates a signature of the provided msg. No options are currently supported.

type Verifier

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

Verifier provides and ed25519 implementation for the wrapping.Verifier interface

func NewVerifier

func NewVerifier(ctx context.Context, opt ...wrapping.Option) (*Verifier, error)

NewVerifier creates a new verifier. Supported options: WithKeyId, WithKeyPurposes, WithPubKey, WithConfigMap

Note: options order of precedence is: local options, WithConfigMap provided options and finally wrapping options.

func (*Verifier) KeyBytes

func (s *Verifier) KeyBytes(context.Context) ([]byte, error)

KeyBytes returns the current key bytes

func (*Verifier) SetConfig

func (s *Verifier) SetConfig(_ context.Context, opt ...wrapping.Option) (*wrapping.WrapperConfig, error)

SetConfig sets the fields on the Verifier

Supported options: wrapping.WithKeyId, wrapping.WithKeyPurposes, wrapping.WithConfigMap and the local WithPubKey

Note: options order of precedence is: local options, WithConfigMap provided options and finally wrapping options.

wrapping.WithConfigMap supports a ConfigPubKey to set the Verifier pub key. along with ConfigKeyId, and ConfigKeyPurposes. ConfigKeyPurposes are a comma delimited list of wrapping.KeyPurpose_name values (for example: "Sign, Verify")

The values in WithConfigMap can also be set via the package's native local options.

func (*Verifier) Verify

func (s *Verifier) Verify(ctx context.Context, msg []byte, sig *wrapping.SigInfo, _ ...wrapping.Option) (bool, error)

Verify will verify the signature of the provided msg. No options are currently supported.

Jump to

Keyboard shortcuts

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