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

Commit

Permalink
chore: Separate barretenberg solver from generic blackbox solver code
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Sep 18, 2023
1 parent e4ba249 commit 17d7010
Show file tree
Hide file tree
Showing 28 changed files with 128 additions and 74 deletions.
3 changes: 2 additions & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"stdlib": "0.26.1",
"brillig": "0.26.1",
"brillig_vm": "0.26.1",
"blackbox_solver": "0.26.1"
"blackbox_solver": "0.26.1",
"barretenberg_blackbox_solver": "0.26.1"
}
41 changes: 28 additions & 13 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]

members = ["acir_field", "acir", "acvm", "acvm_js", "stdlib", "brillig", "brillig_vm", "blackbox_solver"]
members = ["acir_field", "acir", "acvm", "acvm_js", "stdlib", "brillig", "brillig_vm", "blackbox_solver", "barretenberg_blackbox_solver"]
resolver = "2"

[workspace.package]
Expand All @@ -15,7 +15,8 @@ acir = { version = "0.26.1", path = "acir", default-features = false }
acir_field = { version = "0.26.1", path = "acir_field", default-features = false }
stdlib = { package = "acvm_stdlib", version = "0.26.1", path = "stdlib", default-features = false }
brillig = { version = "0.26.1", path = "brillig", default-features = false }
blackbox_solver = { package = "acvm_blackbox_solver", version = "0.26.1", path = "blackbox_solver", default-features = false }
acvm_blackbox_solver = { version = "0.26.1", path = "blackbox_solver", default-features = false }
barretenberg_blackbox_solver = { version = "0.26.1", path = "barretenberg_blackbox_solver", default-features = false }

bincode = "1.3.3"

Expand Down
6 changes: 3 additions & 3 deletions acvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ thiserror.workspace = true
acir.workspace = true
stdlib.workspace = true
brillig_vm = { version = "0.26.1", path = "../brillig_vm", default-features = false }
blackbox_solver.workspace = true
acvm_blackbox_solver.workspace = true

indexmap = "1.7.0"

Expand All @@ -28,13 +28,13 @@ bn254 = [
"acir/bn254",
"stdlib/bn254",
"brillig_vm/bn254",
"blackbox_solver/bn254",
"acvm_blackbox_solver/bn254",
]
bls12_381 = [
"acir/bls12_381",
"stdlib/bls12_381",
"brillig_vm/bls12_381",
"blackbox_solver/bls12_381",
"acvm_blackbox_solver/bls12_381",
]
testing = ["stdlib/testing", "unstable-fallbacks"]
unstable-fallbacks = []
Expand Down
4 changes: 2 additions & 2 deletions acvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
pub mod compiler;
pub mod pwg;

pub use blackbox_solver::{BlackBoxFunctionSolver, BlackBoxResolutionError};
pub use acvm_blackbox_solver::{BlackBoxFunctionSolver, BlackBoxResolutionError};
use core::fmt::Debug;
use pwg::OpcodeResolutionError;

Expand All @@ -14,7 +14,7 @@ pub use acir::FieldElement;
// re-export brillig vm
pub use brillig_vm;
// re-export blackbox solver
pub use blackbox_solver;
pub use acvm_blackbox_solver as blackbox_solver;

/// Supported NP complete languages
/// This might need to be in ACIR instead
Expand Down
2 changes: 1 addition & 1 deletion acvm/src/pwg/blackbox/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use acir::{
native_types::{Witness, WitnessMap},
BlackBoxFunc, FieldElement,
};
use blackbox_solver::{hash_to_field_128_security, BlackBoxResolutionError};
use acvm_blackbox_solver::{hash_to_field_128_security, BlackBoxResolutionError};

use crate::pwg::{insert_value, witness_to_value};
use crate::OpcodeResolutionError;
Expand Down
2 changes: 1 addition & 1 deletion acvm/src/pwg/blackbox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use acir::{
native_types::{Witness, WitnessMap},
FieldElement,
};
use blackbox_solver::{blake2s, keccak256, sha256};
use acvm_blackbox_solver::{blake2s, keccak256, sha256};

use super::{insert_value, OpcodeNotSolvable, OpcodeResolutionError};
use crate::BlackBoxFunctionSolver;
Expand Down
2 changes: 1 addition & 1 deletion acvm/src/pwg/blackbox/signature/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use acir::{
native_types::{Witness, WitnessMap},
FieldElement,
};
use blackbox_solver::{ecdsa_secp256k1_verify, ecdsa_secp256r1_verify};
use acvm_blackbox_solver::{ecdsa_secp256k1_verify, ecdsa_secp256r1_verify};

use crate::{pwg::insert_value, OpcodeResolutionError};

Expand Down
4 changes: 2 additions & 2 deletions acvm/src/pwg/brillig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use acir::{
native_types::WitnessMap,
FieldElement,
};
use blackbox_solver::BlackBoxFunctionSolver;
use acvm_blackbox_solver::BlackBoxFunctionSolver;
use brillig_vm::{Registers, VMStatus, VM};

use crate::{pwg::OpcodeNotSolvable, OpcodeResolutionError};
Expand Down Expand Up @@ -150,7 +150,7 @@ impl BrilligSolver {
}
}

/// Encapsulates a request from a Brillig VM process that encounters a [foreign call opcode][acir::brillig_vm::Opcode::ForeignCall]
/// Encapsulates a request from a Brillig VM process that encounters a [foreign call opcode][acir::brillig_vm::Opcode::ForeignCall]
/// where the result of the foreign call has not yet been provided.
///
/// The caller must resolve this opcode externally based upon the information in the request.
Expand Down
2 changes: 1 addition & 1 deletion acvm/src/pwg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use acir::{
native_types::{Expression, Witness, WitnessMap},
BlackBoxFunc, FieldElement,
};
use blackbox_solver::BlackBoxResolutionError;
use acvm_blackbox_solver::BlackBoxResolutionError;

use self::{
arithmetic::ArithmeticSolver, brillig::BrilligSolver, directives::solve_directives,
Expand Down
2 changes: 1 addition & 1 deletion acvm/tests/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use acvm::{
pwg::{ACVMStatus, ErrorLocation, ForeignCallWaitInfo, OpcodeResolutionError, ACVM},
BlackBoxFunctionSolver,
};
use blackbox_solver::BlackBoxResolutionError;
use acvm_blackbox_solver::BlackBoxResolutionError;

pub(crate) struct StubbedBackend;

Expand Down
2 changes: 1 addition & 1 deletion acvm/tests/stdlib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use acvm::{
pwg::{ACVMStatus, ACVM},
Language,
};
use blackbox_solver::{blake2s, hash_to_field_128_security, keccak256, sha256};
use acvm_blackbox_solver::{blake2s, hash_to_field_128_security, keccak256, sha256};
use paste::paste;
use proptest::prelude::*;

Check warning on line 19 in acvm/tests/stdlib.rs

View workflow job for this annotation

GitHub Actions / Spellcheck / Spellcheck

Unknown word (proptest)
use std::collections::{BTreeMap, BTreeSet};
Expand Down
1 change: 1 addition & 0 deletions acvm_js/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ cfg-if = "1.0.0"

[target.'cfg(target_arch = "wasm32")'.dependencies]
acvm = { version = "0.26.1", path = "../acvm", default-features = false }
barretenberg_blackbox_solver = { version = "0.26.1", path = "../barretenberg_blackbox_solver", default-features = false }
wasm-bindgen = { version = "0.2.87", features = ["serde-serialize"] }
wasm-bindgen-futures = "0.4.36"
serde = { version = "1.0.136", features = ["derive"] }
Expand Down
4 changes: 2 additions & 2 deletions acvm_js/src/execute.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#[allow(deprecated)]
use acvm::{
acir::circuit::{Circuit, OpcodeLocation},
blackbox_solver::BarretenbergSolver,
pwg::{ACVMStatus, ErrorLocation, OpcodeResolutionError, ACVM},
};
#[allow(deprecated)]
use barretenberg_blackbox_solver::BarretenbergSolver;

use js_sys::Error;
use wasm_bindgen::prelude::wasm_bindgen;
Expand Down
70 changes: 70 additions & 0 deletions barretenberg_blackbox_solver/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
[package]
name = "barretenberg_blackbox_solver"
description = "Something about bb"
version = "0.26.1"
authors.workspace = true
edition.workspace = true
license.workspace = true
rust-version.workspace = true
repository.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
acir.workspace = true
acvm_blackbox_solver.workspace = true
thiserror.workspace = true

blake2 = "0.10.6"
sha2 = "0.10.6"
sha3 = "0.10.6"
k256 = { version = "0.11.0", features = [
"ecdsa",
"ecdsa-core",
"sha256",
"digest",
"arithmetic",
] }
p256 = { version = "0.11.0", features = [
"ecdsa",
"ecdsa-core",
"sha256",
"digest",
"arithmetic",
] }
hex = "0.4.2"
num-bigint.workspace = true

# Barretenberg WASM dependencies
rust-embed = { version = "6.6.0", features = [
"debug-embed",
"interpolate-folder-path",
"include-exclude",
] }
[target.'cfg(target_arch = "wasm32")'.dependencies]
wasmer = { version = "3.3", default-features = false, features = [
"js-default",
] }
getrandom = { version = "0.2", features = ["js"] }
wasm-bindgen-futures = "0.4.36"
js-sys = "0.3.62"


[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
getrandom = "0.2"
wasmer = "3.3"


[build-dependencies]
pkg-config = "0.3"
tar = "~0.4.15"
flate2 = "~1.0.1"
reqwest = { version = "0.11.16", default-features = false, features = [
"rustls-tls",
"blocking",
] }

[features]
default = ["bn254"]
bn254 = ["acir/bn254"]
bls12_381 = ["acir/bls12_381"]
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use acir::{BlackBoxFunc, FieldElement};

use crate::{BlackBoxFunctionSolver, BlackBoxResolutionError};
use acvm_blackbox_solver::{BlackBoxFunctionSolver, BlackBoxResolutionError};

mod wasm;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use acir::FieldElement;
use num_bigint::BigUint;

use crate::barretenberg::wasm::FeatureError;
use crate::wasm::FeatureError;

use super::{Barretenberg, Error, FIELD_BYTES};

Expand Down
31 changes: 0 additions & 31 deletions blackbox_solver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,37 +31,6 @@ p256 = { version = "0.11.0", features = [
"digest",
"arithmetic",
] }
hex = "0.4.2"
num-bigint.workspace = true

# Barretenberg WASM dependencies
rust-embed = { version = "6.6.0", features = [
"debug-embed",
"interpolate-folder-path",
"include-exclude",
] }
[target.'cfg(target_arch = "wasm32")'.dependencies]
wasmer = { version = "3.3", default-features = false, features = [
"js-default",
] }
getrandom = { version = "0.2", features = ["js"] }
wasm-bindgen-futures = "0.4.36"
js-sys = "0.3.62"


[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
getrandom = "0.2"
wasmer = "3.3"


[build-dependencies]
pkg-config = "0.3"
tar = "~0.4.15"
flate2 = "~1.0.1"
reqwest = { version = "0.11.16", default-features = false, features = [
"rustls-tls",
"blocking",
] }

[features]
default = ["bn254"]
Expand Down
5 changes: 0 additions & 5 deletions blackbox_solver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ use sha2::Sha256;
use sha3::Keccak256;
use thiserror::Error;

mod barretenberg;

#[allow(deprecated)]
pub use barretenberg::BarretenbergSolver;

#[derive(Clone, PartialEq, Eq, Debug, Error)]
pub enum BlackBoxResolutionError {
#[error("unsupported blackbox function: {0}")]
Expand Down
2 changes: 1 addition & 1 deletion brillig_vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repository.workspace = true

[dependencies]
acir.workspace = true
blackbox_solver.workspace = true
acvm_blackbox_solver.workspace = true
num-bigint.workspace = true
num-traits.workspace = true

Expand Down
2 changes: 1 addition & 1 deletion brillig_vm/src/black_box.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use acir::brillig::{BlackBoxOp, HeapArray, HeapVector, Value};
use acir::{BlackBoxFunc, FieldElement};
use blackbox_solver::{
use acvm_blackbox_solver::{
blake2s, ecdsa_secp256k1_verify, ecdsa_secp256r1_verify, hash_to_field_128_security, keccak256,
sha256, BlackBoxFunctionSolver, BlackBoxResolutionError,
};
Expand Down
Loading

0 comments on commit 17d7010

Please sign in to comment.