Project

minisign

0.0
The project is in a healthy, maintained state
Create and verify minisign signatures
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 7.1
~> 1.3
 Project Readme

Minisign

A ruby implemenation of Minisign.

  • Installation & Usage
    • Read a public key
    • Verify a signature
    • Read a private key
    • Change the private key's password
    • Create a signature
    • Generate a key pair
  • CLI
  • Local Development
  • Documentation

Installation & Usage

gem install minisign

Note: This gem has a conditional dependency on libsodium for the functionality related to key derivation and signature creation. Signature verification does not need libsodium.

Read a public key

require 'minisign'
public_key = Minisign::PublicKey.new('RWSmKaOrT6m3TGwjwBovgOmlhSbyBUw3hyhnSOYruHXbJa36xHr8rq2M')
# or from a file
public_key = Minisign::PublicKey.new(File.read("test/minisign.pub"))

Verify a signature

message = File.read("test/example.txt")
signature = Minisign::Signature.new(File.read("test/example.txt.minisig"))
public_key.verify(signature, message)

Read a private key

password = "password" # optional, if the key is not encrypted
private_key = Minisign::PrivateKey.new(File.read("minisign.key"), password)

Change the private key's password

password = "new password"
private_key.change_password! password
# or remove the password
private_key.change_password! nil

Create a signature

file_path = "example.txt"
password = "password"
trusted_comment = "the trusted comment"
untrusted_comment = "the untrusted comment"
signature = private_key.sign(file_path, File.read(file_path), trusted_comment, untrusted_comment)
File.write("#{file_path}.minisig", signature.to_s)

Generate a key pair

password = "password" # or nil, to generate a private key without encryption
keypair = Minisign::KeyPair.new(password)
keypair.private_key # Minisign::PrivateKey
keypair.public_key # Minisign::PublicKey

CLI

This gem provides an executable minisign that implements the CLI provided by jedisct1/minisign.

See command line options here or run the executable without any arguments to see usage options.

Local Development

irb -Ilib -rminisign

Documentation

The documentation for this gem is published here: https://www.rubydoc.info/gems/minisign/

or if working locally:

yard server --reload