Sha256: f56d965452c24ba79b7bd8a16428b5ac5eec4bbc72ebd105792dd3d63c817600

Contents?: true

Size: 613 Bytes

Versions: 1

Compression:

Stored size: 613 Bytes

Contents

module Cryptosphere
  # Sign the given message with a private key
  def self.sign(key, message)
    AsymmetricCipher.new(key).private_encrypt(kdf(message))
  end

  # Verify a message with the public key. Returns if the signature matches,
  # and false if there's a mismatch
  def self.verify(key, message, signature)
    AsymmetricCipher.new(key).public_decrypt(signature) == kdf(message)
  end

  # Verify a message, raising InvalidSignatureError on signature mismatch
  def self.verify!(key, message, signature)
    verify(key, message, signature) or raise InvalidSignatureError, "signature mismatch"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cryptosphere-0.0.0 lib/cryptosphere/crypto/signature_algorithm.rb