Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
75003d0
[cryptography/certificate] make namespace a part of the scheme
andresilva Dec 18, 2025
32f39fb
[consensus/aggregation] adapt to new scheme API
andresilva Dec 18, 2025
15c39c2
[consensus/ordered_broadcast] new scheme API
andresilva Dec 18, 2025
01d64ea
[consensus/simplex] new scheme API
andresilva Dec 18, 2025
028bfe5
[consensus/fuzz] fix
andresilva Dec 18, 2025
0caff3c
[consensus/marshal] fix
andresilva Dec 18, 2025
5d0faa7
[examples/reshare] fix
andresilva Dec 18, 2025
e0f321c
[examples/log] fix
andresilva Dec 18, 2025
10246e7
[examples/bridge] fix
andresilva Dec 18, 2025
446cd76
todo
andresilva Dec 18, 2025
66ba019
[consensus/simplex] fix test
andresilva Dec 18, 2025
5f07da5
Merge branch 'main' into andre/consensus-avoid-namespace-recomputation
andresilva Dec 19, 2025
4c5b733
[cryptography/certificate] docs
andresilva Dec 19, 2025
286505c
[examples/bridge] single namespace
andresilva Dec 19, 2025
489044f
[consensus/marshal] fix tests
andresilva Dec 19, 2025
05be6fc
[examples/bridge] rename namespaces map
andresilva Dec 19, 2025
65273cb
[examples/bridge] revert
andresilva Dec 19, 2025
d88b17b
[consensus/simplex] nits
andresilva Dec 19, 2025
c083894
[consensus/simplex] nits
andresilva Dec 19, 2025
dee840b
[cryptography/certificate] whitespace
andresilva Dec 19, 2025
ae8c0c3
[cryptography/certificate] nits
andresilva Dec 19, 2025
2fe704a
[cryptography/certificate] nits
andresilva Dec 19, 2025
01a3ee4
[cryptography/certificate] nits
andresilva Dec 19, 2025
7c31e5b
Merge branch 'main' into andre/consensus-avoid-namespace-recomputation
andresilva Dec 20, 2025
77aa7df
Merge branch 'main' into andre/consensus-avoid-namespace-recomputation
andresilva Dec 23, 2025
d37c72f
Merge branch 'main' into andre/consensus-avoid-namespace-recomputation
andresilva Jan 3, 2026
9e0a114
[cryptography] fix secp256r1 certificate scheme
andresilva Jan 3, 2026
e26cd13
[consensus/simplex] fix batcher verifier tests
andresilva Jan 3, 2026
ef0a9ef
[consensus/ordered_broadcast] fix test
andresilva Jan 3, 2026
4c7da9f
Merge branch 'main' into andre/consensus-avoid-namespace-recomputation
andresilva Jan 4, 2026
3c6ad1e
[cryptography] Namespace as Scheme Nits (#2688)
patrick-ogrady Jan 5, 2026
7470e8b
fix regression
patrick-ogrady Jan 5, 2026
924dd81
provider before ctx
patrick-ogrady Jan 5, 2026
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ impl Simplex for SimplexBls12381MultisigMinPk {
type Scheme = bls12381_multisig::Scheme<Ed25519PublicKey, MinPk>;
type Elector = RoundRobin;

fn fixture(context: &mut deterministic::Context, n: u32) -> Fixture<Self::Scheme> {
bls12381_multisig::fixture::<MinPk, _>(context, n)
fn fixture(
context: &mut deterministic::Context,
namespace: &[u8],
n: u32,
) -> Fixture<Self::Scheme> {
bls12381_multisig::fixture::<MinPk, _>(context, namespace, n)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ impl Simplex for SimplexBls12381MultisigMinSig {
type Scheme = bls12381_multisig::Scheme<Ed25519PublicKey, MinSig>;
type Elector = RoundRobin;

fn fixture(context: &mut deterministic::Context, n: u32) -> Fixture<Self::Scheme> {
bls12381_multisig::fixture::<MinSig, _>(context, n)
fn fixture(
context: &mut deterministic::Context,
namespace: &[u8],
n: u32,
) -> Fixture<Self::Scheme> {
bls12381_multisig::fixture::<MinSig, _>(context, namespace, n)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ impl Simplex for SimplexBls12381MinPk {
type Scheme = bls12381_threshold::Scheme<Ed25519PublicKey, MinPk>;
type Elector = Random;

fn fixture(context: &mut deterministic::Context, n: u32) -> Fixture<Self::Scheme> {
bls12381_threshold::fixture::<MinPk, _>(context, n)
fn fixture(
context: &mut deterministic::Context,
namespace: &[u8],
n: u32,
) -> Fixture<Self::Scheme> {
bls12381_threshold::fixture::<MinPk, _>(context, namespace, n)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ impl Simplex for SimplexBls12381MinSig {
type Scheme = bls12381_threshold::Scheme<Ed25519PublicKey, MinSig>;
type Elector = Random;

fn fixture(context: &mut deterministic::Context, n: u32) -> Fixture<Self::Scheme> {
bls12381_threshold::fixture::<MinSig, _>(context, n)
fn fixture(
context: &mut deterministic::Context,
namespace: &[u8],
n: u32,
) -> Fixture<Self::Scheme> {
bls12381_threshold::fixture::<MinSig, _>(context, namespace, n)
}
}

Expand Down
8 changes: 6 additions & 2 deletions consensus/fuzz/fuzz_targets/simplex_ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ impl Simplex for SimplexEd25519 {
type Scheme = ed25519::Scheme;
type Elector = RoundRobin;

fn fixture(context: &mut deterministic::Context, n: u32) -> Fixture<Self::Scheme> {
ed25519::fixture(context, n)
fn fixture(
context: &mut deterministic::Context,
namespace: &[u8],
n: u32,
) -> Fixture<Self::Scheme> {
ed25519::fixture(context, namespace, n)
}
}

Expand Down
8 changes: 6 additions & 2 deletions consensus/fuzz/fuzz_targets/simplex_secp256r1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ impl Simplex for SimplexSecp256r1 {
type Scheme = secp256r1::Scheme<Ed25519PublicKey>;
type Elector = RoundRobin;

fn fixture(context: &mut deterministic::Context, n: u32) -> Fixture<Self::Scheme> {
secp256r1::fixture(context, n)
fn fixture(
context: &mut deterministic::Context,
namespace: &[u8],
n: u32,
) -> Fixture<Self::Scheme> {
secp256r1::fixture(context, namespace, n)
}
}

Expand Down
19 changes: 6 additions & 13 deletions consensus/fuzz/src/disrupter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ pub struct Disrupter<E: Clock + Spawner + CryptoRngCore, S: Scheme<Sha256Digest>
validator: PublicKey,
scheme: S,
participants: Set<PublicKey>,
namespace: Vec<u8>,
fuzz_input: FuzzInput,
last_vote: u64,
last_finalized: u64,
Expand All @@ -52,7 +51,6 @@ where
validator: PublicKey,
scheme: S,
participants: Set<PublicKey>,
namespace: Vec<u8>,
fuzz_input: FuzzInput,
) -> Self {
Self {
Expand All @@ -64,7 +62,6 @@ where
validator,
scheme,
participants,
namespace,
fuzz_input,
}
}
Expand Down Expand Up @@ -222,7 +219,7 @@ where
let _ = sender.send(Recipients::All, mutated.into(), true).await;
} else {
let proposal = self.mutate_proposal(&notarize.proposal);
if let Some(v) = Notarize::sign(&self.scheme, &self.namespace, proposal) {
if let Some(v) = Notarize::sign(&self.scheme, proposal) {
let msg = Vote::<S, Sha256Digest>::Notarize(v).encode().into();
let _ = sender.send(Recipients::All, msg, true).await;
}
Expand All @@ -234,7 +231,7 @@ where
let _ = sender.send(Recipients::All, mutated.into(), true).await;
} else {
let proposal = self.mutate_proposal(&finalize.proposal);
if let Some(v) = Finalize::sign(&self.scheme, &self.namespace, proposal) {
if let Some(v) = Finalize::sign(&self.scheme, proposal) {
let msg = Vote::<S, Sha256Digest>::Finalize(v).encode().into();
let _ = sender.send(Recipients::All, msg, true).await;
}
Expand All @@ -247,9 +244,7 @@ where
} else {
let v = self.random_view(self.last_vote);
let round = Round::new(Epoch::new(EPOCH), View::new(v));
if let Some(v) =
Nullify::<S>::sign::<Sha256Digest>(&self.scheme, &self.namespace, round)
{
if let Some(v) = Nullify::<S>::sign::<Sha256Digest>(&self.scheme, round) {
let msg = Vote::<S, Sha256Digest>::Nullify(v).encode().into();
let _ = sender.send(Recipients::All, msg, true).await;
}
Expand Down Expand Up @@ -338,13 +333,13 @@ where

match self.message() {
Message::Notarize => {
if let Some(vote) = Notarize::sign(&self.scheme, &self.namespace, proposal) {
if let Some(vote) = Notarize::sign(&self.scheme, proposal) {
let msg = Vote::<S, Sha256Digest>::Notarize(vote).encode().into();
let _ = sender.send(Recipients::All, msg, true).await;
}
}
Message::Finalize => {
if let Some(vote) = Finalize::sign(&self.scheme, &self.namespace, proposal) {
if let Some(vote) = Finalize::sign(&self.scheme, proposal) {
let msg = Vote::<S, Sha256Digest>::Finalize(vote).encode().into();
let _ = sender.send(Recipients::All, msg, true).await;
}
Expand All @@ -354,9 +349,7 @@ where
Epoch::new(EPOCH),
View::new(self.random_view(self.last_vote)),
);
if let Some(vote) =
Nullify::<S>::sign::<Sha256Digest>(&self.scheme, &self.namespace, round)
{
if let Some(vote) = Nullify::<S>::sign::<Sha256Digest>(&self.scheme, round) {
let msg = Vote::<S, Sha256Digest>::Nullify(vote).encode().into();
let _ = sender.send(Recipients::All, msg, true).await;
}
Expand Down
12 changes: 6 additions & 6 deletions consensus/fuzz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ where
{
type Scheme: Scheme<Sha256Digest, PublicKey = Ed25519PublicKey>;
type Elector: Elector<Self::Scheme>;
fn fixture(context: &mut deterministic::Context, n: u32) -> Fixture<Self::Scheme>;
fn fixture(
context: &mut deterministic::Context,
namespace: &[u8],
n: u32,
) -> Fixture<Self::Scheme>;
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -143,7 +147,6 @@ impl Arbitrary<'_> for FuzzInput {
fn run<P: Simplex>(input: FuzzInput) {
let (n, _, f) = input.configuration;
let containers = input.containers;
let namespace = NAMESPACE.to_vec();
let cfg = deterministic::Config::new().with_seed(input.seed);
let executor = deterministic::Runner::new(cfg);

Expand All @@ -163,7 +166,7 @@ fn run<P: Simplex>(input: FuzzInput) {
schemes,
verifier: _,
..
} = P::fixture(&mut context, n);
} = P::fixture(&mut context, NAMESPACE, n);

let mut registrations = register(&mut oracle, &participants).await;

Expand Down Expand Up @@ -197,7 +200,6 @@ fn run<P: Simplex>(input: FuzzInput) {
.clone()
.try_into()
.expect("public keys are unique"),
namespace.clone(),
input.clone(),
);
disrupter.start(vote_network, certificate_network);
Expand All @@ -208,7 +210,6 @@ fn run<P: Simplex>(input: FuzzInput) {
let context = context.with_label(&format!("validator_{validator}"));
let elector = P::Elector::default();
let reporter_cfg = reporter::Config {
namespace: namespace.clone(),
participants: participants
.clone()
.try_into()
Expand Down Expand Up @@ -245,7 +246,6 @@ fn run<P: Simplex>(input: FuzzInput) {
partition: validator.to_string(),
mailbox_size: 1024,
epoch: Epoch::new(EPOCH),
namespace: namespace.clone(),
leader_timeout: Duration::from_secs(1),
notarization_timeout: Duration::from_secs(2),
nullify_retry: Duration::from_secs(10),
Expand Down
4 changes: 0 additions & 4 deletions consensus/src/aggregation/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ pub struct Config<
/// Blocking is handled by [commonware_p2p].
pub blocker: B,

/// The application namespace used to sign over different types of messages.
/// Used to prevent replay attacks on other applications.
pub namespace: Vec<u8>,

/// Whether acks are sent as priority.
pub priority_acks: bool,

Expand Down
10 changes: 2 additions & 8 deletions consensus/src/aggregation/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ pub struct Engine<
reporter: Z,
blocker: B,

// ---------- Namespace Constants ----------
/// The namespace signatures.
namespace: Vec<u8>,

// Pruning
/// A tuple representing the epochs to keep in memory.
/// The first element is the number of old epochs to keep.
Expand Down Expand Up @@ -176,7 +172,6 @@ impl<
monitor: cfg.monitor,
provider: cfg.provider,
blocker: cfg.blocker,
namespace: cfg.namespace,
epoch_bounds: cfg.epoch_bounds,
window: cfg.window.into(),
activity_timeout: cfg.activity_timeout,
Expand Down Expand Up @@ -666,7 +661,7 @@ impl<
}

// Validate signature
if !ack.verify(&mut self.context, &*scheme, &self.namespace) {
if !ack.verify(&mut self.context, &*scheme) {
return Err(Error::InvalidAckSignature);
}

Expand Down Expand Up @@ -703,8 +698,7 @@ impl<

// Sign the item
let item = Item { index, digest };
let ack = Ack::sign(&*scheme, &self.namespace, self.epoch, item)
.ok_or(Error::NotSigner(self.epoch))?;
let ack = Ack::sign(&*scheme, self.epoch, item).ok_or(Error::NotSigner(self.epoch))?;

// Journal the ack
self.record(Activity::Ack(ack.clone())).await;
Expand Down
10 changes: 3 additions & 7 deletions consensus/src/aggregation/mocks/reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ pub struct Reporter<R: CryptoRngCore, S: Scheme, D: Digest> {
// RNG used for signature verification with scheme.
rng: R,

// Application namespace
namespace: Vec<u8>,

// Signing scheme for verification
scheme: S,

Expand All @@ -58,13 +55,12 @@ where
S: scheme::Scheme<D>,
D: Digest,
{
pub fn new(rng: R, namespace: &[u8], scheme: S) -> (Self, Mailbox<S, D>) {
pub fn new(rng: R, scheme: S) -> (Self, Mailbox<S, D>) {
let (sender, receiver) = mpsc::channel(1024);
(
Self {
mailbox: receiver,
rng,
namespace: namespace.to_vec(),
scheme,
acks: HashSet::new(),
digests: BTreeMap::new(),
Expand All @@ -81,7 +77,7 @@ where
match msg {
Message::Ack(ack) => {
// Verify properly constructed (not needed in production)
assert!(ack.verify(&mut self.rng, &self.scheme, &self.namespace));
assert!(ack.verify(&mut self.rng, &self.scheme));

// Test encoding/decoding
let encoded = ack.encode();
Expand All @@ -95,7 +91,7 @@ where
}
Message::Certified(certificate) => {
// Verify certificate
assert!(certificate.verify(&mut self.rng, &self.scheme, &self.namespace));
assert!(certificate.verify(&mut self.rng, &self.scheme));

// Test encoding/decoding
let encoded = certificate.encode();
Expand Down
Loading
Loading