ACVM
Add a PartialWitnessGenerator trait. This allows each backend to implement backend specific logic for opaque functions. Eg HashToField can have any hash function internally, blake/sha256 and ACIR would not need to know about it
pub(crate) mod backends;
pub mod compiler;
+pub mod pwg;
mod tier_one;
mod tier_three;
mod tier_two;
@@ -12,7 +13,11 @@ use tier_one::{TierOne, TIER_ONE_MAP};
use tier_three::{TierThree, TIER_THREE_MAP};
use tier_two::{TierTwo, TIER_TWO_MAP};
-use acir::{circuit::Circuit, native_types::Witness};
+use acir::{
+ circuit::{Circuit, Gate},
+ native_types::Witness,
+ OPCODE,
+};
// re-export acir
pub use acir;
@@ -58,13 +63,23 @@ pub fn fetch_by_name(string: &str) -> Option<BackendPointer> {
return Some(BackendPointer::Three(*target));
}
-pub trait Backend: SmartContract + ProofSystemCompiler {}
+pub trait Backend: SmartContract + ProofSystemCompiler + PartialWitnessGenerator {}
+/// This component will generate the backend specific output for
+/// each OPCODE.
+/// Returns an Error if the backend does not support that OPCODE
+pub trait PartialWitnessGenerator {
+ fn solve(
+ &self,
+ initial_witness: &mut BTreeMap<Witness, FieldElement>,
+ gates: Vec<Gate>,
+ ) -> Result<(), OPCODE>;
+}
pub trait SmartContract {
// Takes a verification key and produces a smart contract
// The platform indicator allows a backend to support multiple smart contract platforms
//
- // fn verification_key(&self, platform: u8, vk: &[u8], pi : Vec<FieldElement>) -> &[u8] {
+ // fn verification_key(&self, platform: u8, vk: &[u8]) -> &[u8] {
// todo!("currently the backend is not configured to use this.")
// }
