updated Usage in README and cleaned up libsodium bindings

master
Dave 2018-02-11 23:18:45 -08:00
parent 3fa19b57e3
commit e65a47a4ac
2 changed files with 24 additions and 10 deletions

View File

@ -39,6 +39,19 @@ nonce, encrypted = Cox.encrypt(data, bob.public, alice.secret)
decrypted = Cox.decrypt(encrypted, nonce, alice.public, bob.secret) decrypted = Cox.decrypt(encrypted, nonce, alice.public, bob.secret)
String.new(decrypted) # => "Hello World!" 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 ## Contributing
@ -52,3 +65,4 @@ String.new(decrypted) # => "Hello World!"
## Contributors ## Contributors
- [andrewhamon](https://github.com/andrewhamon) Andrew Hamon - creator, maintainer - [andrewhamon](https://github.com/andrewhamon) Andrew Hamon - creator, maintainer
- [dorkrawk](https://github.com/dorkrawk) Dave Schwantes - contributor

View File

@ -3,21 +3,21 @@ module Cox
lib LibSodium lib LibSodium
fun sodium_init() : LibC::Int fun sodium_init() : LibC::Int
fun crypto_box_publickeybytes() : LibC::SizeT fun crypto_box_publickeybytes() : LibC::SizeT
fun crypto_box_secretkeybytes() : LibC::SizeT fun crypto_box_secretkeybytes() : LibC::SizeT
fun crypto_box_noncebytes() : LibC::SizeT fun crypto_box_noncebytes() : LibC::SizeT
fun crypto_box_macbytes() : LibC::SizeT fun crypto_box_macbytes() : LibC::SizeT
fun crypto_sign_publickeybytes() : LibC::SizeT fun crypto_sign_publickeybytes() : LibC::SizeT
fun crypto_sign_secretkeybytes() : 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() PUBLIC_KEY_BYTES = crypto_box_publickeybytes()
SECRET_KEY_BYTES = crypto_box_secretkeybytes() SECRET_KEY_BYTES = crypto_box_secretkeybytes()
NONCE_BYTES = crypto_box_macbytes() NONCE_BYTES = crypto_box_macbytes()
MAC_BYTES = crypto_box_macbytes() MAC_BYTES = crypto_box_macbytes()
PUBLIC_SIGN_BYTES = crypto_sign_publickeybytes() PUBLIC_SIGN_BYTES = crypto_sign_publickeybytes()
SECRET_SIGN_BYTES = crypto_sign_secretkeybytes() SECRET_SIGN_BYTES = crypto_sign_secretkeybytes()
SIGNATURE_BYTES = crypto_sign_bytes() SIGNATURE_BYTES = crypto_sign_bytes()
fun crypto_box_keypair( fun crypto_box_keypair(
public_key_output : Pointer(LibC::UChar), public_key_output : Pointer(LibC::UChar),