Skip to content

Commit

Permalink
Merge branch 'master' into kw/ref-nargo-maps
Browse files Browse the repository at this point in the history
* master:
  Rename methods that use `conditionalize` to be more descriptive (#739)
  feat(noir)!:  Returned values are no longer required by the prover (#731)
  chore: explicit versions for dependencies (#727)
  chore: readability improvements (#726)
  feat(nargo): include short git commit in cli version output (#721)
  Remove print to console for named proofs in `nargo prove` (#718)
  chore: clean up serde-related dependencies (#722)
  Handle out-of-bound errors in CSE (#471) (#673)
  Remove unused dependencies and only use workspace inheritance on shared deps (#671)
  feat(std_lib)!: modulus bits/bytes methods, and to_bits -> to_le_bits (#697)
  Implement numeric generics (#620)
  Review some TODO in SSA (#698)
  Replace `toml_map_to_field` and `toml_remap` with traits to map between `InputValue`s and `TomlTypes` (#677)
  Apply witness visibility on a parameter level rather than witness level (#712)
  • Loading branch information
TomAFrench committed Feb 3, 2023
2 parents 9e84261 + b0a9695 commit 1bbf679
Show file tree
Hide file tree
Showing 58 changed files with 1,615 additions and 854 deletions.
63 changes: 51 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 3 additions & 42 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ members = [
"crates/iter-extended",
"crates/wasm",
]
exclude = ["examples/9/merkle_tree_processor"]
default-members = ["crates/nargo"]

[workspace.package]
Expand All @@ -34,53 +33,15 @@ noirc_evaluator = { path = "crates/noirc_evaluator" }
noirc_frontend = { path = "crates/noirc_frontend" }
noir_wasm = { path = "crates/wasm" }

ark-bn254 = { version = "^0.3.0", default-features = false, features = [
"curve",
] }
ark-bls12-381 = { version = "^0.3.0", default-features = false, features = [
"curve",
] }
ark-ff = { version = "^0.3.0", default-features = false }
blake2 = "0.9.1"
chumsky = { git = "https://github.com/jfecher/chumsky", rev = "ad9d312" }
cfg-if = "1.0.0"
clap = "2.33.3"
codespan = "0.9.5"
codespan-reporting = "0.9.5"
console_error_panic_hook = "*"
chumsky = { git = "https://github.com/jfecher/chumsky", rev = "ad9d312" }
dirs = "4"
flate2 = "1.0.24"
generational-arena = "0.2.8"
getrandom = { version = "0.2.4", features = ["js"] }
gloo-utils = { version = "0.1", features = ["serde"] }
hex = "0.4.2"
indexmap = "1.7.0"
js-sys = "0.3.55"
lazy_static = "1.4.0"
k256 = { version = "0.7.2", features = [
"ecdsa",
"ecdsa-core",
"sha256",
"digest",
"arithmetic",
] }
pathdiff = "0.2"
num-bigint = "0.4"
num-traits = "0.2.8"
rmp-serde = "1.1.0"
rustc-hash = "1.1.0"
rustc_version = "0.4.0"
serde = { version = "1.0.136", features = ["derive"] }
serde_derive = "1.0.123"
serde_json = "1.0"
sled = "0.34.6"
sha2 = "0.9.3"
smol_str = "0.1.17"
tempdir = "0.3.7"
tempfile = "3.2.0"
termcolor = "1.1.2"
thiserror = "1.0.21"
toml = "0.5.8"
url = "2.2.0"
wasm-bindgen = { version = "*", features = ["serde-serialize"] }
wasm-bindgen-test = "*"
wasm-bindgen = { version = "0.2.83", features = ["serde-serialize"] }
wasm-bindgen-test = "0.3.33"
2 changes: 1 addition & 1 deletion crates/arena/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ edition.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
generational-arena.workspace = true
generational-arena = "0.2.8"
6 changes: 4 additions & 2 deletions crates/fm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ edition.workspace = true
[dependencies]
codespan-reporting.workspace = true
cfg-if.workspace = true

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = { version = "*", features = ["serde-serialize"] }
wasm-bindgen.workspace = true

[dev-dependencies]
tempfile.workspace = true
tempfile = "3.2.0"
10 changes: 10 additions & 0 deletions crates/iter-extended/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,13 @@ where
{
iterable.into_iter().map(f).collect()
}

/// Equivalent to .into_iter().map(f).collect::<Result<BTreeMap<_, _>,_>>()
pub fn try_btree_map<T, K, V, E, F>(iterable: T, f: F) -> Result<BTreeMap<K, V>, E>
where
T: IntoIterator,
K: std::cmp::Ord,
F: FnMut(T::Item) -> Result<(K, V), E>,
{
iterable.into_iter().map(f).collect()
}
16 changes: 8 additions & 8 deletions crates/nargo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition.workspace = true

[build-dependencies]
dirs.workspace = true
rustc_version.workspace = true
rustc_version = "0.4.0"

[dependencies]
dirs.workspace = true
Expand All @@ -20,15 +20,15 @@ noirc_abi.workspace = true
fm.workspace = true
acvm.workspace = true
cfg-if.workspace = true

toml.workspace = true
serde_derive.workspace = true
serde = "1.0.123"
clap.workspace = true
termcolor.workspace = true
hex.workspace = true
tempdir.workspace = true
serde.workspace = true
thiserror.workspace = true
clap = "2.33.3"
const_format = "0.2.30"
git-version = "0.3.5"
hex = "0.4.2"
termcolor = "1.1.2"
tempdir = "0.3.7"

# Backends
aztec_backend = { optional = true, package = "barretenberg_static_lib", git = "https://github.com/noir-lang/aztec_backend", rev = "c673a14be33e445d98b35969716ac59c682036d6" }
Expand Down
54 changes: 49 additions & 5 deletions crates/nargo/src/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
use acvm::{acir::circuit::PublicInputs, FieldElement};
use acvm::{acir::native_types::Witness, FieldElement};
pub use check_cmd::check_from_path;
use clap::{App, AppSettings, Arg};
use const_format::formatcp;
use git_version::git_version;
use noirc_abi::{
input_parser::{Format, InputValue},
Abi,
};
use noirc_driver::Driver;
use noirc_frontend::graph::{CrateName, CrateType};
use std::{
collections::BTreeMap,
collections::{BTreeMap, HashMap, HashSet},
fs::File,
io::Write,
path::{Path, PathBuf},
Expand All @@ -26,6 +29,9 @@ mod new_cmd;
mod prove_cmd;
mod verify_cmd;

const SHORT_GIT_HASH: &str = git_version!(prefix = "git:");
const VERSION_STRING: &str = formatcp!("{} ({})", env!("CARGO_PKG_VERSION"), SHORT_GIT_HASH);

/// A map from the fields in an TOML/JSON file which correspond to some ABI to their values
pub type InputMap = BTreeMap<String, InputValue>;

Expand All @@ -43,7 +49,7 @@ pub fn start_cli() {

let matches = App::new("nargo")
.about("Noir's package manager")
.version("0.1")
.version(VERSION_STRING)
.author("Kevaundray Wedderburn <kevtheappdev@gmail.com>")
.subcommand(
App::new("check")
Expand Down Expand Up @@ -71,7 +77,7 @@ pub fn start_cli() {
.subcommand(
App::new("prove")
.about("Create proof for this program")
.arg(Arg::with_name("proof_name").help("The name of the proof").required(true))
.arg(Arg::with_name("proof_name").help("The name of the proof"))
.arg(show_ssa.clone())
.arg(allow_warnings.clone()),
)
Expand Down Expand Up @@ -181,7 +187,7 @@ fn write_inputs_to_file<P: AsRef<Path>>(
pub fn prove_and_verify(proof_name: &str, prg_dir: &Path, show_ssa: bool) -> bool {
let tmp_dir = TempDir::new("p_and_v_tests").unwrap();
let proof_path = match prove_cmd::prove_with_path(
proof_name,
Some(proof_name),
prg_dir,
&tmp_dir.into_path(),
show_ssa,
Expand All @@ -194,7 +200,7 @@ pub fn prove_and_verify(proof_name: &str, prg_dir: &Path, show_ssa: bool) -> boo
}
};

verify_cmd::verify_with_path(prg_dir, &proof_path, show_ssa, false).unwrap()
verify_cmd::verify_with_path(prg_dir, &proof_path.unwrap(), show_ssa, false).unwrap()
}

fn add_std_lib(driver: &mut Driver) {
Expand All @@ -208,6 +214,44 @@ fn path_to_stdlib() -> PathBuf {
dirs::config_dir().unwrap().join("noir-lang").join("std/src")
}

// Removes duplicates from the list of public input witnesses
fn dedup_public_input_indices(indices: PublicInputs) -> PublicInputs {
let duplicates_removed: HashSet<_> = indices.0.into_iter().collect();
PublicInputs(duplicates_removed.into_iter().collect())
}

// Removes duplicates from the list of public input witnesses and the
// associated list of duplicate values.
pub(crate) fn dedup_public_input_indices_values(
indices: PublicInputs,
values: Vec<FieldElement>,
) -> (PublicInputs, Vec<FieldElement>) {
// Assume that the public input index lists and the values contain duplicates
assert_eq!(indices.0.len(), values.len());

let mut public_inputs_without_duplicates = Vec::new();
let mut already_seen_public_indices = HashMap::new();

for (index, value) in indices.0.iter().zip(values) {
match already_seen_public_indices.get(index) {
Some(expected_value) => {
// The index has already been added
// so lets check that the values already inserted is equal to the value, we wish to insert
assert_eq!(*expected_value, value, "witness index {index:?} does not have a canonical map. The expected value is {expected_value}, the received value is {value}.")
}
None => {
already_seen_public_indices.insert(*index, value);
public_inputs_without_duplicates.push(value)
}
}
}

(
PublicInputs(already_seen_public_indices.keys().copied().collect()),
public_inputs_without_duplicates,
)
}

// FIXME: I not sure that this is the right place for this tests.
#[cfg(test)]
mod tests {
Expand Down
Loading

0 comments on commit 1bbf679

Please sign in to comment.