Skip to content

Commit

Permalink
Merge branch 'master' into tf/decompose-asserted-boolean-multiplications
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench authored Dec 21, 2023
2 parents cc324d2 + 0a36fdf commit 776a8b7
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 26 deletions.
15 changes: 10 additions & 5 deletions acvm-repo/acvm_js/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
{
"name": "@noir-lang/acvm_js",
"version": "0.38.0",
"repository": {
"type": "git",
"url": "https://github.com/noir-lang/acvm.git"
},
"publishConfig": {
"access": "public"
},
"collaborators": [
"contributors": [
"The Noir Team <team@noir-lang.org>"
],
"homepage": "https://noir-lang.org/",
"repository": {
"url": "https://github.com/noir-lang/noir.git",
"directory": "acvm_repo/acvm_js",
"type": "git"
},
"bugs": {
"url": "https://github.com/noir-lang/noir/issues"
},
"license": "MIT",
"main": "./nodejs/acvm_js.js",
"types": "./web/acvm_js.d.ts",
Expand Down
25 changes: 16 additions & 9 deletions compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,19 @@ impl AcirContext {
return Ok(lhs);
}

let inputs = vec![AcirValue::Var(lhs, typ.clone()), AcirValue::Var(rhs, typ)];
let outputs = self.black_box_function(BlackBoxFunc::XOR, inputs, 1)?;
Ok(outputs[0])
let bit_size = typ.bit_size();
if bit_size == 1 {
// Operands are booleans.
//
// a ^ b == a + b - 2*a*b
let sum = self.add_var(lhs, rhs)?;
let prod = self.mul_var(lhs, rhs)?;
self.add_mul_var(sum, -FieldElement::from(2_i128), prod)
} else {
let inputs = vec![AcirValue::Var(lhs, typ.clone()), AcirValue::Var(rhs, typ)];
let outputs = self.black_box_function(BlackBoxFunc::XOR, inputs, 1)?;
Ok(outputs[0])
}
}

/// Returns an `AcirVar` that is the AND result of `lhs` & `rhs`.
Expand Down Expand Up @@ -450,9 +460,8 @@ impl AcirContext {
let max = self.add_constant((1_u128 << bit_size) - 1);
let a = self.sub_var(max, lhs)?;
let b = self.sub_var(max, rhs)?;
let inputs = vec![AcirValue::Var(a, typ.clone()), AcirValue::Var(b, typ)];
let outputs = self.black_box_function(BlackBoxFunc::AND, inputs, 1)?;
self.sub_var(max, outputs[0])
let a_and_b = self.and_var(a, b, typ)?;
self.sub_var(max, a_and_b)
}
}

Expand Down Expand Up @@ -889,9 +898,7 @@ impl AcirContext {

// Unsigned to signed: derive q and r from q1,r1 and the signs of lhs and rhs
// Quotient sign is lhs sign * rhs sign, whose resulting sign bit is the XOR of the sign bits
let sign_sum = self.add_var(lhs_leading, rhs_leading)?;
let sign_prod = self.mul_var(lhs_leading, rhs_leading)?;
let q_sign = self.add_mul_var(sign_sum, -FieldElement::from(2_i128), sign_prod)?;
let q_sign = self.xor_var(lhs_leading, rhs_leading, AcirType::unsigned(1))?;

let quotient = self.two_complement(q1, q_sign, bit_size)?;
let remainder = self.two_complement(r1, lhs_leading, bit_size)?;
Expand Down
11 changes: 8 additions & 3 deletions compiler/wasm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@noir-lang/noir_wasm",
"collaborators": [
"contributors": [
"The Noir Team <team@noir-lang.org>"
],
"version": "0.22.0",
Expand All @@ -14,9 +14,14 @@
"package.json"
],
"sideEffects": false,
"homepage": "https://noir-lang.org/",
"repository": {
"type": "git",
"url": "https://github.com/noir-lang/noir.git"
"url": "https://github.com/noir-lang/noir.git",
"directory": "compiler/wasm",
"type": "git"
},
"bugs": {
"url": "https://github.com/noir-lang/noir/issues"
},
"scripts": {
"build": "bash ./build.sh",
Expand Down
11 changes: 10 additions & 1 deletion tooling/noir_codegen/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
{
"name": "@noir-lang/noir_codegen",
"collaborators": [
"contributors": [
"The Noir Team <team@noir-lang.org>"
],
"version": "0.22.0",
"packageManager": "yarn@3.5.1",
"license": "(MIT OR Apache-2.0)",
"type": "module",
"homepage": "https://noir-lang.org/",
"repository": {
"url": "https://github.com/noir-lang/noir.git",
"directory": "compiler/wasm",
"type": "git"
},
"bugs": {
"url": "https://github.com/noir-lang/noir/issues"
},
"dependencies": {
"@noir-lang/types": "workspace:*",
"glob": "^10.3.10",
Expand Down
11 changes: 10 additions & 1 deletion tooling/noir_js/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
{
"name": "@noir-lang/noir_js",
"collaborators": [
"contributors": [
"The Noir Team <team@noir-lang.org>"
],
"version": "0.22.0",
"packageManager": "yarn@3.5.1",
"license": "(MIT OR Apache-2.0)",
"type": "module",
"homepage": "https://noir-lang.org/",
"repository": {
"url": "https://github.com/noir-lang/noir.git",
"directory": "tooling/noir_js",
"type": "git"
},
"bugs": {
"url": "https://github.com/noir-lang/noir/issues"
},
"dependencies": {
"@noir-lang/acvm_js": "workspace:*",
"@noir-lang/noirc_abi": "workspace:*",
Expand Down
11 changes: 10 additions & 1 deletion tooling/noir_js_backend_barretenberg/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
{
"name": "@noir-lang/backend_barretenberg",
"collaborators": [
"contributors": [
"The Noir Team <team@noir-lang.org>"
],
"version": "0.22.0",
"packageManager": "yarn@3.5.1",
"license": "(MIT OR Apache-2.0)",
"type": "module",
"homepage": "https://noir-lang.org/",
"repository": {
"url": "https://github.com/noir-lang/noir.git",
"directory": "tooling/noir_js_backend_barretenberg",
"type": "git"
},
"bugs": {
"url": "https://github.com/noir-lang/noir/issues"
},
"source": "src/index.ts",
"main": "lib/cjs/index.js",
"module": "lib/esm/index.js",
Expand Down
11 changes: 10 additions & 1 deletion tooling/noir_js_types/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
{
"name": "@noir-lang/types",
"collaborators": [
"contributors": [
"The Noir Team <team@noir-lang.org>"
],
"packageManager": "yarn@3.5.1",
"version": "0.22.0",
"license": "(MIT OR Apache-2.0)",
"homepage": "https://noir-lang.org/",
"repository": {
"url": "https://github.com/noir-lang/noir.git",
"directory": "tooling/noir_js_types",
"type": "git"
},
"bugs": {
"url": "https://github.com/noir-lang/noir/issues"
},
"files": [
"lib",
"package.json"
Expand Down
15 changes: 10 additions & 5 deletions tooling/noirc_abi_wasm/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
{
"name": "@noir-lang/noirc_abi",
"collaborators": [
"contributors": [
"The Noir Team <team@noir-lang.org>"
],
"version": "0.22.0",
"license": "(MIT OR Apache-2.0)",
"homepage": "https://noir-lang.org/",
"repository": {
"url": "https://github.com/noir-lang/noir.git",
"directory": "tooling/noirc_abi_wasm",
"type": "git"
},
"bugs": {
"url": "https://github.com/noir-lang/noir/issues"
},
"files": [
"nodejs",
"web",
Expand All @@ -17,10 +26,6 @@
"types": "./web/noirc_abi_wasm.d.ts",
"module": "./web/noirc_abi_wasm.js",
"sideEffects": false,
"repository": {
"type": "git",
"url": "https://github.com/noir-lang/noir.git"
},
"scripts": {
"build": "bash ./build.sh",
"test": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha",
Expand Down

0 comments on commit 776a8b7

Please sign in to comment.