Skip to content
This repository was archived by the owner on Aug 7, 2026. It is now read-only.
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Added a zeroizing read helper for deserializing sensitive material, fixing secret-key read buffers that were not wiped on error paths (ECDSA) or at all (Falcon, Poseidon2 AEAD) ([#1057](https://github.com/0xMiden/crypto/pull/1057)).
- Parallelize aux trace building for faster proving ([#1074](https://github.com/0xMiden/crypto/issues/1074)).
- Fixed SMT leaf advice decoding by rebuilding decoded entries through `SmtLeaf::new`, so decoded entries must match the supplied leaf index ([#1076](https://github.com/0xMiden/crypto/pull/1076)).
- Fixed `miden-bench` trace spec parsing to reject extra fields and non-Miden dimensions.

## 0.27.0 (2026-06-19)

Expand Down
83 changes: 74 additions & 9 deletions miden-bench/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl FromStr for TraceSpec {

fn from_str(s: &str) -> Result<Self, Self::Err> {
let parts: Vec<&str> = s.split(':').collect();
if parts.len() < 2 {
if !(2..=4).contains(&parts.len()) {
return Err(format!("expected <air>:<log_height>[:<width>[:<aux_cols>]], got '{s}'"));
}

Expand All @@ -180,16 +180,26 @@ impl FromStr for TraceSpec {
let log_height: u8 =
parts[1].parse().map_err(|_| format!("invalid log_height '{}'", parts[1]))?;

let width = if parts.len() > 2 {
parts[2].parse().map_err(|_| format!("invalid width '{}'", parts[2]))?
} else {
DEFAULT_MIDEN_WIDTH
};
let (width, num_aux_cols) = if air_type == AirType::Miden {
let width = if parts.len() > 2 {
parts[2].parse().map_err(|_| format!("invalid width '{}'", parts[2]))?
} else {
DEFAULT_MIDEN_WIDTH
};

let num_aux_cols = if parts.len() > 3 {
parts[3].parse().map_err(|_| format!("invalid aux_cols '{}'", parts[3]))?
} else {
DEFAULT_MIDEN_AUX_COLS
};

let num_aux_cols = if parts.len() > 3 {
parts[3].parse().map_err(|_| format!("invalid aux_cols '{}'", parts[3]))?
(width, num_aux_cols)
} else {
DEFAULT_MIDEN_AUX_COLS
if parts.len() > 2 {
return Err(format!("width and aux_cols only apply to miden traces, got '{s}'"));
}

(0, 0)
};

if air_type == AirType::Miden && width < 9 {
Expand All @@ -204,3 +214,58 @@ impl FromStr for TraceSpec {
})
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn trace_spec_parses_miden_defaults() {
let spec: TraceSpec = "miden:18".parse().unwrap();

assert!(matches!(spec.air_type, AirType::Miden));
assert_eq!(spec.log_height, 18);
assert_eq!(spec.width, DEFAULT_MIDEN_WIDTH);
assert_eq!(spec.num_aux_cols, DEFAULT_MIDEN_AUX_COLS);
}

#[test]
fn trace_spec_parses_miden_dimensions() {
let spec: TraceSpec = "miden:18:64:12".parse().unwrap();

assert!(matches!(spec.air_type, AirType::Miden));
assert_eq!(spec.log_height, 18);
assert_eq!(spec.width, 64);
assert_eq!(spec.num_aux_cols, 12);
}

#[test]
fn trace_spec_parses_hash_trace_without_miden_dimensions() {
let spec: TraceSpec = "keccak:15".parse().unwrap();

assert!(matches!(spec.air_type, AirType::Keccak));
assert_eq!(spec.log_height, 15);
assert_eq!(spec.width, 0);
assert_eq!(spec.num_aux_cols, 0);
}

#[test]
fn trace_spec_rejects_dimensions_for_non_miden_traces() {
let err = match "keccak:15:64".parse::<TraceSpec>() {
Ok(_) => panic!("expected trace spec parsing to fail"),
Err(err) => err,
};

assert!(err.contains("width and aux_cols only apply to miden traces"));
}

#[test]
fn trace_spec_rejects_extra_fields() {
let err = match "miden:18:64:12:extra".parse::<TraceSpec>() {
Ok(_) => panic!("expected trace spec parsing to fail"),
Err(err) => err,
};

assert!(err.contains("expected <air>:<log_height>[:<width>[:<aux_cols>]]"));
}
}
Loading