From 0f68a21481a5014d2cb5f47ce6ad4cb899bc8f55 Mon Sep 17 00:00:00 2001 From: Dave Date: Tue, 13 Feb 2018 20:20:27 -0800 Subject: [PATCH] Get rid of Signature model and change sign and verify to sign_detatched and verify_detached --- spec/cox_spec.cr | 6 +++--- src/cox.cr | 4 ++-- src/cox/signature.cr | 15 --------------- 3 files changed, 5 insertions(+), 20 deletions(-) delete mode 100644 src/cox/signature.cr diff --git a/spec/cox_spec.cr b/spec/cox_spec.cr index c1c416c..d0afed6 100644 --- a/spec/cox_spec.cr +++ b/spec/cox_spec.cr @@ -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 diff --git a/src/cox.cr b/src/cox.cr index ecee5c9..1e5fe1a 100644 --- a/src/cox.cr +++ b/src/cox.cr @@ -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 diff --git a/src/cox/signature.cr b/src/cox/signature.cr deleted file mode 100644 index 1214638..0000000 --- a/src/cox/signature.cr +++ /dev/null @@ -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