Skip to content

Latest commit

 

History

History
101 lines (75 loc) · 2.57 KB

README.md

File metadata and controls

101 lines (75 loc) · 2.57 KB

Minisign

A ruby implemenation of Minisign.

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