minisign

repository·master·Indexed 25 days ago

https://github.com/jedisct1/minisign

A simple, secure, and minimal tool for signing and verifying files using the Ed25519 public-key signature system. It supports cross-platform usage and can be built using Zig (version 0.15.1 or later) or CMake. Key features include generating Ed25519 key pairs, signing files with trusted or untrusted comments, and verifying signatures via public key files or base64 strings.

Tokens
1.5K
Snippets
4
Records
11
Agent score
84%

What's inside minisign

  1. Use Minisign via Docker

    master

    Minisign can be run as a Docker container. Use the -v flag to mount your current directory to /minisign inside the container.

    Generate a key pair in Docker:

    docker run -i --rm -v .:/minisign jedisct1/minisign -s minisign.key -G

    Sign a file in Docker:

    docker run -i --rm -v .:/minisign jedisct1/minisign -s minisign.key -S -m files_to_sign

    Verify a signature in Docker:

    docker run -i --rm -v .:/minisign jedisct1/minisign -Vm file_to_verify -p minisign.pub

    Note: -s minisign.key specifies the secret key to use. The public key will be named minisign.pub.

  2. Verify file signatures

    master

    Use the -V flag to verify that a signature is valid for a given file. The signature file (defaulting to <file>.minisig) must be present in the same directory. You can provide the public key via a file using -p <pubkey_file> or as a base64 string using -P <pubkey>.

    Additional options:

    • -o: Output the file content after successful verification.
    • -H: Requires the signature to be prehashed.
    • -q: Quiet mode (suppress output).
    • -Q: Pretty quiet mode (only print the trusted comment).
  3. Install Minisign via package managers

    master

    Minisign is available as prebuilt packages for several platforms:

    • macOS (Homebrew): brew install minisign
    • Windows (Scoop): scoop install minisign
    • Windows (Chocolatey): choco install minisign
    brew install minisign
  4. Build Minisign with CMake

    master

    To build Minisign using CMake, you need the following dependencies:

    • libsodium (required)
    • CMake
    • pkg-config
    • GCC or Clang

    Standard Build:

    mkdir build
    cd build
    cmake ..
    make
    make install

    Static Binary Configuration: You can configure static binaries using either of these flags:

    • cmake -D STATIC_LIBSODIUM=1 ..
    • cmake -D BUILD_STATIC_EXECUTABLES=1 ..
    mkdir build
    cd build
    cmake ..
    make
    make install
  5. Build Minisign with Zig

    master

    You can build Minisign using the Zig build system.

    Dependencies:

    • libsodium (optional)
    • zig (version 0.15.1 or later)

    Compilation Options:

    • With libsodium (dynamically linked): zig build -Doptimize=ReleaseSmall
    • With libsodium (statically linked): zig build -Doptimize=ReleaseSmall -Dstatic
    • Without libsodium (no dependencies): zig build -Doptimize=ReleaseSmall -Dwithout-libsodium

    Note: Replace ReleaseSmall with ReleaseFast for faster execution at the cost of larger binary size. The resulting binary is located at zig-out/bin/minisign.

    zig build -Doptimize=ReleaseSmall -Dwithout-libsodium
  6. Sign files with Minisign

    master

    Use the -S flag to create signatures for one or more files.

    By default:

    • The secret key is loaded from ${MINISIGN_CONFIG_DIR}/minisign.key or ~/.minisign/minisign.key.
    • The signature file is named <file>.minisig.

    Options:

    • -m <file>: The file(s) to sign.
    • -s <seckey_file>: Path to the secret key file.
    • -t <comment>: Add a one-line trusted comment. This comment is signed and cannot be modified without the secret key. Useful for metadata like timestamps or version numbers to prevent downgrade attacks.
    • -c <comment>: Add a one-line untrusted comment. This can be modified after the signature is created.
    • -l: Use the legacy format.
    • -x <sig_file>: Specify a custom signature file name.
  7. Generate a new Minisign key pair

    master

    Use the -G flag to generate a new Ed25519 key pair.

    By default:

    • The public key is printed to stdout and saved to minisign.pub.
    • The secret key is encrypted and saved to ~/.minisign/minisign.key.

    Options:

    • -f: Force overwrite of an existing key pair.
    • -W: Do not encrypt/decrypt the secret key with a password.
    • -s <seckey_file>: Specify a custom path for the secret key file.
  8. Verify Minisign signatures

    master

    Use the -V flag to verify that a signature is valid for a given file.

    By default:

    • The signature file <file>.minisig must be present in the same directory as the file.
    • The public key is loaded from ./minisign.pub.

    Options:

    • -m <file>: The file to verify.
    • -p <pubkey_file>: Path to the public key file.
    • -P <pubkey>: The public key provided as a base64 string.
    • -o: Output the file content after successful verification.
    • -H: Requires the signature to be prehashed.
    • -q: Quiet mode, suppresses output.
    • -Q: Pretty quiet mode, only prints the trusted comment.
    • -x <sig_file>: Specify a custom signature file name.
  9. Manage Minisign secret keys

    master

    Minisign provides utilities to manage the secret key file:

    • Change/remove password: Use -C to change or remove the password protecting a secret key.
    • Recreate public key: Use -R to recreate a public key file from an existing secret key file.
    • Secret key location: The secret key is typically at ~/.minisign/minisign.key, but can be explicitly set using the -s <seckey_file> flag in most commands.
  10. Minisign CLI Reference

    master

    Summary of Minisign command-line flags:

    FlagDescription
    -GGenerate a new key pair
    -CChange/remove the password of a secret key
    -RRecreate a public key file from a secret key file
    -SSign files
    -VVerify that a signature is valid for a given file
    -H(With -V) Requires the signature to be prehashed
    -lSign using the legacy format
    -m <file>File to sign/verify
    -o(With -V) Output the file content after verification
    -p <pubkey_file>Public key file (default: ./minisign.pub)
    -P <pubkey>Public key, as a base64 string
    -s <seckey_file>Secret key file (default: ~/.minisign/minisign.key)
    -WDo not encrypt/decrypt the secret key with a password
    -x <sig_file>Signature file (default: <file>.minisig)
    -c <comment>Add a one-line untrusted comment
    -t <comment>Add a one-line trusted comment
    -qQuiet mode, suppress output
    -QPretty quiet mode, only print the trusted comment
    -fForce (with -G) overwrite a previous key pair
    -vDisplay version number