diff --git a/README.md b/README.md index f95a702..d8f7c0f 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,19 @@ nonce, encrypted = Cox.encrypt(data, bob.public, alice.secret) decrypted = Cox.decrypt(encrypted, nonce, alice.public, bob.secret) String.new(decrypted) # => "Hello World!" + + +# Public key signing + +message = "Hello World!" + +signing_pair = Cox::SignKeyPair.new + +# Sign the message +signature = Cox.sign(message, signing_pair.secret) + +# And verify +Cox.verify(signature, message, signing_pair.public) # => true ``` ## Contributing @@ -52,3 +65,4 @@ String.new(decrypted) # => "Hello World!" ## Contributors - [andrewhamon](https://github.com/andrewhamon) Andrew Hamon - creator, maintainer +- [dorkrawk](https://github.com/dorkrawk) Dave Schwantes - contributor diff --git a/src/cox/lib_sodium.cr b/src/cox/lib_sodium.cr index 020e97c..8139fb0 100644 --- a/src/cox/lib_sodium.cr +++ b/src/cox/lib_sodium.cr @@ -3,21 +3,21 @@ module Cox lib LibSodium fun sodium_init() : LibC::Int - fun crypto_box_publickeybytes() : LibC::SizeT - fun crypto_box_secretkeybytes() : LibC::SizeT - fun crypto_box_noncebytes() : LibC::SizeT - fun crypto_box_macbytes() : LibC::SizeT + fun crypto_box_publickeybytes() : LibC::SizeT + fun crypto_box_secretkeybytes() : LibC::SizeT + fun crypto_box_noncebytes() : LibC::SizeT + fun crypto_box_macbytes() : LibC::SizeT fun crypto_sign_publickeybytes() : LibC::SizeT fun crypto_sign_secretkeybytes() : LibC::SizeT - fun crypto_sign_bytes() : LibC::SizeT + fun crypto_sign_bytes() : LibC::SizeT - PUBLIC_KEY_BYTES = crypto_box_publickeybytes() - SECRET_KEY_BYTES = crypto_box_secretkeybytes() - NONCE_BYTES = crypto_box_macbytes() - MAC_BYTES = crypto_box_macbytes() + PUBLIC_KEY_BYTES = crypto_box_publickeybytes() + SECRET_KEY_BYTES = crypto_box_secretkeybytes() + NONCE_BYTES = crypto_box_macbytes() + MAC_BYTES = crypto_box_macbytes() PUBLIC_SIGN_BYTES = crypto_sign_publickeybytes() SECRET_SIGN_BYTES = crypto_sign_secretkeybytes() - SIGNATURE_BYTES = crypto_sign_bytes() + SIGNATURE_BYTES = crypto_sign_bytes() fun crypto_box_keypair( public_key_output : Pointer(LibC::UChar),