Skip to content

Commit 234fefb

Browse files
authored
feat: add recursive mode for circuit size calculation in srs_downloader (#23)
1 parent 2d6010d commit 234fefb

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,14 @@ cargo run --bin srs_downloader --features srs-downloader -- -c path/to/your/circ
138138

139139
This will download the SRS and save it to `./srs_cache/your_circuit_name.srs` by default (e.g., `./srs_cache/my_circuit.srs`).
140140

141+
**Recursive Mode:**
142+
143+
For recursive circuits, you can enable recursive mode for circuit size calculation using the `--recursive` or `-r` flag:
144+
145+
```sh
146+
cargo run --bin srs_downloader --features srs-downloader -- -c path/to/your/circuit.json --recursive
147+
```
148+
141149
### 2. Default SRS
142150

143151
If you don't have a specific circuit manifest or want a general-purpose SRS, you can download a default one (supports up to 2^18 constraints):
@@ -156,6 +164,9 @@ You can specify a custom output path for the downloaded SRS file using the `-o`
156164
# For a specific circuit
157165
cargo run --bin srs_downloader --features srs-downloader -- -c path/to/your/circuit.json -o /custom/path/to/srs_file.srs
158166

167+
# For a specific circuit with recursive mode
168+
cargo run --bin srs_downloader --features srs-downloader -- -c path/to/your/circuit.json -o /custom/path/to/srs_file.srs --recursive
169+
159170
# For a default SRS
160171
cargo run --bin srs_downloader --features srs-downloader -- -o /custom/path/to/default.srs
161172
```

noir/src/bin/srs_downloader.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ struct Args {
1919

2020
#[clap(short, long, help = "Specific output path to save the SRS file. If not provided, saves to a default directory.")]
2121
output_path: Option<String>,
22+
23+
#[clap(short, long, help = "Enable recursive mode for circuit size calculation.")]
24+
recursive: bool,
2225
}
2326

2427
fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -44,7 +47,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
4447
}
4548

4649
println!("Circuit '{}' decoded. Downloading SRS...", circuit_name);
47-
let subgroup_size = get_subgroup_size(bytecode, false);
50+
let subgroup_size = get_subgroup_size(bytecode, args.recursive);
4851
let srs: Srs = get_srs(subgroup_size, None);
4952
local_srs = LocalSrs(srs);
5053
println!("SRS for '{}' downloaded.", circuit_name);
@@ -95,6 +98,7 @@ mod tests {
9598
Args {
9699
circuit_path: circuit_path.map(String::from),
97100
output_path: output_path.map(String::from),
101+
recursive: false,
98102
}
99103
}
100104

@@ -125,6 +129,22 @@ mod tests {
125129
assert_eq!(args.circuit_path, Some("test.json".to_string()));
126130
assert_eq!(args.output_path, Some("output/srs.srs".to_string()));
127131
}
132+
133+
#[test]
134+
fn test_args_parsing_recursive_default() {
135+
let args = create_args(None, None);
136+
assert_eq!(args.recursive, false);
137+
}
138+
139+
#[test]
140+
fn test_args_parsing_recursive_explicit() {
141+
let args = Args {
142+
circuit_path: None,
143+
output_path: None,
144+
recursive: true,
145+
};
146+
assert_eq!(args.recursive, true);
147+
}
128148

129149
#[test]
130150
fn test_save_path_default_no_circuit() {

0 commit comments

Comments
 (0)