A ruby implemenation of Minisign.
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
.
require 'minisign'
public_key = Minisign::PublicKey.new('RWSmKaOrT6m3TGwjwBovgOmlhSbyBUw3hyhnSOYruHXbJa36xHr8rq2M')
# or from a file
public_key = Minisign::PublicKey.new(File.read("test/minisign.pub"))
message = File.read("test/example.txt")
signature = Minisign::Signature.new(File.read("test/example.txt.minisig"))
public_key.verify(signature, message)
password = "password" # optional, if the key is not encrypted
private_key = Minisign::PrivateKey.new(File.read("minisign.key"), password)
password = "new password"
private_key.change_password! password
# or remove the password
private_key.change_password! nil
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)
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
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.
irb -Ilib -rminisign
The documentation for this gem is published here: https://www.rubydoc.info/gems/minisign/
or if working locally:
yard server --reload