minisign

package module
v0.0.0-...-a09352b Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 14 Imported by: 375 modules, 360 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-minisign

A Golang library to verify Minisign signatures.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PrivateKey

type PrivateKey struct {
	UntrustedComment   string
	SignatureAlgorithm [2]byte
	KDFAlgorithm       [2]byte
	ChecksumAlgorithm  [2]byte
	KDFSalt            [32]byte
	KDFOpsLimit        uint64
	KDFMemLimit        uint64
	KeyId              [8]byte
	SecretKey          [64]byte
	Checksum           [32]byte
}

PrivateKey is a minisign Ed25519 secret key. It may be stored in encrypted form; call Decrypt with the passphrase before signing in that case.

func DecodePrivateKey

func DecodePrivateKey(in string) (PrivateKey, error)

DecodePrivateKey parses a full minisign secret key file (comment line + base64 payload).

func NewPrivateKey

func NewPrivateKey(in string) (PrivateKey, error)

NewPrivateKey parses a single base64-encoded private key payload.

func NewPrivateKeyFromFile

func NewPrivateKeyFromFile(file string) (PrivateKey, error)

NewPrivateKeyFromFile reads and parses a minisign secret key file.

func (*PrivateKey) Decrypt

func (sk *PrivateKey) Decrypt(password string) error

Decrypt decrypts the secret key in place. It is a no-op on an unencrypted key. The passphrase is verified against the stored Blake2b-256 checksum.

func (*PrivateKey) IsEncrypted

func (sk *PrivateKey) IsEncrypted() bool

IsEncrypted reports whether the key material is still encrypted under a passphrase. Calling Sign on an encrypted key returns an error.

func (*PrivateKey) PublicKey

func (sk *PrivateKey) PublicKey() PublicKey

PublicKey derives the public key from the (decrypted) secret key.

func (*PrivateKey) Sign

func (sk *PrivateKey) Sign(data []byte, opts SignOptions) (Signature, error)

Sign produces a minisign signature over data. The returned Signature can be serialized with Encode.

func (*PrivateKey) SignFile

func (sk *PrivateKey) SignFile(file string, opts SignOptions) (Signature, error)

SignFile signs the contents of a file. In Hashed mode the file is streamed through Blake2b-512 with constant memory; in legacy mode the file is loaded into memory because Ed25519 needs the message twice.

If opts.TrustedComment is empty, a default of "timestamp:<unix>\tfile:<base>" (with "\thashed" appended for prehashed signatures) is used — matching what the reference minisign(1) CLI writes.

func (*PrivateKey) Wipe

func (sk *PrivateKey) Wipe()

Wipe overwrites the in-memory secret key, checksum and key id with zeros. Call this when the key is no longer needed; the buffer will not be usable for signing afterwards.

type PublicKey

type PublicKey struct {
	SignatureAlgorithm [2]byte
	KeyId              [8]byte
	PublicKey          [32]byte
}

func DecodePublicKey

func DecodePublicKey(in string) (PublicKey, error)

func NewPublicKey

func NewPublicKey(publicKeyStr string) (PublicKey, error)

func NewPublicKeyFromFile

func NewPublicKeyFromFile(file string) (PublicKey, error)

func (*PublicKey) Verify

func (publicKey *PublicKey) Verify(bin []byte, signature Signature) (bool, error)

func (*PublicKey) VerifyFromFile

func (publicKey *PublicKey) VerifyFromFile(file string, signature Signature) (bool, error)

type SignOptions

type SignOptions struct {
	// UntrustedComment is written as the first line of the .minisig file.
	// Empty defaults to "signature from minisign secret key".
	UntrustedComment string

	// TrustedComment is signed as part of the global signature.
	// Empty defaults to "timestamp:<unix>".
	TrustedComment string

	// Hashed selects the prehashed signature variant ("ED"), in which the
	// signature is computed over a Blake2b-512 hash of the message. This is
	// the recommended mode and is required for streaming signers. When
	// false, the signature is computed directly over the message bytes
	// (legacy "Ed" mode).
	Hashed bool
}

SignOptions configures a signing operation.

type Signature

type Signature struct {
	UntrustedComment   string
	SignatureAlgorithm [2]byte
	KeyId              [8]byte
	Signature          [64]byte
	TrustedComment     string
	GlobalSignature    [64]byte
}

func DecodeSignature

func DecodeSignature(in string) (Signature, error)

func NewSignatureFromFile

func NewSignatureFromFile(file string) (Signature, error)

func (Signature) Encode

func (sig Signature) Encode() []byte

Encode serializes the signature into the textual minisign .minisig format.

func (Signature) MarshalText

func (sig Signature) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

Jump to

Keyboard shortcuts

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