Get rid of Signature model and change sign and verify to sign_detatched and verify_detached

master
Dave 2018-02-13 20:20:27 -08:00
parent e65a47a4ac
commit 0f68a21481
3 changed files with 5 additions and 20 deletions

View File

@ -27,12 +27,12 @@ describe Cox do
message = "test"
signing_pair = Cox::SignKeyPair.new
# Create signature using the secret key
signature = Cox.sign(message, signing_pair.secret)
signature = Cox.sign_detached(message, signing_pair.secret)
# Verify the signature on the message
verified = Cox.verify(signature, message, signing_pair.public)
verified = Cox.verify_detached(signature, message, signing_pair.public)
verified.should eq(true)
end

View File

@ -23,7 +23,7 @@ module Cox
output_buffer
end
def self.sign(message, secret_key : SignSecretKey)
def self.sign_detached(message, secret_key : SignSecretKey)
message_buffer = message.to_slice
message_buffer_size = message_buffer.bytesize
signature_output_buffer = Bytes.new(LibSodium::SIGNATURE_BYTES)
@ -32,7 +32,7 @@ module Cox
signature_output_buffer
end
def self.verify(signature, message, public_key : SignPublicKey)
def self.verify_detached(signature, message, public_key : SignPublicKey)
signature_buffer = signature.to_slice
message_buffer = message.to_slice
message_buffer_size = message_buffer.bytesize

View File

@ -1,15 +0,0 @@
require "./lib_sodium"
module Cox
class Signature
property bytes : Bytes
KEY_LENGTH = LibSodium::SIGNATURE_BYTES
def initialize(@bytes : Bytes)
if bytes.bytesize != KEY_LENGTH
raise ArgumentError.new("Signature must be #{KEY_LENGTH} bytes, got #{bytes.bytesize}")
end
end
end
end