Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(nargo)!: remove flat_witness feature flag #2208

Merged
merged 1 commit into from
Aug 8, 2023
Merged
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: 0 additions & 1 deletion crates/nargo_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,4 @@ default = ["plonk_bn254"]
# The plonk backend can only use bn254, so we do not specify the field
plonk_bn254 = ["acvm-backend-barretenberg/native"]
plonk_bn254_wasm = ["acvm-backend-barretenberg/wasm"]
flat_witness = ["acvm-backend-barretenberg/native"]

2 changes: 1 addition & 1 deletion crates/nargo_cli/src/backends.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub(crate) use acvm_backend_barretenberg::Barretenberg as ConcreteBackend;

#[cfg(not(any(feature = "plonk_bn254", feature = "plonk_bn254_wasm", feature = "flat_witness")))]
#[cfg(not(any(feature = "plonk_bn254", feature = "plonk_bn254_wasm")))]
compile_error!("please specify a backend to compile with");

#[cfg(all(feature = "plonk_bn254", feature = "plonk_bn254_wasm"))]
Expand Down
23 changes: 1 addition & 22 deletions crates/nargo_cli/src/cli/fs/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,9 @@ pub(crate) fn save_witness_to_dir<P: AsRef<Path>>(
create_named_dir(witness_dir.as_ref(), "witness");
let witness_path = witness_dir.as_ref().join(witness_name).with_extension(WITNESS_EXT);

let buf: Vec<u8> = serialize_witness_map(witnesses)?;
let buf: Vec<u8> = witnesses.try_into()?;

write_to_file(buf.as_slice(), &witness_path);

Ok(witness_path)
}

#[cfg(not(feature = "flat_witness"))]
fn serialize_witness_map(witnesses: WitnessMap) -> Result<Vec<u8>, FilesystemError> {
let buf: Vec<u8> = witnesses.try_into()?;
Ok(buf)
}

#[cfg(feature = "flat_witness")]
fn serialize_witness_map(witnesses: WitnessMap) -> Result<Vec<u8>, FilesystemError> {
let mut buf: Vec<u8> = Vec::new();
let mut counter = 1;
for (index, value) in witnesses {
while counter < index.witness_index() {
buf.extend(vec![0; 32]);
counter += 1;
}
buf.extend_from_slice(&value.to_be_bytes());
counter += 1;
}
Ok(buf)
}