Documentation
¶
Index ¶
- type PrivateKey
- func (sk *PrivateKey) Decrypt(password string) error
- func (sk *PrivateKey) IsEncrypted() bool
- func (sk *PrivateKey) PublicKey() PublicKey
- func (sk *PrivateKey) Sign(data []byte, opts SignOptions) (Signature, error)
- func (sk *PrivateKey) SignFile(file string, opts SignOptions) (Signature, error)
- func (sk *PrivateKey) Wipe()
- type PublicKey
- type SignOptions
- type Signature
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 ¶
func DecodePublicKey ¶
func NewPublicKey ¶
func NewPublicKeyFromFile ¶
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 NewSignatureFromFile ¶
func (Signature) Encode ¶
Encode serializes the signature into the textual minisign .minisig format.
func (Signature) MarshalText ¶
MarshalText implements encoding.TextMarshaler.