From 130d3673ab30e044006e248af6e43da9e81d1ccc Mon Sep 17 00:00:00 2001 From: Tom French Date: Thu, 31 Aug 2023 17:26:53 +0100 Subject: [PATCH] chore(acvm)!: Remove the `Backend` trait --- acvm/src/lib.rs | 74 ------------------------------------------------- 1 file changed, 74 deletions(-) diff --git a/acvm/src/lib.rs b/acvm/src/lib.rs index 08e6479a..5722ff97 100644 --- a/acvm/src/lib.rs +++ b/acvm/src/lib.rs @@ -4,10 +4,6 @@ pub mod compiler; pub mod pwg; -use acir::{ - circuit::{Circuit, Opcode}, - native_types::WitnessMap, -}; pub use blackbox_solver::{BlackBoxFunctionSolver, BlackBoxResolutionError}; use core::fmt::Debug; use pwg::OpcodeResolutionError; @@ -27,73 +23,3 @@ pub enum Language { R1CS, PLONKCSat { width: usize }, } - -pub trait Backend: SmartContract + ProofSystemCompiler + Default + Debug {} - -pub trait SmartContract { - /// The Error type returned by failed function calls in the SmartContract trait. - type Error: std::error::Error; - - // TODO: Allow a backend to support multiple smart contract platforms - - /// Returns an Ethereum smart contract to verify proofs against a given common reference string and verification key. - fn eth_contract(&self, circuit: &Circuit) -> Result; -} - -pub trait ProofSystemCompiler { - /// The Error type returned by failed function calls in the ProofSystemCompiler trait. - type Error: std::error::Error; - - /// The NPC language that this proof system directly accepts. - /// It is possible for ACVM to transpile to different languages, however it is advised to create a new backend - /// as this in most cases will be inefficient. For this reason, we want to throw a hard error - /// if the language and proof system does not line up. - fn np_language(&self) -> Language; - - // Returns true if the backend supports the selected opcode - fn supports_opcode(&self, opcode: &Opcode) -> bool; - - /// Returns the number of gates in a circuit - fn get_exact_circuit_size(&self, circuit: &Circuit) -> Result; - - /// Creates a Proof given the [`Circuit`] and the [witness values][`WitnessMap`] - /// It is important to note that the intermediate witnesses for black box functions will not generated - /// This is the responsibility of the proof system. - /// - /// The `is_recursive` flag represents whether one wants to create proofs that are to be natively verified. - /// A proof system may use a certain hash type for the Fiat-Shamir normally that is not hash friendly (such as keccak to enable Solidity verification), - /// but may want to use a snark-friendly hash function when performing native verification. - fn prove( - &self, - circuit: &Circuit, - witness_values: WitnessMap, - is_recursive: bool, - ) -> Result, Self::Error>; - - /// Verifies a Proof, given the [`Circuit`] and [public inputs][`WitnessMap`] - /// - /// The `is_recursive` flag represents whether one wants to verify proofs that are to be natively verified. - /// The flag must match the `is_recursive` flag used to generate the proof passed into this method, otherwise verification will return false. - fn verify( - &self, - proof: &[u8], - public_inputs: WitnessMap, - circuit: &Circuit, - is_recursive: bool, - ) -> Result; - - /// When performing recursive aggregation in a circuit it is most efficient to use a proof formatted using a backend's native field. - /// This method is exposed to enable backends to integrate a native recursion format and optimize their recursive circuits. - fn proof_as_fields( - &self, - proof: &[u8], - public_inputs: WitnessMap, - ) -> Result, Self::Error>; - - /// When performing recursive aggregation in a circuit it is most efficient to use a verification key formatted using a backend's native field. - /// This method is exposed to enable backends to integrate a native recursion format and optimize their recursive circuits. - fn vk_as_fields( - &self, - verification_key: &[u8], - ) -> Result<(Vec, FieldElement), Self::Error>; -}