signature

package
v0.0.0-...-93cb24a Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKeypair

func GenerateKeypair(name string, rand io.Reader) (secretKey SecretKey, publicKey PublicKey, err error)

GenerateKeypair creates a new nix-store compatible keypair

rand: uses crypto/rand.Reader if nil name: key identifier used by Nix

func VerifyFirst

func VerifyFirst(fingerprint string, signatures []Signature, pubKeys []PublicKey) bool

VerifyFirst returns the result of the first signature that matches a public key. If no matching public key was found, it returns false.

Types

type PublicKey

type PublicKey struct {
	Name string
	Data ed25519.PublicKey
}

PublicKey represents a named ed25519 public key.

func ParsePublicKey

func ParsePublicKey(s string) (PublicKey, error)

ParsePublicKey decodes a serialized string, and returns a PublicKey struct, or an error.

func (PublicKey) String

func (pk PublicKey) String() string

String outputs a string representation as name + ":" + base64(data).

func (PublicKey) Verify

func (pk PublicKey) Verify(fingerprint string, sig Signature) bool

Verify that the fingerprint with the signature against the public key. If the signature and public key don't have the same name, just return false.

type SecretKey

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

SecretKey represents a named ed25519 private key.

func LoadSecretKey

func LoadSecretKey(s string) (SecretKey, error)

LoadSecretKey decodes a <keyname>:<base64> pair into a SecretKey.

func (SecretKey) Sign

func (sk SecretKey) Sign(rand io.Reader, fingerprint string) (Signature, error)

Sign generates a signature for the fingerprint. If rand is nil, it will use rand.Reader.

func (SecretKey) String

func (sk SecretKey) String() string

String outputs a string representation as name + ":" + base64(data).

func (SecretKey) ToPublicKey

func (sk SecretKey) ToPublicKey() PublicKey

ToPublicKey derives the PublicKey from the SecretKey.

type Signature

type Signature struct {
	Name string
	Data []byte
}

Signature represents a named ed25519 signature.

func ParseSignature

func ParseSignature(s string) (Signature, error)

ParseSignature decodes a <keyname>:<base64-signature-data> and returns a *Signature, or an error.

func (Signature) String

func (s Signature) String() string

String returns the encoded <keyname>:<base64-signature-data>.

Jump to

Keyboard shortcuts

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