brndnmtthws / dryoc

Don't Roll Your Own Crypto: pure-Rust, hard to misuse cryptography library
https://docs.rs/dryoc
MIT License
267 stars 14 forks source link

feat: add `VecSignedMessage` type alias #46

Closed SimenB closed 1 year ago

SimenB commented 1 year ago

This provides similar utility as VecBox in dryocsecretbox, allowing the following:

let message: Vec<u8> = some_message_from_somewhere;

let secret_box = VecBox::from_bytes(message).unwrap();

let message = secret_box.decrypt_to_vec(&nonce, &secret_key).unwrap();

let signed_message = VecSignedMessage::from_bytes(&message).unwrap();

signed_message.verify(public_key).unwrap();

let (_signature, message) = signed_message.into_parts();

// use unpacked `message`.

without VecSignedMessage, the from_bytes call on SignedMessage needs type annotations.

(Caveat - while I've used libsodium in javascript before, I'm very new to writing Rust. So this might not make sense πŸ˜€)

netlify[bot] commented 1 year ago

Deploy Preview for dryoc-docs ready!

Name Link
Latest commit 846de8a4d34077f10930fbdce804cff096716fed
Latest deploy log https://app.netlify.com/sites/dryoc-docs/deploys/642efeac76891600084b8cf7
Deploy Preview https://deploy-preview-46--dryoc-docs.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

codecov[bot] commented 1 year ago

Codecov Report

Merging #46 (846de8a) into main (949891e) will not change coverage. The diff coverage is n/a.

@@           Coverage Diff           @@
##             main      #46   +/-   ##
=======================================
  Coverage   65.19%   65.19%           
=======================================
  Files          44       44           
  Lines        3166     3166           
=======================================
  Hits         2064     2064           
  Misses       1102     1102           
Impacted Files Coverage Ξ”
src/sign.rs 15.78% <ΓΈ> (ΓΈ)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more