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
27 changes: 11 additions & 16 deletions packages/wbraid/Cargo.lock

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

66 changes: 66 additions & 0 deletions packages/wbraid/PROVENANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,69 @@ repository-root `REUSE.toml`.
- **Added AGPL-3.0-only headers to `crates/braid/fuzz/`** (`Cargo.toml` and
`.gitignore`), which carried no licence markers. The fuzz crate is its own
cargo workspace and keeps no lockfile, matching the source branch.

## Local modifications for building on stable Rust

The source branch assumes a nightly toolchain; the following changes make the
workspace build with stable Rust (1.96.0), with upstream behaviour restored on
nightly by enabling the named features:

- **Gated `crates/vsc`'s nightly feature gates** (`stmt_expr_attributes`,
`proc_macro_hygiene`) behind `cfg_attr(feature = "custom-warnings", ...)`,
and wrapped every `#[crate::warning(...)]` in statement, expression, or
file-module position the same way — those positions reject proc-macro
attributes on stable even though `custom_warning_macro` expands to a no-op
pass-through when its `on` feature is off. Item-position uses are unchanged.
- **Gated the libtest bench** `crates/vsc/benches/shuffle.rs`
(`#![feature(test)]`, a hard error on stable) behind a new empty
`nightly-benches` feature via `required-features`, so `--all-targets` builds
skip it on stable.
- **Pinned `primefield` to `0.14.0-rc.9` in `Cargo.lock`**: cargo's pre-release
semver rules resolve `p256 0.14.0-rc.9`'s `primefield 0.14.0-rc.9`
requirement to the API-incompatible `0.14.0` final release, which does not
compile against p256 rc.9.
- The `[[patch.unused]]` entry for `auto_generate_cdp` in `Cargo.lock` is
written by cargo because `packages/.cargo/config.toml` (an ancestor config)
declares that patch for the main workspace; it is inert here.

`cargo clippy --workspace` passes on stable. `cargo clippy -p vsc
--all-targets` fails inside `crates/vsc`'s test modules and the
`shuffle_scaling` example (mostly `unwrap_used` and pedantic lints in test
code, identical on nightly); that upstream state is left untouched.

## Local modifications for clippy

The tree was imported with warn-level clippy findings in `braid`, `rnk` and
`v2v`, so a `-D warnings` gate failed. The following changes make

```
cargo clippy --workspace --exclude vsc --all-targets --no-deps -- -D warnings
cargo clippy -p vsc --no-deps
```

pass on stable 1.96.0. `crates/vsc` is linted separately at upstream's own
levels (`--no-deps` keeps `-D warnings` from reaching it through the workspace
run) and is untouched: its lib passes, with upstream's warn-level
`indexing_slicing` findings.

- **`crates/braid`**: dropped the same-type casts of `PROTOCOL_MANAGER_INDEX`
and a `clone()` of the `Copy` type `MessageType`; `AccumulatorSet::extract`
is `flatten().cloned()`. Two functions were over the argument limit:
`Trustee::sign_mix` lost its unused `_self_index` parameter;
`compute_partial_decryptions_inner` keeps its eight under
`#[expect(clippy::too_many_arguments)]`, since it exists as a monomorphized
call target for the dispatching function and takes exactly that function's
locals. In `tests/model_check*.rs`: two `clone()`s of `Copy` group elements
and a redundant closure.
- **`crates/rnk`**: the seven value types' inherent `to_string()` methods
(`inherent_to_string`) became `fmt::Display` impls producing the same JSON.
`.to_string()` callers are unaffected; the `unwrap()` on serialization is
gone.
- **`crates/v2v`**: `is_multiple_of` for the `% 2` checks, a `clone()` of a
`Copy` scalar, and the test module of `wire/protinfo.rs` moved to the end of
the file (`items_after_test_module`, it had sat between the parse and emit
halves). `wire::crypto::pos_seed` keeps its eight parameters under
`#[expect(clippy::too_many_arguments)]`: they map one-to-one onto the node
the spec hashes. In `tests/`: needless borrows, a `&PathBuf` parameter that is
now `&Path`, a duplicated `allow(dead_code)`, and a boxed-closure table that
is now fn pointers behind a type alias.
4 changes: 2 additions & 2 deletions packages/wbraid/crates/b4/src/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ use std::time::Duration;

pub async fn init_s3_client() -> Client {
let config = aws_config::load_defaults(BehaviorVersion::latest()).await;

// Force path-style URLs for LocalStack compatibility
let s3_config = aws_sdk_s3::config::Builder::from(&config)
.force_path_style(true)
.build();

Client::from_conf(s3_config)
}

Expand Down
6 changes: 3 additions & 3 deletions packages/wbraid/crates/b4/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ pub struct AppState {

impl AppState {
pub fn new(db: SqlitePool, s3_client: S3Client) -> Self {
let bucket_name = std::env::var("S3_BUCKET_NAME")
.unwrap_or_else(|_| "wbraid-messages".to_string());
let bucket_name =
std::env::var("S3_BUCKET_NAME").unwrap_or_else(|_| "wbraid-messages".to_string());

Self {
db,
s3_client,
Expand Down
17 changes: 9 additions & 8 deletions packages/wbraid/crates/braid/src/board/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ mod tests {

use crate::messages::artifact::Configuration;
use crate::messages::newtypes::{zero_hash, ConfigurationHash, PublicKeyHash};
use crate::protocol_manager::ProtocolManager;
use crate::messages::wire::ProtocolMessage;
use crate::protocol_manager::ProtocolManager;

use cryptography::utils::serialization::Serializable;

Expand Down Expand Up @@ -363,7 +363,11 @@ mod tests {
let first = ProtocolMessage::<C>::shares(&trustee1, DATE, cfg_hash, &vec![1u8, 2, 3]);
let first_bytes = first.ser();
client.post(vec![first]).await?;
assert_eq!(board.snapshot().len(), 2, "Configuration + the first Shares");
assert_eq!(
board.snapshot().len(),
2,
"Configuration + the first Shares"
);
assert_eq!(client.own_posts().len(), 1, "the slot is now recorded");

// A recomputed sharing for the same slot: fresh randomness, so a different
Expand Down Expand Up @@ -403,8 +407,7 @@ mod tests {
cfg_message,
} = setup::<C>(2)?;
let sk1 = signing_keys.into_iter().next().unwrap();
let trustee1 =
Trustee::<C>::new("1".to_string(), sk1, KeyPair::<C>::generate(), &cfg)?;
let trustee1 = Trustee::<C>::new("1".to_string(), sk1, KeyPair::<C>::generate(), &cfg)?;

// Parent (DKG) board: Configuration + a Shares from trustee 1.
let parent_board = MemoryBoard::<C>::new();
Expand Down Expand Up @@ -493,8 +496,7 @@ mod tests {
cfg_message,
} = setup::<C>(2)?;
let sk1 = signing_keys.into_iter().next().unwrap();
let trustee1 =
Trustee::<C>::new("1".to_string(), sk1, KeyPair::<C>::generate(), &cfg)?;
let trustee1 = Trustee::<C>::new("1".to_string(), sk1, KeyPair::<C>::generate(), &cfg)?;

let dkg_board = MemoryBoard::<C>::new();
dkg_board.push(cfg_message);
Expand Down Expand Up @@ -563,8 +565,7 @@ mod tests {
..
} = setup::<C>(2)?;
let sk1 = signing_keys.into_iter().next().unwrap();
let trustee1 =
Trustee::<C>::new("1".to_string(), sk1, KeyPair::<C>::generate(), &cfg)?;
let trustee1 = Trustee::<C>::new("1".to_string(), sk1, KeyPair::<C>::generate(), &cfg)?;

let board = MemoryBoard::<C>::new();
board.push(cfg_message);
Expand Down
5 changes: 4 additions & 1 deletion packages/wbraid/crates/braid/src/board/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ impl<C: Context> MessageStore<C> {
/// message (single ballots slot per board). Feeds the tally-scoped
/// Fiat-Shamir labels of the mix and decrypt phases.
pub fn tally_id(&self) -> Option<u128> {
self.ballots.keys().next().map(|predicate| predicate.tally_id)
self.ballots
.keys()
.next()
.map(|predicate| predicate.tally_id)
}

/// The body bytes of the `Mix` message whose output out-hash is `output`.
Expand Down
2 changes: 1 addition & 1 deletion packages/wbraid/crates/braid/src/board/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub fn verify<C: Context>(
message.sender.pk
)
})?;
let is_manager = position == PROTOCOL_MANAGER_INDEX as usize;
let is_manager = position == PROTOCOL_MANAGER_INDEX;
let verifier = if is_manager {
&configuration.protocol_manager
} else {
Expand Down
6 changes: 1 addition & 5 deletions packages/wbraid/crates/braid/src/datalog/accumulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ impl<T: Ord + std::fmt::Debug + Clone> AccumulatorSet<T> {

/// Extract all present values in trustee-index order.
pub(crate) fn extract(&self) -> Vec<T> {
self.values
.iter()
.filter(|t| t.is_some())
.map(|t| t.clone().expect("t.is_some() == true"))
.collect()
self.values.iter().flatten().cloned().collect()
}
}
3 changes: 1 addition & 2 deletions packages/wbraid/crates/braid/src/datalog/composed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ mod tests {
/// manager input and must halt the protocol.
#[test]
fn mixing_set_size_must_match_threshold() {
run(&config_and_ballots(vec![1, 2]))
.expect("a threshold-sized mixing set must not error");
run(&config_and_ballots(vec![1, 2])).expect("a threshold-sized mixing set must not error");

for trustees in [vec![1], vec![1, 2, 3]] {
let err = run(&config_and_ballots(trustees.clone()))
Expand Down
2 changes: 1 addition & 1 deletion packages/wbraid/crates/braid/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ extern crate cfg_if;

pub mod board;
pub mod datalog;
pub mod messages;
pub mod dispatch;
pub mod messages;
pub mod protocol_manager;
pub mod session;
pub mod trustee;
Expand Down
2 changes: 1 addition & 1 deletion packages/wbraid/crates/braid/src/messages/artifact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<C: Context> Configuration<C> {
trustee_pk: &<C::SignatureScheme as SignatureScheme<C::Rng>>::Verifier,
) -> Option<usize> {
if trustee_pk == &self.protocol_manager {
Some(PROTOCOL_MANAGER_INDEX as usize)
Some(PROTOCOL_MANAGER_INDEX)
} else {
self.trustees.iter().position(|t| t == trustee_pk)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/wbraid/crates/braid/src/messages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
//! *participant* (a `Signer`) rather than message vocabulary — lives in
//! [`crate::protocol_manager`], alongside [`crate::trustee`].

pub mod newtypes;
pub mod artifact;
pub mod newtypes;
pub mod wire;

pub mod predicate;
2 changes: 1 addition & 1 deletion packages/wbraid/crates/braid/src/messages/wire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl<C: Context> Clone for ProtocolMessage<C> {
ProtocolMessage {
sender: self.sender.clone(),
signature: self.signature.clone(),
message_type: self.message_type.clone(),
message_type: self.message_type,
head: self.head.clone(),
body: self.body.clone(),
}
Expand Down
7 changes: 3 additions & 4 deletions packages/wbraid/crates/braid/src/native/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,9 @@ impl Persistence for SqlitePersistence {
async fn load_own_posts(&self) -> Result<Vec<(Predicate, StagedRef)>> {
let conn = self.conn.lock().expect("predicate store mutex poisoned");
let mut statement = conn.prepare("SELECT bytes, staged_ref FROM own_posts")?;
let rows = statement
.query_map([], |row| {
Ok((row.get::<_, Vec<u8>>(0)?, row.get::<_, String>(1)?))
})?;
let rows = statement.query_map([], |row| {
Ok((row.get::<_, Vec<u8>>(0)?, row.get::<_, String>(1)?))
})?;
let mut out = Vec::new();
for row in rows {
let (bytes, staged) = row?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ use crate::board::transport::{MemoryBoard, MemoryTransport};
use crate::board::BoardClient;
use crate::messages::artifact::Configuration;
use crate::messages::newtypes::{ConfigurationHash, Timestamp};
use crate::protocol_manager::ProtocolManager;
use crate::messages::wire::ProtocolMessage;
use crate::native::persistence::SqlitePersistence;
use crate::protocol_manager::ProtocolManager;
use crate::trustee::Trustee;

const DATE: Timestamp = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ use crate::messages::artifact::{Ballots, Configuration, DkgPublicKey, Plaintexts
use crate::messages::newtypes::{
hash_bytes, ConfigurationHash, PublicKeyHash, Timestamp, TrusteeIndex, MAX_TRUSTEES,
};
use crate::protocol_manager::ProtocolManager;
use crate::messages::wire::{MessageType, ProtocolMessage};
use crate::protocol_manager::ProtocolManager;

use crate::board::persistence::NoOpPersistence;
use crate::board::transport::Transport;
use crate::board::BoardClient;
use crate::native::http_transport::HttpTransport;
use crate::trustee::Trustee;
use crate::session::Session;
use crate::trustee::Trustee;

/// b4 server endpoint the test drives against (must be running, with S3).
const HTTP_URL: &str = "http://127.0.0.1:3000";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ use crate::messages::artifact::{Ballots, Configuration, DkgPublicKey, Plaintexts
use crate::messages::newtypes::{
hash_bytes, ConfigurationHash, PublicKeyHash, Timestamp, TrusteeIndex, MAX_TRUSTEES,
};
use crate::protocol_manager::ProtocolManager;
use crate::messages::wire::{MessageType, ProtocolMessage};
use crate::protocol_manager::ProtocolManager;

use crate::board::persistence::Persistence;
use crate::board::transport::Transport;
Expand Down Expand Up @@ -262,10 +262,7 @@ fn temp_db(tag: &str) -> std::path::PathBuf {
/// Drive `trustees` over their board `clients` to a fixpoint via the update-first
/// cycle (§6), sequentially (HTTP latency dominates). Trustee `i` is paired with
/// client `i`.
async fn drive<C, T, P>(
trustees: &[Trustee<C>],
clients: &mut [BoardClient<C, T, P>],
) -> Result<()>
async fn drive<C, T, P>(trustees: &[Trustee<C>], clients: &mut [BoardClient<C, T, P>]) -> Result<()>
where
C: Context,
T: Transport<C>,
Expand Down
Loading
Loading