Skip to content

Commit

Permalink
Update crypto_box requirement from 0.7.1 to 0.8.1 (#107)
Browse files Browse the repository at this point in the history
* Update crypto_box requirement from 0.7.1 to 0.8.1

Updates the requirements on [crypto_box](https://github.com/RustCrypto/nacl-compat) to permit the latest version.
- [Release notes](https://github.com/RustCrypto/nacl-compat/releases)
- [Commits](RustCrypto/nacl-compat@crypto_box-v0.7.1...crypto_box-v0.8.1)

---
updated-dependencies:
- dependency-name: crypto_box
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* update with crypto_box new API

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alex Xiong <alex.xiong.tech@gmail.com>
  • Loading branch information
2 people authored and sveitser committed Sep 30, 2022
1 parent fbbe665 commit 2a53abb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ zeroize = { version = "1.3", default-features = false }
itertools = { version = "0.10.1", default-features = false, features = [ "use_alloc" ] }
serde = { version = "1.0", features = ["derive"] }
generic-array = { version = "^0.14", default-features = false }
crypto_box = { version = "0.7.1", default-features = false, features = [ "u64_backend", "alloc" ] }
crypto_box = "0.8.1"
displaydoc = { version = "0.2.3", default-features = false }
derivative = { version = "2", features = ["use_core"] }
rand_chacha = { version = "0.3.1", default-features = false }
Expand Down
15 changes: 6 additions & 9 deletions primitives/src/aead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use ark_std::{
vec::Vec,
};
use crypto_box::{
aead::{Aead, Nonce, Payload},
aead::{Aead, AeadCore, Nonce, Payload},
ChaChaBox,
};
use generic_array::{typenum::U24, GenericArray};
Expand Down Expand Up @@ -82,19 +82,16 @@ impl EncKey {
/// during encryption will cause decryption to fail, which is useful if you
/// would like to "bind" the ciphertext to some identifier, like a
/// digital signature key.
pub fn encrypt<R>(
pub fn encrypt(
&self,
rng: &mut R,
mut rng: impl RngCore + CryptoRng,
message: &[u8],
aad: &[u8],
) -> Result<Ciphertext, PrimitivesError>
where
R: RngCore + CryptoRng,
{
let nonce = crypto_box::generate_nonce(rng);
) -> Result<Ciphertext, PrimitivesError> {
let nonce = ChaChaBox::generate_nonce(&mut rng);

// generate an ephemeral key pair as the virtual sender to derive the crypto box
let ephemeral_sk = crypto_box::SecretKey::generate(rng);
let ephemeral_sk = crypto_box::SecretKey::generate(&mut rng);
let ephemeral_pk = EncKey(crypto_box::PublicKey::from(&ephemeral_sk));
let my_box = ChaChaBox::new(&self.0, &ephemeral_sk);

Expand Down

0 comments on commit 2a53abb

Please sign in to comment.