Skip to content

Commit

Permalink
chore(nargo)!: remove flat_witness feature flag (#2208)
Browse files Browse the repository at this point in the history
chore!: remove `flat_witess` feature flag
  • Loading branch information
TomAFrench authored Aug 8, 2023
1 parent 5b95ab5 commit 32d52d3
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 24 deletions.
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)
}

0 comments on commit 32d52d3

Please sign in to comment.