Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = "https://github.com/monkeytroop/monkey-troop"

[workspace.dependencies]
# Async runtime
tokio = { version = "1.52", features = ["full"] }
tokio = { version = "1.52", features = ["full", "test-util"] }
async-trait = "0.1"

# Web framework
Expand Down Expand Up @@ -52,8 +52,8 @@ uuid = { version = "1", features = ["v4"] }
# Crypto (E2E encryption)
x25519-dalek = { version = "2.0", features = ["static_secrets"] }
chacha20poly1305 = "0.10"
hkdf = "0.12"
hkdf = "0.12.4"
sha2 = "0.10"
base64 = "0.22"
rand = "0.8"
rand_core = { version = "0.6", features = ["getrandom"] }
rand_core = "0.6"
Comment on lines 54 to +59

Copilot AI Apr 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hkdf is pinned with an exact version requirement (=0.12.4). Unless there is a known incompatibility with newer 0.12.x patch releases, consider using a non-exact constraint (e.g., 0.12.4 / 0.12) so Cargo can pick up patch-level bug/security fixes without another PR.

Copilot uses AI. Check for mistakes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from unittest.mock import patch
from datetime import datetime, timezone
from unittest.mock import MagicMock

Expand Down Expand Up @@ -169,9 +170,6 @@ def test_select_node_all_suspended_returns_none(
assert selected is None


from unittest.mock import patch


def test__weighted_select_empty_candidates(discovery_service, mock_reputation_repo):
"""If candidates list is empty, return None immediately."""
selected = discovery_service._weighted_select([])
Expand Down
1 change: 1 addition & 0 deletions shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ chacha20poly1305 = { workspace = true }
hkdf = { workspace = true }
sha2 = { workspace = true }
base64 = { workspace = true }
rand = { workspace = true }
rand_core = { workspace = true }

[dev-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions shared/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use base64::Engine;
use chacha20poly1305::aead::Aead;
use chacha20poly1305::{ChaCha20Poly1305, KeyInit, Nonce};
use hkdf::Hkdf;
use rand_core::{OsRng, RngCore};
use rand_core::RngCore;
use serde::{Deserialize, Serialize};
use sha2::Sha256;
use x25519_dalek::{PublicKey, StaticSecret};
Expand Down Expand Up @@ -41,7 +41,7 @@ pub struct E2EChunkEnvelope {

/// Generate a new X25519 keypair, returning (secret, base64-encoded public key)
pub fn generate_keypair() -> (StaticSecret, String) {
let secret = StaticSecret::random_from_rng(OsRng);
let secret = StaticSecret::random_from_rng(rand::thread_rng());
let public = PublicKey::from(&secret);
let public_b64 = BASE64.encode(public.as_bytes());
(secret, public_b64)
Expand Down Expand Up @@ -70,7 +70,7 @@ pub fn derive_session_key(shared_secret: &[u8; 32]) -> Result<[u8; 32]> {
/// Generate a random 12-byte nonce
pub fn generate_base_nonce() -> [u8; 12] {
let mut nonce = [0u8; 12];
OsRng.fill_bytes(&mut nonce);
rand::thread_rng().fill_bytes(&mut nonce);
nonce
}

Expand Down
Loading