Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into joss/oracle-predicate
Browse files Browse the repository at this point in the history
* master: (49 commits)
  feat(acvm)!: Add CommonReferenceString backend trait (#231)
  fix(acir): Hide variants of WitnessMapError and export it from package (#283)
  feat!: Introduce WitnessMap data structure to avoid leaking internal structure (#252)
  feat!: use struct variants for blackbox function calls (#269)
  chore(acvm)!: Backend trait must implement Debug (#275)
  chore!: remove `OpcodeResolutionError::UnexpectedOpcode` (#274)
  chore(acvm)!: rename `hash_to_field128_security` to `hash_to_field_128_security` (#271)
  feat(acvm)!: update black box solver interfaces to match `pwg:black_box::solve` (#268)
  chore(acir_field): remove unnecessary `to_vec()` (#267)
  chore(acvm)!: expose separate solvers for AND and XOR opcodes (#266)
  feat(acvm)!: Simplification pass for ACIR (#151)
  changes the name of blake to be blakes2s256 (#261)
  update hash functions (#260)
  feat!: Remove `solve` from PWG trait & introduce separate solvers for each blackbox (#257)
  chore: Release 0.11.0 (#250)
  feat(acvm): Add generic error for failing to solve an opcode (#251)
  fix(acir): Fix `Expression` multiplication to correctly handle degree 1 terms (#255)
  chore(acir): organise opcodes definitions (#254)
  chore: remove usage of `insert_witness` with `insert_value` (#253)
  feat: Add Keccak Hash function (#259)
  ...
  • Loading branch information
TomAFrench committed May 16, 2023
2 parents f626631 + eeddcf1 commit e8cfc5b
Show file tree
Hide file tree
Showing 45 changed files with 3,438 additions and 1,291 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{".":"0.8.0","acir":"0.8.0","acir_field":"0.8.0","acvm":"0.8.0","stdlib":"0.8.0"}
{".":"0.11.0","acir":"0.11.0","acir_field":"0.11.0","acvm":"0.11.0","stdlib":"0.11.0"}
105 changes: 105 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,111 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.11.0](https://github.com/noir-lang/acvm/compare/root-v0.10.3...root-v0.11.0) (2023-05-04)


### ⚠ BREAKING CHANGES

* **acvm:** Introduce Error type for fallible Backend traits ([#248](https://github.com/noir-lang/acvm/issues/248))

### Features

* **acvm:** Add generic error for failing to solve an opcode ([#251](https://github.com/noir-lang/acvm/issues/251)) ([bc89528](https://github.com/noir-lang/acvm/commit/bc8952820de610e585d505decfac6e590bbb1a35))
* **acvm:** Introduce Error type for fallible Backend traits ([#248](https://github.com/noir-lang/acvm/issues/248)) ([45c45f7](https://github.com/noir-lang/acvm/commit/45c45f7cdb79c3ccb0373ca0e698b282d4dabc39))
* Add Keccak Hash function ([#259](https://github.com/noir-lang/acvm/issues/259)) ([443c734](https://github.com/noir-lang/acvm/commit/443c73482eeef6cc42a1a254bf0d7706698ee353))


### Bug Fixes

* **acir:** Fix `Expression` multiplication to correctly handle degree 1 terms ([#255](https://github.com/noir-lang/acvm/issues/255)) ([e399396](https://github.com/noir-lang/acvm/commit/e399396f7e06deb6b831517af17018607df3f252))

## [0.10.3](https://github.com/noir-lang/acvm/compare/root-v0.10.2...root-v0.10.3) (2023-04-28)


### Bug Fixes

* add default feature flag to ACVM crate ([#245](https://github.com/noir-lang/acvm/issues/245)) ([455fddb](https://github.com/noir-lang/acvm/commit/455fddbc19af81cb01d54e29cad199691e1a1d98))

## [0.10.2](https://github.com/noir-lang/acvm/compare/root-v0.10.1...root-v0.10.2) (2023-04-28)


### Bug Fixes

* add default flag to `acvm_stdlib` ([#242](https://github.com/noir-lang/acvm/issues/242)) ([83b6fa8](https://github.com/noir-lang/acvm/commit/83b6fa8302569add7e3ac8481b2fd2a6a1ff3576))

## [0.10.1](https://github.com/noir-lang/acvm/compare/root-v0.10.0...root-v0.10.1) (2023-04-28)


### Bug Fixes

* **acir:** add `bn254` as default feature flag ([#240](https://github.com/noir-lang/acvm/issues/240)) ([e56973d](https://github.com/noir-lang/acvm/commit/e56973d8dc1745fe9bb844ec8347acd4d836d42f))

## [0.10.0](https://github.com/noir-lang/acvm/compare/root-v0.9.0...root-v0.10.0) (2023-04-26)


### ⚠ BREAKING CHANGES

* return `Result<OpcodeResolution, OpcodeResolutionError>` from `solve_range_opcode` ([#238](https://github.com/noir-lang/acvm/issues/238))
* **acvm:** have all black box functions return `Result<OpcodeResolution, OpcodeResolutionError>` ([#237](https://github.com/noir-lang/acvm/issues/237))
* **acvm:** implement `hash_to_field_128_security` ([#230](https://github.com/noir-lang/acvm/issues/230))
* replace `MerkleMembership` opcode with `ComputeMerkleRoot` ([#233](https://github.com/noir-lang/acvm/issues/233))
* require `Backend` to implement `Default` trait ([#223](https://github.com/noir-lang/acvm/issues/223))
* Make GeneralOptimizer crate visible ([#220](https://github.com/noir-lang/acvm/issues/220))
* return `PartialWitnessGeneratorStatus` from `PartialWitnessGenerator.solve` ([#213](https://github.com/noir-lang/acvm/issues/213))
* organise operator implementations for Expression ([#190](https://github.com/noir-lang/acvm/issues/190))

### Features

* **acvm:** have all black box functions return `Result&lt;OpcodeResolution, OpcodeResolutionError&gt;` ([#237](https://github.com/noir-lang/acvm/issues/237)) ([e8e93fd](https://github.com/noir-lang/acvm/commit/e8e93fda0db18f0d266dd1aacbb53ec787992dc9))
* **acvm:** implement `hash_to_field_128_security` ([#230](https://github.com/noir-lang/acvm/issues/230)) ([198fb69](https://github.com/noir-lang/acvm/commit/198fb69e90a5ed3c0a8716d888b4dc6c2f9b18aa))
* Add range opcode optimization ([#219](https://github.com/noir-lang/acvm/issues/219)) ([7abe6e5](https://github.com/noir-lang/acvm/commit/7abe6e5f6d6fea379c3748a910afd00db066eb45))
* implement `add_mul` on `Expression` ([#207](https://github.com/noir-lang/acvm/issues/207)) ([f156e18](https://github.com/noir-lang/acvm/commit/f156e18cf7a0f1a99bbe1683b8e75fec8325e6dd))
* implement `FieldElement::from&lt;bool&gt;()` ([#203](https://github.com/noir-lang/acvm/issues/203)) ([476cfa2](https://github.com/noir-lang/acvm/commit/476cfa247fddb515c64c2801c6868357c9375294))
* replace `MerkleMembership` opcode with `ComputeMerkleRoot` ([#233](https://github.com/noir-lang/acvm/issues/233)) ([74bfee8](https://github.com/noir-lang/acvm/commit/74bfee80e0ff0d205aee1eea548c97ade8bd0e41))
* require `Backend` to implement `Default` trait ([#223](https://github.com/noir-lang/acvm/issues/223)) ([00282dc](https://github.com/noir-lang/acvm/commit/00282dc5e2b03947bf709a088d829f3e0ba80eed))
* return `PartialWitnessGeneratorStatus` from `PartialWitnessGenerator.solve` ([#213](https://github.com/noir-lang/acvm/issues/213)) ([e877bed](https://github.com/noir-lang/acvm/commit/e877bed2cca76bd486e9bed66b4230e65a01f0a2))
* return `Result&lt;OpcodeResolution, OpcodeResolutionError&gt;` from `solve_range_opcode` ([#238](https://github.com/noir-lang/acvm/issues/238)) ([15d3c5a](https://github.com/noir-lang/acvm/commit/15d3c5a9be2dd92f266fcb7e672da17cada9fec5))


### Bug Fixes

* prevent `bn254` feature flag always being enabled ([#225](https://github.com/noir-lang/acvm/issues/225)) ([82eee6a](https://github.com/noir-lang/acvm/commit/82eee6ab08ae480f04904ca8571fd88f4466c000))


### Miscellaneous Chores

* Make GeneralOptimizer crate visible ([#220](https://github.com/noir-lang/acvm/issues/220)) ([64bb346](https://github.com/noir-lang/acvm/commit/64bb346524428a0ce196826ea1e5ccde08ad6201))
* organise operator implementations for Expression ([#190](https://github.com/noir-lang/acvm/issues/190)) ([a619df6](https://github.com/noir-lang/acvm/commit/a619df614bbb9b2518b788b42a7553b069823a0f))

## [0.9.0](https://github.com/noir-lang/acvm/compare/root-v0.8.1...root-v0.9.0) (2023-04-07)


### ⚠ BREAKING CHANGES

* **acvm:** Remove deprecated eth_contract_from_cs from SmartContract trait ([#185](https://github.com/noir-lang/acvm/issues/185))
* **acvm:** make `Backend` trait object safe ([#180](https://github.com/noir-lang/acvm/issues/180))

### Features

* **acvm:** make `Backend` trait object safe ([#180](https://github.com/noir-lang/acvm/issues/180)) ([fd28657](https://github.com/noir-lang/acvm/commit/fd28657426260ce3c53517b75a27eb5c4a74e234))


### Bug Fixes

* Add test for Out of Memory ([#188](https://github.com/noir-lang/acvm/issues/188)) ([c3db985](https://github.com/noir-lang/acvm/commit/c3db985893e7e59ea04005bb3a57eda5c6ce28c7))


### Miscellaneous Chores

* **acvm:** Remove deprecated eth_contract_from_cs from SmartContract trait ([#185](https://github.com/noir-lang/acvm/issues/185)) ([ee59c9e](https://github.com/noir-lang/acvm/commit/ee59c9efe9a54ff6b97e4daaebf64f3e327e97d9))

## [0.8.1](https://github.com/noir-lang/acvm/compare/root-v0.8.0...root-v0.8.1) (2023-03-30)


### Bug Fixes

* unwraps if inputs is zero ([#171](https://github.com/noir-lang/acvm/issues/171)) ([10a3bb2](https://github.com/noir-lang/acvm/commit/10a3bb2a9930ccf422b3f08227aae07775686860))

## [0.8.0](https://github.com/noir-lang/acvm/compare/root-v0.7.1...root-v0.8.0) (2023-03-28)


Expand Down
13 changes: 6 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@
members = ["acir_field", "acir", "acvm", "stdlib"]

[workspace.package]
authors = ["The Noir Team <kevtheappdev@gmail.com>"]
authors = ["The Noir Team <team@noir-lang.org>"]
edition = "2021"
license = "MIT"
rust-version = "1.66"

[workspace.dependencies]
acir = { version = "0.8.0", path = "acir" }
acir_field = { version = "0.8.0", path = "acir_field" }
stdlib = { package = "acvm_stdlib", version = "0.8.0", path = "stdlib" }
acir = { version = "0.11.0", path = "acir", default-features = false }
acir_field = { version = "0.11.0", path = "acir_field", default-features = false }
stdlib = { package = "acvm_stdlib", version = "0.11.0", path = "stdlib", default-features = false }

hex = "0.4.2"
num-bigint = "0.4"
num-traits = "0.2"

blake2 = "0.9.1"
thiserror = "1.0.21"

serde = { version = "1.0.136", features = ["derive"] }
serde = { version = "1.0.136", features = ["derive"] }
62 changes: 62 additions & 0 deletions acir/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,67 @@
# Changelog

## [0.11.0](https://github.com/noir-lang/acvm/compare/acir-v0.10.3...acir-v0.11.0) (2023-05-04)


### Bug Fixes

* **acir:** Fix `Expression` multiplication to correctly handle degree 1 terms ([#255](https://github.com/noir-lang/acvm/issues/255)) ([e399396](https://github.com/noir-lang/acvm/commit/e399396f7e06deb6b831517af17018607df3f252))

## [0.10.3](https://github.com/noir-lang/acvm/compare/acir-v0.10.2...acir-v0.10.3) (2023-04-28)


### Miscellaneous Chores

* **acir:** Synchronize undefined versions

## [0.10.2](https://github.com/noir-lang/acvm/compare/acir-v0.10.1...acir-v0.10.2) (2023-04-28)


### Miscellaneous Chores

* **acir:** Synchronize undefined versions

## [0.10.1](https://github.com/noir-lang/acvm/compare/acir-v0.10.0...acir-v0.10.1) (2023-04-28)


### Bug Fixes

* **acir:** add `bn254` as default feature flag ([#240](https://github.com/noir-lang/acvm/issues/240)) ([e56973d](https://github.com/noir-lang/acvm/commit/e56973d8dc1745fe9bb844ec8347acd4d836d42f))

## [0.10.0](https://github.com/noir-lang/acvm/compare/acir-v0.9.0...acir-v0.10.0) (2023-04-26)


### ⚠ BREAKING CHANGES

* replace `MerkleMembership` opcode with `ComputeMerkleRoot` ([#233](https://github.com/noir-lang/acvm/issues/233))
* return `PartialWitnessGeneratorStatus` from `PartialWitnessGenerator.solve` ([#213](https://github.com/noir-lang/acvm/issues/213))
* organise operator implementations for Expression ([#190](https://github.com/noir-lang/acvm/issues/190))

### Features

* implement `add_mul` on `Expression` ([#207](https://github.com/noir-lang/acvm/issues/207)) ([f156e18](https://github.com/noir-lang/acvm/commit/f156e18cf7a0f1a99bbe1683b8e75fec8325e6dd))
* replace `MerkleMembership` opcode with `ComputeMerkleRoot` ([#233](https://github.com/noir-lang/acvm/issues/233)) ([74bfee8](https://github.com/noir-lang/acvm/commit/74bfee80e0ff0d205aee1eea548c97ade8bd0e41))
* return `PartialWitnessGeneratorStatus` from `PartialWitnessGenerator.solve` ([#213](https://github.com/noir-lang/acvm/issues/213)) ([e877bed](https://github.com/noir-lang/acvm/commit/e877bed2cca76bd486e9bed66b4230e65a01f0a2))


### Miscellaneous Chores

* organise operator implementations for Expression ([#190](https://github.com/noir-lang/acvm/issues/190)) ([a619df6](https://github.com/noir-lang/acvm/commit/a619df614bbb9b2518b788b42a7553b069823a0f))

## [0.9.0](https://github.com/noir-lang/acvm/compare/acir-v0.8.1...acir-v0.9.0) (2023-04-07)


### Bug Fixes

* Add test for Out of Memory ([#188](https://github.com/noir-lang/acvm/issues/188)) ([c3db985](https://github.com/noir-lang/acvm/commit/c3db985893e7e59ea04005bb3a57eda5c6ce28c7))

## [0.8.1](https://github.com/noir-lang/acvm/compare/acir-v0.8.0...acir-v0.8.1) (2023-03-30)


### Bug Fixes

* unwraps if inputs is zero ([#171](https://github.com/noir-lang/acvm/issues/171)) ([10a3bb2](https://github.com/noir-lang/acvm/commit/10a3bb2a9930ccf422b3f08227aae07775686860))

## [0.8.0](https://github.com/noir-lang/acvm/compare/acir-v0.7.1...acir-v0.8.0) (2023-03-28)


Expand Down
4 changes: 3 additions & 1 deletion acir/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "acir"
description = "ACIR is the IR that the VM processes, it is analogous to LLVM IR"
version = "0.8.0"
version = "0.11.0"
authors.workspace = true
edition.workspace = true
license.workspace = true
Expand All @@ -12,6 +12,7 @@ rust-version.workspace = true
[dependencies]
acir_field.workspace = true
serde.workspace = true
thiserror.workspace = true

rmp-serde = "1.1.0"
flate2 = "1.0.24"
Expand All @@ -22,5 +23,6 @@ strum = "0.24"
strum_macros = "0.24"

[features]
default = ["bn254"]
bn254 = ["acir_field/bn254"]
bls12_381 = ["acir_field/bls12_381"]
94 changes: 5 additions & 89 deletions acir/src/circuit/black_box_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub enum BlackBoxFunc {
RANGE,
SHA256,
Blake2s,
MerkleMembership,
ComputeMerkleRoot,
SchnorrVerify,
Pedersen,
// 128 here specifies that this function
Expand All @@ -35,7 +35,7 @@ impl BlackBoxFunc {
match self {
BlackBoxFunc::AES => 0,
BlackBoxFunc::SHA256 => 1,
BlackBoxFunc::MerkleMembership => 2,
BlackBoxFunc::ComputeMerkleRoot => 2,
BlackBoxFunc::SchnorrVerify => 3,
BlackBoxFunc::Blake2s => 4,
BlackBoxFunc::Pedersen => 5,
Expand All @@ -52,7 +52,7 @@ impl BlackBoxFunc {
let function = match index {
0 => BlackBoxFunc::AES,
1 => BlackBoxFunc::SHA256,
2 => BlackBoxFunc::MerkleMembership,
2 => BlackBoxFunc::ComputeMerkleRoot,
3 => BlackBoxFunc::SchnorrVerify,
4 => BlackBoxFunc::Blake2s,
5 => BlackBoxFunc::Pedersen,
Expand All @@ -71,7 +71,7 @@ impl BlackBoxFunc {
match self {
BlackBoxFunc::AES => "aes",
BlackBoxFunc::SHA256 => "sha256",
BlackBoxFunc::MerkleMembership => "merkle_membership",
BlackBoxFunc::ComputeMerkleRoot => "compute_merkle_root",
BlackBoxFunc::SchnorrVerify => "schnorr_verify",
BlackBoxFunc::Blake2s => "blake2s",
BlackBoxFunc::Pedersen => "pedersen",
Expand All @@ -88,7 +88,7 @@ impl BlackBoxFunc {
match op_name {
"aes" => Some(BlackBoxFunc::AES),
"sha256" => Some(BlackBoxFunc::SHA256),
"merkle_membership" => Some(BlackBoxFunc::MerkleMembership),
"compute_merkle_root" => Some(BlackBoxFunc::ComputeMerkleRoot),
"schnorr_verify" => Some(BlackBoxFunc::SchnorrVerify),
"blake2s" => Some(BlackBoxFunc::Blake2s),
"pedersen" => Some(BlackBoxFunc::Pedersen),
Expand All @@ -105,90 +105,6 @@ impl BlackBoxFunc {
pub fn is_valid_black_box_func_name(op_name: &str) -> bool {
BlackBoxFunc::lookup(op_name).is_some()
}
pub fn definition(&self) -> FuncDefinition {
let name = self.name();
match self {
BlackBoxFunc::AES => unimplemented!(),
BlackBoxFunc::SHA256 => FuncDefinition {
name,
input_size: InputSize::Variable,
output_size: OutputSize(32),
},
BlackBoxFunc::Blake2s => FuncDefinition {
name,
input_size: InputSize::Variable,
output_size: OutputSize(32),
},
BlackBoxFunc::HashToField128Security => {
FuncDefinition { name, input_size: InputSize::Variable, output_size: OutputSize(1) }
}
BlackBoxFunc::MerkleMembership => {
FuncDefinition { name, input_size: InputSize::Variable, output_size: OutputSize(1) }
}
BlackBoxFunc::SchnorrVerify => FuncDefinition {
name,
// XXX: input_size can be changed to fixed, once we hash
// the message before passing it to schnorr.
// This is assuming all hashes will be 256 bits. Reasonable?
input_size: InputSize::Variable,
output_size: OutputSize(1),
},
BlackBoxFunc::Pedersen => {
FuncDefinition { name, input_size: InputSize::Variable, output_size: OutputSize(2) }
}
BlackBoxFunc::EcdsaSecp256k1 => {
FuncDefinition { name, input_size: InputSize::Variable, output_size: OutputSize(1) }
}
BlackBoxFunc::FixedBaseScalarMul => {
FuncDefinition { name, input_size: InputSize::Fixed(1), output_size: OutputSize(2) }
}
BlackBoxFunc::AND => {
FuncDefinition { name, input_size: InputSize::Fixed(2), output_size: OutputSize(1) }
}
BlackBoxFunc::XOR => {
FuncDefinition { name, input_size: InputSize::Fixed(2), output_size: OutputSize(1) }
}
BlackBoxFunc::RANGE => {
FuncDefinition { name, input_size: InputSize::Fixed(1), output_size: OutputSize(0) }
}
BlackBoxFunc::Keccak256 => FuncDefinition {
name,
input_size: InputSize::Variable,
output_size: OutputSize(32),
},
}
}
}

// Descriptor as to whether the input/output is fixed or variable
// Example: The input for Sha256 is Variable and the output is fixed at 2 witnesses
// each holding 128 bits of the actual Sha256 function
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub enum InputSize {
Variable,
Fixed(u128),
}

impl InputSize {
pub fn fixed_size(&self) -> Option<u128> {
match self {
InputSize::Variable => None,
InputSize::Fixed(size) => Some(*size),
}
}
}

// Output size Cannot currently vary, so we use a separate struct
// XXX: In the future, we may be able to allow the output to vary based on the input size, however this implies support for dynamic circuits
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub struct OutputSize(pub u128);

#[derive(Clone, Debug, Hash)]
// Specs for how many inputs/outputs the method takes.
pub struct FuncDefinition {
pub name: &'static str,
pub input_size: InputSize,
pub output_size: OutputSize,
}

#[cfg(test)]
Expand Down
Loading

0 comments on commit e8cfc5b

Please sign in to comment.