From a83788732c3d650dcb96f0303087d410c95cc2a1 Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Mon, 18 Nov 2024 12:00:06 +0000 Subject: [PATCH 01/32] IT FINALLY WORKS :D --- .../acir_formal_proofs/CMakeLists.txt | 1 + .../barretenberg/acir_formal_proofs/README.md | 11 + .../acir_formal_proofs/acir_loader.cpp | 13 + .../acir_formal_proofs/acir_loader.hpp | 23 + .../acir_formal_proofs/acir_loader.test.cpp | 14 + .../src/acir_instruction_builder.rs | 227 +++ .../compiler/noirc_evaluator/src/lib.rs | 4 + .../noirc_evaluator/ssa_test/Cargo.lock | 1794 +++++++++++++++++ .../noirc_evaluator/ssa_test/Cargo.toml | 10 + .../noirc_evaluator/ssa_test/src/main.rs | 18 + 10 files changed, 2115 insertions(+) create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/CMakeLists.txt create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp create mode 100644 noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs create mode 100644 noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock create mode 100644 noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml create mode 100644 noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/CMakeLists.txt new file mode 100644 index 00000000000..72391a847d6 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/CMakeLists.txt @@ -0,0 +1 @@ +barretenberg_module(acir_formal_proofs dsl) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md new file mode 100644 index 00000000000..89f1fd52a9c --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md @@ -0,0 +1,11 @@ +# Formal verifier of instructions produced by the conversion from Noir SSA to ACIR. + +## + +## how + +1. generate instructions' acir [with this](../../../../../noir/noir-repo/compiler/noirc_evaluator/ssa_test/) +2. move artifacts to this directory +3. ??? +4. ??? +5. verified diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp new file mode 100644 index 00000000000..130d06e7483 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp @@ -0,0 +1,13 @@ +#include "acir_loader.hpp" +#include "barretenberg/dsl/acir_format/acir_format.hpp" +#include "barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp" +#include +#include + + +AcirInstructionLoader::AcirInstructionLoader(std::vector const& acir_bytes, std::string instruction_name) +{ + this->acir_program_buf = acir_bytes; + this->instruction_name = instruction_name; + this->constraint_systems = acir_format::program_buf_to_acir_format(acir_bytes, false); +} \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp new file mode 100644 index 00000000000..923eb4ac0c3 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp @@ -0,0 +1,23 @@ +#pragma once +#include "barretenberg/dsl/acir_format/acir_format.hpp" +#include +#include + + +class AcirInstructionLoader { +public: + AcirInstructionLoader() = default; + AcirInstructionLoader(const AcirInstructionLoader& other) = default; + AcirInstructionLoader(AcirInstructionLoader&& other) = default; + AcirInstructionLoader& operator=(const AcirInstructionLoader other) = delete; + AcirInstructionLoader&& operator=(AcirInstructionLoader&& other) = delete; + + ~AcirInstructionLoader() = default; + + AcirInstructionLoader(std::vector const& acir_program_buf, std::string instruction_name); + +private: + std::string instruction_name; + std::vector acir_program_buf; + std::vector constraint_systems; +}; \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp new file mode 100644 index 00000000000..73244c6fa77 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp @@ -0,0 +1,14 @@ +#include "acir_loader.hpp" +#include "barretenberg/common/test.hpp" +#include "barretenberg/dsl/acir_format/acir_format.hpp" +#include + +TEST(acir_formal_proofs, loader) +{ + std::vector const program = std::vector( + {1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 52, 48, 48, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 10, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 11, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 10, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 11, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 51, 48, 54, 52, 52, 101, 55, 50, 101, 49, 51, 49, 97, 48, 50, 57, 98, 56, 53, 48, 52, 53, 98, 54, 56, 49, 56, 49, 53, 56, 53, 100, 50, 56, 51, 51, 101, 56, 52, 56, 55, 57, 98, 57, 55, 48, 57, 49, 52, 51, 101, 49, 102, 53, 57, 51, 101, 102, 102, 102, 102, 99, 48, 49, 2, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 51, 48, 54, 52, 52, 101, 55, 50, 101, 49, 51, 49, 97, 48, 50, 57, 98, 56, 53, 48, 52, 53, 98, 54, 56, 49, 56, 49, 53, 56, 53, 100, 50, 56, 51, 51, 101, 56, 52, 56, 55, 57, 98, 57, 55, 48, 57, 49, 52, 51, 101, 49, 102, 53, 57, 51, 102, 48, 48, 48, 48, 48, 48, 48, 3, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 1, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 51, 48, 54, 52, 52, 101, 55, 50, 101, 49, 51, 49, 97, 48, 50, 57, 98, 56, 53, 48, 52, 53, 98, 54, 56, 49, 56, 49, 53, 56, 53, 100, 50, 56, 51, 51, 101, 56, 52, 56, 55, 57, 98, 57, 55, 48, 57, 49, 52, 51, 101, 49, 102, 53, 57, 51, 102, 48, 48, 48, 48, 48, 48, 48, 3, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 50, 9, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0}); + std::string truncate{ "Truncate" }; + AcirInstructionLoader truncate_acir = AcirInstructionLoader(program, truncate); + info("amogus"); + EXPECT_EQ(1 + 1, 2); +} \ No newline at end of file diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs new file mode 100644 index 00000000000..1094fc0ac26 --- /dev/null +++ b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs @@ -0,0 +1,227 @@ +use std::collections::BTreeSet; +use acvm::{ + acir::{ + circuit::{ + Circuit, ExpressionWidth, + Program as AcirProgram, PublicInputs, + }, + native_types::Witness, + }, + FieldElement, +}; + +use crate::ssa::ssa_gen::Ssa; +use crate::ssa::ir::map::Id; + +use crate::ssa::{ + function_builder::FunctionBuilder, + ir::{instruction::BinaryOp, types::Type}, +}; +use crate::brillig::Brillig; +use serde::{Deserialize, Serialize}; + + + +#[derive(Serialize, Deserialize)] +pub struct InstructionArtifacts { + // name of used instruction + pub instruction_name: String, + + // ssa represented as format string acir(inline) {...} + pub formatted_ssa: String, + + // serde_json serialized ssa + pub serialized_ssa: String, + + // bytes of acir program + pub serialized_acir: Vec, +} + +impl InstructionArtifacts { + fn new_binary(op: BinaryOp, instruction_name: String) -> Self { + let ssa = binary_function(op); + let serialized_ssa = &serde_json::to_string(&ssa).unwrap(); + let formatted_ssa = format!("{}", ssa); + + let program = ssa_to_acir_program(ssa); + let serialized_program = AcirProgram::serialize_program(&program); + + Self { + instruction_name: instruction_name, + formatted_ssa: formatted_ssa, + serialized_ssa: serialized_ssa.to_string(), + serialized_acir: serialized_program + } + } + + fn new_by_func(ssa_generate_function: fn() -> Ssa, instruction_name: String) -> Self { + let ssa = ssa_generate_function(); + let serialized_ssa = &serde_json::to_string(&ssa).unwrap(); + let formatted_ssa = format!("{}", ssa); + + let program = ssa_to_acir_program(ssa); + let serialized_program = AcirProgram::serialize_program(&program); + + Self { + instruction_name: instruction_name, + formatted_ssa: formatted_ssa, + serialized_ssa: serialized_ssa.to_string(), + serialized_acir: serialized_program + } + + } + + fn new_constrain() -> Self { + return Self::new_by_func(constrain_function, "Constrain".into()) + } + + fn new_not() -> Self { + return Self::new_by_func(not_function, "Not".into()) + } + + fn new_range_check() -> Self { + return Self::new_by_func(range_check_function, "RangeCheck".into()) + } + + fn new_truncate() -> Self { + return Self::new_by_func(truncate_function, "Truncate".into()) + } +} + +fn ssa_to_acir_program(ssa: Ssa) -> AcirProgram { + // third brillig names, fourth errors + let (acir_functions, brillig, _, _) = ssa + .into_acir(&Brillig::default(), ExpressionWidth::default()) + .expect("Should compile manually written SSA into ACIR"); + + let mut functions: Vec> = Vec::new(); + for acir_func in acir_functions.iter() { + // no private params, i think + let public_params: BTreeSet = acir_func.input_witnesses.clone().into_iter().collect(); + let ret_values: BTreeSet = acir_func.return_witnesses.clone().into_iter().collect(); + let circuit: Circuit = Circuit { + current_witness_index: acir_func.current_witness_index().witness_index(), + opcodes: acir_func.opcodes().to_vec(), + public_parameters: PublicInputs(public_params), + return_values: PublicInputs(ret_values), + ..Circuit::::default() + }; + functions.push(circuit); + } + return AcirProgram { functions: functions, unconstrained_functions: brillig }; +} + +fn binary_function(op: BinaryOp) -> Ssa { + // returns v0 op v1 + let main_id = Id::new(0); + let mut builder = FunctionBuilder::new("main".into(), main_id); + let v0 = builder.add_parameter(Type::unsigned(64)); + + // bit size of v1 differs, because shl shr max second argument 8 bit; + let v1; + // let three = builder.numeric_constant(3u128, Type::unsigned(8)); + + if op == BinaryOp::Shl || op == BinaryOp::Shr { + v1 = builder.add_parameter(Type::unsigned(8)); + } else { + v1 = builder.add_parameter(Type::unsigned(64)); + } + + let v2 = builder.insert_binary(v0, op, v1); + builder.terminate_with_return(vec![v2]); + + let func = builder.finish(); + // it doesnt remove bit shifts, it replaces it with something smart + let cleared_func = func.remove_bit_shifts(); + return cleared_func; +} + +fn constrain_function() -> Ssa { + // constrains v0 == v1, returns v1 + let main_id = Id::new(0); + let mut builder = FunctionBuilder::new("main".into(), main_id); + + let v0 = builder.add_parameter(Type::field()); + let v1 = builder.add_parameter(Type::field()); + builder.insert_constrain(v0, v1, None); + builder.terminate_with_return(vec![v1]); + + return builder.finish() +} + +fn not_function() -> Ssa { + // returns not v0 + let main_id = Id::new(0); + let mut builder = FunctionBuilder::new("main".into(), main_id); + + let v0 = builder.add_parameter(Type::unsigned(64)); + let v1 = builder.insert_not(v0); + builder.terminate_with_return(vec![v1]); + + return builder.finish() +} + +fn range_check_function() -> Ssa { + // check v0: u64 limited by 64 bits ?.. + let main_id = Id::new(0); + let mut builder = FunctionBuilder::new("main".into(), main_id); + + let v0 = builder.add_parameter(Type::field()); + builder.insert_range_check(v0, 64, Some("Range Check failed".to_string())); + builder.terminate_with_return(vec![v0]); + + return builder.finish() +} + +fn truncate_function() -> Ssa { + // truncate v0: field 10, 20?.. + let main_id = Id::new(0); + let mut builder = FunctionBuilder::new("main".into(), main_id); + + let v0 = builder.add_parameter(Type::field()); + let v1 = builder.insert_truncate(v0, 10, 20); + builder.terminate_with_return(vec![v1]); + + return builder.finish() +} + +pub fn all_instructions() -> Vec { + let mut artifacts: Vec = Vec::new(); + + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Add, "Binary::Add".into())); + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Sub, "Binary::Sub".into())); + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Mul, "Binary::Mul".into())); + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Div, "Binary::Div".into())); + + // with field panic + // panic on Mod Should compile manually written SSA into ACIR: InvalidRangeConstraint + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Mod, "Binary::Mod".into())); + + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Eq, "Binary::Eq".into())); + + // with field panic + // thread 'main' panicked at /home/defkit/work/noir/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs:1225:9: + // assertion failed: max_bits + 1 < F::max_num_bits() + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Lt, "Binary::Lt".into())); + + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::And, "Binary::And".into())); + + // with field + // attempt to shift left with overflow + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Or, "Binary::Or".into())); + + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Xor, "Binary::Xor".into())); + + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Shl, "Binary::Shl".into())); + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Shr, "Binary::Shr".into())); + + // with field + // attempt to shift left with overflow + artifacts.push(InstructionArtifacts::new_not()); + + artifacts.push(InstructionArtifacts::new_constrain()); + artifacts.push(InstructionArtifacts::new_range_check()); + artifacts.push(InstructionArtifacts::new_truncate()); + + return artifacts; +} diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/lib.rs b/noir/noir-repo/compiler/noirc_evaluator/src/lib.rs index 5f0c7a5bbb8..c2ad2890d5a 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/lib.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/lib.rs @@ -13,6 +13,10 @@ pub mod brillig; pub use ssa::create_program; pub use ssa::ir::instruction::ErrorType; +pub mod acir_instruction_builder; +pub use acir_instruction_builder::{ + all_instructions, InstructionArtifacts +}; /// Trims leading whitespace from each line of the input string, according to /// how much leading whitespace there is on the first non-empty line. diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock new file mode 100644 index 00000000000..a5acc985db5 --- /dev/null +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock @@ -0,0 +1,1794 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "acir" +version = "0.54.0" +dependencies = [ + "acir_field", + "base64 0.21.7", + "bincode", + "brillig", + "flate2", + "serde", + "serde-big-array", + "thiserror", +] + +[[package]] +name = "acir_field" +version = "0.54.0" +dependencies = [ + "ark-bn254", + "ark-ff", + "cfg-if", + "hex", + "num-bigint", + "serde", +] + +[[package]] +name = "acvm" +version = "0.54.0" +dependencies = [ + "acir", + "acvm_blackbox_solver", + "brillig_vm", + "indexmap 1.9.3", + "num-bigint", + "serde", + "thiserror", + "tracing", +] + +[[package]] +name = "acvm_blackbox_solver" +version = "0.54.0" +dependencies = [ + "acir", + "blake2", + "blake3", + "k256", + "keccak", + "libaes", + "num-bigint", + "p256", + "sha2", + "thiserror", +] + +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "ark-bn254" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a22f4561524cd949590d78d7d4c5df8f592430d221f7f3c9497bbafd8972120f" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-std", +] + +[[package]] +name = "ark-ec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" +dependencies = [ + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", + "itertools", + "num-traits", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "digest", + "itertools", + "num-bigint", + "num-traits", + "paste", + "rustc_version", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-poly" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest", + "num-bigint", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand", +] + +[[package]] +name = "arrayref" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" + +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bitmaps" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031043d04099746d8db04daf1fa424b2bc8bd69d92b25962dcde24da39ab64a2" +dependencies = [ + "typenum", +] + +[[package]] +name = "blake2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +dependencies = [ + "digest", +] + +[[package]] +name = "blake3" +version = "1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d82033247fd8e890df8f740e407ad4d038debb9eb1f40533fffb32e7d17dc6f7" +dependencies = [ + "arrayref", + "arrayvec", + "cc", + "cfg-if", + "constant_time_eq", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bn254_blackbox_solver" +version = "0.54.0" +dependencies = [ + "acir", + "acvm_blackbox_solver", + "ark-bn254", + "ark-ec", + "ark-ff", + "hex", + "lazy_static", + "noir_grumpkin", + "num-bigint", +] + +[[package]] +name = "brillig" +version = "0.54.0" +dependencies = [ + "acir_field", + "serde", +] + +[[package]] +name = "brillig_vm" +version = "0.54.0" +dependencies = [ + "acir", + "acvm_blackbox_solver", + "num-bigint", + "num-traits", + "thiserror", +] + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cc" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-targets", +] + +[[package]] +name = "codespan" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3362992a0d9f1dd7c3d0e89e0ab2bb540b7a95fea8cd798090e758fda2899b5e" +dependencies = [ + "codespan-reporting", + "serde", +] + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "serde", + "termcolor", + "unicode-width", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "constant_time_eq" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "cpufeatures" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[package]] +name = "crypto-bigint" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.87", +] + +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "der" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", + "serde", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", + "subtle", +] + +[[package]] +name = "ecdsa" +version = "0.14.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +dependencies = [ + "der", + "elliptic-curve", + "rfc6979", + "signature", +] + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "elliptic-curve" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +dependencies = [ + "base16ct", + "crypto-bigint", + "der", + "digest", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "rand_core", + "subtle", +] + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "flate2" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "fm" +version = "0.38.0" +dependencies = [ + "codespan-reporting", + "iter-extended", + "serde", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "group" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashbrown" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "im" +version = "15.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0acd33ff0285af998aaf9b57342af478078f53492322fafc47450e09397e0e9" +dependencies = [ + "bitmaps", + "rand_core", + "rand_xoshiro", + "serde", + "sized-chunks", + "typenum", + "version_check", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "indexmap" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +dependencies = [ + "equivalent", + "hashbrown 0.15.1", + "serde", +] + +[[package]] +name = "iter-extended" +version = "0.38.0" + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "js-sys" +version = "0.3.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "jsonrpc" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34efde8d2422fb79ed56db1d3aea8fa5b583351d15a26770cdee2f88813dd702" +dependencies = [ + "base64 0.13.1", + "minreq", + "serde", + "serde_json", +] + +[[package]] +name = "k256" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "sha2", +] + +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libaes" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82903360c009b816f5ab72a9b68158c27c301ee2c3f20655b55c5e589e7d3bb7" + +[[package]] +name = "libc" +version = "0.2.164" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "miniz_oxide" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", +] + +[[package]] +name = "minreq" +version = "2.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "763d142cdff44aaadd9268bebddb156ef6c65a0e13486bb81673cf2d8739f9b0" +dependencies = [ + "log", + "serde", + "serde_json", +] + +[[package]] +name = "noir_grumpkin" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7d49a4b14b13c0dc730b05780b385828ab88f4148daaad7db080ecdce07350" +dependencies = [ + "ark-bn254", + "ark-ec", + "ark-ff", + "ark-std", +] + +[[package]] +name = "noirc_arena" +version = "0.38.0" + +[[package]] +name = "noirc_errors" +version = "0.38.0" +dependencies = [ + "acvm", + "base64 0.21.7", + "codespan", + "codespan-reporting", + "flate2", + "fm", + "noirc_printable_type", + "serde", + "serde_json", + "serde_with", + "tracing", +] + +[[package]] +name = "noirc_evaluator" +version = "0.38.0" +dependencies = [ + "acvm", + "bn254_blackbox_solver", + "cfg-if", + "chrono", + "fxhash", + "im", + "iter-extended", + "noirc_errors", + "noirc_frontend", + "num-bigint", + "num-traits", + "rayon", + "serde", + "serde_json", + "serde_with", + "thiserror", + "tracing", +] + +[[package]] +name = "noirc_frontend" +version = "0.38.0" +dependencies = [ + "acvm", + "bn254_blackbox_solver", + "cfg-if", + "fm", + "im", + "iter-extended", + "noirc_arena", + "noirc_errors", + "noirc_printable_type", + "num-bigint", + "num-traits", + "petgraph", + "rangemap", + "regex", + "rustc-hash", + "serde", + "serde_json", + "small-ord-set", + "smol_str", + "strum", + "strum_macros", + "thiserror", + "tracing", +] + +[[package]] +name = "noirc_printable_type" +version = "0.38.0" +dependencies = [ + "acvm", + "iter-extended", + "jsonrpc", + "regex", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "p256" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" +dependencies = [ + "ecdsa", + "elliptic-curve", + "sha2", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "petgraph" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" +dependencies = [ + "fixedbitset", + "indexmap 2.6.0", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" + +[[package]] +name = "pkcs8" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_xoshiro" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa" +dependencies = [ + "rand_core", +] + +[[package]] +name = "rangemap" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f60fcc7d6849342eff22c4350c8b9a989ee8ceabc4b481253e8946b9fe83d684" + +[[package]] +name = "rayon" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "rfc6979" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +dependencies = [ + "crypto-bigint", + "hmac", + "zeroize", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustversion" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "sec1" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + +[[package]] +name = "serde" +version = "1.0.215" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde-big-array" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11fc7cc2c76d73e0f27ee52abbd64eec84d46f370c88371120433196934e4b7f" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.215" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "serde_json" +version = "1.0.133" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e28bdad6db2b8340e449f7108f020b3b092e8583a9e3fb82713e1d4e71fe817" +dependencies = [ + "base64 0.22.1", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.6.0", + "serde", + "serde_derive", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +dependencies = [ + "digest", + "rand_core", +] + +[[package]] +name = "sized-chunks" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16d69225bde7a69b235da73377861095455d298f2b970996eec25ddbb42b3d1e" +dependencies = [ + "bitmaps", + "typenum", +] + +[[package]] +name = "small-ord-set" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf7035a2b2268a5be8c1395738565b06beda836097e12021cdefc06b127a0e7e" +dependencies = [ + "smallvec", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "smol_str" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fad6c857cbab2627dcf01ec85a623ca4e7dcb5691cbaa3d7fb7653671f0d09c9" +dependencies = [ + "serde", +] + +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "ssa_test" +version = "0.1.0" +dependencies = [ + "noirc_evaluator", + "serde", + "serde_json", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", +] + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "time" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-ident" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" + +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +dependencies = [ + "cfg-if", + "once_cell", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.87", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" + +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml new file mode 100644 index 00000000000..6b6a37cc916 --- /dev/null +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "ssa_test" +version = "0.1.0" +edition = "2021" + +[dependencies] +noirc_evaluator = {path = "../"} +serde = "1.0.214" +serde_json = "1.0.120" +[workspace] diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs new file mode 100644 index 00000000000..2c8eff05834 --- /dev/null +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs @@ -0,0 +1,18 @@ +use::noirc_evaluator::acir_instruction_builder::{ + all_instructions, InstructionArtifacts +}; + + +fn main() { + let all_artifacts: Vec = all_instructions(); + + for artifacts in all_artifacts.iter() { + println!("============{}==============", artifacts.instruction_name); + println!("{:?}", artifacts.serialized_acir); + // println!("{}", artifacts.serialized_ssa); + // println!("Acir length: {:?}", artifacts.serialized_acir.len()); + // let artifacts_serialized = serde_json::to_string(&artifacts).unwrap(); + // println!("{}", artifacts_serialized); + } +} + From 5750f4ccdfbafd1e05f1fcf4fc146349d15aa339 Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Mon, 18 Nov 2024 12:03:26 +0000 Subject: [PATCH 02/32] i forgot cmakelists --- barretenberg/cpp/src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/barretenberg/cpp/src/CMakeLists.txt b/barretenberg/cpp/src/CMakeLists.txt index 85fbaf19f38..9253dea58f7 100644 --- a/barretenberg/cpp/src/CMakeLists.txt +++ b/barretenberg/cpp/src/CMakeLists.txt @@ -96,6 +96,7 @@ add_subdirectory(barretenberg/ultra_honk) add_subdirectory(barretenberg/vm) add_subdirectory(barretenberg/wasi) add_subdirectory(barretenberg/world_state) +add_subdirectory(barretenberg/acir_formal_proofs) if(SMT) add_subdirectory(barretenberg/smt_verification) From cc71c305aca08537a0a13288a1e22a8f965db90a Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Mon, 18 Nov 2024 12:34:04 +0000 Subject: [PATCH 03/32] save artifacts --- .../noirc_evaluator/ssa_test/.gitignore | 2 ++ .../noirc_evaluator/ssa_test/Cargo.lock | 1 + .../noirc_evaluator/ssa_test/README.md | 2 ++ .../noirc_evaluator/ssa_test/src/main.rs | 21 ++++++++++++------- 4 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 noir/noir-repo/compiler/noirc_evaluator/ssa_test/.gitignore create mode 100644 noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/.gitignore b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/.gitignore new file mode 100644 index 00000000000..6c7b7f9b99c --- /dev/null +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/.gitignore @@ -0,0 +1,2 @@ +Cargo.lock +artifacts/* diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock index a5acc985db5..cbf8632da41 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock @@ -957,6 +957,7 @@ dependencies = [ "bn254_blackbox_solver", "cfg-if", "chrono", + "flate2", "fxhash", "im", "iter-extended", diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md new file mode 100644 index 00000000000..73bdfcb4007 --- /dev/null +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md @@ -0,0 +1,2 @@ +# WHY +USED FOR FORMAL VERIFYING SSA INSTRUCTIONS PRODUCED BY THE CONVERSION SSA->ACIR diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs index 2c8eff05834..f56a50afbcc 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs @@ -1,18 +1,25 @@ +use std::fs::File; +use std::io::Write; +use std::path::Path; use::noirc_evaluator::acir_instruction_builder::{ all_instructions, InstructionArtifacts }; +fn save_to_file(data: &[u8], filename: &str) -> Result<(), std::io::Error> { + let path = Path::new(filename); + let mut file = File::create(path)?; + file.write_all(data)?; + Ok(()) +} fn main() { let all_artifacts: Vec = all_instructions(); for artifacts in all_artifacts.iter() { - println!("============{}==============", artifacts.instruction_name); - println!("{:?}", artifacts.serialized_acir); - // println!("{}", artifacts.serialized_ssa); - // println!("Acir length: {:?}", artifacts.serialized_acir.len()); - // let artifacts_serialized = serde_json::to_string(&artifacts).unwrap(); - // println!("{}", artifacts_serialized); + let filename = format!("artifacts/{}{}", artifacts.instruction_name, ".acir"); + match save_to_file(&artifacts.serialized_acir, &filename) { + Ok(_) => (), + Err(error) => println!("Error saving data: {}", error), + } } } - From a791e76a355395b3f65df6bcd10f8907a8346e09 Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Thu, 21 Nov 2024 13:23:04 +0000 Subject: [PATCH 04/32] stable version for verifying --- .../compiler/noirc_evaluator/Cargo.toml | 1 + .../src/acir_instruction_builder.rs | 24 ++++++++++++------- .../noirc_evaluator/ssa_test/src/main.rs | 1 + 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/noir/noir-repo/compiler/noirc_evaluator/Cargo.toml b/noir/noir-repo/compiler/noirc_evaluator/Cargo.toml index aac07339dd6..add1a6b9aec 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/Cargo.toml +++ b/noir/noir-repo/compiler/noirc_evaluator/Cargo.toml @@ -27,6 +27,7 @@ serde_json.workspace = true serde_with = "3.2.0" tracing.workspace = true chrono = "0.4.37" +flate2 = "1.0.35" rayon.workspace = true cfg-if.workspace = true diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs index 1094fc0ac26..e65f16dfc58 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs @@ -1,4 +1,6 @@ use std::collections::BTreeSet; +use flate2::read::GzDecoder; +use std::io::Read; use acvm::{ acir::{ circuit::{ @@ -20,7 +22,12 @@ use crate::ssa::{ use crate::brillig::Brillig; use serde::{Deserialize, Serialize}; - +fn ungzip(compressed_data: Vec) -> Vec { + let mut decompressed_data: Vec = Vec::new(); + let mut decoder = GzDecoder::new(&compressed_data[..]); + decoder.read_to_end(&mut decompressed_data).unwrap(); + return decompressed_data; +} #[derive(Serialize, Deserialize)] pub struct InstructionArtifacts { @@ -33,7 +40,7 @@ pub struct InstructionArtifacts { // serde_json serialized ssa pub serialized_ssa: String, - // bytes of acir program + // bytes of acir program. Ungzipped!! pub serialized_acir: Vec, } @@ -50,7 +57,7 @@ impl InstructionArtifacts { instruction_name: instruction_name, formatted_ssa: formatted_ssa, serialized_ssa: serialized_ssa.to_string(), - serialized_acir: serialized_program + serialized_acir: ungzip(serialized_program) } } @@ -66,7 +73,7 @@ impl InstructionArtifacts { instruction_name: instruction_name, formatted_ssa: formatted_ssa, serialized_ssa: serialized_ssa.to_string(), - serialized_acir: serialized_program + serialized_acir: ungzip(serialized_program) } } @@ -96,14 +103,15 @@ fn ssa_to_acir_program(ssa: Ssa) -> AcirProgram { let mut functions: Vec> = Vec::new(); for acir_func in acir_functions.iter() { - // no private params, i think - let public_params: BTreeSet = acir_func.input_witnesses.clone().into_iter().collect(); + // inputs and output as private + let mut private_params: BTreeSet = acir_func.input_witnesses.clone().into_iter().collect(); let ret_values: BTreeSet = acir_func.return_witnesses.clone().into_iter().collect(); + + private_params.extend(ret_values.iter().cloned()); let circuit: Circuit = Circuit { current_witness_index: acir_func.current_witness_index().witness_index(), opcodes: acir_func.opcodes().to_vec(), - public_parameters: PublicInputs(public_params), - return_values: PublicInputs(ret_values), + private_parameters: private_params, ..Circuit::::default() }; functions.push(circuit); diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs index f56a50afbcc..282eea01a77 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs @@ -16,6 +16,7 @@ fn main() { let all_artifacts: Vec = all_instructions(); for artifacts in all_artifacts.iter() { + println!("{}", artifacts.formatted_ssa); let filename = format!("artifacts/{}{}", artifacts.instruction_name, ".acir"); match save_to_file(&artifacts.serialized_acir, &filename) { Ok(_) => (), From 56559cf7fce08564b1b28ebe20726ba486af2379 Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Fri, 22 Nov 2024 14:48:00 +0000 Subject: [PATCH 05/32] dummy --- .../acir_formal_proofs/.gitignore | 1 + .../acir_formal_proofs/CMakeLists.txt | 2 +- .../acir_formal_proofs/acir_loader.cpp | 28 +++++ .../acir_formal_proofs/acir_loader.hpp | 3 + .../acir_formal_proofs/acir_loader.test.cpp | 114 ++++++++++++++++-- .../src/acir_instruction_builder.rs | 9 +- 6 files changed, 145 insertions(+), 12 deletions(-) create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/.gitignore diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/.gitignore b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/.gitignore new file mode 100644 index 00000000000..62dd1ddc077 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/.gitignore @@ -0,0 +1 @@ +artifacts/* diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/CMakeLists.txt index 72391a847d6..43b9fc20ca7 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/CMakeLists.txt @@ -1 +1 @@ -barretenberg_module(acir_formal_proofs dsl) \ No newline at end of file +barretenberg_module(acir_formal_proofs dsl circuit_checker smt_verification) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp index 130d06e7483..1e609a9c165 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp @@ -3,6 +3,28 @@ #include "barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp" #include #include +#include + + +std::vector readFile(std::string filename) +{ + std::ifstream file(filename, std::ios::binary); + file.unsetf(std::ios::skipws); + + std::streampos fileSize; + + file.seekg(0, std::ios::end); + fileSize = file.tellg(); + file.seekg(0, std::ios::beg); + + std::vector vec; + + vec.insert(vec.begin(), + std::istream_iterator(file), + std::istream_iterator()); + file.close(); + return vec; +} AcirInstructionLoader::AcirInstructionLoader(std::vector const& acir_bytes, std::string instruction_name) @@ -10,4 +32,10 @@ AcirInstructionLoader::AcirInstructionLoader(std::vector const& acir_by this->acir_program_buf = acir_bytes; this->instruction_name = instruction_name; this->constraint_systems = acir_format::program_buf_to_acir_format(acir_bytes, false); +} + +AcirInstructionLoader::AcirInstructionLoader(std::string filename) { + this->acir_program_buf = readFile(filename); + this->instruction_name = filename; + this->constraint_systems = acir_format::program_buf_to_acir_format(this->acir_program_buf, false); } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp index 923eb4ac0c3..7f3e03d3b01 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp @@ -15,6 +15,9 @@ class AcirInstructionLoader { ~AcirInstructionLoader() = default; AcirInstructionLoader(std::vector const& acir_program_buf, std::string instruction_name); + AcirInstructionLoader(std::string filename); + + std::vector get_constraint_systems() { return this->constraint_systems; } private: std::string instruction_name; diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp index 73244c6fa77..eef0402634e 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp @@ -1,14 +1,114 @@ #include "acir_loader.hpp" +#include "barretenberg/circuit_checker/circuit_checker.hpp" #include "barretenberg/common/test.hpp" #include "barretenberg/dsl/acir_format/acir_format.hpp" +#include "barretenberg/smt_verification/circuit/ultra_circuit.hpp" +#include "barretenberg/stdlib/client_ivc_verifier/client_ivc_recursive_verifier.hpp" +#include "barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp" #include -TEST(acir_formal_proofs, loader) +TEST(acir_formal_proofs, slow) { - std::vector const program = std::vector( - {1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 52, 48, 48, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 10, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 11, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 10, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 11, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 51, 48, 54, 52, 52, 101, 55, 50, 101, 49, 51, 49, 97, 48, 50, 57, 98, 56, 53, 48, 52, 53, 98, 54, 56, 49, 56, 49, 53, 56, 53, 100, 50, 56, 51, 51, 101, 56, 52, 56, 55, 57, 98, 57, 55, 48, 57, 49, 52, 51, 101, 49, 102, 53, 57, 51, 101, 102, 102, 102, 102, 99, 48, 49, 2, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 51, 48, 54, 52, 52, 101, 55, 50, 101, 49, 51, 49, 97, 48, 50, 57, 98, 56, 53, 48, 52, 53, 98, 54, 56, 49, 56, 49, 53, 56, 53, 100, 50, 56, 51, 51, 101, 56, 52, 56, 55, 57, 98, 57, 55, 48, 57, 49, 52, 51, 101, 49, 102, 53, 57, 51, 102, 48, 48, 48, 48, 48, 48, 48, 3, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 1, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 51, 48, 54, 52, 52, 101, 55, 50, 101, 49, 51, 49, 97, 48, 50, 57, 98, 56, 53, 48, 52, 53, 98, 54, 56, 49, 56, 49, 53, 56, 53, 100, 50, 56, 51, 51, 101, 56, 52, 56, 55, 57, 98, 57, 55, 48, 57, 49, 52, 51, 101, 49, 102, 53, 57, 51, 102, 48, 48, 48, 48, 48, 48, 48, 3, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 50, 9, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0}); - std::string truncate{ "Truncate" }; - AcirInstructionLoader truncate_acir = AcirInstructionLoader(program, truncate); - info("amogus"); - EXPECT_EQ(1 + 1, 2); + AcirInstructionLoader add = + AcirInstructionLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Add.acir"); + auto system = add.get_constraint_systems().at(0); + bb::UltraCircuitBuilder builder = acir_format::create_circuit(system, false); + info(builder.public_inputs); + // info(builder.variables); + builder.set_variable_name(0, "a"); + builder.set_variable_name(1, "b"); + builder.set_variable_name(2, "c"); + builder.set_variable_name(3, "d"); + builder.set_variable_name(4, "e"); + EXPECT_TRUE(bb::CircuitChecker::check(builder)); + + auto buf = builder.export_circuit(); + smt_circuit::CircuitSchema circuit_info = smt_circuit_schema::unpack_from_buffer(buf); + smt_solver::Solver s(circuit_info.modulus); + smt_circuit::UltraCircuit circuit(circuit_info, &s, smt_terms::TermType::FFTerm); + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + info(c); + auto cr = a + b; + c != cr; + bool res = s.check(); + EXPECT_TRUE(false); + s.print_assertions(); + info(s.getResult()); + EXPECT_FALSE(res); +} + +TEST(acir_formal_proofs, uint_terms_add) +{ + AcirInstructionLoader add = + AcirInstructionLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Add.acir"); + auto system = add.get_constraint_systems().at(0); + bb::UltraCircuitBuilder builder = acir_format::create_circuit(system, false); + info(builder.public_inputs); + // info(builder.variables); + builder.set_variable_name(0, "a"); + builder.set_variable_name(1, "b"); + builder.set_variable_name(2, "c"); + builder.set_variable_name(3, "d"); + builder.set_variable_name(4, "e"); + EXPECT_TRUE(bb::CircuitChecker::check(builder)); + + auto buf = builder.export_circuit(); + smt_circuit::CircuitSchema circuit_info = smt_circuit_schema::unpack_from_buffer(buf); + smt_solver::Solver s(circuit_info.modulus); + smt_circuit::UltraCircuit circuit(circuit_info, &s, smt_terms::TermType::BVTerm); + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + info(c); + auto cr = a + b; + c != cr; + bool res = s.check(); + EXPECT_TRUE(false); + s.print_assertions(); + info(s.getResult()); + EXPECT_FALSE(res); +} + +TEST(acir_formal_proofs, public_inputs) +{ + AcirInstructionLoader add = + AcirInstructionLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Add.public.acir"); + auto system = add.get_constraint_systems().at(0); + bb::UltraCircuitBuilder builder = acir_format::create_circuit(system, false); + // builder.zero_idx = 4; + info(builder.zero_idx); + info("Public inputs in builder", builder.public_inputs); + info(builder.real_variable_index[2]); + info(builder.real_variable_index[3]); + builder.variables[0] = 10; + builder.variables[1] = 10; + // if we set second variable check circuit throws error :(, so output in third??? + builder.variables[3] = 20; + EXPECT_TRUE(bb::CircuitChecker::check(builder)); + + builder.set_variable_name(0, "a"); + builder.set_variable_name(1, "b"); + builder.set_variable_name(2, "c"); + builder.set_variable_name(3, "d"); + builder.set_variable_name(4, "e"); + EXPECT_TRUE(bb::CircuitChecker::check(builder)); + + auto buf = builder.export_circuit(); + smt_circuit::CircuitSchema circuit_info = smt_circuit_schema::unpack_from_buffer(buf); + info("Circuit info public inputs", circuit_info.public_inps); + smt_solver::Solver s(circuit_info.modulus); + smt_circuit::UltraCircuit circuit(circuit_info, &s, smt_terms::TermType::BVTerm); + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + info(c); + auto cr = a + b; + c != cr; + bool res = s.check(); + EXPECT_TRUE(false); + s.print_assertions(); + info(s.getResult()); + EXPECT_FALSE(res); } \ No newline at end of file diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs index e65f16dfc58..da545a21e80 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs @@ -100,15 +100,16 @@ fn ssa_to_acir_program(ssa: Ssa) -> AcirProgram { let (acir_functions, brillig, _, _) = ssa .into_acir(&Brillig::default(), ExpressionWidth::default()) .expect("Should compile manually written SSA into ACIR"); - + let mut functions: Vec> = Vec::new(); for acir_func in acir_functions.iter() { // inputs and output as private let mut private_params: BTreeSet = acir_func.input_witnesses.clone().into_iter().collect(); let ret_values: BTreeSet = acir_func.return_witnesses.clone().into_iter().collect(); + let circuit: Circuit ; private_params.extend(ret_values.iter().cloned()); - let circuit: Circuit = Circuit { + circuit = Circuit { current_witness_index: acir_func.current_witness_index().witness_index(), opcodes: acir_func.opcodes().to_vec(), private_parameters: private_params, @@ -123,7 +124,7 @@ fn binary_function(op: BinaryOp) -> Ssa { // returns v0 op v1 let main_id = Id::new(0); let mut builder = FunctionBuilder::new("main".into(), main_id); - let v0 = builder.add_parameter(Type::unsigned(64)); + let v0 = builder.add_parameter(Type::unsigned(8)); // bit size of v1 differs, because shl shr max second argument 8 bit; let v1; @@ -132,7 +133,7 @@ fn binary_function(op: BinaryOp) -> Ssa { if op == BinaryOp::Shl || op == BinaryOp::Shr { v1 = builder.add_parameter(Type::unsigned(8)); } else { - v1 = builder.add_parameter(Type::unsigned(64)); + v1 = builder.add_parameter(Type::unsigned(8)); } let v2 = builder.insert_binary(v0, op, v1); From c364e639426668f9a025466a461f85b47768f544 Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Mon, 18 Nov 2024 12:00:06 +0000 Subject: [PATCH 06/32] IT FINALLY WORKS :D --- .../acir_formal_proofs/CMakeLists.txt | 1 + .../barretenberg/acir_formal_proofs/README.md | 11 + .../acir_formal_proofs/acir_loader.cpp | 13 + .../acir_formal_proofs/acir_loader.hpp | 23 + .../acir_formal_proofs/acir_loader.test.cpp | 14 + .../src/acir_instruction_builder.rs | 227 +++ .../compiler/noirc_evaluator/src/lib.rs | 4 + .../noirc_evaluator/ssa_test/Cargo.lock | 1794 +++++++++++++++++ .../noirc_evaluator/ssa_test/Cargo.toml | 10 + .../noirc_evaluator/ssa_test/src/main.rs | 18 + 10 files changed, 2115 insertions(+) create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/CMakeLists.txt create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp create mode 100644 noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs create mode 100644 noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock create mode 100644 noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml create mode 100644 noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/CMakeLists.txt new file mode 100644 index 00000000000..72391a847d6 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/CMakeLists.txt @@ -0,0 +1 @@ +barretenberg_module(acir_formal_proofs dsl) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md new file mode 100644 index 00000000000..89f1fd52a9c --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md @@ -0,0 +1,11 @@ +# Formal verifier of instructions produced by the conversion from Noir SSA to ACIR. + +## + +## how + +1. generate instructions' acir [with this](../../../../../noir/noir-repo/compiler/noirc_evaluator/ssa_test/) +2. move artifacts to this directory +3. ??? +4. ??? +5. verified diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp new file mode 100644 index 00000000000..130d06e7483 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp @@ -0,0 +1,13 @@ +#include "acir_loader.hpp" +#include "barretenberg/dsl/acir_format/acir_format.hpp" +#include "barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp" +#include +#include + + +AcirInstructionLoader::AcirInstructionLoader(std::vector const& acir_bytes, std::string instruction_name) +{ + this->acir_program_buf = acir_bytes; + this->instruction_name = instruction_name; + this->constraint_systems = acir_format::program_buf_to_acir_format(acir_bytes, false); +} \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp new file mode 100644 index 00000000000..923eb4ac0c3 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp @@ -0,0 +1,23 @@ +#pragma once +#include "barretenberg/dsl/acir_format/acir_format.hpp" +#include +#include + + +class AcirInstructionLoader { +public: + AcirInstructionLoader() = default; + AcirInstructionLoader(const AcirInstructionLoader& other) = default; + AcirInstructionLoader(AcirInstructionLoader&& other) = default; + AcirInstructionLoader& operator=(const AcirInstructionLoader other) = delete; + AcirInstructionLoader&& operator=(AcirInstructionLoader&& other) = delete; + + ~AcirInstructionLoader() = default; + + AcirInstructionLoader(std::vector const& acir_program_buf, std::string instruction_name); + +private: + std::string instruction_name; + std::vector acir_program_buf; + std::vector constraint_systems; +}; \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp new file mode 100644 index 00000000000..73244c6fa77 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp @@ -0,0 +1,14 @@ +#include "acir_loader.hpp" +#include "barretenberg/common/test.hpp" +#include "barretenberg/dsl/acir_format/acir_format.hpp" +#include + +TEST(acir_formal_proofs, loader) +{ + std::vector const program = std::vector( + {1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 52, 48, 48, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 10, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 11, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 10, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 11, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 51, 48, 54, 52, 52, 101, 55, 50, 101, 49, 51, 49, 97, 48, 50, 57, 98, 56, 53, 48, 52, 53, 98, 54, 56, 49, 56, 49, 53, 56, 53, 100, 50, 56, 51, 51, 101, 56, 52, 56, 55, 57, 98, 57, 55, 48, 57, 49, 52, 51, 101, 49, 102, 53, 57, 51, 101, 102, 102, 102, 102, 99, 48, 49, 2, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 51, 48, 54, 52, 52, 101, 55, 50, 101, 49, 51, 49, 97, 48, 50, 57, 98, 56, 53, 48, 52, 53, 98, 54, 56, 49, 56, 49, 53, 56, 53, 100, 50, 56, 51, 51, 101, 56, 52, 56, 55, 57, 98, 57, 55, 48, 57, 49, 52, 51, 101, 49, 102, 53, 57, 51, 102, 48, 48, 48, 48, 48, 48, 48, 3, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 1, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 51, 48, 54, 52, 52, 101, 55, 50, 101, 49, 51, 49, 97, 48, 50, 57, 98, 56, 53, 48, 52, 53, 98, 54, 56, 49, 56, 49, 53, 56, 53, 100, 50, 56, 51, 51, 101, 56, 52, 56, 55, 57, 98, 57, 55, 48, 57, 49, 52, 51, 101, 49, 102, 53, 57, 51, 102, 48, 48, 48, 48, 48, 48, 48, 3, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 50, 9, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0}); + std::string truncate{ "Truncate" }; + AcirInstructionLoader truncate_acir = AcirInstructionLoader(program, truncate); + info("amogus"); + EXPECT_EQ(1 + 1, 2); +} \ No newline at end of file diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs new file mode 100644 index 00000000000..1094fc0ac26 --- /dev/null +++ b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs @@ -0,0 +1,227 @@ +use std::collections::BTreeSet; +use acvm::{ + acir::{ + circuit::{ + Circuit, ExpressionWidth, + Program as AcirProgram, PublicInputs, + }, + native_types::Witness, + }, + FieldElement, +}; + +use crate::ssa::ssa_gen::Ssa; +use crate::ssa::ir::map::Id; + +use crate::ssa::{ + function_builder::FunctionBuilder, + ir::{instruction::BinaryOp, types::Type}, +}; +use crate::brillig::Brillig; +use serde::{Deserialize, Serialize}; + + + +#[derive(Serialize, Deserialize)] +pub struct InstructionArtifacts { + // name of used instruction + pub instruction_name: String, + + // ssa represented as format string acir(inline) {...} + pub formatted_ssa: String, + + // serde_json serialized ssa + pub serialized_ssa: String, + + // bytes of acir program + pub serialized_acir: Vec, +} + +impl InstructionArtifacts { + fn new_binary(op: BinaryOp, instruction_name: String) -> Self { + let ssa = binary_function(op); + let serialized_ssa = &serde_json::to_string(&ssa).unwrap(); + let formatted_ssa = format!("{}", ssa); + + let program = ssa_to_acir_program(ssa); + let serialized_program = AcirProgram::serialize_program(&program); + + Self { + instruction_name: instruction_name, + formatted_ssa: formatted_ssa, + serialized_ssa: serialized_ssa.to_string(), + serialized_acir: serialized_program + } + } + + fn new_by_func(ssa_generate_function: fn() -> Ssa, instruction_name: String) -> Self { + let ssa = ssa_generate_function(); + let serialized_ssa = &serde_json::to_string(&ssa).unwrap(); + let formatted_ssa = format!("{}", ssa); + + let program = ssa_to_acir_program(ssa); + let serialized_program = AcirProgram::serialize_program(&program); + + Self { + instruction_name: instruction_name, + formatted_ssa: formatted_ssa, + serialized_ssa: serialized_ssa.to_string(), + serialized_acir: serialized_program + } + + } + + fn new_constrain() -> Self { + return Self::new_by_func(constrain_function, "Constrain".into()) + } + + fn new_not() -> Self { + return Self::new_by_func(not_function, "Not".into()) + } + + fn new_range_check() -> Self { + return Self::new_by_func(range_check_function, "RangeCheck".into()) + } + + fn new_truncate() -> Self { + return Self::new_by_func(truncate_function, "Truncate".into()) + } +} + +fn ssa_to_acir_program(ssa: Ssa) -> AcirProgram { + // third brillig names, fourth errors + let (acir_functions, brillig, _, _) = ssa + .into_acir(&Brillig::default(), ExpressionWidth::default()) + .expect("Should compile manually written SSA into ACIR"); + + let mut functions: Vec> = Vec::new(); + for acir_func in acir_functions.iter() { + // no private params, i think + let public_params: BTreeSet = acir_func.input_witnesses.clone().into_iter().collect(); + let ret_values: BTreeSet = acir_func.return_witnesses.clone().into_iter().collect(); + let circuit: Circuit = Circuit { + current_witness_index: acir_func.current_witness_index().witness_index(), + opcodes: acir_func.opcodes().to_vec(), + public_parameters: PublicInputs(public_params), + return_values: PublicInputs(ret_values), + ..Circuit::::default() + }; + functions.push(circuit); + } + return AcirProgram { functions: functions, unconstrained_functions: brillig }; +} + +fn binary_function(op: BinaryOp) -> Ssa { + // returns v0 op v1 + let main_id = Id::new(0); + let mut builder = FunctionBuilder::new("main".into(), main_id); + let v0 = builder.add_parameter(Type::unsigned(64)); + + // bit size of v1 differs, because shl shr max second argument 8 bit; + let v1; + // let three = builder.numeric_constant(3u128, Type::unsigned(8)); + + if op == BinaryOp::Shl || op == BinaryOp::Shr { + v1 = builder.add_parameter(Type::unsigned(8)); + } else { + v1 = builder.add_parameter(Type::unsigned(64)); + } + + let v2 = builder.insert_binary(v0, op, v1); + builder.terminate_with_return(vec![v2]); + + let func = builder.finish(); + // it doesnt remove bit shifts, it replaces it with something smart + let cleared_func = func.remove_bit_shifts(); + return cleared_func; +} + +fn constrain_function() -> Ssa { + // constrains v0 == v1, returns v1 + let main_id = Id::new(0); + let mut builder = FunctionBuilder::new("main".into(), main_id); + + let v0 = builder.add_parameter(Type::field()); + let v1 = builder.add_parameter(Type::field()); + builder.insert_constrain(v0, v1, None); + builder.terminate_with_return(vec![v1]); + + return builder.finish() +} + +fn not_function() -> Ssa { + // returns not v0 + let main_id = Id::new(0); + let mut builder = FunctionBuilder::new("main".into(), main_id); + + let v0 = builder.add_parameter(Type::unsigned(64)); + let v1 = builder.insert_not(v0); + builder.terminate_with_return(vec![v1]); + + return builder.finish() +} + +fn range_check_function() -> Ssa { + // check v0: u64 limited by 64 bits ?.. + let main_id = Id::new(0); + let mut builder = FunctionBuilder::new("main".into(), main_id); + + let v0 = builder.add_parameter(Type::field()); + builder.insert_range_check(v0, 64, Some("Range Check failed".to_string())); + builder.terminate_with_return(vec![v0]); + + return builder.finish() +} + +fn truncate_function() -> Ssa { + // truncate v0: field 10, 20?.. + let main_id = Id::new(0); + let mut builder = FunctionBuilder::new("main".into(), main_id); + + let v0 = builder.add_parameter(Type::field()); + let v1 = builder.insert_truncate(v0, 10, 20); + builder.terminate_with_return(vec![v1]); + + return builder.finish() +} + +pub fn all_instructions() -> Vec { + let mut artifacts: Vec = Vec::new(); + + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Add, "Binary::Add".into())); + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Sub, "Binary::Sub".into())); + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Mul, "Binary::Mul".into())); + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Div, "Binary::Div".into())); + + // with field panic + // panic on Mod Should compile manually written SSA into ACIR: InvalidRangeConstraint + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Mod, "Binary::Mod".into())); + + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Eq, "Binary::Eq".into())); + + // with field panic + // thread 'main' panicked at /home/defkit/work/noir/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs:1225:9: + // assertion failed: max_bits + 1 < F::max_num_bits() + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Lt, "Binary::Lt".into())); + + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::And, "Binary::And".into())); + + // with field + // attempt to shift left with overflow + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Or, "Binary::Or".into())); + + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Xor, "Binary::Xor".into())); + + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Shl, "Binary::Shl".into())); + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Shr, "Binary::Shr".into())); + + // with field + // attempt to shift left with overflow + artifacts.push(InstructionArtifacts::new_not()); + + artifacts.push(InstructionArtifacts::new_constrain()); + artifacts.push(InstructionArtifacts::new_range_check()); + artifacts.push(InstructionArtifacts::new_truncate()); + + return artifacts; +} diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/lib.rs b/noir/noir-repo/compiler/noirc_evaluator/src/lib.rs index 8127e3d03ef..cf11b651ede 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/lib.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/lib.rs @@ -11,6 +11,10 @@ pub mod ssa; pub use ssa::create_program; pub use ssa::ir::instruction::ErrorType; +pub mod acir_instruction_builder; +pub use acir_instruction_builder::{ + all_instructions, InstructionArtifacts +}; /// Trims leading whitespace from each line of the input string, according to /// how much leading whitespace there is on the first non-empty line. diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock new file mode 100644 index 00000000000..a5acc985db5 --- /dev/null +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock @@ -0,0 +1,1794 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "acir" +version = "0.54.0" +dependencies = [ + "acir_field", + "base64 0.21.7", + "bincode", + "brillig", + "flate2", + "serde", + "serde-big-array", + "thiserror", +] + +[[package]] +name = "acir_field" +version = "0.54.0" +dependencies = [ + "ark-bn254", + "ark-ff", + "cfg-if", + "hex", + "num-bigint", + "serde", +] + +[[package]] +name = "acvm" +version = "0.54.0" +dependencies = [ + "acir", + "acvm_blackbox_solver", + "brillig_vm", + "indexmap 1.9.3", + "num-bigint", + "serde", + "thiserror", + "tracing", +] + +[[package]] +name = "acvm_blackbox_solver" +version = "0.54.0" +dependencies = [ + "acir", + "blake2", + "blake3", + "k256", + "keccak", + "libaes", + "num-bigint", + "p256", + "sha2", + "thiserror", +] + +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "ark-bn254" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a22f4561524cd949590d78d7d4c5df8f592430d221f7f3c9497bbafd8972120f" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-std", +] + +[[package]] +name = "ark-ec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" +dependencies = [ + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", + "itertools", + "num-traits", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "digest", + "itertools", + "num-bigint", + "num-traits", + "paste", + "rustc_version", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-poly" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest", + "num-bigint", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand", +] + +[[package]] +name = "arrayref" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" + +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bitmaps" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031043d04099746d8db04daf1fa424b2bc8bd69d92b25962dcde24da39ab64a2" +dependencies = [ + "typenum", +] + +[[package]] +name = "blake2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +dependencies = [ + "digest", +] + +[[package]] +name = "blake3" +version = "1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d82033247fd8e890df8f740e407ad4d038debb9eb1f40533fffb32e7d17dc6f7" +dependencies = [ + "arrayref", + "arrayvec", + "cc", + "cfg-if", + "constant_time_eq", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bn254_blackbox_solver" +version = "0.54.0" +dependencies = [ + "acir", + "acvm_blackbox_solver", + "ark-bn254", + "ark-ec", + "ark-ff", + "hex", + "lazy_static", + "noir_grumpkin", + "num-bigint", +] + +[[package]] +name = "brillig" +version = "0.54.0" +dependencies = [ + "acir_field", + "serde", +] + +[[package]] +name = "brillig_vm" +version = "0.54.0" +dependencies = [ + "acir", + "acvm_blackbox_solver", + "num-bigint", + "num-traits", + "thiserror", +] + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cc" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-targets", +] + +[[package]] +name = "codespan" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3362992a0d9f1dd7c3d0e89e0ab2bb540b7a95fea8cd798090e758fda2899b5e" +dependencies = [ + "codespan-reporting", + "serde", +] + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "serde", + "termcolor", + "unicode-width", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "constant_time_eq" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "cpufeatures" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[package]] +name = "crypto-bigint" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.87", +] + +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "der" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", + "serde", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", + "subtle", +] + +[[package]] +name = "ecdsa" +version = "0.14.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +dependencies = [ + "der", + "elliptic-curve", + "rfc6979", + "signature", +] + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "elliptic-curve" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +dependencies = [ + "base16ct", + "crypto-bigint", + "der", + "digest", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "rand_core", + "subtle", +] + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "flate2" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "fm" +version = "0.38.0" +dependencies = [ + "codespan-reporting", + "iter-extended", + "serde", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "group" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashbrown" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "im" +version = "15.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0acd33ff0285af998aaf9b57342af478078f53492322fafc47450e09397e0e9" +dependencies = [ + "bitmaps", + "rand_core", + "rand_xoshiro", + "serde", + "sized-chunks", + "typenum", + "version_check", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "indexmap" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +dependencies = [ + "equivalent", + "hashbrown 0.15.1", + "serde", +] + +[[package]] +name = "iter-extended" +version = "0.38.0" + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "js-sys" +version = "0.3.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "jsonrpc" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34efde8d2422fb79ed56db1d3aea8fa5b583351d15a26770cdee2f88813dd702" +dependencies = [ + "base64 0.13.1", + "minreq", + "serde", + "serde_json", +] + +[[package]] +name = "k256" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "sha2", +] + +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libaes" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82903360c009b816f5ab72a9b68158c27c301ee2c3f20655b55c5e589e7d3bb7" + +[[package]] +name = "libc" +version = "0.2.164" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "miniz_oxide" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", +] + +[[package]] +name = "minreq" +version = "2.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "763d142cdff44aaadd9268bebddb156ef6c65a0e13486bb81673cf2d8739f9b0" +dependencies = [ + "log", + "serde", + "serde_json", +] + +[[package]] +name = "noir_grumpkin" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7d49a4b14b13c0dc730b05780b385828ab88f4148daaad7db080ecdce07350" +dependencies = [ + "ark-bn254", + "ark-ec", + "ark-ff", + "ark-std", +] + +[[package]] +name = "noirc_arena" +version = "0.38.0" + +[[package]] +name = "noirc_errors" +version = "0.38.0" +dependencies = [ + "acvm", + "base64 0.21.7", + "codespan", + "codespan-reporting", + "flate2", + "fm", + "noirc_printable_type", + "serde", + "serde_json", + "serde_with", + "tracing", +] + +[[package]] +name = "noirc_evaluator" +version = "0.38.0" +dependencies = [ + "acvm", + "bn254_blackbox_solver", + "cfg-if", + "chrono", + "fxhash", + "im", + "iter-extended", + "noirc_errors", + "noirc_frontend", + "num-bigint", + "num-traits", + "rayon", + "serde", + "serde_json", + "serde_with", + "thiserror", + "tracing", +] + +[[package]] +name = "noirc_frontend" +version = "0.38.0" +dependencies = [ + "acvm", + "bn254_blackbox_solver", + "cfg-if", + "fm", + "im", + "iter-extended", + "noirc_arena", + "noirc_errors", + "noirc_printable_type", + "num-bigint", + "num-traits", + "petgraph", + "rangemap", + "regex", + "rustc-hash", + "serde", + "serde_json", + "small-ord-set", + "smol_str", + "strum", + "strum_macros", + "thiserror", + "tracing", +] + +[[package]] +name = "noirc_printable_type" +version = "0.38.0" +dependencies = [ + "acvm", + "iter-extended", + "jsonrpc", + "regex", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "p256" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" +dependencies = [ + "ecdsa", + "elliptic-curve", + "sha2", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "petgraph" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" +dependencies = [ + "fixedbitset", + "indexmap 2.6.0", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" + +[[package]] +name = "pkcs8" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_xoshiro" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa" +dependencies = [ + "rand_core", +] + +[[package]] +name = "rangemap" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f60fcc7d6849342eff22c4350c8b9a989ee8ceabc4b481253e8946b9fe83d684" + +[[package]] +name = "rayon" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "rfc6979" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +dependencies = [ + "crypto-bigint", + "hmac", + "zeroize", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustversion" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "sec1" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + +[[package]] +name = "serde" +version = "1.0.215" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde-big-array" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11fc7cc2c76d73e0f27ee52abbd64eec84d46f370c88371120433196934e4b7f" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.215" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "serde_json" +version = "1.0.133" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e28bdad6db2b8340e449f7108f020b3b092e8583a9e3fb82713e1d4e71fe817" +dependencies = [ + "base64 0.22.1", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.6.0", + "serde", + "serde_derive", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +dependencies = [ + "digest", + "rand_core", +] + +[[package]] +name = "sized-chunks" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16d69225bde7a69b235da73377861095455d298f2b970996eec25ddbb42b3d1e" +dependencies = [ + "bitmaps", + "typenum", +] + +[[package]] +name = "small-ord-set" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf7035a2b2268a5be8c1395738565b06beda836097e12021cdefc06b127a0e7e" +dependencies = [ + "smallvec", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "smol_str" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fad6c857cbab2627dcf01ec85a623ca4e7dcb5691cbaa3d7fb7653671f0d09c9" +dependencies = [ + "serde", +] + +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "ssa_test" +version = "0.1.0" +dependencies = [ + "noirc_evaluator", + "serde", + "serde_json", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", +] + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "time" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-ident" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" + +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +dependencies = [ + "cfg-if", + "once_cell", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.87", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" + +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml new file mode 100644 index 00000000000..6b6a37cc916 --- /dev/null +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "ssa_test" +version = "0.1.0" +edition = "2021" + +[dependencies] +noirc_evaluator = {path = "../"} +serde = "1.0.214" +serde_json = "1.0.120" +[workspace] diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs new file mode 100644 index 00000000000..2c8eff05834 --- /dev/null +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs @@ -0,0 +1,18 @@ +use::noirc_evaluator::acir_instruction_builder::{ + all_instructions, InstructionArtifacts +}; + + +fn main() { + let all_artifacts: Vec = all_instructions(); + + for artifacts in all_artifacts.iter() { + println!("============{}==============", artifacts.instruction_name); + println!("{:?}", artifacts.serialized_acir); + // println!("{}", artifacts.serialized_ssa); + // println!("Acir length: {:?}", artifacts.serialized_acir.len()); + // let artifacts_serialized = serde_json::to_string(&artifacts).unwrap(); + // println!("{}", artifacts_serialized); + } +} + From 579c5ff8cd119266edc58217d3f7a14cba83e44b Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Mon, 18 Nov 2024 12:03:26 +0000 Subject: [PATCH 07/32] i forgot cmakelists --- barretenberg/cpp/src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/barretenberg/cpp/src/CMakeLists.txt b/barretenberg/cpp/src/CMakeLists.txt index 93f4bb4eb45..7f2265e1f8f 100644 --- a/barretenberg/cpp/src/CMakeLists.txt +++ b/barretenberg/cpp/src/CMakeLists.txt @@ -96,6 +96,7 @@ add_subdirectory(barretenberg/ultra_honk) add_subdirectory(barretenberg/vm) add_subdirectory(barretenberg/wasi) add_subdirectory(barretenberg/world_state) +add_subdirectory(barretenberg/acir_formal_proofs) if(SMT) add_subdirectory(barretenberg/smt_verification) From be6ef363da45decbea2ef458e8969cc944fa618c Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Mon, 18 Nov 2024 12:34:04 +0000 Subject: [PATCH 08/32] save artifacts --- .../noirc_evaluator/ssa_test/.gitignore | 2 ++ .../noirc_evaluator/ssa_test/Cargo.lock | 1 + .../noirc_evaluator/ssa_test/README.md | 2 ++ .../noirc_evaluator/ssa_test/src/main.rs | 21 ++++++++++++------- 4 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 noir/noir-repo/compiler/noirc_evaluator/ssa_test/.gitignore create mode 100644 noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/.gitignore b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/.gitignore new file mode 100644 index 00000000000..6c7b7f9b99c --- /dev/null +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/.gitignore @@ -0,0 +1,2 @@ +Cargo.lock +artifacts/* diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock index a5acc985db5..cbf8632da41 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock @@ -957,6 +957,7 @@ dependencies = [ "bn254_blackbox_solver", "cfg-if", "chrono", + "flate2", "fxhash", "im", "iter-extended", diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md new file mode 100644 index 00000000000..73bdfcb4007 --- /dev/null +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md @@ -0,0 +1,2 @@ +# WHY +USED FOR FORMAL VERIFYING SSA INSTRUCTIONS PRODUCED BY THE CONVERSION SSA->ACIR diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs index 2c8eff05834..f56a50afbcc 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs @@ -1,18 +1,25 @@ +use std::fs::File; +use std::io::Write; +use std::path::Path; use::noirc_evaluator::acir_instruction_builder::{ all_instructions, InstructionArtifacts }; +fn save_to_file(data: &[u8], filename: &str) -> Result<(), std::io::Error> { + let path = Path::new(filename); + let mut file = File::create(path)?; + file.write_all(data)?; + Ok(()) +} fn main() { let all_artifacts: Vec = all_instructions(); for artifacts in all_artifacts.iter() { - println!("============{}==============", artifacts.instruction_name); - println!("{:?}", artifacts.serialized_acir); - // println!("{}", artifacts.serialized_ssa); - // println!("Acir length: {:?}", artifacts.serialized_acir.len()); - // let artifacts_serialized = serde_json::to_string(&artifacts).unwrap(); - // println!("{}", artifacts_serialized); + let filename = format!("artifacts/{}{}", artifacts.instruction_name, ".acir"); + match save_to_file(&artifacts.serialized_acir, &filename) { + Ok(_) => (), + Err(error) => println!("Error saving data: {}", error), + } } } - From 6b27d0eab8a69b5fdf4b60e052d309bf2e930305 Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Thu, 21 Nov 2024 13:23:04 +0000 Subject: [PATCH 09/32] stable version for verifying --- .../compiler/noirc_evaluator/Cargo.toml | 1 + .../src/acir_instruction_builder.rs | 24 ++++++++++++------- .../noirc_evaluator/ssa_test/src/main.rs | 1 + 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/noir/noir-repo/compiler/noirc_evaluator/Cargo.toml b/noir/noir-repo/compiler/noirc_evaluator/Cargo.toml index e25b5bf855a..cfd9c53d79c 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/Cargo.toml +++ b/noir/noir-repo/compiler/noirc_evaluator/Cargo.toml @@ -26,6 +26,7 @@ serde_json.workspace = true serde_with = "3.2.0" tracing.workspace = true chrono = "0.4.37" +flate2 = "1.0.35" rayon.workspace = true cfg-if.workspace = true diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs index 1094fc0ac26..e65f16dfc58 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs @@ -1,4 +1,6 @@ use std::collections::BTreeSet; +use flate2::read::GzDecoder; +use std::io::Read; use acvm::{ acir::{ circuit::{ @@ -20,7 +22,12 @@ use crate::ssa::{ use crate::brillig::Brillig; use serde::{Deserialize, Serialize}; - +fn ungzip(compressed_data: Vec) -> Vec { + let mut decompressed_data: Vec = Vec::new(); + let mut decoder = GzDecoder::new(&compressed_data[..]); + decoder.read_to_end(&mut decompressed_data).unwrap(); + return decompressed_data; +} #[derive(Serialize, Deserialize)] pub struct InstructionArtifacts { @@ -33,7 +40,7 @@ pub struct InstructionArtifacts { // serde_json serialized ssa pub serialized_ssa: String, - // bytes of acir program + // bytes of acir program. Ungzipped!! pub serialized_acir: Vec, } @@ -50,7 +57,7 @@ impl InstructionArtifacts { instruction_name: instruction_name, formatted_ssa: formatted_ssa, serialized_ssa: serialized_ssa.to_string(), - serialized_acir: serialized_program + serialized_acir: ungzip(serialized_program) } } @@ -66,7 +73,7 @@ impl InstructionArtifacts { instruction_name: instruction_name, formatted_ssa: formatted_ssa, serialized_ssa: serialized_ssa.to_string(), - serialized_acir: serialized_program + serialized_acir: ungzip(serialized_program) } } @@ -96,14 +103,15 @@ fn ssa_to_acir_program(ssa: Ssa) -> AcirProgram { let mut functions: Vec> = Vec::new(); for acir_func in acir_functions.iter() { - // no private params, i think - let public_params: BTreeSet = acir_func.input_witnesses.clone().into_iter().collect(); + // inputs and output as private + let mut private_params: BTreeSet = acir_func.input_witnesses.clone().into_iter().collect(); let ret_values: BTreeSet = acir_func.return_witnesses.clone().into_iter().collect(); + + private_params.extend(ret_values.iter().cloned()); let circuit: Circuit = Circuit { current_witness_index: acir_func.current_witness_index().witness_index(), opcodes: acir_func.opcodes().to_vec(), - public_parameters: PublicInputs(public_params), - return_values: PublicInputs(ret_values), + private_parameters: private_params, ..Circuit::::default() }; functions.push(circuit); diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs index f56a50afbcc..282eea01a77 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs @@ -16,6 +16,7 @@ fn main() { let all_artifacts: Vec = all_instructions(); for artifacts in all_artifacts.iter() { + println!("{}", artifacts.formatted_ssa); let filename = format!("artifacts/{}{}", artifacts.instruction_name, ".acir"); match save_to_file(&artifacts.serialized_acir, &filename) { Ok(_) => (), From 84319b29a25f43fee69ba634a7f830e1b86c64e1 Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Fri, 22 Nov 2024 14:48:00 +0000 Subject: [PATCH 10/32] dummy --- .../acir_formal_proofs/.gitignore | 1 + .../acir_formal_proofs/CMakeLists.txt | 2 +- .../acir_formal_proofs/acir_loader.cpp | 28 +++++ .../acir_formal_proofs/acir_loader.hpp | 3 + .../acir_formal_proofs/acir_loader.test.cpp | 114 ++++++++++++++++-- .../src/acir_instruction_builder.rs | 9 +- 6 files changed, 145 insertions(+), 12 deletions(-) create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/.gitignore diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/.gitignore b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/.gitignore new file mode 100644 index 00000000000..62dd1ddc077 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/.gitignore @@ -0,0 +1 @@ +artifacts/* diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/CMakeLists.txt index 72391a847d6..43b9fc20ca7 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/CMakeLists.txt @@ -1 +1 @@ -barretenberg_module(acir_formal_proofs dsl) \ No newline at end of file +barretenberg_module(acir_formal_proofs dsl circuit_checker smt_verification) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp index 130d06e7483..1e609a9c165 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp @@ -3,6 +3,28 @@ #include "barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp" #include #include +#include + + +std::vector readFile(std::string filename) +{ + std::ifstream file(filename, std::ios::binary); + file.unsetf(std::ios::skipws); + + std::streampos fileSize; + + file.seekg(0, std::ios::end); + fileSize = file.tellg(); + file.seekg(0, std::ios::beg); + + std::vector vec; + + vec.insert(vec.begin(), + std::istream_iterator(file), + std::istream_iterator()); + file.close(); + return vec; +} AcirInstructionLoader::AcirInstructionLoader(std::vector const& acir_bytes, std::string instruction_name) @@ -10,4 +32,10 @@ AcirInstructionLoader::AcirInstructionLoader(std::vector const& acir_by this->acir_program_buf = acir_bytes; this->instruction_name = instruction_name; this->constraint_systems = acir_format::program_buf_to_acir_format(acir_bytes, false); +} + +AcirInstructionLoader::AcirInstructionLoader(std::string filename) { + this->acir_program_buf = readFile(filename); + this->instruction_name = filename; + this->constraint_systems = acir_format::program_buf_to_acir_format(this->acir_program_buf, false); } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp index 923eb4ac0c3..7f3e03d3b01 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp @@ -15,6 +15,9 @@ class AcirInstructionLoader { ~AcirInstructionLoader() = default; AcirInstructionLoader(std::vector const& acir_program_buf, std::string instruction_name); + AcirInstructionLoader(std::string filename); + + std::vector get_constraint_systems() { return this->constraint_systems; } private: std::string instruction_name; diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp index 73244c6fa77..eef0402634e 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp @@ -1,14 +1,114 @@ #include "acir_loader.hpp" +#include "barretenberg/circuit_checker/circuit_checker.hpp" #include "barretenberg/common/test.hpp" #include "barretenberg/dsl/acir_format/acir_format.hpp" +#include "barretenberg/smt_verification/circuit/ultra_circuit.hpp" +#include "barretenberg/stdlib/client_ivc_verifier/client_ivc_recursive_verifier.hpp" +#include "barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp" #include -TEST(acir_formal_proofs, loader) +TEST(acir_formal_proofs, slow) { - std::vector const program = std::vector( - {1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 52, 48, 48, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 10, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 11, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 10, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 11, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 51, 48, 54, 52, 52, 101, 55, 50, 101, 49, 51, 49, 97, 48, 50, 57, 98, 56, 53, 48, 52, 53, 98, 54, 56, 49, 56, 49, 53, 56, 53, 100, 50, 56, 51, 51, 101, 56, 52, 56, 55, 57, 98, 57, 55, 48, 57, 49, 52, 51, 101, 49, 102, 53, 57, 51, 101, 102, 102, 102, 102, 99, 48, 49, 2, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 51, 48, 54, 52, 52, 101, 55, 50, 101, 49, 51, 49, 97, 48, 50, 57, 98, 56, 53, 48, 52, 53, 98, 54, 56, 49, 56, 49, 53, 56, 53, 100, 50, 56, 51, 51, 101, 56, 52, 56, 55, 57, 98, 57, 55, 48, 57, 49, 52, 51, 101, 49, 102, 53, 57, 51, 102, 48, 48, 48, 48, 48, 48, 48, 3, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 1, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 51, 48, 54, 52, 52, 101, 55, 50, 101, 49, 51, 49, 97, 48, 50, 57, 98, 56, 53, 48, 52, 53, 98, 54, 56, 49, 56, 49, 53, 56, 53, 100, 50, 56, 51, 51, 101, 56, 52, 56, 55, 57, 98, 57, 55, 48, 57, 49, 52, 51, 101, 49, 102, 53, 57, 51, 102, 48, 48, 48, 48, 48, 48, 48, 3, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 50, 9, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0}); - std::string truncate{ "Truncate" }; - AcirInstructionLoader truncate_acir = AcirInstructionLoader(program, truncate); - info("amogus"); - EXPECT_EQ(1 + 1, 2); + AcirInstructionLoader add = + AcirInstructionLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Add.acir"); + auto system = add.get_constraint_systems().at(0); + bb::UltraCircuitBuilder builder = acir_format::create_circuit(system, false); + info(builder.public_inputs); + // info(builder.variables); + builder.set_variable_name(0, "a"); + builder.set_variable_name(1, "b"); + builder.set_variable_name(2, "c"); + builder.set_variable_name(3, "d"); + builder.set_variable_name(4, "e"); + EXPECT_TRUE(bb::CircuitChecker::check(builder)); + + auto buf = builder.export_circuit(); + smt_circuit::CircuitSchema circuit_info = smt_circuit_schema::unpack_from_buffer(buf); + smt_solver::Solver s(circuit_info.modulus); + smt_circuit::UltraCircuit circuit(circuit_info, &s, smt_terms::TermType::FFTerm); + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + info(c); + auto cr = a + b; + c != cr; + bool res = s.check(); + EXPECT_TRUE(false); + s.print_assertions(); + info(s.getResult()); + EXPECT_FALSE(res); +} + +TEST(acir_formal_proofs, uint_terms_add) +{ + AcirInstructionLoader add = + AcirInstructionLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Add.acir"); + auto system = add.get_constraint_systems().at(0); + bb::UltraCircuitBuilder builder = acir_format::create_circuit(system, false); + info(builder.public_inputs); + // info(builder.variables); + builder.set_variable_name(0, "a"); + builder.set_variable_name(1, "b"); + builder.set_variable_name(2, "c"); + builder.set_variable_name(3, "d"); + builder.set_variable_name(4, "e"); + EXPECT_TRUE(bb::CircuitChecker::check(builder)); + + auto buf = builder.export_circuit(); + smt_circuit::CircuitSchema circuit_info = smt_circuit_schema::unpack_from_buffer(buf); + smt_solver::Solver s(circuit_info.modulus); + smt_circuit::UltraCircuit circuit(circuit_info, &s, smt_terms::TermType::BVTerm); + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + info(c); + auto cr = a + b; + c != cr; + bool res = s.check(); + EXPECT_TRUE(false); + s.print_assertions(); + info(s.getResult()); + EXPECT_FALSE(res); +} + +TEST(acir_formal_proofs, public_inputs) +{ + AcirInstructionLoader add = + AcirInstructionLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Add.public.acir"); + auto system = add.get_constraint_systems().at(0); + bb::UltraCircuitBuilder builder = acir_format::create_circuit(system, false); + // builder.zero_idx = 4; + info(builder.zero_idx); + info("Public inputs in builder", builder.public_inputs); + info(builder.real_variable_index[2]); + info(builder.real_variable_index[3]); + builder.variables[0] = 10; + builder.variables[1] = 10; + // if we set second variable check circuit throws error :(, so output in third??? + builder.variables[3] = 20; + EXPECT_TRUE(bb::CircuitChecker::check(builder)); + + builder.set_variable_name(0, "a"); + builder.set_variable_name(1, "b"); + builder.set_variable_name(2, "c"); + builder.set_variable_name(3, "d"); + builder.set_variable_name(4, "e"); + EXPECT_TRUE(bb::CircuitChecker::check(builder)); + + auto buf = builder.export_circuit(); + smt_circuit::CircuitSchema circuit_info = smt_circuit_schema::unpack_from_buffer(buf); + info("Circuit info public inputs", circuit_info.public_inps); + smt_solver::Solver s(circuit_info.modulus); + smt_circuit::UltraCircuit circuit(circuit_info, &s, smt_terms::TermType::BVTerm); + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + info(c); + auto cr = a + b; + c != cr; + bool res = s.check(); + EXPECT_TRUE(false); + s.print_assertions(); + info(s.getResult()); + EXPECT_FALSE(res); } \ No newline at end of file diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs index e65f16dfc58..da545a21e80 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs @@ -100,15 +100,16 @@ fn ssa_to_acir_program(ssa: Ssa) -> AcirProgram { let (acir_functions, brillig, _, _) = ssa .into_acir(&Brillig::default(), ExpressionWidth::default()) .expect("Should compile manually written SSA into ACIR"); - + let mut functions: Vec> = Vec::new(); for acir_func in acir_functions.iter() { // inputs and output as private let mut private_params: BTreeSet = acir_func.input_witnesses.clone().into_iter().collect(); let ret_values: BTreeSet = acir_func.return_witnesses.clone().into_iter().collect(); + let circuit: Circuit ; private_params.extend(ret_values.iter().cloned()); - let circuit: Circuit = Circuit { + circuit = Circuit { current_witness_index: acir_func.current_witness_index().witness_index(), opcodes: acir_func.opcodes().to_vec(), private_parameters: private_params, @@ -123,7 +124,7 @@ fn binary_function(op: BinaryOp) -> Ssa { // returns v0 op v1 let main_id = Id::new(0); let mut builder = FunctionBuilder::new("main".into(), main_id); - let v0 = builder.add_parameter(Type::unsigned(64)); + let v0 = builder.add_parameter(Type::unsigned(8)); // bit size of v1 differs, because shl shr max second argument 8 bit; let v1; @@ -132,7 +133,7 @@ fn binary_function(op: BinaryOp) -> Ssa { if op == BinaryOp::Shl || op == BinaryOp::Shr { v1 = builder.add_parameter(Type::unsigned(8)); } else { - v1 = builder.add_parameter(Type::unsigned(64)); + v1 = builder.add_parameter(Type::unsigned(8)); } let v2 = builder.insert_binary(v0, op, v1); From 28cd1f98b428f7bf72a00761d05898cc47795797 Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Mon, 25 Nov 2024 13:14:47 +0000 Subject: [PATCH 11/32] smol refactor --- .../compiler/noirc_evaluator/Cargo.toml | 1 - .../src/acir_instruction_builder.rs | 15 ++------- .../noirc_evaluator/ssa_test/Cargo.lock | 32 +++++++++---------- .../noirc_evaluator/ssa_test/Cargo.toml | 1 + .../noirc_evaluator/ssa_test/README.md | 3 ++ .../noirc_evaluator/ssa_test/src/main.rs | 9 ++++++ 6 files changed, 31 insertions(+), 30 deletions(-) diff --git a/noir/noir-repo/compiler/noirc_evaluator/Cargo.toml b/noir/noir-repo/compiler/noirc_evaluator/Cargo.toml index cfd9c53d79c..e25b5bf855a 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/Cargo.toml +++ b/noir/noir-repo/compiler/noirc_evaluator/Cargo.toml @@ -26,7 +26,6 @@ serde_json.workspace = true serde_with = "3.2.0" tracing.workspace = true chrono = "0.4.37" -flate2 = "1.0.35" rayon.workspace = true cfg-if.workspace = true diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs index da545a21e80..5034b680db1 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs @@ -1,6 +1,4 @@ use std::collections::BTreeSet; -use flate2::read::GzDecoder; -use std::io::Read; use acvm::{ acir::{ circuit::{ @@ -22,13 +20,6 @@ use crate::ssa::{ use crate::brillig::Brillig; use serde::{Deserialize, Serialize}; -fn ungzip(compressed_data: Vec) -> Vec { - let mut decompressed_data: Vec = Vec::new(); - let mut decoder = GzDecoder::new(&compressed_data[..]); - decoder.read_to_end(&mut decompressed_data).unwrap(); - return decompressed_data; -} - #[derive(Serialize, Deserialize)] pub struct InstructionArtifacts { // name of used instruction @@ -40,7 +31,7 @@ pub struct InstructionArtifacts { // serde_json serialized ssa pub serialized_ssa: String, - // bytes of acir program. Ungzipped!! + // bytes of acir program. Gzipped!! pub serialized_acir: Vec, } @@ -57,7 +48,7 @@ impl InstructionArtifacts { instruction_name: instruction_name, formatted_ssa: formatted_ssa, serialized_ssa: serialized_ssa.to_string(), - serialized_acir: ungzip(serialized_program) + serialized_acir: serialized_program } } @@ -73,7 +64,7 @@ impl InstructionArtifacts { instruction_name: instruction_name, formatted_ssa: formatted_ssa, serialized_ssa: serialized_ssa.to_string(), - serialized_acir: ungzip(serialized_program) + serialized_acir: serialized_program } } diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock index cbf8632da41..4b76160736d 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "acir" -version = "0.54.0" +version = "0.55.0" dependencies = [ "acir_field", "base64 0.21.7", @@ -18,7 +18,7 @@ dependencies = [ [[package]] name = "acir_field" -version = "0.54.0" +version = "0.55.0" dependencies = [ "ark-bn254", "ark-ff", @@ -30,13 +30,12 @@ dependencies = [ [[package]] name = "acvm" -version = "0.54.0" +version = "0.55.0" dependencies = [ "acir", "acvm_blackbox_solver", "brillig_vm", "indexmap 1.9.3", - "num-bigint", "serde", "thiserror", "tracing", @@ -44,7 +43,7 @@ dependencies = [ [[package]] name = "acvm_blackbox_solver" -version = "0.54.0" +version = "0.55.0" dependencies = [ "acir", "blake2", @@ -316,7 +315,7 @@ dependencies = [ [[package]] name = "bn254_blackbox_solver" -version = "0.54.0" +version = "0.55.0" dependencies = [ "acir", "acvm_blackbox_solver", @@ -331,7 +330,7 @@ dependencies = [ [[package]] name = "brillig" -version = "0.54.0" +version = "0.55.0" dependencies = [ "acir_field", "serde", @@ -339,7 +338,7 @@ dependencies = [ [[package]] name = "brillig_vm" -version = "0.54.0" +version = "0.55.0" dependencies = [ "acir", "acvm_blackbox_solver", @@ -643,7 +642,7 @@ dependencies = [ [[package]] name = "fm" -version = "0.38.0" +version = "0.39.0" dependencies = [ "codespan-reporting", "iter-extended", @@ -807,7 +806,7 @@ dependencies = [ [[package]] name = "iter-extended" -version = "0.38.0" +version = "0.39.0" [[package]] name = "itertools" @@ -930,11 +929,11 @@ dependencies = [ [[package]] name = "noirc_arena" -version = "0.38.0" +version = "0.39.0" [[package]] name = "noirc_errors" -version = "0.38.0" +version = "0.39.0" dependencies = [ "acvm", "base64 0.21.7", @@ -951,20 +950,18 @@ dependencies = [ [[package]] name = "noirc_evaluator" -version = "0.38.0" +version = "0.39.0" dependencies = [ "acvm", "bn254_blackbox_solver", "cfg-if", "chrono", - "flate2", "fxhash", "im", "iter-extended", "noirc_errors", "noirc_frontend", "num-bigint", - "num-traits", "rayon", "serde", "serde_json", @@ -975,7 +972,7 @@ dependencies = [ [[package]] name = "noirc_frontend" -version = "0.38.0" +version = "0.39.0" dependencies = [ "acvm", "bn254_blackbox_solver", @@ -1004,7 +1001,7 @@ dependencies = [ [[package]] name = "noirc_printable_type" -version = "0.38.0" +version = "0.39.0" dependencies = [ "acvm", "iter-extended", @@ -1428,6 +1425,7 @@ dependencies = [ name = "ssa_test" version = "0.1.0" dependencies = [ + "flate2", "noirc_evaluator", "serde", "serde_json", diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml index 6b6a37cc916..2655d46fb7d 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml @@ -7,4 +7,5 @@ edition = "2021" noirc_evaluator = {path = "../"} serde = "1.0.214" serde_json = "1.0.120" +flate2 = "1.0.35" [workspace] diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md index 73bdfcb4007..2eccde7ea00 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md @@ -1,2 +1,5 @@ # WHY USED FOR FORMAL VERIFYING SSA INSTRUCTIONS PRODUCED BY THE CONVERSION SSA->ACIR + +# how +`cargo run && cp artifacts/* ../../../../../barretenberg/cpp/src/barretenberg/acir_formal_proofs/artifacts/` diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs index 282eea01a77..e3de2bb97e4 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs @@ -1,10 +1,19 @@ use std::fs::File; use std::io::Write; +use std::io::Read; use std::path::Path; +use flate2::read::GzDecoder; use::noirc_evaluator::acir_instruction_builder::{ all_instructions, InstructionArtifacts }; +fn ungzip(compressed_data: Vec) -> Vec { + let mut decompressed_data: Vec = Vec::new(); + let mut decoder = GzDecoder::new(&compressed_data[..]); + decoder.read_to_end(&mut decompressed_data).unwrap(); + return decompressed_data; +} + fn save_to_file(data: &[u8], filename: &str) -> Result<(), std::io::Error> { let path = Path::new(filename); let mut file = File::create(path)?; From 8ea00fcf57be9b21bb7a62f5a2540b6063ddebc9 Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Mon, 25 Nov 2024 15:12:24 +0000 Subject: [PATCH 12/32] smol refactor --- .../acir_formal_proofs/acir_loader.cpp | 42 ++- .../acir_formal_proofs/acir_loader.hpp | 34 +-- .../acir_formal_proofs/acir_loader.test.cpp | 245 ++++++++++++------ .../src/acir_instruction_builder.rs | 2 +- .../noirc_evaluator/ssa_test/src/main.rs | 3 +- 5 files changed, 215 insertions(+), 111 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp index 1e609a9c165..ffe4eafd448 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp @@ -1,10 +1,12 @@ #include "acir_loader.hpp" #include "barretenberg/dsl/acir_format/acir_format.hpp" #include "barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp" -#include -#include +#include "barretenberg/smt_verification/circuit/ultra_circuit.hpp" +#include "barretenberg/smt_verification/terms/term.hpp" +#include "msgpack/v3/sbuffer_decl.hpp" #include - +#include +#include std::vector readFile(std::string filename) { @@ -19,23 +21,35 @@ std::vector readFile(std::string filename) std::vector vec; - vec.insert(vec.begin(), - std::istream_iterator(file), - std::istream_iterator()); + vec.insert(vec.begin(), std::istream_iterator(file), std::istream_iterator()); file.close(); return vec; } +AcirToSmtLoader::AcirToSmtLoader(std::string filename) +{ + this->acir_program_buf = readFile(filename); + this->instruction_name = filename; + this->constraint_system = acir_format::program_buf_to_acir_format(this->acir_program_buf, false).at(0); + bb::UltraCircuitBuilder builder = acir_format::create_circuit(this->constraint_system, false); + // naming first three variables + // for binary noir sets indices as 0 1 2 + // for unary noir sets indices as 0 1 + builder.set_variable_name(0, "a"); + builder.set_variable_name(1, "b"); + builder.set_variable_name(2, "c"); + // builder.set_variable_name(3, "d"); + this->circuit_buf = builder.export_circuit(); +} -AcirInstructionLoader::AcirInstructionLoader(std::vector const& acir_bytes, std::string instruction_name) +smt_solver::Solver AcirToSmtLoader::get_solver() { - this->acir_program_buf = acir_bytes; - this->instruction_name = instruction_name; - this->constraint_systems = acir_format::program_buf_to_acir_format(acir_bytes, false); + smt_circuit::CircuitSchema circuit_info = smt_circuit_schema::unpack_from_buffer(this->circuit_buf); + return smt_solver::Solver(circuit_info.modulus); } -AcirInstructionLoader::AcirInstructionLoader(std::string filename) { - this->acir_program_buf = readFile(filename); - this->instruction_name = filename; - this->constraint_systems = acir_format::program_buf_to_acir_format(this->acir_program_buf, false); +smt_circuit::UltraCircuit AcirToSmtLoader::get_circuit(smt_solver::Solver* solver) +{ + smt_circuit::CircuitSchema circuit_info = smt_circuit_schema::unpack_from_buffer(this->circuit_buf); + return smt_circuit::UltraCircuit(circuit_info, solver, smt_terms::TermType::BVTerm); } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp index 7f3e03d3b01..9874164ee85 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp @@ -1,26 +1,28 @@ #pragma once #include "barretenberg/dsl/acir_format/acir_format.hpp" -#include +#include "barretenberg/smt_verification/circuit/ultra_circuit.hpp" +#include "msgpack/v3/sbuffer_decl.hpp" #include +#include +class AcirToSmtLoader { + public: + AcirToSmtLoader() = delete; + AcirToSmtLoader(const AcirToSmtLoader& other) = delete; + AcirToSmtLoader(AcirToSmtLoader&& other) = delete; + AcirToSmtLoader& operator=(const AcirToSmtLoader other) = delete; + AcirToSmtLoader&& operator=(AcirToSmtLoader&& other) = delete; -class AcirInstructionLoader { -public: - AcirInstructionLoader() = default; - AcirInstructionLoader(const AcirInstructionLoader& other) = default; - AcirInstructionLoader(AcirInstructionLoader&& other) = default; - AcirInstructionLoader& operator=(const AcirInstructionLoader other) = delete; - AcirInstructionLoader&& operator=(AcirInstructionLoader&& other) = delete; - - ~AcirInstructionLoader() = default; + ~AcirToSmtLoader() = default; + AcirToSmtLoader(std::string filename); - AcirInstructionLoader(std::vector const& acir_program_buf, std::string instruction_name); - AcirInstructionLoader(std::string filename); - - std::vector get_constraint_systems() { return this->constraint_systems; } + acir_format::AcirFormat get_constraint_systems() { return this->constraint_system; } + smt_solver::Solver get_solver(); + smt_circuit::UltraCircuit get_circuit(smt_solver::Solver* solver); -private: + private: std::string instruction_name; std::vector acir_program_buf; - std::vector constraint_systems; + acir_format::AcirFormat constraint_system; + msgpack::sbuffer circuit_buf; }; \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp index eef0402634e..22276abac63 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp @@ -3,112 +3,199 @@ #include "barretenberg/common/test.hpp" #include "barretenberg/dsl/acir_format/acir_format.hpp" #include "barretenberg/smt_verification/circuit/ultra_circuit.hpp" +#include "barretenberg/smt_verification/solver/solver.hpp" #include "barretenberg/stdlib/client_ivc_verifier/client_ivc_recursive_verifier.hpp" #include "barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp" #include -TEST(acir_formal_proofs, slow) +TEST(acir_formal_proofs, uint_terms_add) { - AcirInstructionLoader add = - AcirInstructionLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Add.acir"); - auto system = add.get_constraint_systems().at(0); - bb::UltraCircuitBuilder builder = acir_format::create_circuit(system, false); - info(builder.public_inputs); - // info(builder.variables); - builder.set_variable_name(0, "a"); - builder.set_variable_name(1, "b"); - builder.set_variable_name(2, "c"); - builder.set_variable_name(3, "d"); - builder.set_variable_name(4, "e"); - EXPECT_TRUE(bb::CircuitChecker::check(builder)); - - auto buf = builder.export_circuit(); - smt_circuit::CircuitSchema circuit_info = smt_circuit_schema::unpack_from_buffer(buf); - smt_solver::Solver s(circuit_info.modulus); - smt_circuit::UltraCircuit circuit(circuit_info, &s, smt_terms::TermType::FFTerm); + AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Add.acir"); + smt_solver::Solver solver = loader.get_solver(); + smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); auto a = circuit["a"]; auto b = circuit["b"]; auto c = circuit["c"]; - info(c); auto cr = a + b; c != cr; - bool res = s.check(); - EXPECT_TRUE(false); - s.print_assertions(); - info(s.getResult()); + bool res = solver.check(); + solver.print_assertions(); + info(solver.getResult()); EXPECT_FALSE(res); } -TEST(acir_formal_proofs, uint_terms_add) +TEST(acir_formal_proofs, uint_terms_mul) { - AcirInstructionLoader add = - AcirInstructionLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Add.acir"); - auto system = add.get_constraint_systems().at(0); - bb::UltraCircuitBuilder builder = acir_format::create_circuit(system, false); - info(builder.public_inputs); - // info(builder.variables); - builder.set_variable_name(0, "a"); - builder.set_variable_name(1, "b"); - builder.set_variable_name(2, "c"); - builder.set_variable_name(3, "d"); - builder.set_variable_name(4, "e"); - EXPECT_TRUE(bb::CircuitChecker::check(builder)); + AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Mul.acir"); + smt_solver::Solver solver = loader.get_solver(); + smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a * b; + c != cr; + bool res = solver.check(); + solver.print_assertions(); + info(solver.getResult()); + EXPECT_FALSE(res); +} - auto buf = builder.export_circuit(); - smt_circuit::CircuitSchema circuit_info = smt_circuit_schema::unpack_from_buffer(buf); - smt_solver::Solver s(circuit_info.modulus); - smt_circuit::UltraCircuit circuit(circuit_info, &s, smt_terms::TermType::BVTerm); +TEST(acir_formal_proofs, uint_terms_and) +{ + AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::And.acir"); + smt_solver::Solver solver = loader.get_solver(); + smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); auto a = circuit["a"]; auto b = circuit["b"]; auto c = circuit["c"]; - info(c); - auto cr = a + b; + auto cr = a & b; + c != cr; + bool res = solver.check(); + solver.print_assertions(); + info(solver.getResult()); + EXPECT_FALSE(res); +} + +TEST(acir_formal_proofs, uint_terms_div) +{ + AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Div.acir"); + smt_solver::Solver solver = loader.get_solver(); + smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a / b; c != cr; - bool res = s.check(); - EXPECT_TRUE(false); - s.print_assertions(); - info(s.getResult()); + bool res = solver.check(); + solver.print_assertions(); + info(solver.getResult()); EXPECT_FALSE(res); } -TEST(acir_formal_proofs, public_inputs) +/*TEST(acir_formal_proofs, uint_terms_eq) { - AcirInstructionLoader add = - AcirInstructionLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Add.public.acir"); - auto system = add.get_constraint_systems().at(0); - bb::UltraCircuitBuilder builder = acir_format::create_circuit(system, false); - // builder.zero_idx = 4; - info(builder.zero_idx); - info("Public inputs in builder", builder.public_inputs); - info(builder.real_variable_index[2]); - info(builder.real_variable_index[3]); - builder.variables[0] = 10; - builder.variables[1] = 10; - // if we set second variable check circuit throws error :(, so output in third??? - builder.variables[3] = 20; - EXPECT_TRUE(bb::CircuitChecker::check(builder)); + AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Eq.acir"); + smt_solver::Solver solver = loader.get_solver(); + smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a == b; + c != cr; + bool res = solver.check(); + solver.print_assertions(); + info(solver.getResult()); + EXPECT_FALSE(res); +}*/ - builder.set_variable_name(0, "a"); - builder.set_variable_name(1, "b"); - builder.set_variable_name(2, "c"); - builder.set_variable_name(3, "d"); - builder.set_variable_name(4, "e"); - EXPECT_TRUE(bb::CircuitChecker::check(builder)); +/* TEST(acir_formal_proofs, uint_terms_lt) +{ + AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Lt.acir"); + smt_solver::Solver solver = loader.get_solver(); + smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a < b; + c != cr; + bool res = solver.check(); + solver.print_assertions(); + info(solver.getResult()); + EXPECT_FALSE(res); +} */ - auto buf = builder.export_circuit(); - smt_circuit::CircuitSchema circuit_info = smt_circuit_schema::unpack_from_buffer(buf); - info("Circuit info public inputs", circuit_info.public_inps); - smt_solver::Solver s(circuit_info.modulus); - smt_circuit::UltraCircuit circuit(circuit_info, &s, smt_terms::TermType::BVTerm); +/* TEST(acir_formal_proofs, uint_terms_mod) +{ + AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Mod.acir"); + smt_solver::Solver solver = loader.get_solver(); + smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); auto a = circuit["a"]; auto b = circuit["b"]; auto c = circuit["c"]; - info(c); - auto cr = a + b; + auto cr = a % b; c != cr; - bool res = s.check(); - EXPECT_TRUE(false); - s.print_assertions(); - info(s.getResult()); + bool res = solver.check(); + solver.print_assertions(); + info(solver.getResult()); EXPECT_FALSE(res); -} \ No newline at end of file +} */ + +TEST(acir_formal_proofs, uint_terms_or) +{ + AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Or.acir"); + smt_solver::Solver solver = loader.get_solver(); + smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a | b; + c != cr; + bool res = solver.check(); + solver.print_assertions(); + info(solver.getResult()); + EXPECT_FALSE(res); +} + +/*TEST(acir_formal_proofs, uint_terms_shl) +{ + AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Shl.acir"); + smt_solver::Solver solver = loader.get_solver(); + smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a << b; + c != cr; + bool res = solver.check(); + solver.print_assertions(); + info(solver.getResult()); + EXPECT_FALSE(res); +} + +TEST(acir_formal_proofs, uint_terms_shr) +{ + AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Shr.acir"); + smt_solver::Solver solver = loader.get_solver(); + smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a >> b; + c != cr; + bool res = solver.check(); + solver.print_assertions(); + info(solver.getResult()); + EXPECT_FALSE(res); +} */ + +TEST(acir_formal_proofs, uint_terms_sub) +{ + AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Sub.acir"); + smt_solver::Solver solver = loader.get_solver(); + smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a - b; + c != cr; + bool res = solver.check(); + solver.print_assertions(); + info(solver.getResult()); + EXPECT_FALSE(res); +} + +TEST(acir_formal_proofs, uint_terms_xor) +{ + AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Xor.acir"); + smt_solver::Solver solver = loader.get_solver(); + smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a ^ b; + c != cr; + bool res = solver.check(); + solver.print_assertions(); + info(solver.getResult()); + EXPECT_FALSE(res); +} diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs index 5034b680db1..873add9edcd 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs @@ -3,7 +3,7 @@ use acvm::{ acir::{ circuit::{ Circuit, ExpressionWidth, - Program as AcirProgram, PublicInputs, + Program as AcirProgram }, native_types::Witness, }, diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs index e3de2bb97e4..ce8ba04e98e 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs @@ -27,7 +27,8 @@ fn main() { for artifacts in all_artifacts.iter() { println!("{}", artifacts.formatted_ssa); let filename = format!("artifacts/{}{}", artifacts.instruction_name, ".acir"); - match save_to_file(&artifacts.serialized_acir, &filename) { + let acir = &artifacts.serialized_acir; + match save_to_file(&ungzip(acir.clone()), &filename) { Ok(_) => (), Err(error) => println!("Error saving data: {}", error), } From 58c1268eee6c3468cae382b857403ea9f32c4acd Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Mon, 25 Nov 2024 15:36:43 +0000 Subject: [PATCH 13/32] forgot to resolve merge conflicts --- .../acir_formal_proofs/acir_loader.cpp | 28 ----- .../acir_formal_proofs/acir_loader.hpp | 26 ---- .../acir_formal_proofs/acir_loader.test.cpp | 112 ------------------ .../compiler/noirc_evaluator/Cargo.toml | 1 - .../src/acir_instruction_builder.rs | 61 +++------- .../noirc_evaluator/ssa_test/Cargo.toml | 3 - .../noirc_evaluator/ssa_test/README.md | 3 - .../noirc_evaluator/ssa_test/src/main.rs | 11 -- 8 files changed, 15 insertions(+), 230 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp index 07044339d2b..ffe4eafd448 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp @@ -1,19 +1,12 @@ #include "acir_loader.hpp" #include "barretenberg/dsl/acir_format/acir_format.hpp" #include "barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp" -<<<<<<< HEAD #include "barretenberg/smt_verification/circuit/ultra_circuit.hpp" #include "barretenberg/smt_verification/terms/term.hpp" #include "msgpack/v3/sbuffer_decl.hpp" #include #include #include -======= -#include -#include -#include - ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 std::vector readFile(std::string filename) { @@ -28,18 +21,11 @@ std::vector readFile(std::string filename) std::vector vec; -<<<<<<< HEAD vec.insert(vec.begin(), std::istream_iterator(file), std::istream_iterator()); -======= - vec.insert(vec.begin(), - std::istream_iterator(file), - std::istream_iterator()); ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 file.close(); return vec; } -<<<<<<< HEAD AcirToSmtLoader::AcirToSmtLoader(std::string filename) { this->acir_program_buf = readFile(filename); @@ -66,18 +52,4 @@ smt_circuit::UltraCircuit AcirToSmtLoader::get_circuit(smt_solver::Solver* solve { smt_circuit::CircuitSchema circuit_info = smt_circuit_schema::unpack_from_buffer(this->circuit_buf); return smt_circuit::UltraCircuit(circuit_info, solver, smt_terms::TermType::BVTerm); -======= - -AcirInstructionLoader::AcirInstructionLoader(std::vector const& acir_bytes, std::string instruction_name) -{ - this->acir_program_buf = acir_bytes; - this->instruction_name = instruction_name; - this->constraint_systems = acir_format::program_buf_to_acir_format(acir_bytes, false); -} - -AcirInstructionLoader::AcirInstructionLoader(std::string filename) { - this->acir_program_buf = readFile(filename); - this->instruction_name = filename; - this->constraint_systems = acir_format::program_buf_to_acir_format(this->acir_program_buf, false); ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp index b4047566992..9874164ee85 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp @@ -1,6 +1,5 @@ #pragma once #include "barretenberg/dsl/acir_format/acir_format.hpp" -<<<<<<< HEAD #include "barretenberg/smt_verification/circuit/ultra_circuit.hpp" #include "msgpack/v3/sbuffer_decl.hpp" #include @@ -26,29 +25,4 @@ class AcirToSmtLoader { std::vector acir_program_buf; acir_format::AcirFormat constraint_system; msgpack::sbuffer circuit_buf; -======= -#include -#include - - -class AcirInstructionLoader { -public: - AcirInstructionLoader() = default; - AcirInstructionLoader(const AcirInstructionLoader& other) = default; - AcirInstructionLoader(AcirInstructionLoader&& other) = default; - AcirInstructionLoader& operator=(const AcirInstructionLoader other) = delete; - AcirInstructionLoader&& operator=(AcirInstructionLoader&& other) = delete; - - ~AcirInstructionLoader() = default; - - AcirInstructionLoader(std::vector const& acir_program_buf, std::string instruction_name); - AcirInstructionLoader(std::string filename); - - std::vector get_constraint_systems() { return this->constraint_systems; } - -private: - std::string instruction_name; - std::vector acir_program_buf; - std::vector constraint_systems; ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 }; \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp index 2b862043806..1e1c7a27f17 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp @@ -3,18 +3,13 @@ #include "barretenberg/common/test.hpp" #include "barretenberg/dsl/acir_format/acir_format.hpp" #include "barretenberg/smt_verification/circuit/ultra_circuit.hpp" -<<<<<<< HEAD #include "barretenberg/smt_verification/solver/solver.hpp" -======= ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 #include "barretenberg/stdlib/client_ivc_verifier/client_ivc_recursive_verifier.hpp" #include "barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp" #include -<<<<<<< HEAD TEST(acir_formal_proofs, uint_terms_add) { - AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Add.acir"); smt_solver::Solver solver = loader.get_solver(); smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); auto a = circuit["a"]; @@ -203,110 +198,3 @@ TEST(acir_formal_proofs, uint_terms_xor) info(solver.getResult()); EXPECT_FALSE(res); } -======= -TEST(acir_formal_proofs, slow) -{ - AcirInstructionLoader add = - AcirInstructionLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Add.acir"); - auto system = add.get_constraint_systems().at(0); - bb::UltraCircuitBuilder builder = acir_format::create_circuit(system, false); - info(builder.public_inputs); - // info(builder.variables); - builder.set_variable_name(0, "a"); - builder.set_variable_name(1, "b"); - builder.set_variable_name(2, "c"); - builder.set_variable_name(3, "d"); - builder.set_variable_name(4, "e"); - EXPECT_TRUE(bb::CircuitChecker::check(builder)); - - auto buf = builder.export_circuit(); - smt_circuit::CircuitSchema circuit_info = smt_circuit_schema::unpack_from_buffer(buf); - smt_solver::Solver s(circuit_info.modulus); - smt_circuit::UltraCircuit circuit(circuit_info, &s, smt_terms::TermType::FFTerm); - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - info(c); - auto cr = a + b; - c != cr; - bool res = s.check(); - EXPECT_TRUE(false); - s.print_assertions(); - info(s.getResult()); - EXPECT_FALSE(res); -} - -TEST(acir_formal_proofs, uint_terms_add) -{ - AcirInstructionLoader add = - AcirInstructionLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Add.acir"); - auto system = add.get_constraint_systems().at(0); - bb::UltraCircuitBuilder builder = acir_format::create_circuit(system, false); - info(builder.public_inputs); - // info(builder.variables); - builder.set_variable_name(0, "a"); - builder.set_variable_name(1, "b"); - builder.set_variable_name(2, "c"); - builder.set_variable_name(3, "d"); - builder.set_variable_name(4, "e"); - EXPECT_TRUE(bb::CircuitChecker::check(builder)); - - auto buf = builder.export_circuit(); - smt_circuit::CircuitSchema circuit_info = smt_circuit_schema::unpack_from_buffer(buf); - smt_solver::Solver s(circuit_info.modulus); - smt_circuit::UltraCircuit circuit(circuit_info, &s, smt_terms::TermType::BVTerm); - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - info(c); - auto cr = a + b; - c != cr; - bool res = s.check(); - EXPECT_TRUE(false); - s.print_assertions(); - info(s.getResult()); - EXPECT_FALSE(res); -} - -TEST(acir_formal_proofs, public_inputs) -{ - AcirInstructionLoader add = - AcirInstructionLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Add.public.acir"); - auto system = add.get_constraint_systems().at(0); - bb::UltraCircuitBuilder builder = acir_format::create_circuit(system, false); - // builder.zero_idx = 4; - info(builder.zero_idx); - info("Public inputs in builder", builder.public_inputs); - info(builder.real_variable_index[2]); - info(builder.real_variable_index[3]); - builder.variables[0] = 10; - builder.variables[1] = 10; - // if we set second variable check circuit throws error :(, so output in third??? - builder.variables[3] = 20; - EXPECT_TRUE(bb::CircuitChecker::check(builder)); - - builder.set_variable_name(0, "a"); - builder.set_variable_name(1, "b"); - builder.set_variable_name(2, "c"); - builder.set_variable_name(3, "d"); - builder.set_variable_name(4, "e"); - EXPECT_TRUE(bb::CircuitChecker::check(builder)); - - auto buf = builder.export_circuit(); - smt_circuit::CircuitSchema circuit_info = smt_circuit_schema::unpack_from_buffer(buf); - info("Circuit info public inputs", circuit_info.public_inps); - smt_solver::Solver s(circuit_info.modulus); - smt_circuit::UltraCircuit circuit(circuit_info, &s, smt_terms::TermType::BVTerm); - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - info(c); - auto cr = a + b; - c != cr; - bool res = s.check(); - EXPECT_TRUE(false); - s.print_assertions(); - info(s.getResult()); - EXPECT_FALSE(res); -} ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 diff --git a/noir/noir-repo/compiler/noirc_evaluator/Cargo.toml b/noir/noir-repo/compiler/noirc_evaluator/Cargo.toml index cfd9c53d79c..e25b5bf855a 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/Cargo.toml +++ b/noir/noir-repo/compiler/noirc_evaluator/Cargo.toml @@ -26,7 +26,6 @@ serde_json.workspace = true serde_with = "3.2.0" tracing.workspace = true chrono = "0.4.37" -flate2 = "1.0.35" rayon.workspace = true cfg-if.workspace = true diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs index 9fa84b61126..eefea04e23a 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs @@ -1,18 +1,9 @@ use std::collections::BTreeSet; -<<<<<<< HEAD -======= -use flate2::read::GzDecoder; -use std::io::Read; ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 use acvm::{ acir::{ circuit::{ Circuit, ExpressionWidth, -<<<<<<< HEAD Program as AcirProgram -======= - Program as AcirProgram, PublicInputs, ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 }, native_types::Witness, }, @@ -29,16 +20,6 @@ use crate::ssa::{ use crate::brillig::Brillig; use serde::{Deserialize, Serialize}; -<<<<<<< HEAD -======= -fn ungzip(compressed_data: Vec) -> Vec { - let mut decompressed_data: Vec = Vec::new(); - let mut decoder = GzDecoder::new(&compressed_data[..]); - decoder.read_to_end(&mut decompressed_data).unwrap(); - return decompressed_data; -} - ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 #[derive(Serialize, Deserialize)] pub struct InstructionArtifacts { // name of used instruction @@ -50,11 +31,7 @@ pub struct InstructionArtifacts { // serde_json serialized ssa pub serialized_ssa: String, -<<<<<<< HEAD // bytes of acir program. Gzipped!! -======= - // bytes of acir program. Ungzipped!! ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 pub serialized_acir: Vec, } @@ -66,16 +43,12 @@ impl InstructionArtifacts { let program = ssa_to_acir_program(ssa); let serialized_program = AcirProgram::serialize_program(&program); - + Self { instruction_name: instruction_name, formatted_ssa: formatted_ssa, serialized_ssa: serialized_ssa.to_string(), -<<<<<<< HEAD serialized_acir: serialized_program -======= - serialized_acir: ungzip(serialized_program) ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 } } @@ -86,16 +59,12 @@ impl InstructionArtifacts { let program = ssa_to_acir_program(ssa); let serialized_program = AcirProgram::serialize_program(&program); - + Self { instruction_name: instruction_name, formatted_ssa: formatted_ssa, serialized_ssa: serialized_ssa.to_string(), -<<<<<<< HEAD serialized_acir: serialized_program -======= - serialized_acir: ungzip(serialized_program) ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 } } @@ -122,7 +91,7 @@ fn ssa_to_acir_program(ssa: Ssa) -> AcirProgram { let (acir_functions, brillig, _, _) = ssa .into_acir(&Brillig::default(), ExpressionWidth::default()) .expect("Should compile manually written SSA into ACIR"); - + let mut functions: Vec> = Vec::new(); for acir_func in acir_functions.iter() { // inputs and output as private @@ -171,7 +140,7 @@ fn constrain_function() -> Ssa { // constrains v0 == v1, returns v1 let main_id = Id::new(0); let mut builder = FunctionBuilder::new("main".into(), main_id); - + let v0 = builder.add_parameter(Type::field()); let v1 = builder.add_parameter(Type::field()); builder.insert_constrain(v0, v1, None); @@ -184,7 +153,7 @@ fn not_function() -> Ssa { // returns not v0 let main_id = Id::new(0); let mut builder = FunctionBuilder::new("main".into(), main_id); - + let v0 = builder.add_parameter(Type::unsigned(64)); let v1 = builder.insert_not(v0); builder.terminate_with_return(vec![v1]); @@ -196,7 +165,7 @@ fn range_check_function() -> Ssa { // check v0: u64 limited by 64 bits ?.. let main_id = Id::new(0); let mut builder = FunctionBuilder::new("main".into(), main_id); - + let v0 = builder.add_parameter(Type::field()); builder.insert_range_check(v0, 64, Some("Range Check failed".to_string())); builder.terminate_with_return(vec![v0]); @@ -208,7 +177,7 @@ fn truncate_function() -> Ssa { // truncate v0: field 10, 20?.. let main_id = Id::new(0); let mut builder = FunctionBuilder::new("main".into(), main_id); - + let v0 = builder.add_parameter(Type::field()); let v1 = builder.insert_truncate(v0, 10, 20); builder.terminate_with_return(vec![v1]); @@ -225,27 +194,27 @@ pub fn all_instructions() -> Vec { artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Div, "Binary::Div".into())); // with field panic - // panic on Mod Should compile manually written SSA into ACIR: InvalidRangeConstraint + // panic on Mod Should compile manually written SSA into ACIR: InvalidRangeConstraint artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Mod, "Binary::Mod".into())); - + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Eq, "Binary::Eq".into())); - + // with field panic // thread 'main' panicked at /home/defkit/work/noir/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs:1225:9: // assertion failed: max_bits + 1 < F::max_num_bits() artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Lt, "Binary::Lt".into())); - + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::And, "Binary::And".into())); - + // with field // attempt to shift left with overflow artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Or, "Binary::Or".into())); artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Xor, "Binary::Xor".into())); - + artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Shl, "Binary::Shl".into())); artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Shr, "Binary::Shr".into())); - + // with field // attempt to shift left with overflow artifacts.push(InstructionArtifacts::new_not()); @@ -255,4 +224,4 @@ pub fn all_instructions() -> Vec { artifacts.push(InstructionArtifacts::new_truncate()); return artifacts; -} +} diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml index 5bc26e6747c..2655d46fb7d 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml @@ -7,8 +7,5 @@ edition = "2021" noirc_evaluator = {path = "../"} serde = "1.0.214" serde_json = "1.0.120" -<<<<<<< HEAD flate2 = "1.0.35" -======= ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 [workspace] diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md index af7e3a0bc62..2eccde7ea00 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md @@ -1,8 +1,5 @@ # WHY USED FOR FORMAL VERIFYING SSA INSTRUCTIONS PRODUCED BY THE CONVERSION SSA->ACIR -<<<<<<< HEAD # how `cargo run && cp artifacts/* ../../../../../barretenberg/cpp/src/barretenberg/acir_formal_proofs/artifacts/` -======= ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs index 28c2f039dc9..ce8ba04e98e 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs @@ -1,17 +1,12 @@ use std::fs::File; use std::io::Write; -<<<<<<< HEAD use std::io::Read; use std::path::Path; use flate2::read::GzDecoder; -======= -use std::path::Path; ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 use::noirc_evaluator::acir_instruction_builder::{ all_instructions, InstructionArtifacts }; -<<<<<<< HEAD fn ungzip(compressed_data: Vec) -> Vec { let mut decompressed_data: Vec = Vec::new(); let mut decoder = GzDecoder::new(&compressed_data[..]); @@ -19,8 +14,6 @@ fn ungzip(compressed_data: Vec) -> Vec { return decompressed_data; } -======= ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 fn save_to_file(data: &[u8], filename: &str) -> Result<(), std::io::Error> { let path = Path::new(filename); let mut file = File::create(path)?; @@ -34,12 +27,8 @@ fn main() { for artifacts in all_artifacts.iter() { println!("{}", artifacts.formatted_ssa); let filename = format!("artifacts/{}{}", artifacts.instruction_name, ".acir"); -<<<<<<< HEAD let acir = &artifacts.serialized_acir; match save_to_file(&ungzip(acir.clone()), &filename) { -======= - match save_to_file(&artifacts.serialized_acir, &filename) { ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 Ok(_) => (), Err(error) => println!("Error saving data: {}", error), } From e1a6541ce0d0b0c849823f8b5e8e4ae8e98f0916 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 26 Nov 2024 14:50:15 +0000 Subject: [PATCH 14/32] i forgor to resolve conflicts in cargolock... --- .../noirc_evaluator/ssa_test/Cargo.lock | 71 ------------------- .../noirc_evaluator/ssa_test/README.md | 2 +- 2 files changed, 1 insertion(+), 72 deletions(-) diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock index 47001d634ce..4b76160736d 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock @@ -4,11 +4,7 @@ version = 3 [[package]] name = "acir" -<<<<<<< HEAD version = "0.55.0" -======= -version = "0.54.0" ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 dependencies = [ "acir_field", "base64 0.21.7", @@ -22,11 +18,7 @@ dependencies = [ [[package]] name = "acir_field" -<<<<<<< HEAD version = "0.55.0" -======= -version = "0.54.0" ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 dependencies = [ "ark-bn254", "ark-ff", @@ -38,20 +30,12 @@ dependencies = [ [[package]] name = "acvm" -<<<<<<< HEAD version = "0.55.0" -======= -version = "0.54.0" ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 dependencies = [ "acir", "acvm_blackbox_solver", "brillig_vm", "indexmap 1.9.3", -<<<<<<< HEAD -======= - "num-bigint", ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 "serde", "thiserror", "tracing", @@ -59,11 +43,7 @@ dependencies = [ [[package]] name = "acvm_blackbox_solver" -<<<<<<< HEAD version = "0.55.0" -======= -version = "0.54.0" ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 dependencies = [ "acir", "blake2", @@ -335,11 +315,7 @@ dependencies = [ [[package]] name = "bn254_blackbox_solver" -<<<<<<< HEAD version = "0.55.0" -======= -version = "0.54.0" ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 dependencies = [ "acir", "acvm_blackbox_solver", @@ -354,11 +330,7 @@ dependencies = [ [[package]] name = "brillig" -<<<<<<< HEAD version = "0.55.0" -======= -version = "0.54.0" ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 dependencies = [ "acir_field", "serde", @@ -366,11 +338,7 @@ dependencies = [ [[package]] name = "brillig_vm" -<<<<<<< HEAD version = "0.55.0" -======= -version = "0.54.0" ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 dependencies = [ "acir", "acvm_blackbox_solver", @@ -674,11 +642,7 @@ dependencies = [ [[package]] name = "fm" -<<<<<<< HEAD version = "0.39.0" -======= -version = "0.38.0" ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 dependencies = [ "codespan-reporting", "iter-extended", @@ -842,11 +806,7 @@ dependencies = [ [[package]] name = "iter-extended" -<<<<<<< HEAD version = "0.39.0" -======= -version = "0.38.0" ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 [[package]] name = "itertools" @@ -969,19 +929,11 @@ dependencies = [ [[package]] name = "noirc_arena" -<<<<<<< HEAD version = "0.39.0" [[package]] name = "noirc_errors" version = "0.39.0" -======= -version = "0.38.0" - -[[package]] -name = "noirc_errors" -version = "0.38.0" ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 dependencies = [ "acvm", "base64 0.21.7", @@ -998,30 +950,18 @@ dependencies = [ [[package]] name = "noirc_evaluator" -<<<<<<< HEAD version = "0.39.0" -======= -version = "0.38.0" ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 dependencies = [ "acvm", "bn254_blackbox_solver", "cfg-if", "chrono", -<<<<<<< HEAD -======= - "flate2", ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 "fxhash", "im", "iter-extended", "noirc_errors", "noirc_frontend", "num-bigint", -<<<<<<< HEAD -======= - "num-traits", ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 "rayon", "serde", "serde_json", @@ -1032,11 +972,7 @@ dependencies = [ [[package]] name = "noirc_frontend" -<<<<<<< HEAD version = "0.39.0" -======= -version = "0.38.0" ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 dependencies = [ "acvm", "bn254_blackbox_solver", @@ -1065,11 +1001,7 @@ dependencies = [ [[package]] name = "noirc_printable_type" -<<<<<<< HEAD version = "0.39.0" -======= -version = "0.38.0" ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 dependencies = [ "acvm", "iter-extended", @@ -1493,10 +1425,7 @@ dependencies = [ name = "ssa_test" version = "0.1.0" dependencies = [ -<<<<<<< HEAD "flate2", -======= ->>>>>>> 56559cf7fce08564b1b28ebe20726ba486af2379 "noirc_evaluator", "serde", "serde_json", diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md index 2eccde7ea00..886659cb5d0 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md @@ -2,4 +2,4 @@ USED FOR FORMAL VERIFYING SSA INSTRUCTIONS PRODUCED BY THE CONVERSION SSA->ACIR # how -`cargo run && cp artifacts/* ../../../../../barretenberg/cpp/src/barretenberg/acir_formal_proofs/artifacts/` +`mkdir artifacts && cargo run && mkdir ../../../../../barretenberg/cpp/src/barretenberg/acir_formal_proofs/artifacts/ && cp artifacts/* ../../../../../barretenberg/cpp/src/barretenberg/acir_formal_proofs/artifacts/` From 7dd7e9822f593fca4c35ad3eedfcf390acb0ce9f Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Wed, 27 Nov 2024 13:35:44 +0000 Subject: [PATCH 15/32] hmm --- .../acir_formal_proofs/acir_loader.cpp | 2 +- .../acir_formal_proofs/acir_loader.hpp | 2 +- .../acir_formal_proofs/acir_loader.test.cpp | 97 ++++++++++++++++--- .../check_circuits.test.cpp | 0 .../circuit/ultra_circuit.cpp | 2 +- .../src/acir_instruction_builder.rs | 35 ++++--- .../noirc_evaluator/ssa_test/src/main.rs | 2 +- 7 files changed, 110 insertions(+), 30 deletions(-) create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/check_circuits.test.cpp diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp index ffe4eafd448..b6519e46314 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp @@ -38,7 +38,7 @@ AcirToSmtLoader::AcirToSmtLoader(std::string filename) builder.set_variable_name(0, "a"); builder.set_variable_name(1, "b"); builder.set_variable_name(2, "c"); - // builder.set_variable_name(3, "d"); + builder.set_variable_name(3, "d"); this->circuit_buf = builder.export_circuit(); } diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp index 9874164ee85..44fb26baa84 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp @@ -16,7 +16,7 @@ class AcirToSmtLoader { ~AcirToSmtLoader() = default; AcirToSmtLoader(std::string filename); - acir_format::AcirFormat get_constraint_systems() { return this->constraint_system; } + acir_format::AcirFormat& get_constraint_systems() { return this->constraint_system; } smt_solver::Solver get_solver(); smt_circuit::UltraCircuit get_circuit(smt_solver::Solver* solver); diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp index 1e1c7a27f17..6236bdf2f77 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp @@ -6,11 +6,13 @@ #include "barretenberg/smt_verification/solver/solver.hpp" #include "barretenberg/stdlib/client_ivc_verifier/client_ivc_recursive_verifier.hpp" #include "barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp" +#include "barretenberg/circuit_checker/circuit_checker.hpp" #include TEST(acir_formal_proofs, uint_terms_add) { - smt_solver::Solver solver = loader.get_solver(); + AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Add.acir"); + smt_solver::Solver solver = loader.get_solver(); smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); auto a = circuit["a"]; auto b = circuit["b"]; @@ -53,29 +55,55 @@ TEST(acir_formal_proofs, uint_terms_and) solver.print_assertions(); info(solver.getResult()); EXPECT_FALSE(res); + + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + std::unordered_map vals = solver.model(terms); + info("a = ", vals["a"]); + info("b = ", vals["b"]); + info("c = ", vals["c"]); + info("c_res = ", vals["cr"]); + } -TEST(acir_formal_proofs, uint_terms_div) +/*TEST(acir_formal_proofs, uint_terms_div) { AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Div.acir"); smt_solver::Solver solver = loader.get_solver(); smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); + // c = a // b + // a = b * c + k where k < b + // k = a - b * c + // auto a = circuit["a"]; auto b = circuit["b"]; auto c = circuit["c"]; - auto cr = a / b; - c != cr; + auto cr = a - c * b; + cr < b; bool res = solver.check(); solver.print_assertions(); info(solver.getResult()); + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + std::unordered_map vals = solver.model(terms); + info("a = ", vals["a"]); + info("b = ", vals["b"]); + info("c = ", vals["c"]); + info("c_res = ", vals["cr"]); + EXPECT_FALSE(res); -} +}*/ -/*TEST(acir_formal_proofs, uint_terms_eq) +/* TEST(acir_formal_proofs, uint_terms_eq) { AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Eq.acir"); smt_solver::Solver solver = loader.get_solver(); smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); + // c is bool var = (a == b) + // so if c is True a - b == 0 + // if c is False a - b == k + // so if circuit is correct + // ( a - b ) * (c ^ 1) == 0 + // if a - b != 0 and c is True k * (a - b) = 0, circuit is incorrect + // if a - b == 0 auto a = circuit["a"]; auto b = circuit["b"]; auto c = circuit["c"]; @@ -85,7 +113,7 @@ TEST(acir_formal_proofs, uint_terms_div) solver.print_assertions(); info(solver.getResult()); EXPECT_FALSE(res); -}*/ +} */ /* TEST(acir_formal_proofs, uint_terms_lt) { @@ -103,21 +131,26 @@ TEST(acir_formal_proofs, uint_terms_div) EXPECT_FALSE(res); } */ -/* TEST(acir_formal_proofs, uint_terms_mod) +TEST(acir_formal_proofs, uint_terms_mod) { AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Mod.acir"); smt_solver::Solver solver = loader.get_solver(); smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - auto cr = a % b; - c != cr; + // c = a mod b + // k * b + c = a + // k = (a - c) / b + // (a - c) * b + c * b == a * b + smt_circuit::STerm a = circuit["a"]; + smt_circuit::STerm b = circuit["b"]; + smt_circuit::STerm c = circuit["c"]; + smt_circuit::STerm c1 = (a - c) * b + c * b; + smt_circuit::STerm c2 = a * b; + c1 != c2; bool res = solver.check(); solver.print_assertions(); info(solver.getResult()); EXPECT_FALSE(res); -} */ +} TEST(acir_formal_proofs, uint_terms_or) { @@ -133,6 +166,14 @@ TEST(acir_formal_proofs, uint_terms_or) solver.print_assertions(); info(solver.getResult()); EXPECT_FALSE(res); + + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + std::unordered_map vals = solver.model(terms); + info("a = ", vals["a"]); + info("b = ", vals["b"]); + info("c = ", vals["c"]); + info("c_res = ", vals["cr"]); + } /*TEST(acir_formal_proofs, uint_terms_shl) @@ -197,4 +238,32 @@ TEST(acir_formal_proofs, uint_terms_xor) solver.print_assertions(); info(solver.getResult()); EXPECT_FALSE(res); + + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + std::unordered_map vals = solver.model(terms); + info("a = ", vals["a"]); + info("b = ", vals["b"]); + info("c = ", vals["c"]); + info("c_res = ", vals["cr"]); } + + +TEST(acir_circuit_check, uint_terms_add) +{ + AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Add.public.acir"); + bb::UltraCircuitBuilder builder = acir_format::create_circuit(loader.get_constraint_systems(), false); + // naming first three variables + // for binary noir sets indices as 0 1 2 + // for unary noir sets indices as 0 1 + info(builder.public_inputs); + info(builder.zero_idx); + builder.set_variable_name(0, "a"); + builder.set_variable_name(1, "b"); + builder.set_variable_name(2, "c"); + builder.set_variable_name(3, "d"); + builder.variables[0] = 1; + builder.variables[1] = 1; + builder.variables[3] = 2; + // builder.variables[4] = 1; + EXPECT_TRUE(bb::CircuitChecker::check(builder)); +} \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/check_circuits.test.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/check_circuits.test.cpp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/barretenberg/cpp/src/barretenberg/smt_verification/circuit/ultra_circuit.cpp b/barretenberg/cpp/src/barretenberg/smt_verification/circuit/ultra_circuit.cpp index 01cb3728524..155a17c8c63 100644 --- a/barretenberg/cpp/src/barretenberg/smt_verification/circuit/ultra_circuit.cpp +++ b/barretenberg/cpp/src/barretenberg/smt_verification/circuit/ultra_circuit.cpp @@ -95,7 +95,7 @@ size_t UltraCircuit::handle_arithmetic_relation(size_t cursor, size_t idx) return cursor + 1; } - STerm res = this->symbolic_vars[0]; + STerm res = this->symbolic_vars[this->variable_names_inverse["zero"]]; static const bb::fr neg_half = bb::fr(-2).invert(); if (!q_arith.is_zero()) { diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs index eefea04e23a..a7d2fa07982 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs @@ -3,7 +3,7 @@ use acvm::{ acir::{ circuit::{ Circuit, ExpressionWidth, - Program as AcirProgram + Program as AcirProgram, PublicInputs }, native_types::Witness, }, @@ -93,19 +93,30 @@ fn ssa_to_acir_program(ssa: Ssa) -> AcirProgram { .expect("Should compile manually written SSA into ACIR"); let mut functions: Vec> = Vec::new(); + // TODO refactor this... + let public_vars: bool = true; + for acir_func in acir_functions.iter() { - // inputs and output as private let mut private_params: BTreeSet = acir_func.input_witnesses.clone().into_iter().collect(); let ret_values: BTreeSet = acir_func.return_witnesses.clone().into_iter().collect(); - - let circuit: Circuit ; + let circuit: Circuit; + if public_vars { + circuit = Circuit { + current_witness_index: acir_func.current_witness_index().witness_index(), + opcodes: acir_func.opcodes().to_vec(), + public_parameters: PublicInputs(private_params.clone()), + return_values: PublicInputs(ret_values.clone()), + ..Circuit::::default() + }; + } else { + circuit = Circuit { + current_witness_index: acir_func.current_witness_index().witness_index(), + opcodes: acir_func.opcodes().to_vec(), + private_parameters: private_params.clone(), + ..Circuit::::default() + }; + } private_params.extend(ret_values.iter().cloned()); - circuit = Circuit { - current_witness_index: acir_func.current_witness_index().witness_index(), - opcodes: acir_func.opcodes().to_vec(), - private_parameters: private_params, - ..Circuit::::default() - }; functions.push(circuit); } return AcirProgram { functions: functions, unconstrained_functions: brillig }; @@ -115,7 +126,7 @@ fn binary_function(op: BinaryOp) -> Ssa { // returns v0 op v1 let main_id = Id::new(0); let mut builder = FunctionBuilder::new("main".into(), main_id); - let v0 = builder.add_parameter(Type::unsigned(8)); + let v0 = builder.add_parameter(Type::unsigned(16)); // bit size of v1 differs, because shl shr max second argument 8 bit; let v1; @@ -124,7 +135,7 @@ fn binary_function(op: BinaryOp) -> Ssa { if op == BinaryOp::Shl || op == BinaryOp::Shr { v1 = builder.add_parameter(Type::unsigned(8)); } else { - v1 = builder.add_parameter(Type::unsigned(8)); + v1 = builder.add_parameter(Type::unsigned(16)); } let v2 = builder.insert_binary(v0, op, v1); diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs index ce8ba04e98e..e081e76633a 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs @@ -26,7 +26,7 @@ fn main() { for artifacts in all_artifacts.iter() { println!("{}", artifacts.formatted_ssa); - let filename = format!("artifacts/{}{}", artifacts.instruction_name, ".acir"); + let filename = format!("artifacts/{}{}", artifacts.instruction_name, ".public.acir"); let acir = &artifacts.serialized_acir; match save_to_file(&ungzip(acir.clone()), &filename) { Ok(_) => (), From d58a19a87f0c3998a1ac1fa09e1eda84730d0330 Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Fri, 29 Nov 2024 18:55:01 +0000 Subject: [PATCH 16/32] smol refactor --- .../src/.acir_instruction_builder.rs.swp | Bin 0 -> 16384 bytes .../src/acir_instruction_builder.rs | 215 +++++++++--------- .../compiler/noirc_evaluator/src/lib.rs | 2 +- .../noirc_evaluator/ssa_test/src/main.rs | 33 ++- 4 files changed, 140 insertions(+), 110 deletions(-) create mode 100644 noir/noir-repo/compiler/noirc_evaluator/src/.acir_instruction_builder.rs.swp diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/.acir_instruction_builder.rs.swp b/noir/noir-repo/compiler/noirc_evaluator/src/.acir_instruction_builder.rs.swp new file mode 100644 index 0000000000000000000000000000000000000000..02cd36050cef256e1387e61f3e2501f830d14d15 GIT binary patch literal 16384 zcmeI3UyLM09mh*igah=D1TjQYwm-K*YCfu@;HCEv&e8AX6*StuWUS4EwP=~XIU(J7nLTDYhNm# zU;O0J`D2UoN9P|re)X_lstqoLm$Z!L^Dw#?Zpd;W%~WAN<_no;3sE-6RU&JrD3F_B zQiVDz7Rn-82qRSlDlK(UMOtNPuwJPomPMy1ub!^=@d|haNP*kfv7?Lk)31AGj_^A^ z{2BV`FRy@Cz$@St@CtYZyaHYUuYgzJ|3m?u-@v|%vcA`rH?!aGnfU&Xy?WL?pYXrI z-rr@ve>>rCZ~d27z$@St@CtYZyaHYUuYgy;E8rFI3U~#)0`GzXVa(Ver27Y2@Z6&06O4S@VDC- zdl~!yd>ac~aY2W|m}z@Khq?C0QT;05q)@HBV`ynYK~FM?lyZ-BGl40s6K2wp>> zz6UgT2E-r&H-XDHGxjV{pbw6Nf84~_-@#?@9QX=&4BQQF2ZzBSa5MPJ2N?SncouvU z?14vs01tyZ!OJ%?_ABs9@LlkEZ~?4=F1Q2y_5Fj3373}tzg#gqqgOr%$(QO7#9<~lkHHf7YB zl73Vb1qvB#DV@r)#QBm~Zo5XN27t-22$Pm^QiYV{pW;?iM}F1gw$PhlQ92%p)Z9iC zO}z1%7*!gD9qB9hskK7NuGC9U)#W&eq(?&7TC!P|Lm4|Ng)$1Vqd-xXBr-xJkEb%I zG#{^ow@OV>^*4fEUt+zi7-g5MbaX=peacRqMQCN(4;9{#Q1JCEOHklmh=yM0eqn*H ztvY$yU|4elL0EwyG(6)H*8hSSyB{LFS< zph-f2r&O%_j$hpmNru+2l1)L{e7!c*<^lfZkomF4prVzKkxq z2|h{Ar^$6{l1{9*m1>%4H?=1+JvA8wdt2rsbPZjEDs>Y%-8fE7Y8Yi&f<|qsw2`26 zSIR<#iMk|X(gXdaLwg}H|=Kpp2lM2TBRG4gC+)nL5MCB2PWFs?f8SkJp@S2 zSfGQAjs=p-D7@QHD2LQ*oE+H#prbg=T8LqYpy>j$_J`Af%{Wwdgu0_m>o@M0K@rA^ zg=qEtk=D%a-b|Z1-$Vk#oETXUVHPg244x^oREUw7vlO*crCUXqPmba6vKicvsVv-H z*95hltm&PI5$p>qcrUf>rVQKrG{*>G>h&7^(>JVPb^Z@EtaX)!MLn$3Q>c~YwhcFp z%J{<>GY9i?HNU>rqXv1xS4LfXxzLK9=QL}wPa4bv-0n$R9Y0wQ0(kJP?`T=_ ztY@Ybn9Z1nT8Dr7lFD-#A30J#)hA4$3p6cyXlT^+oJ7qdmeJTk7RLJbego);1-t@Y0k42pz$@St@CtYZyaNB73e>wcb|*J%*5FtunT1Dl-^r`8-nK+zt12530lz)5)0W#5H{|rS{qW zZ02SgckiI>RoC?Dm}P2_?^aDMr?Dd^?%u&7pVN-%bEDS?PU9@GH$&TRcnyYsp^pXL dL~RG_3Y%s3@kPGG&(a3Sc92#B, } +pub enum VariableType { + Field, + Unsigned, + Signed +} + +pub struct Variable { + pub variable_type: VariableType, + // ignored on Field type + pub variable_size: u32 +} + impl InstructionArtifacts { - fn new_binary(op: BinaryOp, instruction_name: String) -> Self { - let ssa = binary_function(op); + fn get_type(variable: &Variable) -> Type { + match variable.variable_type { + VariableType::Field => Type::field(), + VariableType::Signed => Type::signed(variable.variable_size), + VariableType::Unsigned => Type::unsigned(variable.variable_size) + } + } + + fn new_binary(op: BinaryOp, instruction_name: String, first_variable: &Variable, second_variable: &Variable) -> Self { + let first_variable_type = Self::get_type(first_variable); + let second_variable_type = Self::get_type(second_variable); + let ssa = binary_function(op, first_variable_type, second_variable_type); let serialized_ssa = &serde_json::to_string(&ssa).unwrap(); let formatted_ssa = format!("{}", ssa); @@ -52,8 +74,9 @@ impl InstructionArtifacts { } } - fn new_by_func(ssa_generate_function: fn() -> Ssa, instruction_name: String) -> Self { - let ssa = ssa_generate_function(); + fn new_by_func(ssa_generate_function: fn(Type) -> Ssa, instruction_name: String, variable: &Variable) -> Self { + let variable_type = Self::get_type(variable); + let ssa = ssa_generate_function(variable_type); let serialized_ssa = &serde_json::to_string(&ssa).unwrap(); let formatted_ssa = format!("{}", ssa); @@ -69,20 +92,68 @@ impl InstructionArtifacts { } - fn new_constrain() -> Self { - return Self::new_by_func(constrain_function, "Constrain".into()) + pub fn new_constrain(variable: &Variable) -> Self { + return Self::new_by_func(constrain_function, "Constrain".into(), variable) + } + + pub fn new_not(variable: &Variable) -> Self { + return Self::new_by_func(not_function, "Not".into(), variable) + } + + pub fn new_range_check(variable: &Variable) -> Self { + return Self::new_by_func(range_check_function, "RangeCheck".into(), variable) + } + + pub fn new_truncate(variable: &Variable) -> Self { + return Self::new_by_func(truncate_function, "Truncate".into(), variable) + } + + pub fn new_add(first_variable: &Variable, second_variable: &Variable) -> Self { + return Self::new_binary(BinaryOp::Add, "Binary::Add".into(), first_variable, second_variable); + } + + pub fn new_sub(first_variable: &Variable, second_variable: &Variable) -> Self { + return Self::new_binary(BinaryOp::Sub, "Binary::Sub".into(), first_variable, second_variable); + } + + pub fn new_xor(first_variable: &Variable, second_variable: &Variable) -> Self { + return Self::new_binary(BinaryOp::Xor, "Binary::Xor".into(), first_variable, second_variable); + } + + pub fn new_and(first_variable: &Variable, second_variable: &Variable) -> Self { + return Self::new_binary(BinaryOp::And, "Binary::And".into(), first_variable, second_variable); + } + + pub fn new_or(first_variable: &Variable, second_variable: &Variable) -> Self { + return Self::new_binary(BinaryOp::Or, "Binary::Or".into(), first_variable, second_variable); + } + + pub fn new_lt(first_variable: &Variable, second_variable: &Variable) -> Self { + return Self::new_binary(BinaryOp::Lt, "Binary::Lt".into(), first_variable, second_variable); + } + + pub fn new_eq(first_variable: &Variable, second_variable: &Variable) -> Self { + return Self::new_binary(BinaryOp::Eq, "Binary::Eq".into(), first_variable, second_variable); + } + + pub fn new_mod(first_variable: &Variable, second_variable: &Variable) -> Self { + return Self::new_binary(BinaryOp::Mod, "Binary::Mod".into(), first_variable, second_variable); + } + + pub fn new_mul(first_variable: &Variable, second_variable: &Variable) -> Self { + return Self::new_binary(BinaryOp::Mul, "Binary::Mul".into(), first_variable, second_variable); } - fn new_not() -> Self { - return Self::new_by_func(not_function, "Not".into()) + pub fn new_div(first_variable: &Variable, second_variable: &Variable) -> Self { + return Self::new_binary(BinaryOp::Div, "Binary::Div".into(), first_variable, second_variable); } - fn new_range_check() -> Self { - return Self::new_by_func(range_check_function, "RangeCheck".into()) + pub fn new_shl(first_variable: &Variable, second_variable: &Variable) -> Self { + return Self::new_binary(BinaryOp::Shl, "Binary::Shl".into(), first_variable, second_variable); } - fn new_truncate() -> Self { - return Self::new_by_func(truncate_function, "Truncate".into()) + pub fn new_shr(first_variable: &Variable, second_variable: &Variable) -> Self { + return Self::new_binary(BinaryOp::Shl, "Binary::Shl".into(), first_variable, second_variable); } } @@ -93,146 +164,82 @@ fn ssa_to_acir_program(ssa: Ssa) -> AcirProgram { .expect("Should compile manually written SSA into ACIR"); let mut functions: Vec> = Vec::new(); - // TODO refactor this... - let public_vars: bool = true; for acir_func in acir_functions.iter() { let mut private_params: BTreeSet = acir_func.input_witnesses.clone().into_iter().collect(); let ret_values: BTreeSet = acir_func.return_witnesses.clone().into_iter().collect(); let circuit: Circuit; - if public_vars { - circuit = Circuit { - current_witness_index: acir_func.current_witness_index().witness_index(), - opcodes: acir_func.opcodes().to_vec(), - public_parameters: PublicInputs(private_params.clone()), - return_values: PublicInputs(ret_values.clone()), - ..Circuit::::default() - }; - } else { - circuit = Circuit { - current_witness_index: acir_func.current_witness_index().witness_index(), - opcodes: acir_func.opcodes().to_vec(), - private_parameters: private_params.clone(), - ..Circuit::::default() - }; - } private_params.extend(ret_values.iter().cloned()); + circuit = Circuit { + current_witness_index: acir_func.current_witness_index().witness_index(), + opcodes: acir_func.opcodes().to_vec(), + private_parameters: private_params.clone(), + ..Circuit::::default() + }; functions.push(circuit); } return AcirProgram { functions: functions, unconstrained_functions: brillig }; } -fn binary_function(op: BinaryOp) -> Ssa { +fn binary_function(op: BinaryOp, first_variable_type: Type, second_variable_type: Type) -> Ssa { // returns v0 op v1 let main_id = Id::new(0); let mut builder = FunctionBuilder::new("main".into(), main_id); - let v0 = builder.add_parameter(Type::unsigned(16)); - - // bit size of v1 differs, because shl shr max second argument 8 bit; - let v1; - // let three = builder.numeric_constant(3u128, Type::unsigned(8)); - - if op == BinaryOp::Shl || op == BinaryOp::Shr { - v1 = builder.add_parameter(Type::unsigned(8)); - } else { - v1 = builder.add_parameter(Type::unsigned(16)); - } - + let v0 = builder.add_parameter(first_variable_type); + let v1 = builder.add_parameter(second_variable_type); let v2 = builder.insert_binary(v0, op, v1); builder.terminate_with_return(vec![v2]); let func = builder.finish(); - // it doesnt remove bit shifts, it replaces it with something smart + // remove_bit_shifts doesnt remove bit shifts, it replaces it with something smart let cleared_func = func.remove_bit_shifts(); return cleared_func; } -fn constrain_function() -> Ssa { +fn constrain_function(variable_type: Type) -> Ssa { // constrains v0 == v1, returns v1 let main_id = Id::new(0); let mut builder = FunctionBuilder::new("main".into(), main_id); - let v0 = builder.add_parameter(Type::field()); - let v1 = builder.add_parameter(Type::field()); + let v0 = builder.add_parameter(variable_type.clone()); + let v1 = builder.add_parameter(variable_type); builder.insert_constrain(v0, v1, None); builder.terminate_with_return(vec![v1]); - return builder.finish() -} - -fn not_function() -> Ssa { - // returns not v0 - let main_id = Id::new(0); - let mut builder = FunctionBuilder::new("main".into(), main_id); - - let v0 = builder.add_parameter(Type::unsigned(64)); - let v1 = builder.insert_not(v0); - builder.terminate_with_return(vec![v1]); - - return builder.finish() + return builder.finish(); } -fn range_check_function() -> Ssa { - // check v0: u64 limited by 64 bits ?.. +fn range_check_function(variable_type: Type) -> Ssa { let main_id = Id::new(0); let mut builder = FunctionBuilder::new("main".into(), main_id); - let v0 = builder.add_parameter(Type::field()); + let v0 = builder.add_parameter(variable_type); builder.insert_range_check(v0, 64, Some("Range Check failed".to_string())); builder.terminate_with_return(vec![v0]); return builder.finish() } -fn truncate_function() -> Ssa { +fn truncate_function(variable_type: Type) -> Ssa { // truncate v0: field 10, 20?.. let main_id = Id::new(0); let mut builder = FunctionBuilder::new("main".into(), main_id); - let v0 = builder.add_parameter(Type::field()); + let v0 = builder.add_parameter(variable_type); let v1 = builder.insert_truncate(v0, 10, 20); builder.terminate_with_return(vec![v1]); - return builder.finish() + return builder.finish(); } -pub fn all_instructions() -> Vec { - let mut artifacts: Vec = Vec::new(); - - artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Add, "Binary::Add".into())); - artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Sub, "Binary::Sub".into())); - artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Mul, "Binary::Mul".into())); - artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Div, "Binary::Div".into())); - - // with field panic - // panic on Mod Should compile manually written SSA into ACIR: InvalidRangeConstraint - artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Mod, "Binary::Mod".into())); - - artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Eq, "Binary::Eq".into())); - - // with field panic - // thread 'main' panicked at /home/defkit/work/noir/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs:1225:9: - // assertion failed: max_bits + 1 < F::max_num_bits() - artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Lt, "Binary::Lt".into())); - - artifacts.push(InstructionArtifacts::new_binary(BinaryOp::And, "Binary::And".into())); - - // with field - // attempt to shift left with overflow - artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Or, "Binary::Or".into())); - - artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Xor, "Binary::Xor".into())); - - artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Shl, "Binary::Shl".into())); - artifacts.push(InstructionArtifacts::new_binary(BinaryOp::Shr, "Binary::Shr".into())); - - // with field - // attempt to shift left with overflow - artifacts.push(InstructionArtifacts::new_not()); +fn not_function(variable_type: Type) -> Ssa { + // returns not v0 + let main_id = Id::new(0); + let mut builder = FunctionBuilder::new("main".into(), main_id); - artifacts.push(InstructionArtifacts::new_constrain()); - artifacts.push(InstructionArtifacts::new_range_check()); - artifacts.push(InstructionArtifacts::new_truncate()); + let v0 = builder.add_parameter(variable_type); + let v1 = builder.insert_not(v0); + builder.terminate_with_return(vec![v1]); - return artifacts; + return builder.finish() } diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/lib.rs b/noir/noir-repo/compiler/noirc_evaluator/src/lib.rs index cf11b651ede..8c0445455b1 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/lib.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/lib.rs @@ -13,7 +13,7 @@ pub use ssa::create_program; pub use ssa::ir::instruction::ErrorType; pub mod acir_instruction_builder; pub use acir_instruction_builder::{ - all_instructions, InstructionArtifacts + InstructionArtifacts, VariableType, Variable }; /// Trims leading whitespace from each line of the input string, according to diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs index e081e76633a..b6e74865391 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs @@ -4,7 +4,7 @@ use std::io::Read; use std::path::Path; use flate2::read::GzDecoder; use::noirc_evaluator::acir_instruction_builder::{ - all_instructions, InstructionArtifacts + InstructionArtifacts, VariableType, Variable }; fn ungzip(compressed_data: Vec) -> Vec { @@ -21,12 +21,10 @@ fn save_to_file(data: &[u8], filename: &str) -> Result<(), std::io::Error> { Ok(()) } -fn main() { - let all_artifacts: Vec = all_instructions(); - +fn save_artifacts(all_artifacts: Vec) { for artifacts in all_artifacts.iter() { println!("{}", artifacts.formatted_ssa); - let filename = format!("artifacts/{}{}", artifacts.instruction_name, ".public.acir"); + let filename = format!("artifacts/{}{}", artifacts.instruction_name, ".acir"); let acir = &artifacts.serialized_acir; match save_to_file(&ungzip(acir.clone()), &filename) { Ok(_) => (), @@ -34,3 +32,28 @@ fn main() { } } } + +fn main() { + let mut all_artifacts: Vec = Vec::new(); + let u64_var = Variable{ variable_type: VariableType::Unsigned, variable_size: 64}; + let u8_var = Variable{ variable_type: VariableType::Unsigned, variable_size: 8}; + all_artifacts.push(InstructionArtifacts::new_add(&u64_var, &u64_var)); + all_artifacts.push(InstructionArtifacts::new_sub(&u64_var, &u64_var)); + all_artifacts.push(InstructionArtifacts::new_mul(&u64_var, &u64_var)); + all_artifacts.push(InstructionArtifacts::new_mod(&u64_var, &u64_var)); + all_artifacts.push(InstructionArtifacts::new_xor(&u64_var, &u64_var)); + all_artifacts.push(InstructionArtifacts::new_and(&u64_var, &u64_var)); + all_artifacts.push(InstructionArtifacts::new_div(&u64_var, &u64_var)); + all_artifacts.push(InstructionArtifacts::new_eq(&u64_var, &u64_var)); + all_artifacts.push(InstructionArtifacts::new_lt(&u64_var, &u64_var)); + all_artifacts.push(InstructionArtifacts::new_and(&u64_var, &u64_var)); + all_artifacts.push(InstructionArtifacts::new_xor(&u64_var, &u64_var)); + all_artifacts.push(InstructionArtifacts::new_or(&u64_var, &u64_var)); + all_artifacts.push(InstructionArtifacts::new_shl(&u64_var, &u8_var)); + all_artifacts.push(InstructionArtifacts::new_shr(&u64_var, &u8_var)); + all_artifacts.push(InstructionArtifacts::new_not(&u64_var)); + all_artifacts.push(InstructionArtifacts::new_constrain(&u64_var)); + all_artifacts.push(InstructionArtifacts::new_truncate(&u64_var)); + all_artifacts.push(InstructionArtifacts::new_range_check(&u64_var)); + save_artifacts(all_artifacts); +} From 4f0710533b6906051a9c7d8fd389e1ba33faa9d7 Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Mon, 2 Dec 2024 12:05:04 +0000 Subject: [PATCH 17/32] ples have a patient i have problems --- .../src/.acir_instruction_builder.rs.swp | Bin 16384 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 noir/noir-repo/compiler/noirc_evaluator/src/.acir_instruction_builder.rs.swp diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/.acir_instruction_builder.rs.swp b/noir/noir-repo/compiler/noirc_evaluator/src/.acir_instruction_builder.rs.swp deleted file mode 100644 index 02cd36050cef256e1387e61f3e2501f830d14d15..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI3UyLM09mh*igah=D1TjQYwm-K*YCfu@;HCEv&e8AX6*StuWUS4EwP=~XIU(J7nLTDYhNm# zU;O0J`D2UoN9P|re)X_lstqoLm$Z!L^Dw#?Zpd;W%~WAN<_no;3sE-6RU&JrD3F_B zQiVDz7Rn-82qRSlDlK(UMOtNPuwJPomPMy1ub!^=@d|haNP*kfv7?Lk)31AGj_^A^ z{2BV`FRy@Cz$@St@CtYZyaHYUuYgzJ|3m?u-@v|%vcA`rH?!aGnfU&Xy?WL?pYXrI z-rr@ve>>rCZ~d27z$@St@CtYZyaHYUuYgy;E8rFI3U~#)0`GzXVa(Ver27Y2@Z6&06O4S@VDC- zdl~!yd>ac~aY2W|m}z@Khq?C0QT;05q)@HBV`ynYK~FM?lyZ-BGl40s6K2wp>> zz6UgT2E-r&H-XDHGxjV{pbw6Nf84~_-@#?@9QX=&4BQQF2ZzBSa5MPJ2N?SncouvU z?14vs01tyZ!OJ%?_ABs9@LlkEZ~?4=F1Q2y_5Fj3373}tzg#gqqgOr%$(QO7#9<~lkHHf7YB zl73Vb1qvB#DV@r)#QBm~Zo5XN27t-22$Pm^QiYV{pW;?iM}F1gw$PhlQ92%p)Z9iC zO}z1%7*!gD9qB9hskK7NuGC9U)#W&eq(?&7TC!P|Lm4|Ng)$1Vqd-xXBr-xJkEb%I zG#{^ow@OV>^*4fEUt+zi7-g5MbaX=peacRqMQCN(4;9{#Q1JCEOHklmh=yM0eqn*H ztvY$yU|4elL0EwyG(6)H*8hSSyB{LFS< zph-f2r&O%_j$hpmNru+2l1)L{e7!c*<^lfZkomF4prVzKkxq z2|h{Ar^$6{l1{9*m1>%4H?=1+JvA8wdt2rsbPZjEDs>Y%-8fE7Y8Yi&f<|qsw2`26 zSIR<#iMk|X(gXdaLwg}H|=Kpp2lM2TBRG4gC+)nL5MCB2PWFs?f8SkJp@S2 zSfGQAjs=p-D7@QHD2LQ*oE+H#prbg=T8LqYpy>j$_J`Af%{Wwdgu0_m>o@M0K@rA^ zg=qEtk=D%a-b|Z1-$Vk#oETXUVHPg244x^oREUw7vlO*crCUXqPmba6vKicvsVv-H z*95hltm&PI5$p>qcrUf>rVQKrG{*>G>h&7^(>JVPb^Z@EtaX)!MLn$3Q>c~YwhcFp z%J{<>GY9i?HNU>rqXv1xS4LfXxzLK9=QL}wPa4bv-0n$R9Y0wQ0(kJP?`T=_ ztY@Ybn9Z1nT8Dr7lFD-#A30J#)hA4$3p6cyXlT^+oJ7qdmeJTk7RLJbego);1-t@Y0k42pz$@St@CtYZyaNB73e>wcb|*J%*5FtunT1Dl-^r`8-nK+zt12530lz)5)0W#5H{|rS{qW zZ02SgckiI>RoC?Dm}P2_?^aDMr?Dd^?%u&7pVN-%bEDS?PU9@GH$&TRcnyYsp^pXL dL~RG_3Y%s3@kPGG&(a3Sc92#B Date: Tue, 3 Dec 2024 05:49:08 +0000 Subject: [PATCH 18/32] verif changes --- .../acir_formal_proofs/acir_loader.cpp | 15 +- .../acir_formal_proofs/acir_loader.hpp | 5 +- .../acir_formal_proofs/acir_loader.test.cpp | 239 ++++++++++++------ 3 files changed, 169 insertions(+), 90 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp index b6519e46314..cb6e9fe67d5 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp @@ -31,24 +31,25 @@ AcirToSmtLoader::AcirToSmtLoader(std::string filename) this->acir_program_buf = readFile(filename); this->instruction_name = filename; this->constraint_system = acir_format::program_buf_to_acir_format(this->acir_program_buf, false).at(0); + this->circuit_buf = this->get_circuit_builder().export_circuit(); +} + +bb::UltraCircuitBuilder AcirToSmtLoader::get_circuit_builder() +{ bb::UltraCircuitBuilder builder = acir_format::create_circuit(this->constraint_system, false); - // naming first three variables - // for binary noir sets indices as 0 1 2 - // for unary noir sets indices as 0 1 builder.set_variable_name(0, "a"); builder.set_variable_name(1, "b"); builder.set_variable_name(2, "c"); - builder.set_variable_name(3, "d"); - this->circuit_buf = builder.export_circuit(); + return builder; } -smt_solver::Solver AcirToSmtLoader::get_solver() +smt_solver::Solver AcirToSmtLoader::get_smt_solver() { smt_circuit::CircuitSchema circuit_info = smt_circuit_schema::unpack_from_buffer(this->circuit_buf); return smt_solver::Solver(circuit_info.modulus); } -smt_circuit::UltraCircuit AcirToSmtLoader::get_circuit(smt_solver::Solver* solver) +smt_circuit::UltraCircuit AcirToSmtLoader::get_smt_circuit(smt_solver::Solver* solver) { smt_circuit::CircuitSchema circuit_info = smt_circuit_schema::unpack_from_buffer(this->circuit_buf); return smt_circuit::UltraCircuit(circuit_info, solver, smt_terms::TermType::BVTerm); diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp index 44fb26baa84..eb4d50aa41d 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp @@ -17,8 +17,9 @@ class AcirToSmtLoader { AcirToSmtLoader(std::string filename); acir_format::AcirFormat& get_constraint_systems() { return this->constraint_system; } - smt_solver::Solver get_solver(); - smt_circuit::UltraCircuit get_circuit(smt_solver::Solver* solver); + bb::UltraCircuitBuilder get_circuit_builder(); + smt_solver::Solver get_smt_solver(); + smt_circuit::UltraCircuit get_smt_circuit(smt_solver::Solver* solver); private: std::string instruction_name; diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp index 6236bdf2f77..429a74ce875 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp @@ -4,16 +4,39 @@ #include "barretenberg/dsl/acir_format/acir_format.hpp" #include "barretenberg/smt_verification/circuit/ultra_circuit.hpp" #include "barretenberg/smt_verification/solver/solver.hpp" +#include "barretenberg/smt_verification/util/smt_util.hpp" #include "barretenberg/stdlib/client_ivc_verifier/client_ivc_recursive_verifier.hpp" #include "barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp" -#include "barretenberg/circuit_checker/circuit_checker.hpp" #include +// defkit/print_assertions TODO delete all print_assertions from tests +const std::string ARTIFACTS_PATH = "../src/barretenberg/acir_formal_proofs/artifacts/"; + +// saves to ARTIFACTS_PATH/{instruction_name}.witness +void save_buggy_witness(std::string instruction_name, smt_circuit::UltraCircuit circuit) +{ + // stay it empty, dont want to see them in stdout + std::vector special_names; + info("Saving bug for op ", instruction_name); + default_model_single(special_names, circuit, ARTIFACTS_PATH + instruction_name + ".witness"); +} + +bool verify_buggy_witness(std::string instruction_name) +{ + std::vector witness = import_witness_single(ARTIFACTS_PATH + instruction_name + ".witness.pack"); + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + instruction_name + ".acir"); + bb::UltraCircuitBuilder builder = loader.get_circuit_builder(); + for (uint i = 0; i < witness.size(); i++) { + builder.variables[i] = witness[i]; + } + return bb::CircuitChecker::check(builder); +} + TEST(acir_formal_proofs, uint_terms_add) { - AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Add.acir"); - smt_solver::Solver solver = loader.get_solver(); - smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Add.acir"); + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); auto a = circuit["a"]; auto b = circuit["b"]; auto c = circuit["c"]; @@ -23,13 +46,17 @@ TEST(acir_formal_proofs, uint_terms_add) solver.print_assertions(); info(solver.getResult()); EXPECT_FALSE(res); + + if (res) { + save_buggy_witness("Binary::Add", circuit); + } } TEST(acir_formal_proofs, uint_terms_mul) { - AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Mul.acir"); - smt_solver::Solver solver = loader.get_solver(); - smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Mul.acir"); + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); auto a = circuit["a"]; auto b = circuit["b"]; auto c = circuit["c"]; @@ -39,13 +66,17 @@ TEST(acir_formal_proofs, uint_terms_mul) solver.print_assertions(); info(solver.getResult()); EXPECT_FALSE(res); + + if (res) { + save_buggy_witness("Binary::Mul", circuit); + } } TEST(acir_formal_proofs, uint_terms_and) { - AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::And.acir"); - smt_solver::Solver solver = loader.get_solver(); - smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::And.acir"); + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); auto a = circuit["a"]; auto b = circuit["b"]; auto c = circuit["c"]; @@ -55,67 +86,94 @@ TEST(acir_formal_proofs, uint_terms_and) solver.print_assertions(); info(solver.getResult()); EXPECT_FALSE(res); - - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); - std::unordered_map vals = solver.model(terms); - info("a = ", vals["a"]); - info("b = ", vals["b"]); - info("c = ", vals["c"]); - info("c_res = ", vals["cr"]); - + if (res) { + save_buggy_witness("Binary::And", circuit); + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + std::unordered_map vals = solver.model(terms); + info("a = ", vals["a"]); + info("b = ", vals["b"]); + info("c = ", vals["c"]); + info("c_res = ", vals["cr"]); + } } -/*TEST(acir_formal_proofs, uint_terms_div) +TEST(acir_formal_proofs, uint_terms_div) { AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Div.acir"); - smt_solver::Solver solver = loader.get_solver(); - smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); - // c = a // b - // a = b * c + k where k < b - // k = a - b * c - // + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); auto a = circuit["a"]; auto b = circuit["b"]; auto c = circuit["c"]; - auto cr = a - c * b; - cr < b; + auto cr = a / b; + c == cr; bool res = solver.check(); solver.print_assertions(); info(solver.getResult()); - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); - std::unordered_map vals = solver.model(terms); - info("a = ", vals["a"]); - info("b = ", vals["b"]); - info("c = ", vals["c"]); - info("c_res = ", vals["cr"]); + EXPECT_FALSE(res); + if (res) { + save_buggy_witness("Binary::Div", circuit); + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + std::unordered_map vals = solver.model(terms); + info("a = ", vals["a"]); + info("b = ", vals["b"]); + info("c = ", vals["c"]); + info("c_res = ", vals["cr"]); + } +} +// checks to times +// if a == b c must be 0 +// if a != b must be 1 +TEST(acir_formal_proofs, uint_terms_eq_on_equality) +{ + AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Eq.acir"); + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + a == b; + c != 1; + bool res = solver.check(); + solver.print_assertions(); + info(solver.getResult()); EXPECT_FALSE(res); -}*/ + if (res) { + save_buggy_witness("Binary::Eq", circuit); + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c } }); + std::unordered_map vals = solver.model(terms); + info("a = ", vals["a"]); + info("b = ", vals["b"]); + info("c = ", vals["c"]); + } +} -/* TEST(acir_formal_proofs, uint_terms_eq) +TEST(acir_formal_proofs, uint_terms_eq_on_inequality) { AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Eq.acir"); - smt_solver::Solver solver = loader.get_solver(); - smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); - // c is bool var = (a == b) - // so if c is True a - b == 0 - // if c is False a - b == k - // so if circuit is correct - // ( a - b ) * (c ^ 1) == 0 - // if a - b != 0 and c is True k * (a - b) = 0, circuit is incorrect - // if a - b == 0 + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); auto a = circuit["a"]; auto b = circuit["b"]; auto c = circuit["c"]; - auto cr = a == b; - c != cr; + a != b; + c != 0; bool res = solver.check(); solver.print_assertions(); info(solver.getResult()); EXPECT_FALSE(res); -} */ + if (res) { + save_buggy_witness("Binary::Eq", circuit); + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c } }); + std::unordered_map vals = solver.model(terms); + info("a = ", vals["a"]); + info("b = ", vals["b"]); + info("c = ", vals["c"]); + } +} -/* TEST(acir_formal_proofs, uint_terms_lt) +/*TEST(acir_formal_proofs, uint_terms_lt) { AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Lt.acir"); smt_solver::Solver solver = loader.get_solver(); @@ -129,13 +187,14 @@ TEST(acir_formal_proofs, uint_terms_and) solver.print_assertions(); info(solver.getResult()); EXPECT_FALSE(res); -} */ +} +*/ TEST(acir_formal_proofs, uint_terms_mod) { - AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Mod.acir"); - smt_solver::Solver solver = loader.get_solver(); - smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Mod.acir"); + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); // c = a mod b // k * b + c = a // k = (a - c) / b @@ -150,13 +209,16 @@ TEST(acir_formal_proofs, uint_terms_mod) solver.print_assertions(); info(solver.getResult()); EXPECT_FALSE(res); + if (res) { + save_buggy_witness("Binary::Mod", circuit); + } } TEST(acir_formal_proofs, uint_terms_or) { - AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Or.acir"); - smt_solver::Solver solver = loader.get_solver(); - smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Or.acir"); + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); auto a = circuit["a"]; auto b = circuit["b"]; auto c = circuit["c"]; @@ -166,17 +228,18 @@ TEST(acir_formal_proofs, uint_terms_or) solver.print_assertions(); info(solver.getResult()); EXPECT_FALSE(res); - - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); - std::unordered_map vals = solver.model(terms); - info("a = ", vals["a"]); - info("b = ", vals["b"]); - info("c = ", vals["c"]); - info("c_res = ", vals["cr"]); - + if (res) { + save_buggy_witness("Binary::Or", circuit); + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + std::unordered_map vals = solver.model(terms); + info("a = ", vals["a"]); + info("b = ", vals["b"]); + info("c = ", vals["c"]); + info("c_res = ", vals["cr"]); + } } -/*TEST(acir_formal_proofs, uint_terms_shl) +/* TEST(acir_formal_proofs, uint_terms_shl) { AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Shl.acir"); smt_solver::Solver solver = loader.get_solver(); @@ -191,8 +254,9 @@ TEST(acir_formal_proofs, uint_terms_or) info(solver.getResult()); EXPECT_FALSE(res); } +*/ -TEST(acir_formal_proofs, uint_terms_shr) +/*TEST(acir_formal_proofs, uint_terms_shr) { AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Shr.acir"); smt_solver::Solver solver = loader.get_solver(); @@ -210,9 +274,9 @@ TEST(acir_formal_proofs, uint_terms_shr) TEST(acir_formal_proofs, uint_terms_sub) { - AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Sub.acir"); - smt_solver::Solver solver = loader.get_solver(); - smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Sub.acir"); + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); auto a = circuit["a"]; auto b = circuit["b"]; auto c = circuit["c"]; @@ -222,13 +286,16 @@ TEST(acir_formal_proofs, uint_terms_sub) solver.print_assertions(); info(solver.getResult()); EXPECT_FALSE(res); + if (res) { + save_buggy_witness("Binary::Sub", circuit); + } } TEST(acir_formal_proofs, uint_terms_xor) { - AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Xor.acir"); - smt_solver::Solver solver = loader.get_solver(); - smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Xor.acir"); + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); auto a = circuit["a"]; auto b = circuit["b"]; auto c = circuit["c"]; @@ -238,19 +305,28 @@ TEST(acir_formal_proofs, uint_terms_xor) solver.print_assertions(); info(solver.getResult()); EXPECT_FALSE(res); - - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); - std::unordered_map vals = solver.model(terms); - info("a = ", vals["a"]); - info("b = ", vals["b"]); - info("c = ", vals["c"]); - info("c_res = ", vals["cr"]); + if (res) { + save_buggy_witness("Binary::Xor", circuit); + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + std::unordered_map vals = solver.model(terms); + info("a = ", vals["a"]); + info("b = ", vals["b"]); + info("c = ", vals["c"]); + info("c_res = ", vals["cr"]); + } } +// if failed, bug NOT verified +// fali on file not found or check circuit +TEST(acir_formal_proofs, uint_terms_and_verify_bug) +{ + EXPECT_TRUE(verify_buggy_witness("Binary::And")); +} -TEST(acir_circuit_check, uint_terms_add) +/*TEST(acir_circuit_check, uint_terms_add) { - AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Add.public.acir"); + AcirToSmtLoader loader = + AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Add.public.acir"); bb::UltraCircuitBuilder builder = acir_format::create_circuit(loader.get_constraint_systems(), false); // naming first three variables // for binary noir sets indices as 0 1 2 @@ -266,4 +342,5 @@ TEST(acir_circuit_check, uint_terms_add) builder.variables[3] = 2; // builder.variables[4] = 1; EXPECT_TRUE(bb::CircuitChecker::check(builder)); -} \ No newline at end of file +} +*/ \ No newline at end of file From 802b0cd6a978dc966a3d1789f215430a3af41866 Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Mon, 9 Dec 2024 09:39:34 +0000 Subject: [PATCH 19/32] smol shifts --- .../acir_formal_proofs/acir_loader.test.cpp | 1266 ++++++++++++++++- .../shift_codegen/codegen.py | 161 +++ .../acir_formal_proofs/shift_codegen/shl.cpp | 585 ++++++++ .../acir_formal_proofs/shift_codegen/shl.ssa | 588 ++++++++ .../acir_formal_proofs/shift_codegen/shr.cpp | 585 ++++++++ .../acir_formal_proofs/shift_codegen/shr.ssa | 588 ++++++++ 6 files changed, 3749 insertions(+), 24 deletions(-) create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/codegen.py create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shl.cpp create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shl.ssa create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shr.cpp create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shr.ssa diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp index 429a74ce875..0611bba4684 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp @@ -28,6 +28,9 @@ bool verify_buggy_witness(std::string instruction_name) bb::UltraCircuitBuilder builder = loader.get_circuit_builder(); for (uint i = 0; i < witness.size(); i++) { builder.variables[i] = witness[i]; + if (i < 100) { + info(witness[i]); + } } return bb::CircuitChecker::check(builder); } @@ -66,7 +69,6 @@ TEST(acir_formal_proofs, uint_terms_mul) solver.print_assertions(); info(solver.getResult()); EXPECT_FALSE(res); - if (res) { save_buggy_witness("Binary::Mul", circuit); } @@ -161,6 +163,7 @@ TEST(acir_formal_proofs, uint_terms_eq_on_inequality) c != 0; bool res = solver.check(); solver.print_assertions(); + info(solver.getResult()); EXPECT_FALSE(res); if (res) { @@ -176,19 +179,35 @@ TEST(acir_formal_proofs, uint_terms_eq_on_inequality) /*TEST(acir_formal_proofs, uint_terms_lt) { AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Lt.acir"); - smt_solver::Solver solver = loader.get_solver(); - smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); + auto a = smt_circuit::BVVar("a", &solver); + auto b = smt_circuit::BVVar("b", &solver); + auto c = smt_circuit::BVVar("c", &solver); + a < b; + c != 1; + bool res = solver.check(); + solver.print_assertions(); + info(solver.getResult()); + EXPECT_FALSE(res); +}*/ + +/*TEST(acir_formal_proofs, uint_terms_gt) +{ + AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Lt.acir"); + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); + auto a = circuit["a"]; auto b = circuit["b"]; auto c = circuit["c"]; - auto cr = a < b; - c != cr; + a > b; + c != 0; bool res = solver.check(); solver.print_assertions(); info(solver.getResult()); EXPECT_FALSE(res); -} -*/ +}*/ TEST(acir_formal_proofs, uint_terms_mod) { @@ -204,6 +223,7 @@ TEST(acir_formal_proofs, uint_terms_mod) smt_circuit::STerm c = circuit["c"]; smt_circuit::STerm c1 = (a - c) * b + c * b; smt_circuit::STerm c2 = a * b; + c1 != c2; bool res = solver.check(); solver.print_assertions(); @@ -239,38 +259,1211 @@ TEST(acir_formal_proofs, uint_terms_or) } } -/* TEST(acir_formal_proofs, uint_terms_shl) +TEST(acir_formal_proofs, uint_terms_shl) { AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Shl.acir"); - smt_solver::Solver solver = loader.get_solver(); - smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - auto cr = a << b; + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); + auto a = smt_circuit::BVVar("a", &solver); + auto b = smt_circuit::BVVar("b", &solver); + auto c = smt_circuit::BVVar("c", &solver); + auto v0 = a; + auto v1 = b; + auto v5 = smt_terms::BVConst("1", &solver, 10); + auto v6 = v5; + auto v7 = v1; + auto v9 = v7; + auto v12 = v9 & smt_terms::BVConst("9223372036854775808", &solver, 10); + auto v13 = v12 ^ smt_terms::BVConst("1", &solver, 10); + auto v14 = v12; + auto v15 = v13; + auto v16 = v14 * smt_terms::BVConst("2", &solver, 10); + auto v17 = v16 + v15; + auto v18 = v17 * v17; + auto v19 = v18 * smt_terms::BVConst("2", &solver, 10); + auto v21 = v9 & smt_terms::BVConst("4611686018427387904", &solver, 10); + auto v22 = v21 ^ smt_terms::BVConst("1", &solver, 10); + auto v23 = v21; + auto v24 = v22; + auto v25 = v19 * v23; + auto v26 = v18 * v24; + auto v27 = v25 + v26; + auto v28 = v27 * v27; + auto v29 = v28 * smt_terms::BVConst("2", &solver, 10); + auto v31 = v9 & smt_terms::BVConst("2305843009213693952", &solver, 10); + auto v32 = v31 ^ smt_terms::BVConst("1", &solver, 10); + auto v33 = v31; + auto v34 = v32; + auto v35 = v29 * v33; + auto v36 = v28 * v34; + auto v37 = v35 + v36; + auto v38 = v37 * v37; + auto v39 = v38 * smt_terms::BVConst("2", &solver, 10); + auto v41 = v9 & smt_terms::BVConst("1152921504606846976", &solver, 10); + auto v42 = v41 ^ smt_terms::BVConst("1", &solver, 10); + auto v43 = v41; + auto v44 = v42; + auto v45 = v39 * v43; + auto v46 = v38 * v44; + auto v47 = v45 + v46; + auto v48 = v47 * v47; + auto v49 = v48 * smt_terms::BVConst("2", &solver, 10); + auto v51 = v9 & smt_terms::BVConst("576460752303423488", &solver, 10); + auto v52 = v51 ^ smt_terms::BVConst("1", &solver, 10); + auto v53 = v51; + auto v54 = v52; + auto v55 = v49 * v53; + auto v56 = v48 * v54; + auto v57 = v55 + v56; + auto v58 = v57 * v57; + auto v59 = v58 * smt_terms::BVConst("2", &solver, 10); + auto v61 = v9 & smt_terms::BVConst("288230376151711744", &solver, 10); + auto v62 = v61 ^ smt_terms::BVConst("1", &solver, 10); + auto v63 = v61; + auto v64 = v62; + auto v65 = v59 * v63; + auto v66 = v58 * v64; + auto v67 = v65 + v66; + auto v68 = v67 * v67; + auto v69 = v68 * smt_terms::BVConst("2", &solver, 10); + auto v71 = v9 & smt_terms::BVConst("144115188075855872", &solver, 10); + auto v72 = v71 ^ smt_terms::BVConst("1", &solver, 10); + auto v73 = v71; + auto v74 = v72; + auto v75 = v69 * v73; + auto v76 = v68 * v74; + auto v77 = v75 + v76; + auto v78 = v77 * v77; + auto v79 = v78 * smt_terms::BVConst("2", &solver, 10); + auto v81 = v9 & smt_terms::BVConst("72057594037927936", &solver, 10); + auto v82 = v81 ^ smt_terms::BVConst("1", &solver, 10); + auto v83 = v81; + auto v84 = v82; + auto v85 = v79 * v83; + auto v86 = v78 * v84; + auto v87 = v85 + v86; + auto v88 = v87 * v87; + auto v89 = v88 * smt_terms::BVConst("2", &solver, 10); + auto v91 = v9 & smt_terms::BVConst("36028797018963968", &solver, 10); + auto v92 = v91 ^ smt_terms::BVConst("1", &solver, 10); + auto v93 = v91; + auto v94 = v92; + auto v95 = v89 * v93; + auto v96 = v88 * v94; + auto v97 = v95 + v96; + auto v98 = v97 * v97; + auto v99 = v98 * smt_terms::BVConst("2", &solver, 10); + auto v101 = v9 & smt_terms::BVConst("18014398509481984", &solver, 10); + auto v102 = v101 ^ smt_terms::BVConst("1", &solver, 10); + auto v103 = v101; + auto v104 = v102; + auto v105 = v99 * v103; + auto v106 = v98 * v104; + auto v107 = v105 + v106; + auto v108 = v107 * v107; + auto v109 = v108 * smt_terms::BVConst("2", &solver, 10); + auto v111 = v9 & smt_terms::BVConst("9007199254740992", &solver, 10); + auto v112 = v111 ^ smt_terms::BVConst("1", &solver, 10); + auto v113 = v111; + auto v114 = v112; + auto v115 = v109 * v113; + auto v116 = v108 * v114; + auto v117 = v115 + v116; + auto v118 = v117 * v117; + auto v119 = v118 * smt_terms::BVConst("2", &solver, 10); + auto v121 = v9 & smt_terms::BVConst("4503599627370496", &solver, 10); + auto v122 = v121 ^ smt_terms::BVConst("1", &solver, 10); + auto v123 = v121; + auto v124 = v122; + auto v125 = v119 * v123; + auto v126 = v118 * v124; + auto v127 = v125 + v126; + auto v128 = v127 * v127; + auto v129 = v128 * smt_terms::BVConst("2", &solver, 10); + auto v131 = v9 & smt_terms::BVConst("2251799813685248", &solver, 10); + auto v132 = v131 ^ smt_terms::BVConst("1", &solver, 10); + auto v133 = v131; + auto v134 = v132; + auto v135 = v129 * v133; + auto v136 = v128 * v134; + auto v137 = v135 + v136; + auto v138 = v137 * v137; + auto v139 = v138 * smt_terms::BVConst("2", &solver, 10); + auto v141 = v9 & smt_terms::BVConst("1125899906842624", &solver, 10); + auto v142 = v141 ^ smt_terms::BVConst("1", &solver, 10); + auto v143 = v141; + auto v144 = v142; + auto v145 = v139 * v143; + auto v146 = v138 * v144; + auto v147 = v145 + v146; + auto v148 = v147 * v147; + auto v149 = v148 * smt_terms::BVConst("2", &solver, 10); + auto v151 = v9 & smt_terms::BVConst("562949953421312", &solver, 10); + auto v152 = v151 ^ smt_terms::BVConst("1", &solver, 10); + auto v153 = v151; + auto v154 = v152; + auto v155 = v149 * v153; + auto v156 = v148 * v154; + auto v157 = v155 + v156; + auto v158 = v157 * v157; + auto v159 = v158 * smt_terms::BVConst("2", &solver, 10); + auto v161 = v9 & smt_terms::BVConst("281474976710656", &solver, 10); + auto v162 = v161 ^ smt_terms::BVConst("1", &solver, 10); + auto v163 = v161; + auto v164 = v162; + auto v165 = v159 * v163; + auto v166 = v158 * v164; + auto v167 = v165 + v166; + auto v168 = v167 * v167; + auto v169 = v168 * smt_terms::BVConst("2", &solver, 10); + auto v171 = v9 & smt_terms::BVConst("140737488355328", &solver, 10); + auto v172 = v171 ^ smt_terms::BVConst("1", &solver, 10); + auto v173 = v171; + auto v174 = v172; + auto v175 = v169 * v173; + auto v176 = v168 * v174; + auto v177 = v175 + v176; + auto v178 = v177 * v177; + auto v179 = v178 * smt_terms::BVConst("2", &solver, 10); + auto v181 = v9 & smt_terms::BVConst("70368744177664", &solver, 10); + auto v182 = v181 ^ smt_terms::BVConst("1", &solver, 10); + auto v183 = v181; + auto v184 = v182; + auto v185 = v179 * v183; + auto v186 = v178 * v184; + auto v187 = v185 + v186; + auto v188 = v187 * v187; + auto v189 = v188 * smt_terms::BVConst("2", &solver, 10); + auto v191 = v9 & smt_terms::BVConst("35184372088832", &solver, 10); + auto v192 = v191 ^ smt_terms::BVConst("1", &solver, 10); + auto v193 = v191; + auto v194 = v192; + auto v195 = v189 * v193; + auto v196 = v188 * v194; + auto v197 = v195 + v196; + auto v198 = v197 * v197; + auto v199 = v198 * smt_terms::BVConst("2", &solver, 10); + auto v201 = v9 & smt_terms::BVConst("17592186044416", &solver, 10); + auto v202 = v201 ^ smt_terms::BVConst("1", &solver, 10); + auto v203 = v201; + auto v204 = v202; + auto v205 = v199 * v203; + auto v206 = v198 * v204; + auto v207 = v205 + v206; + auto v208 = v207 * v207; + auto v209 = v208 * smt_terms::BVConst("2", &solver, 10); + auto v211 = v9 & smt_terms::BVConst("8796093022208", &solver, 10); + auto v212 = v211 ^ smt_terms::BVConst("1", &solver, 10); + auto v213 = v211; + auto v214 = v212; + auto v215 = v209 * v213; + auto v216 = v208 * v214; + auto v217 = v215 + v216; + auto v218 = v217 * v217; + auto v219 = v218 * smt_terms::BVConst("2", &solver, 10); + auto v221 = v9 & smt_terms::BVConst("4398046511104", &solver, 10); + auto v222 = v221 ^ smt_terms::BVConst("1", &solver, 10); + auto v223 = v221; + auto v224 = v222; + auto v225 = v219 * v223; + auto v226 = v218 * v224; + auto v227 = v225 + v226; + auto v228 = v227 * v227; + auto v229 = v228 * smt_terms::BVConst("2", &solver, 10); + auto v231 = v9 & smt_terms::BVConst("2199023255552", &solver, 10); + auto v232 = v231 ^ smt_terms::BVConst("1", &solver, 10); + auto v233 = v231; + auto v234 = v232; + auto v235 = v229 * v233; + auto v236 = v228 * v234; + auto v237 = v235 + v236; + auto v238 = v237 * v237; + auto v239 = v238 * smt_terms::BVConst("2", &solver, 10); + auto v241 = v9 & smt_terms::BVConst("1099511627776", &solver, 10); + auto v242 = v241 ^ smt_terms::BVConst("1", &solver, 10); + auto v243 = v241; + auto v244 = v242; + auto v245 = v239 * v243; + auto v246 = v238 * v244; + auto v247 = v245 + v246; + auto v248 = v247 * v247; + auto v249 = v248 * smt_terms::BVConst("2", &solver, 10); + auto v251 = v9 & smt_terms::BVConst("549755813888", &solver, 10); + auto v252 = v251 ^ smt_terms::BVConst("1", &solver, 10); + auto v253 = v251; + auto v254 = v252; + auto v255 = v249 * v253; + auto v256 = v248 * v254; + auto v257 = v255 + v256; + auto v258 = v257 * v257; + auto v259 = v258 * smt_terms::BVConst("2", &solver, 10); + auto v261 = v9 & smt_terms::BVConst("274877906944", &solver, 10); + auto v262 = v261 ^ smt_terms::BVConst("1", &solver, 10); + auto v263 = v261; + auto v264 = v262; + auto v265 = v259 * v263; + auto v266 = v258 * v264; + auto v267 = v265 + v266; + auto v268 = v267 * v267; + auto v269 = v268 * smt_terms::BVConst("2", &solver, 10); + auto v271 = v9 & smt_terms::BVConst("137438953472", &solver, 10); + auto v272 = v271 ^ smt_terms::BVConst("1", &solver, 10); + auto v273 = v271; + auto v274 = v272; + auto v275 = v269 * v273; + auto v276 = v268 * v274; + auto v277 = v275 + v276; + auto v278 = v277 * v277; + auto v279 = v278 * smt_terms::BVConst("2", &solver, 10); + auto v281 = v9 & smt_terms::BVConst("68719476736", &solver, 10); + auto v282 = v281 ^ smt_terms::BVConst("1", &solver, 10); + auto v283 = v281; + auto v284 = v282; + auto v285 = v279 * v283; + auto v286 = v278 * v284; + auto v287 = v285 + v286; + auto v288 = v287 * v287; + auto v289 = v288 * smt_terms::BVConst("2", &solver, 10); + auto v291 = v9 & smt_terms::BVConst("34359738368", &solver, 10); + auto v292 = v291 ^ smt_terms::BVConst("1", &solver, 10); + auto v293 = v291; + auto v294 = v292; + auto v295 = v289 * v293; + auto v296 = v288 * v294; + auto v297 = v295 + v296; + auto v298 = v297 * v297; + auto v299 = v298 * smt_terms::BVConst("2", &solver, 10); + auto v301 = v9 & smt_terms::BVConst("17179869184", &solver, 10); + auto v302 = v301 ^ smt_terms::BVConst("1", &solver, 10); + auto v303 = v301; + auto v304 = v302; + auto v305 = v299 * v303; + auto v306 = v298 * v304; + auto v307 = v305 + v306; + auto v308 = v307 * v307; + auto v309 = v308 * smt_terms::BVConst("2", &solver, 10); + auto v311 = v9 & smt_terms::BVConst("8589934592", &solver, 10); + auto v312 = v311 ^ smt_terms::BVConst("1", &solver, 10); + auto v313 = v311; + auto v314 = v312; + auto v315 = v309 * v313; + auto v316 = v308 * v314; + auto v317 = v315 + v316; + auto v318 = v317 * v317; + auto v319 = v318 * smt_terms::BVConst("2", &solver, 10); + auto v321 = v9 & smt_terms::BVConst("4294967296", &solver, 10); + auto v322 = v321 ^ smt_terms::BVConst("1", &solver, 10); + auto v323 = v321; + auto v324 = v322; + auto v325 = v319 * v323; + auto v326 = v318 * v324; + auto v327 = v325 + v326; + auto v328 = v327 * v327; + auto v329 = v328 * smt_terms::BVConst("2", &solver, 10); + auto v331 = v9 & smt_terms::BVConst("2147483648", &solver, 10); + auto v332 = v331 ^ smt_terms::BVConst("1", &solver, 10); + auto v333 = v331; + auto v334 = v332; + auto v335 = v329 * v333; + auto v336 = v328 * v334; + auto v337 = v335 + v336; + auto v338 = v337 * v337; + auto v339 = v338 * smt_terms::BVConst("2", &solver, 10); + auto v341 = v9 & smt_terms::BVConst("1073741824", &solver, 10); + auto v342 = v341 ^ smt_terms::BVConst("1", &solver, 10); + auto v343 = v341; + auto v344 = v342; + auto v345 = v339 * v343; + auto v346 = v338 * v344; + auto v347 = v345 + v346; + auto v348 = v347 * v347; + auto v349 = v348 * smt_terms::BVConst("2", &solver, 10); + auto v351 = v9 & smt_terms::BVConst("536870912", &solver, 10); + auto v352 = v351 ^ smt_terms::BVConst("1", &solver, 10); + auto v353 = v351; + auto v354 = v352; + auto v355 = v349 * v353; + auto v356 = v348 * v354; + auto v357 = v355 + v356; + auto v358 = v357 * v357; + auto v359 = v358 * smt_terms::BVConst("2", &solver, 10); + auto v361 = v9 & smt_terms::BVConst("268435456", &solver, 10); + auto v362 = v361 ^ smt_terms::BVConst("1", &solver, 10); + auto v363 = v361; + auto v364 = v362; + auto v365 = v359 * v363; + auto v366 = v358 * v364; + auto v367 = v365 + v366; + auto v368 = v367 * v367; + auto v369 = v368 * smt_terms::BVConst("2", &solver, 10); + auto v371 = v9 & smt_terms::BVConst("134217728", &solver, 10); + auto v372 = v371 ^ smt_terms::BVConst("1", &solver, 10); + auto v373 = v371; + auto v374 = v372; + auto v375 = v369 * v373; + auto v376 = v368 * v374; + auto v377 = v375 + v376; + auto v378 = v377 * v377; + auto v379 = v378 * smt_terms::BVConst("2", &solver, 10); + auto v381 = v9 & smt_terms::BVConst("67108864", &solver, 10); + auto v382 = v381 ^ smt_terms::BVConst("1", &solver, 10); + auto v383 = v381; + auto v384 = v382; + auto v385 = v379 * v383; + auto v386 = v378 * v384; + auto v387 = v385 + v386; + auto v388 = v387 * v387; + auto v389 = v388 * smt_terms::BVConst("2", &solver, 10); + auto v391 = v9 & smt_terms::BVConst("33554432", &solver, 10); + auto v392 = v391 ^ smt_terms::BVConst("1", &solver, 10); + auto v393 = v391; + auto v394 = v392; + auto v395 = v389 * v393; + auto v396 = v388 * v394; + auto v397 = v395 + v396; + auto v398 = v397 * v397; + auto v399 = v398 * smt_terms::BVConst("2", &solver, 10); + auto v401 = v9 & smt_terms::BVConst("16777216", &solver, 10); + auto v402 = v401 ^ smt_terms::BVConst("1", &solver, 10); + auto v403 = v401; + auto v404 = v402; + auto v405 = v399 * v403; + auto v406 = v398 * v404; + auto v407 = v405 + v406; + auto v408 = v407 * v407; + auto v409 = v408 * smt_terms::BVConst("2", &solver, 10); + auto v411 = v9 & smt_terms::BVConst("8388608", &solver, 10); + auto v412 = v411 ^ smt_terms::BVConst("1", &solver, 10); + auto v413 = v411; + auto v414 = v412; + auto v415 = v409 * v413; + auto v416 = v408 * v414; + auto v417 = v415 + v416; + auto v418 = v417 * v417; + auto v419 = v418 * smt_terms::BVConst("2", &solver, 10); + auto v421 = v9 & smt_terms::BVConst("4194304", &solver, 10); + auto v422 = v421 ^ smt_terms::BVConst("1", &solver, 10); + auto v423 = v421; + auto v424 = v422; + auto v425 = v419 * v423; + auto v426 = v418 * v424; + auto v427 = v425 + v426; + auto v428 = v427 * v427; + auto v429 = v428 * smt_terms::BVConst("2", &solver, 10); + auto v431 = v9 & smt_terms::BVConst("2097152", &solver, 10); + auto v432 = v431 ^ smt_terms::BVConst("1", &solver, 10); + auto v433 = v431; + auto v434 = v432; + auto v435 = v429 * v433; + auto v436 = v428 * v434; + auto v437 = v435 + v436; + auto v438 = v437 * v437; + auto v439 = v438 * smt_terms::BVConst("2", &solver, 10); + auto v441 = v9 & smt_terms::BVConst("1048576", &solver, 10); + auto v442 = v441 ^ smt_terms::BVConst("1", &solver, 10); + auto v443 = v441; + auto v444 = v442; + auto v445 = v439 * v443; + auto v446 = v438 * v444; + auto v447 = v445 + v446; + auto v448 = v447 * v447; + auto v449 = v448 * smt_terms::BVConst("2", &solver, 10); + auto v451 = v9 & smt_terms::BVConst("524288", &solver, 10); + auto v452 = v451 ^ smt_terms::BVConst("1", &solver, 10); + auto v453 = v451; + auto v454 = v452; + auto v455 = v449 * v453; + auto v456 = v448 * v454; + auto v457 = v455 + v456; + auto v458 = v457 * v457; + auto v459 = v458 * smt_terms::BVConst("2", &solver, 10); + auto v461 = v9 & smt_terms::BVConst("262144", &solver, 10); + auto v462 = v461 ^ smt_terms::BVConst("1", &solver, 10); + auto v463 = v461; + auto v464 = v462; + auto v465 = v459 * v463; + auto v466 = v458 * v464; + auto v467 = v465 + v466; + auto v468 = v467 * v467; + auto v469 = v468 * smt_terms::BVConst("2", &solver, 10); + auto v471 = v9 & smt_terms::BVConst("131072", &solver, 10); + auto v472 = v471 ^ smt_terms::BVConst("1", &solver, 10); + auto v473 = v471; + auto v474 = v472; + auto v475 = v469 * v473; + auto v476 = v468 * v474; + auto v477 = v475 + v476; + auto v478 = v477 * v477; + auto v479 = v478 * smt_terms::BVConst("2", &solver, 10); + auto v481 = v9 & smt_terms::BVConst("65536", &solver, 10); + auto v482 = v481 ^ smt_terms::BVConst("1", &solver, 10); + auto v483 = v481; + auto v484 = v482; + auto v485 = v479 * v483; + auto v486 = v478 * v484; + auto v487 = v485 + v486; + auto v488 = v487 * v487; + auto v489 = v488 * smt_terms::BVConst("2", &solver, 10); + auto v491 = v9 & smt_terms::BVConst("32768", &solver, 10); + auto v492 = v491 ^ smt_terms::BVConst("1", &solver, 10); + auto v493 = v491; + auto v494 = v492; + auto v495 = v489 * v493; + auto v496 = v488 * v494; + auto v497 = v495 + v496; + auto v498 = v497 * v497; + auto v499 = v498 * smt_terms::BVConst("2", &solver, 10); + auto v501 = v9 & smt_terms::BVConst("16384", &solver, 10); + auto v502 = v501 ^ smt_terms::BVConst("1", &solver, 10); + auto v503 = v501; + auto v504 = v502; + auto v505 = v499 * v503; + auto v506 = v498 * v504; + auto v507 = v505 + v506; + auto v508 = v507 * v507; + auto v509 = v508 * smt_terms::BVConst("2", &solver, 10); + auto v511 = v9 & smt_terms::BVConst("8192", &solver, 10); + auto v512 = v511 ^ smt_terms::BVConst("1", &solver, 10); + auto v513 = v511; + auto v514 = v512; + auto v515 = v509 * v513; + auto v516 = v508 * v514; + auto v517 = v515 + v516; + auto v518 = v517 * v517; + auto v519 = v518 * smt_terms::BVConst("2", &solver, 10); + auto v521 = v9 & smt_terms::BVConst("4096", &solver, 10); + auto v522 = v521 ^ smt_terms::BVConst("1", &solver, 10); + auto v523 = v521; + auto v524 = v522; + auto v525 = v519 * v523; + auto v526 = v518 * v524; + auto v527 = v525 + v526; + auto v528 = v527 * v527; + auto v529 = v528 * smt_terms::BVConst("2", &solver, 10); + auto v531 = v9 & smt_terms::BVConst("2048", &solver, 10); + auto v532 = v531 ^ smt_terms::BVConst("1", &solver, 10); + auto v533 = v531; + auto v534 = v532; + auto v535 = v529 * v533; + auto v536 = v528 * v534; + auto v537 = v535 + v536; + auto v538 = v537 * v537; + auto v539 = v538 * smt_terms::BVConst("2", &solver, 10); + auto v541 = v9 & smt_terms::BVConst("1024", &solver, 10); + auto v542 = v541 ^ smt_terms::BVConst("1", &solver, 10); + auto v543 = v541; + auto v544 = v542; + auto v545 = v539 * v543; + auto v546 = v538 * v544; + auto v547 = v545 + v546; + auto v548 = v547 * v547; + auto v549 = v548 * smt_terms::BVConst("2", &solver, 10); + auto v551 = v9 & smt_terms::BVConst("512", &solver, 10); + auto v552 = v551 ^ smt_terms::BVConst("1", &solver, 10); + auto v553 = v551; + auto v554 = v552; + auto v555 = v549 * v553; + auto v556 = v548 * v554; + auto v557 = v555 + v556; + auto v558 = v557 * v557; + auto v559 = v558 * smt_terms::BVConst("2", &solver, 10); + auto v561 = v9 & smt_terms::BVConst("256", &solver, 10); + auto v562 = v561 ^ smt_terms::BVConst("1", &solver, 10); + auto v563 = v561; + auto v564 = v562; + auto v565 = v559 * v563; + auto v566 = v558 * v564; + auto v567 = v565 + v566; + auto v568 = v567 * v567; + auto v569 = v568 * smt_terms::BVConst("2", &solver, 10); + auto v571 = v9 & smt_terms::BVConst("128", &solver, 10); + auto v572 = v571 ^ smt_terms::BVConst("1", &solver, 10); + auto v573 = v571; + auto v574 = v572; + auto v575 = v569 * v573; + auto v576 = v568 * v574; + auto v577 = v575 + v576; + auto v578 = v577 * v577; + auto v579 = v578 * smt_terms::BVConst("2", &solver, 10); + auto v581 = v9 & smt_terms::BVConst("64", &solver, 10); + auto v582 = v581 ^ smt_terms::BVConst("1", &solver, 10); + auto v583 = v581; + auto v584 = v582; + auto v585 = v579 * v583; + auto v586 = v578 * v584; + auto v587 = v585 + v586; + auto v588 = v587 * v587; + auto v589 = v588 * smt_terms::BVConst("2", &solver, 10); + auto v591 = v9 & smt_terms::BVConst("32", &solver, 10); + auto v592 = v591 ^ smt_terms::BVConst("1", &solver, 10); + auto v593 = v591; + auto v594 = v592; + auto v595 = v589 * v593; + auto v596 = v588 * v594; + auto v597 = v595 + v596; + auto v598 = v597 * v597; + auto v599 = v598 * smt_terms::BVConst("2", &solver, 10); + auto v601 = v9 & smt_terms::BVConst("16", &solver, 10); + auto v602 = v601 ^ smt_terms::BVConst("1", &solver, 10); + auto v603 = v601; + auto v604 = v602; + auto v605 = v599 * v603; + auto v606 = v598 * v604; + auto v607 = v605 + v606; + auto v608 = v607 * v607; + auto v609 = v608 * smt_terms::BVConst("2", &solver, 10); + auto v611 = v9 & smt_terms::BVConst("8", &solver, 10); + auto v612 = v611 ^ smt_terms::BVConst("1", &solver, 10); + auto v613 = v611; + auto v614 = v612; + auto v615 = v609 * v613; + auto v616 = v608 * v614; + auto v617 = v615 + v616; + auto v618 = v617 * v617; + auto v619 = v618 * smt_terms::BVConst("2", &solver, 10); + auto v620 = v9 & smt_terms::BVConst("4", &solver, 10); + auto v621 = v620 ^ smt_terms::BVConst("1", &solver, 10); + auto v622 = v620; + auto v623 = v621; + auto v624 = v619 * v622; + auto v625 = v618 * v623; + auto v626 = v624 + v625; + auto v627 = v626 * v626; + auto v628 = v627 * smt_terms::BVConst("2", &solver, 10); + auto v629 = v9 & smt_terms::BVConst("2", &solver, 10); + auto v630 = v629 ^ smt_terms::BVConst("1", &solver, 10); + auto v631 = v629; + auto v632 = v630; + auto v633 = v628 * v631; + auto v634 = v627 * v632; + auto v635 = v633 + v634; + auto v636 = v635 * v635; + auto v637 = v636 * smt_terms::BVConst("2", &solver, 10); + auto v639 = v9 & smt_terms::BVConst("1", &solver, 10); + auto v640 = v639 ^ smt_terms::BVConst("1", &solver, 10); + auto v641 = v639; + auto v642 = v640; + auto v643 = v637 * v641; + auto v644 = v636 * v642; + auto v645 = v643 + v644; + auto v646 = v645; + auto v647 = v6 * v646; + auto v648 = v0; + auto v649 = v647; + auto v650 = v648 * v649; + auto v651 = v650 & smt_terms::BVConst("18446744073709551615", &solver, 10); + auto v652 = v651; + auto cr = v652; c != cr; bool res = solver.check(); - solver.print_assertions(); - info(solver.getResult()); + if (res) { + save_buggy_witness("Binary::Shl", circuit); + } EXPECT_FALSE(res); } -*/ -/*TEST(acir_formal_proofs, uint_terms_shr) +TEST(acir_formal_proofs, uint_terms_shr) { AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Shr.acir"); - smt_solver::Solver solver = loader.get_solver(); - smt_circuit::UltraCircuit circuit = loader.get_circuit(&solver); + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); auto a = circuit["a"]; auto b = circuit["b"]; auto c = circuit["c"]; - auto cr = a >> b; + auto v0 = a; + auto v1 = b; + auto v5 = smt_terms::BVConst("1", &solver, 10); + auto v6 = v5; + auto v7 = v1; + auto v9 = v7; + auto v12 = v9 & smt_terms::BVConst("9223372036854775808", &solver, 10); + auto v13 = v12 ^ smt_terms::BVConst("1", &solver, 10); + auto v14 = v12; + auto v15 = v13; + auto v16 = v14 * smt_terms::BVConst("2", &solver, 10); + auto v17 = v16 + v15; + auto v18 = v17 * v17; + auto v19 = v18 * smt_terms::BVConst("2", &solver, 10); + auto v21 = v9 & smt_terms::BVConst("4611686018427387904", &solver, 10); + auto v22 = v21 ^ smt_terms::BVConst("1", &solver, 10); + auto v23 = v21; + auto v24 = v22; + auto v25 = v19 * v23; + auto v26 = v18 * v24; + auto v27 = v25 + v26; + auto v28 = v27 * v27; + auto v29 = v28 * smt_terms::BVConst("2", &solver, 10); + auto v31 = v9 & smt_terms::BVConst("2305843009213693952", &solver, 10); + auto v32 = v31 ^ smt_terms::BVConst("1", &solver, 10); + auto v33 = v31; + auto v34 = v32; + auto v35 = v29 * v33; + auto v36 = v28 * v34; + auto v37 = v35 + v36; + auto v38 = v37 * v37; + auto v39 = v38 * smt_terms::BVConst("2", &solver, 10); + auto v41 = v9 & smt_terms::BVConst("1152921504606846976", &solver, 10); + auto v42 = v41 ^ smt_terms::BVConst("1", &solver, 10); + auto v43 = v41; + auto v44 = v42; + auto v45 = v39 * v43; + auto v46 = v38 * v44; + auto v47 = v45 + v46; + auto v48 = v47 * v47; + auto v49 = v48 * smt_terms::BVConst("2", &solver, 10); + auto v51 = v9 & smt_terms::BVConst("576460752303423488", &solver, 10); + auto v52 = v51 ^ smt_terms::BVConst("1", &solver, 10); + auto v53 = v51; + auto v54 = v52; + auto v55 = v49 * v53; + auto v56 = v48 * v54; + auto v57 = v55 + v56; + auto v58 = v57 * v57; + auto v59 = v58 * smt_terms::BVConst("2", &solver, 10); + auto v61 = v9 & smt_terms::BVConst("288230376151711744", &solver, 10); + auto v62 = v61 ^ smt_terms::BVConst("1", &solver, 10); + auto v63 = v61; + auto v64 = v62; + auto v65 = v59 * v63; + auto v66 = v58 * v64; + auto v67 = v65 + v66; + auto v68 = v67 * v67; + auto v69 = v68 * smt_terms::BVConst("2", &solver, 10); + auto v71 = v9 & smt_terms::BVConst("144115188075855872", &solver, 10); + auto v72 = v71 ^ smt_terms::BVConst("1", &solver, 10); + auto v73 = v71; + auto v74 = v72; + auto v75 = v69 * v73; + auto v76 = v68 * v74; + auto v77 = v75 + v76; + auto v78 = v77 * v77; + auto v79 = v78 * smt_terms::BVConst("2", &solver, 10); + auto v81 = v9 & smt_terms::BVConst("72057594037927936", &solver, 10); + auto v82 = v81 ^ smt_terms::BVConst("1", &solver, 10); + auto v83 = v81; + auto v84 = v82; + auto v85 = v79 * v83; + auto v86 = v78 * v84; + auto v87 = v85 + v86; + auto v88 = v87 * v87; + auto v89 = v88 * smt_terms::BVConst("2", &solver, 10); + auto v91 = v9 & smt_terms::BVConst("36028797018963968", &solver, 10); + auto v92 = v91 ^ smt_terms::BVConst("1", &solver, 10); + auto v93 = v91; + auto v94 = v92; + auto v95 = v89 * v93; + auto v96 = v88 * v94; + auto v97 = v95 + v96; + auto v98 = v97 * v97; + auto v99 = v98 * smt_terms::BVConst("2", &solver, 10); + auto v101 = v9 & smt_terms::BVConst("18014398509481984", &solver, 10); + auto v102 = v101 ^ smt_terms::BVConst("1", &solver, 10); + auto v103 = v101; + auto v104 = v102; + auto v105 = v99 * v103; + auto v106 = v98 * v104; + auto v107 = v105 + v106; + auto v108 = v107 * v107; + auto v109 = v108 * smt_terms::BVConst("2", &solver, 10); + auto v111 = v9 & smt_terms::BVConst("9007199254740992", &solver, 10); + auto v112 = v111 ^ smt_terms::BVConst("1", &solver, 10); + auto v113 = v111; + auto v114 = v112; + auto v115 = v109 * v113; + auto v116 = v108 * v114; + auto v117 = v115 + v116; + auto v118 = v117 * v117; + auto v119 = v118 * smt_terms::BVConst("2", &solver, 10); + auto v121 = v9 & smt_terms::BVConst("4503599627370496", &solver, 10); + auto v122 = v121 ^ smt_terms::BVConst("1", &solver, 10); + auto v123 = v121; + auto v124 = v122; + auto v125 = v119 * v123; + auto v126 = v118 * v124; + auto v127 = v125 + v126; + auto v128 = v127 * v127; + auto v129 = v128 * smt_terms::BVConst("2", &solver, 10); + auto v131 = v9 & smt_terms::BVConst("2251799813685248", &solver, 10); + auto v132 = v131 ^ smt_terms::BVConst("1", &solver, 10); + auto v133 = v131; + auto v134 = v132; + auto v135 = v129 * v133; + auto v136 = v128 * v134; + auto v137 = v135 + v136; + auto v138 = v137 * v137; + auto v139 = v138 * smt_terms::BVConst("2", &solver, 10); + auto v141 = v9 & smt_terms::BVConst("1125899906842624", &solver, 10); + auto v142 = v141 ^ smt_terms::BVConst("1", &solver, 10); + auto v143 = v141; + auto v144 = v142; + auto v145 = v139 * v143; + auto v146 = v138 * v144; + auto v147 = v145 + v146; + auto v148 = v147 * v147; + auto v149 = v148 * smt_terms::BVConst("2", &solver, 10); + auto v151 = v9 & smt_terms::BVConst("562949953421312", &solver, 10); + auto v152 = v151 ^ smt_terms::BVConst("1", &solver, 10); + auto v153 = v151; + auto v154 = v152; + auto v155 = v149 * v153; + auto v156 = v148 * v154; + auto v157 = v155 + v156; + auto v158 = v157 * v157; + auto v159 = v158 * smt_terms::BVConst("2", &solver, 10); + auto v161 = v9 & smt_terms::BVConst("281474976710656", &solver, 10); + auto v162 = v161 ^ smt_terms::BVConst("1", &solver, 10); + auto v163 = v161; + auto v164 = v162; + auto v165 = v159 * v163; + auto v166 = v158 * v164; + auto v167 = v165 + v166; + auto v168 = v167 * v167; + auto v169 = v168 * smt_terms::BVConst("2", &solver, 10); + auto v171 = v9 & smt_terms::BVConst("140737488355328", &solver, 10); + auto v172 = v171 ^ smt_terms::BVConst("1", &solver, 10); + auto v173 = v171; + auto v174 = v172; + auto v175 = v169 * v173; + auto v176 = v168 * v174; + auto v177 = v175 + v176; + auto v178 = v177 * v177; + auto v179 = v178 * smt_terms::BVConst("2", &solver, 10); + auto v181 = v9 & smt_terms::BVConst("70368744177664", &solver, 10); + auto v182 = v181 ^ smt_terms::BVConst("1", &solver, 10); + auto v183 = v181; + auto v184 = v182; + auto v185 = v179 * v183; + auto v186 = v178 * v184; + auto v187 = v185 + v186; + auto v188 = v187 * v187; + auto v189 = v188 * smt_terms::BVConst("2", &solver, 10); + auto v191 = v9 & smt_terms::BVConst("35184372088832", &solver, 10); + auto v192 = v191 ^ smt_terms::BVConst("1", &solver, 10); + auto v193 = v191; + auto v194 = v192; + auto v195 = v189 * v193; + auto v196 = v188 * v194; + auto v197 = v195 + v196; + auto v198 = v197 * v197; + auto v199 = v198 * smt_terms::BVConst("2", &solver, 10); + auto v201 = v9 & smt_terms::BVConst("17592186044416", &solver, 10); + auto v202 = v201 ^ smt_terms::BVConst("1", &solver, 10); + auto v203 = v201; + auto v204 = v202; + auto v205 = v199 * v203; + auto v206 = v198 * v204; + auto v207 = v205 + v206; + auto v208 = v207 * v207; + auto v209 = v208 * smt_terms::BVConst("2", &solver, 10); + auto v211 = v9 & smt_terms::BVConst("8796093022208", &solver, 10); + auto v212 = v211 ^ smt_terms::BVConst("1", &solver, 10); + auto v213 = v211; + auto v214 = v212; + auto v215 = v209 * v213; + auto v216 = v208 * v214; + auto v217 = v215 + v216; + auto v218 = v217 * v217; + auto v219 = v218 * smt_terms::BVConst("2", &solver, 10); + auto v221 = v9 & smt_terms::BVConst("4398046511104", &solver, 10); + auto v222 = v221 ^ smt_terms::BVConst("1", &solver, 10); + auto v223 = v221; + auto v224 = v222; + auto v225 = v219 * v223; + auto v226 = v218 * v224; + auto v227 = v225 + v226; + auto v228 = v227 * v227; + auto v229 = v228 * smt_terms::BVConst("2", &solver, 10); + auto v231 = v9 & smt_terms::BVConst("2199023255552", &solver, 10); + auto v232 = v231 ^ smt_terms::BVConst("1", &solver, 10); + auto v233 = v231; + auto v234 = v232; + auto v235 = v229 * v233; + auto v236 = v228 * v234; + auto v237 = v235 + v236; + auto v238 = v237 * v237; + auto v239 = v238 * smt_terms::BVConst("2", &solver, 10); + auto v241 = v9 & smt_terms::BVConst("1099511627776", &solver, 10); + auto v242 = v241 ^ smt_terms::BVConst("1", &solver, 10); + auto v243 = v241; + auto v244 = v242; + auto v245 = v239 * v243; + auto v246 = v238 * v244; + auto v247 = v245 + v246; + auto v248 = v247 * v247; + auto v249 = v248 * smt_terms::BVConst("2", &solver, 10); + auto v251 = v9 & smt_terms::BVConst("549755813888", &solver, 10); + auto v252 = v251 ^ smt_terms::BVConst("1", &solver, 10); + auto v253 = v251; + auto v254 = v252; + auto v255 = v249 * v253; + auto v256 = v248 * v254; + auto v257 = v255 + v256; + auto v258 = v257 * v257; + auto v259 = v258 * smt_terms::BVConst("2", &solver, 10); + auto v261 = v9 & smt_terms::BVConst("274877906944", &solver, 10); + auto v262 = v261 ^ smt_terms::BVConst("1", &solver, 10); + auto v263 = v261; + auto v264 = v262; + auto v265 = v259 * v263; + auto v266 = v258 * v264; + auto v267 = v265 + v266; + auto v268 = v267 * v267; + auto v269 = v268 * smt_terms::BVConst("2", &solver, 10); + auto v271 = v9 & smt_terms::BVConst("137438953472", &solver, 10); + auto v272 = v271 ^ smt_terms::BVConst("1", &solver, 10); + auto v273 = v271; + auto v274 = v272; + auto v275 = v269 * v273; + auto v276 = v268 * v274; + auto v277 = v275 + v276; + auto v278 = v277 * v277; + auto v279 = v278 * smt_terms::BVConst("2", &solver, 10); + auto v281 = v9 & smt_terms::BVConst("68719476736", &solver, 10); + auto v282 = v281 ^ smt_terms::BVConst("1", &solver, 10); + auto v283 = v281; + auto v284 = v282; + auto v285 = v279 * v283; + auto v286 = v278 * v284; + auto v287 = v285 + v286; + auto v288 = v287 * v287; + auto v289 = v288 * smt_terms::BVConst("2", &solver, 10); + auto v291 = v9 & smt_terms::BVConst("34359738368", &solver, 10); + auto v292 = v291 ^ smt_terms::BVConst("1", &solver, 10); + auto v293 = v291; + auto v294 = v292; + auto v295 = v289 * v293; + auto v296 = v288 * v294; + auto v297 = v295 + v296; + auto v298 = v297 * v297; + auto v299 = v298 * smt_terms::BVConst("2", &solver, 10); + auto v301 = v9 & smt_terms::BVConst("17179869184", &solver, 10); + auto v302 = v301 ^ smt_terms::BVConst("1", &solver, 10); + auto v303 = v301; + auto v304 = v302; + auto v305 = v299 * v303; + auto v306 = v298 * v304; + auto v307 = v305 + v306; + auto v308 = v307 * v307; + auto v309 = v308 * smt_terms::BVConst("2", &solver, 10); + auto v311 = v9 & smt_terms::BVConst("8589934592", &solver, 10); + auto v312 = v311 ^ smt_terms::BVConst("1", &solver, 10); + auto v313 = v311; + auto v314 = v312; + auto v315 = v309 * v313; + auto v316 = v308 * v314; + auto v317 = v315 + v316; + auto v318 = v317 * v317; + auto v319 = v318 * smt_terms::BVConst("2", &solver, 10); + auto v321 = v9 & smt_terms::BVConst("4294967296", &solver, 10); + auto v322 = v321 ^ smt_terms::BVConst("1", &solver, 10); + auto v323 = v321; + auto v324 = v322; + auto v325 = v319 * v323; + auto v326 = v318 * v324; + auto v327 = v325 + v326; + auto v328 = v327 * v327; + auto v329 = v328 * smt_terms::BVConst("2", &solver, 10); + auto v331 = v9 & smt_terms::BVConst("2147483648", &solver, 10); + auto v332 = v331 ^ smt_terms::BVConst("1", &solver, 10); + auto v333 = v331; + auto v334 = v332; + auto v335 = v329 * v333; + auto v336 = v328 * v334; + auto v337 = v335 + v336; + auto v338 = v337 * v337; + auto v339 = v338 * smt_terms::BVConst("2", &solver, 10); + auto v341 = v9 & smt_terms::BVConst("1073741824", &solver, 10); + auto v342 = v341 ^ smt_terms::BVConst("1", &solver, 10); + auto v343 = v341; + auto v344 = v342; + auto v345 = v339 * v343; + auto v346 = v338 * v344; + auto v347 = v345 + v346; + auto v348 = v347 * v347; + auto v349 = v348 * smt_terms::BVConst("2", &solver, 10); + auto v351 = v9 & smt_terms::BVConst("536870912", &solver, 10); + auto v352 = v351 ^ smt_terms::BVConst("1", &solver, 10); + auto v353 = v351; + auto v354 = v352; + auto v355 = v349 * v353; + auto v356 = v348 * v354; + auto v357 = v355 + v356; + auto v358 = v357 * v357; + auto v359 = v358 * smt_terms::BVConst("2", &solver, 10); + auto v361 = v9 & smt_terms::BVConst("268435456", &solver, 10); + auto v362 = v361 ^ smt_terms::BVConst("1", &solver, 10); + auto v363 = v361; + auto v364 = v362; + auto v365 = v359 * v363; + auto v366 = v358 * v364; + auto v367 = v365 + v366; + auto v368 = v367 * v367; + auto v369 = v368 * smt_terms::BVConst("2", &solver, 10); + auto v371 = v9 & smt_terms::BVConst("134217728", &solver, 10); + auto v372 = v371 ^ smt_terms::BVConst("1", &solver, 10); + auto v373 = v371; + auto v374 = v372; + auto v375 = v369 * v373; + auto v376 = v368 * v374; + auto v377 = v375 + v376; + auto v378 = v377 * v377; + auto v379 = v378 * smt_terms::BVConst("2", &solver, 10); + auto v381 = v9 & smt_terms::BVConst("67108864", &solver, 10); + auto v382 = v381 ^ smt_terms::BVConst("1", &solver, 10); + auto v383 = v381; + auto v384 = v382; + auto v385 = v379 * v383; + auto v386 = v378 * v384; + auto v387 = v385 + v386; + auto v388 = v387 * v387; + auto v389 = v388 * smt_terms::BVConst("2", &solver, 10); + auto v391 = v9 & smt_terms::BVConst("33554432", &solver, 10); + auto v392 = v391 ^ smt_terms::BVConst("1", &solver, 10); + auto v393 = v391; + auto v394 = v392; + auto v395 = v389 * v393; + auto v396 = v388 * v394; + auto v397 = v395 + v396; + auto v398 = v397 * v397; + auto v399 = v398 * smt_terms::BVConst("2", &solver, 10); + auto v401 = v9 & smt_terms::BVConst("16777216", &solver, 10); + auto v402 = v401 ^ smt_terms::BVConst("1", &solver, 10); + auto v403 = v401; + auto v404 = v402; + auto v405 = v399 * v403; + auto v406 = v398 * v404; + auto v407 = v405 + v406; + auto v408 = v407 * v407; + auto v409 = v408 * smt_terms::BVConst("2", &solver, 10); + auto v411 = v9 & smt_terms::BVConst("8388608", &solver, 10); + auto v412 = v411 ^ smt_terms::BVConst("1", &solver, 10); + auto v413 = v411; + auto v414 = v412; + auto v415 = v409 * v413; + auto v416 = v408 * v414; + auto v417 = v415 + v416; + auto v418 = v417 * v417; + auto v419 = v418 * smt_terms::BVConst("2", &solver, 10); + auto v421 = v9 & smt_terms::BVConst("4194304", &solver, 10); + auto v422 = v421 ^ smt_terms::BVConst("1", &solver, 10); + auto v423 = v421; + auto v424 = v422; + auto v425 = v419 * v423; + auto v426 = v418 * v424; + auto v427 = v425 + v426; + auto v428 = v427 * v427; + auto v429 = v428 * smt_terms::BVConst("2", &solver, 10); + auto v431 = v9 & smt_terms::BVConst("2097152", &solver, 10); + auto v432 = v431 ^ smt_terms::BVConst("1", &solver, 10); + auto v433 = v431; + auto v434 = v432; + auto v435 = v429 * v433; + auto v436 = v428 * v434; + auto v437 = v435 + v436; + auto v438 = v437 * v437; + auto v439 = v438 * smt_terms::BVConst("2", &solver, 10); + auto v441 = v9 & smt_terms::BVConst("1048576", &solver, 10); + auto v442 = v441 ^ smt_terms::BVConst("1", &solver, 10); + auto v443 = v441; + auto v444 = v442; + auto v445 = v439 * v443; + auto v446 = v438 * v444; + auto v447 = v445 + v446; + auto v448 = v447 * v447; + auto v449 = v448 * smt_terms::BVConst("2", &solver, 10); + auto v451 = v9 & smt_terms::BVConst("524288", &solver, 10); + auto v452 = v451 ^ smt_terms::BVConst("1", &solver, 10); + auto v453 = v451; + auto v454 = v452; + auto v455 = v449 * v453; + auto v456 = v448 * v454; + auto v457 = v455 + v456; + auto v458 = v457 * v457; + auto v459 = v458 * smt_terms::BVConst("2", &solver, 10); + auto v461 = v9 & smt_terms::BVConst("262144", &solver, 10); + auto v462 = v461 ^ smt_terms::BVConst("1", &solver, 10); + auto v463 = v461; + auto v464 = v462; + auto v465 = v459 * v463; + auto v466 = v458 * v464; + auto v467 = v465 + v466; + auto v468 = v467 * v467; + auto v469 = v468 * smt_terms::BVConst("2", &solver, 10); + auto v471 = v9 & smt_terms::BVConst("131072", &solver, 10); + auto v472 = v471 ^ smt_terms::BVConst("1", &solver, 10); + auto v473 = v471; + auto v474 = v472; + auto v475 = v469 * v473; + auto v476 = v468 * v474; + auto v477 = v475 + v476; + auto v478 = v477 * v477; + auto v479 = v478 * smt_terms::BVConst("2", &solver, 10); + auto v481 = v9 & smt_terms::BVConst("65536", &solver, 10); + auto v482 = v481 ^ smt_terms::BVConst("1", &solver, 10); + auto v483 = v481; + auto v484 = v482; + auto v485 = v479 * v483; + auto v486 = v478 * v484; + auto v487 = v485 + v486; + auto v488 = v487 * v487; + auto v489 = v488 * smt_terms::BVConst("2", &solver, 10); + auto v491 = v9 & smt_terms::BVConst("32768", &solver, 10); + auto v492 = v491 ^ smt_terms::BVConst("1", &solver, 10); + auto v493 = v491; + auto v494 = v492; + auto v495 = v489 * v493; + auto v496 = v488 * v494; + auto v497 = v495 + v496; + auto v498 = v497 * v497; + auto v499 = v498 * smt_terms::BVConst("2", &solver, 10); + auto v501 = v9 & smt_terms::BVConst("16384", &solver, 10); + auto v502 = v501 ^ smt_terms::BVConst("1", &solver, 10); + auto v503 = v501; + auto v504 = v502; + auto v505 = v499 * v503; + auto v506 = v498 * v504; + auto v507 = v505 + v506; + auto v508 = v507 * v507; + auto v509 = v508 * smt_terms::BVConst("2", &solver, 10); + auto v511 = v9 & smt_terms::BVConst("8192", &solver, 10); + auto v512 = v511 ^ smt_terms::BVConst("1", &solver, 10); + auto v513 = v511; + auto v514 = v512; + auto v515 = v509 * v513; + auto v516 = v508 * v514; + auto v517 = v515 + v516; + auto v518 = v517 * v517; + auto v519 = v518 * smt_terms::BVConst("2", &solver, 10); + auto v521 = v9 & smt_terms::BVConst("4096", &solver, 10); + auto v522 = v521 ^ smt_terms::BVConst("1", &solver, 10); + auto v523 = v521; + auto v524 = v522; + auto v525 = v519 * v523; + auto v526 = v518 * v524; + auto v527 = v525 + v526; + auto v528 = v527 * v527; + auto v529 = v528 * smt_terms::BVConst("2", &solver, 10); + auto v531 = v9 & smt_terms::BVConst("2048", &solver, 10); + auto v532 = v531 ^ smt_terms::BVConst("1", &solver, 10); + auto v533 = v531; + auto v534 = v532; + auto v535 = v529 * v533; + auto v536 = v528 * v534; + auto v537 = v535 + v536; + auto v538 = v537 * v537; + auto v539 = v538 * smt_terms::BVConst("2", &solver, 10); + auto v541 = v9 & smt_terms::BVConst("1024", &solver, 10); + auto v542 = v541 ^ smt_terms::BVConst("1", &solver, 10); + auto v543 = v541; + auto v544 = v542; + auto v545 = v539 * v543; + auto v546 = v538 * v544; + auto v547 = v545 + v546; + auto v548 = v547 * v547; + auto v549 = v548 * smt_terms::BVConst("2", &solver, 10); + auto v551 = v9 & smt_terms::BVConst("512", &solver, 10); + auto v552 = v551 ^ smt_terms::BVConst("1", &solver, 10); + auto v553 = v551; + auto v554 = v552; + auto v555 = v549 * v553; + auto v556 = v548 * v554; + auto v557 = v555 + v556; + auto v558 = v557 * v557; + auto v559 = v558 * smt_terms::BVConst("2", &solver, 10); + auto v561 = v9 & smt_terms::BVConst("256", &solver, 10); + auto v562 = v561 ^ smt_terms::BVConst("1", &solver, 10); + auto v563 = v561; + auto v564 = v562; + auto v565 = v559 * v563; + auto v566 = v558 * v564; + auto v567 = v565 + v566; + auto v568 = v567 * v567; + auto v569 = v568 * smt_terms::BVConst("2", &solver, 10); + auto v571 = v9 & smt_terms::BVConst("128", &solver, 10); + auto v572 = v571 ^ smt_terms::BVConst("1", &solver, 10); + auto v573 = v571; + auto v574 = v572; + auto v575 = v569 * v573; + auto v576 = v568 * v574; + auto v577 = v575 + v576; + auto v578 = v577 * v577; + auto v579 = v578 * smt_terms::BVConst("2", &solver, 10); + auto v581 = v9 & smt_terms::BVConst("64", &solver, 10); + auto v582 = v581 ^ smt_terms::BVConst("1", &solver, 10); + auto v583 = v581; + auto v584 = v582; + auto v585 = v579 * v583; + auto v586 = v578 * v584; + auto v587 = v585 + v586; + auto v588 = v587 * v587; + auto v589 = v588 * smt_terms::BVConst("2", &solver, 10); + auto v591 = v9 & smt_terms::BVConst("32", &solver, 10); + auto v592 = v591 ^ smt_terms::BVConst("1", &solver, 10); + auto v593 = v591; + auto v594 = v592; + auto v595 = v589 * v593; + auto v596 = v588 * v594; + auto v597 = v595 + v596; + auto v598 = v597 * v597; + auto v599 = v598 * smt_terms::BVConst("2", &solver, 10); + auto v601 = v9 & smt_terms::BVConst("16", &solver, 10); + auto v602 = v601 ^ smt_terms::BVConst("1", &solver, 10); + auto v603 = v601; + auto v604 = v602; + auto v605 = v599 * v603; + auto v606 = v598 * v604; + auto v607 = v605 + v606; + auto v608 = v607 * v607; + auto v609 = v608 * smt_terms::BVConst("2", &solver, 10); + auto v611 = v9 & smt_terms::BVConst("8", &solver, 10); + auto v612 = v611 ^ smt_terms::BVConst("1", &solver, 10); + auto v613 = v611; + auto v614 = v612; + auto v615 = v609 * v613; + auto v616 = v608 * v614; + auto v617 = v615 + v616; + auto v618 = v617 * v617; + auto v619 = v618 * smt_terms::BVConst("2", &solver, 10); + auto v620 = v9 & smt_terms::BVConst("4", &solver, 10); + auto v621 = v620 ^ smt_terms::BVConst("1", &solver, 10); + auto v622 = v620; + auto v623 = v621; + auto v624 = v619 * v622; + auto v625 = v618 * v623; + auto v626 = v624 + v625; + auto v627 = v626 * v626; + auto v628 = v627 * smt_terms::BVConst("2", &solver, 10); + auto v629 = v9 & smt_terms::BVConst("2", &solver, 10); + auto v630 = v629 ^ smt_terms::BVConst("1", &solver, 10); + auto v631 = v629; + auto v632 = v630; + auto v633 = v628 * v631; + auto v634 = v627 * v632; + auto v635 = v633 + v634; + auto v636 = v635 * v635; + auto v637 = v636 * smt_terms::BVConst("2", &solver, 10); + auto v639 = v9 & smt_terms::BVConst("1", &solver, 10); + auto v640 = v639 ^ smt_terms::BVConst("1", &solver, 10); + auto v641 = v639; + auto v642 = v640; + auto v643 = v637 * v641; + auto v644 = v636 * v642; + auto v645 = v643 + v644; + auto v646 = v645; + auto v647 = v6 * v646; + auto v648 = v0; + auto v649 = v647; + auto v650 = v648 * v649; + auto v651 = v650 & smt_terms::BVConst("18446744073709551615", &solver, 10); + auto v652 = v651; + auto cr = v652; c != cr; bool res = solver.check(); - solver.print_assertions(); - info(solver.getResult()); + if (res) { + save_buggy_witness("Binary::Shl", circuit); + } EXPECT_FALSE(res); -} */ +} TEST(acir_formal_proofs, uint_terms_sub) { @@ -316,6 +1509,31 @@ TEST(acir_formal_proofs, uint_terms_xor) } } +TEST(acir_formal_proofs, uint_terms_not) +{ + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Not.acir"); + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); + auto a = circuit["a"]; + auto b = circuit["b"]; + // 2**64 - 1 + auto mask = smt_terms::BVConst("18446744073709551615", &solver, 10); + auto br = a ^ mask; + br != b; + bool res = solver.check(); + solver.print_assertions(); + info(solver.getResult()); + EXPECT_FALSE(res); + if (res) { + save_buggy_witness("Binary::Not", circuit); + std::unordered_map terms({ { "a", a }, { "b", b }, { "br", br } }); + std::unordered_map vals = solver.model(terms); + info("a = ", vals["a"]); + info("b = ", vals["b"]); + info("br = ", vals["br"]); + } +} + // if failed, bug NOT verified // fali on file not found or check circuit TEST(acir_formal_proofs, uint_terms_and_verify_bug) diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/codegen.py b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/codegen.py new file mode 100644 index 00000000000..61178d0b0fd --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/codegen.py @@ -0,0 +1,161 @@ +import re + + +def parse_op(line: str) -> str: + # VAR1 = OP VAR2 ... ALMOST ALWAYS! + # only with return var doesnt work + t = line.split(' ') + if len(t) == 2: + return t[0] + return t[2] + + +def not_call(line: str) -> str: + # VARIABLE one should be defined + # v13 = not v12, without fields, only for one-bits + names = line.split(' ') + vars = (names[0], names[3]) + return f'auto {vars[0]} = {vars[1]} ^ smt_terms::BVConst("1", &solver, 10);' + + +def add_call(line: str) -> str: + # v17 = add v16, v15 always like this + line = line.replace(",", "") + names = line.split(' ') + vars = (names[0], names[3], names[4]) + return f"auto {vars[0]} = {vars[1]} + {vars[2]};" + + +def array_get_call(line: str) -> str: + # v12 = array_get v9, index Field 63 -> u1 + # we take it from little endian + # so getting by index 63 is VAR & (2 ** 63) + line = line.replace(",", "") + names = line.split(' ') + vars = (names[0], names[3], names[6]) + index = int(vars[2]) + mask = f'smt_terms::BVConst("{2**index}", &solver, 10)' + return f"auto {vars[0]} = {vars[1]} & {mask};" + + +def mul_call(line: str) -> str: + # v16 = mul Field 2, v14 + # v18 = mul v17, v17 + # v19 = mul v18, Field 2 + # so we have 3 cases + line = line.replace(",", "") + names = line.split(' ') + if len(names) == 5: + # case v18 = mul v17, v17 + vars = (names[0], names[3], names[4]) + elif names[3] == 'Field': + # case v16 = mul Field 2, v14 + vars = (names[0], names[5], 'smt_terms::BVConst("2", &solver, 10)') + elif names[4] == 'Field': + # case v19 = mul v18, Field 2 + vars = (names[0], names[3], 'smt_terms::BVConst("2", &solver, 10)') + else: + raise ValueError("Something strange with mul call", line) + + return f"auto {vars[0]} = {vars[1]} * {vars[2]};" + + +def truncate_call(line: str) -> str: + # v651 = truncate v650 to 64 bits, max_bit_size: 254 + line = line.replace(",", "") + names = line.split(' ') + vars = (names[0], names[3], names[5]) + t = 2 ** int(vars[2]) - 1 + return f'auto {vars[0]} = {vars[1]} & smt_terms::BVConst("{t}", &solver, 10);' + + +def cast_call(line: str) -> str: + # v641 = cast v639 as Field + # type doesnt matter i think + line = line.replace(",", "") + names = line.split(' ') + vars = (names[0], names[3]) + return f'auto {vars[0]} = {vars[1]};' + + +def lt_call(line: str) -> str: + # in shl it ignored i dont know how it works + # in shr it used for multiplying result + # if it shift >= 64 result multiplied by 0 + # but it should be 0 itself... + # so i leave it equal to 1 + line = line.replace(",", "") + names = line.split(' ') + vars = (names[0], ) + return f'auto {vars[0]} = smt_terms::BVConst("{1}", &solver, 10);' + + +def call_call(line: str) -> str: + # v9 = call to_le_bits(v7) -> [u1; 64] + line = line.replace(",", "") + names = line.split(' ') + name_in_func = re.findall( + r'to_le_bits\((.*)\)', names[3] + )[0] + vars = (names[0], name_in_func) + return f'auto {vars[0]} = {vars[1]};' + + +def return_call(line: str) -> str: + # return v652 + line = line.replace(",", "") + names = line.split(' ') + vars = (names[1], ) + return f'auto cr = {vars[0]};' + + +MAPPING = { + "add": add_call, + "array_get": array_get_call, + "call": call_call, + "cast": cast_call, + "lt": lt_call, + "mul": mul_call, + "not": not_call, + "truncate": truncate_call, + "return": return_call +} + + +def generate_by_line(line: str) -> str: + op = parse_op(line) + # throws expcetion on unknown op + return MAPPING.get(op, None)(line) + + +def parse_formatted_ssa(ssa: str) -> str: + # starts with acir(inline) fn main f0 { + # b0(v0: u64, v1: u8): + # so skip first two lines + # ends with }, skipping last line + ssa_lines = ssa.split('\n')[2:-1] + cpp_generated_lines = [] + for ssa_line in ssa_lines: + cpp_generated_lines.append( + generate_by_line(ssa_line.strip()) + ) + return '\t' + '\n\t'.join(cpp_generated_lines) + + +def main(): + with open('./shl.ssa', 'r') as f: + ssa = f.read() + + with open('./shl.cpp', 'w') as f: + f.write(parse_formatted_ssa(ssa)) + + with open('./shr.ssa', 'r') as f: + ssa = f.read() + + with open('./shr.cpp', 'w') as f: + f.write(parse_formatted_ssa(ssa)) + + + +if __name__ == "__main__": + main() diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shl.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shl.cpp new file mode 100644 index 00000000000..1c04811916e --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shl.cpp @@ -0,0 +1,585 @@ + auto v5 = smt_terms::BVConst("1", &solver, 10); + auto v6 = v5; + auto v7 = v1; + auto v9 = v7; + auto v12 = v9 & smt_terms::BVConst("9223372036854775808", &solver, 10); + auto v13 = v12 ^ smt_terms::BVConst("1", &solver, 10); + auto v14 = v12; + auto v15 = v13; + auto v16 = v14 * smt_terms::BVConst("2", &solver, 10); + auto v17 = v16 + v15; + auto v18 = v17 * v17; + auto v19 = v18 * smt_terms::BVConst("2", &solver, 10); + auto v21 = v9 & smt_terms::BVConst("4611686018427387904", &solver, 10); + auto v22 = v21 ^ smt_terms::BVConst("1", &solver, 10); + auto v23 = v21; + auto v24 = v22; + auto v25 = v19 * v23; + auto v26 = v18 * v24; + auto v27 = v25 + v26; + auto v28 = v27 * v27; + auto v29 = v28 * smt_terms::BVConst("2", &solver, 10); + auto v31 = v9 & smt_terms::BVConst("2305843009213693952", &solver, 10); + auto v32 = v31 ^ smt_terms::BVConst("1", &solver, 10); + auto v33 = v31; + auto v34 = v32; + auto v35 = v29 * v33; + auto v36 = v28 * v34; + auto v37 = v35 + v36; + auto v38 = v37 * v37; + auto v39 = v38 * smt_terms::BVConst("2", &solver, 10); + auto v41 = v9 & smt_terms::BVConst("1152921504606846976", &solver, 10); + auto v42 = v41 ^ smt_terms::BVConst("1", &solver, 10); + auto v43 = v41; + auto v44 = v42; + auto v45 = v39 * v43; + auto v46 = v38 * v44; + auto v47 = v45 + v46; + auto v48 = v47 * v47; + auto v49 = v48 * smt_terms::BVConst("2", &solver, 10); + auto v51 = v9 & smt_terms::BVConst("576460752303423488", &solver, 10); + auto v52 = v51 ^ smt_terms::BVConst("1", &solver, 10); + auto v53 = v51; + auto v54 = v52; + auto v55 = v49 * v53; + auto v56 = v48 * v54; + auto v57 = v55 + v56; + auto v58 = v57 * v57; + auto v59 = v58 * smt_terms::BVConst("2", &solver, 10); + auto v61 = v9 & smt_terms::BVConst("288230376151711744", &solver, 10); + auto v62 = v61 ^ smt_terms::BVConst("1", &solver, 10); + auto v63 = v61; + auto v64 = v62; + auto v65 = v59 * v63; + auto v66 = v58 * v64; + auto v67 = v65 + v66; + auto v68 = v67 * v67; + auto v69 = v68 * smt_terms::BVConst("2", &solver, 10); + auto v71 = v9 & smt_terms::BVConst("144115188075855872", &solver, 10); + auto v72 = v71 ^ smt_terms::BVConst("1", &solver, 10); + auto v73 = v71; + auto v74 = v72; + auto v75 = v69 * v73; + auto v76 = v68 * v74; + auto v77 = v75 + v76; + auto v78 = v77 * v77; + auto v79 = v78 * smt_terms::BVConst("2", &solver, 10); + auto v81 = v9 & smt_terms::BVConst("72057594037927936", &solver, 10); + auto v82 = v81 ^ smt_terms::BVConst("1", &solver, 10); + auto v83 = v81; + auto v84 = v82; + auto v85 = v79 * v83; + auto v86 = v78 * v84; + auto v87 = v85 + v86; + auto v88 = v87 * v87; + auto v89 = v88 * smt_terms::BVConst("2", &solver, 10); + auto v91 = v9 & smt_terms::BVConst("36028797018963968", &solver, 10); + auto v92 = v91 ^ smt_terms::BVConst("1", &solver, 10); + auto v93 = v91; + auto v94 = v92; + auto v95 = v89 * v93; + auto v96 = v88 * v94; + auto v97 = v95 + v96; + auto v98 = v97 * v97; + auto v99 = v98 * smt_terms::BVConst("2", &solver, 10); + auto v101 = v9 & smt_terms::BVConst("18014398509481984", &solver, 10); + auto v102 = v101 ^ smt_terms::BVConst("1", &solver, 10); + auto v103 = v101; + auto v104 = v102; + auto v105 = v99 * v103; + auto v106 = v98 * v104; + auto v107 = v105 + v106; + auto v108 = v107 * v107; + auto v109 = v108 * smt_terms::BVConst("2", &solver, 10); + auto v111 = v9 & smt_terms::BVConst("9007199254740992", &solver, 10); + auto v112 = v111 ^ smt_terms::BVConst("1", &solver, 10); + auto v113 = v111; + auto v114 = v112; + auto v115 = v109 * v113; + auto v116 = v108 * v114; + auto v117 = v115 + v116; + auto v118 = v117 * v117; + auto v119 = v118 * smt_terms::BVConst("2", &solver, 10); + auto v121 = v9 & smt_terms::BVConst("4503599627370496", &solver, 10); + auto v122 = v121 ^ smt_terms::BVConst("1", &solver, 10); + auto v123 = v121; + auto v124 = v122; + auto v125 = v119 * v123; + auto v126 = v118 * v124; + auto v127 = v125 + v126; + auto v128 = v127 * v127; + auto v129 = v128 * smt_terms::BVConst("2", &solver, 10); + auto v131 = v9 & smt_terms::BVConst("2251799813685248", &solver, 10); + auto v132 = v131 ^ smt_terms::BVConst("1", &solver, 10); + auto v133 = v131; + auto v134 = v132; + auto v135 = v129 * v133; + auto v136 = v128 * v134; + auto v137 = v135 + v136; + auto v138 = v137 * v137; + auto v139 = v138 * smt_terms::BVConst("2", &solver, 10); + auto v141 = v9 & smt_terms::BVConst("1125899906842624", &solver, 10); + auto v142 = v141 ^ smt_terms::BVConst("1", &solver, 10); + auto v143 = v141; + auto v144 = v142; + auto v145 = v139 * v143; + auto v146 = v138 * v144; + auto v147 = v145 + v146; + auto v148 = v147 * v147; + auto v149 = v148 * smt_terms::BVConst("2", &solver, 10); + auto v151 = v9 & smt_terms::BVConst("562949953421312", &solver, 10); + auto v152 = v151 ^ smt_terms::BVConst("1", &solver, 10); + auto v153 = v151; + auto v154 = v152; + auto v155 = v149 * v153; + auto v156 = v148 * v154; + auto v157 = v155 + v156; + auto v158 = v157 * v157; + auto v159 = v158 * smt_terms::BVConst("2", &solver, 10); + auto v161 = v9 & smt_terms::BVConst("281474976710656", &solver, 10); + auto v162 = v161 ^ smt_terms::BVConst("1", &solver, 10); + auto v163 = v161; + auto v164 = v162; + auto v165 = v159 * v163; + auto v166 = v158 * v164; + auto v167 = v165 + v166; + auto v168 = v167 * v167; + auto v169 = v168 * smt_terms::BVConst("2", &solver, 10); + auto v171 = v9 & smt_terms::BVConst("140737488355328", &solver, 10); + auto v172 = v171 ^ smt_terms::BVConst("1", &solver, 10); + auto v173 = v171; + auto v174 = v172; + auto v175 = v169 * v173; + auto v176 = v168 * v174; + auto v177 = v175 + v176; + auto v178 = v177 * v177; + auto v179 = v178 * smt_terms::BVConst("2", &solver, 10); + auto v181 = v9 & smt_terms::BVConst("70368744177664", &solver, 10); + auto v182 = v181 ^ smt_terms::BVConst("1", &solver, 10); + auto v183 = v181; + auto v184 = v182; + auto v185 = v179 * v183; + auto v186 = v178 * v184; + auto v187 = v185 + v186; + auto v188 = v187 * v187; + auto v189 = v188 * smt_terms::BVConst("2", &solver, 10); + auto v191 = v9 & smt_terms::BVConst("35184372088832", &solver, 10); + auto v192 = v191 ^ smt_terms::BVConst("1", &solver, 10); + auto v193 = v191; + auto v194 = v192; + auto v195 = v189 * v193; + auto v196 = v188 * v194; + auto v197 = v195 + v196; + auto v198 = v197 * v197; + auto v199 = v198 * smt_terms::BVConst("2", &solver, 10); + auto v201 = v9 & smt_terms::BVConst("17592186044416", &solver, 10); + auto v202 = v201 ^ smt_terms::BVConst("1", &solver, 10); + auto v203 = v201; + auto v204 = v202; + auto v205 = v199 * v203; + auto v206 = v198 * v204; + auto v207 = v205 + v206; + auto v208 = v207 * v207; + auto v209 = v208 * smt_terms::BVConst("2", &solver, 10); + auto v211 = v9 & smt_terms::BVConst("8796093022208", &solver, 10); + auto v212 = v211 ^ smt_terms::BVConst("1", &solver, 10); + auto v213 = v211; + auto v214 = v212; + auto v215 = v209 * v213; + auto v216 = v208 * v214; + auto v217 = v215 + v216; + auto v218 = v217 * v217; + auto v219 = v218 * smt_terms::BVConst("2", &solver, 10); + auto v221 = v9 & smt_terms::BVConst("4398046511104", &solver, 10); + auto v222 = v221 ^ smt_terms::BVConst("1", &solver, 10); + auto v223 = v221; + auto v224 = v222; + auto v225 = v219 * v223; + auto v226 = v218 * v224; + auto v227 = v225 + v226; + auto v228 = v227 * v227; + auto v229 = v228 * smt_terms::BVConst("2", &solver, 10); + auto v231 = v9 & smt_terms::BVConst("2199023255552", &solver, 10); + auto v232 = v231 ^ smt_terms::BVConst("1", &solver, 10); + auto v233 = v231; + auto v234 = v232; + auto v235 = v229 * v233; + auto v236 = v228 * v234; + auto v237 = v235 + v236; + auto v238 = v237 * v237; + auto v239 = v238 * smt_terms::BVConst("2", &solver, 10); + auto v241 = v9 & smt_terms::BVConst("1099511627776", &solver, 10); + auto v242 = v241 ^ smt_terms::BVConst("1", &solver, 10); + auto v243 = v241; + auto v244 = v242; + auto v245 = v239 * v243; + auto v246 = v238 * v244; + auto v247 = v245 + v246; + auto v248 = v247 * v247; + auto v249 = v248 * smt_terms::BVConst("2", &solver, 10); + auto v251 = v9 & smt_terms::BVConst("549755813888", &solver, 10); + auto v252 = v251 ^ smt_terms::BVConst("1", &solver, 10); + auto v253 = v251; + auto v254 = v252; + auto v255 = v249 * v253; + auto v256 = v248 * v254; + auto v257 = v255 + v256; + auto v258 = v257 * v257; + auto v259 = v258 * smt_terms::BVConst("2", &solver, 10); + auto v261 = v9 & smt_terms::BVConst("274877906944", &solver, 10); + auto v262 = v261 ^ smt_terms::BVConst("1", &solver, 10); + auto v263 = v261; + auto v264 = v262; + auto v265 = v259 * v263; + auto v266 = v258 * v264; + auto v267 = v265 + v266; + auto v268 = v267 * v267; + auto v269 = v268 * smt_terms::BVConst("2", &solver, 10); + auto v271 = v9 & smt_terms::BVConst("137438953472", &solver, 10); + auto v272 = v271 ^ smt_terms::BVConst("1", &solver, 10); + auto v273 = v271; + auto v274 = v272; + auto v275 = v269 * v273; + auto v276 = v268 * v274; + auto v277 = v275 + v276; + auto v278 = v277 * v277; + auto v279 = v278 * smt_terms::BVConst("2", &solver, 10); + auto v281 = v9 & smt_terms::BVConst("68719476736", &solver, 10); + auto v282 = v281 ^ smt_terms::BVConst("1", &solver, 10); + auto v283 = v281; + auto v284 = v282; + auto v285 = v279 * v283; + auto v286 = v278 * v284; + auto v287 = v285 + v286; + auto v288 = v287 * v287; + auto v289 = v288 * smt_terms::BVConst("2", &solver, 10); + auto v291 = v9 & smt_terms::BVConst("34359738368", &solver, 10); + auto v292 = v291 ^ smt_terms::BVConst("1", &solver, 10); + auto v293 = v291; + auto v294 = v292; + auto v295 = v289 * v293; + auto v296 = v288 * v294; + auto v297 = v295 + v296; + auto v298 = v297 * v297; + auto v299 = v298 * smt_terms::BVConst("2", &solver, 10); + auto v301 = v9 & smt_terms::BVConst("17179869184", &solver, 10); + auto v302 = v301 ^ smt_terms::BVConst("1", &solver, 10); + auto v303 = v301; + auto v304 = v302; + auto v305 = v299 * v303; + auto v306 = v298 * v304; + auto v307 = v305 + v306; + auto v308 = v307 * v307; + auto v309 = v308 * smt_terms::BVConst("2", &solver, 10); + auto v311 = v9 & smt_terms::BVConst("8589934592", &solver, 10); + auto v312 = v311 ^ smt_terms::BVConst("1", &solver, 10); + auto v313 = v311; + auto v314 = v312; + auto v315 = v309 * v313; + auto v316 = v308 * v314; + auto v317 = v315 + v316; + auto v318 = v317 * v317; + auto v319 = v318 * smt_terms::BVConst("2", &solver, 10); + auto v321 = v9 & smt_terms::BVConst("4294967296", &solver, 10); + auto v322 = v321 ^ smt_terms::BVConst("1", &solver, 10); + auto v323 = v321; + auto v324 = v322; + auto v325 = v319 * v323; + auto v326 = v318 * v324; + auto v327 = v325 + v326; + auto v328 = v327 * v327; + auto v329 = v328 * smt_terms::BVConst("2", &solver, 10); + auto v331 = v9 & smt_terms::BVConst("2147483648", &solver, 10); + auto v332 = v331 ^ smt_terms::BVConst("1", &solver, 10); + auto v333 = v331; + auto v334 = v332; + auto v335 = v329 * v333; + auto v336 = v328 * v334; + auto v337 = v335 + v336; + auto v338 = v337 * v337; + auto v339 = v338 * smt_terms::BVConst("2", &solver, 10); + auto v341 = v9 & smt_terms::BVConst("1073741824", &solver, 10); + auto v342 = v341 ^ smt_terms::BVConst("1", &solver, 10); + auto v343 = v341; + auto v344 = v342; + auto v345 = v339 * v343; + auto v346 = v338 * v344; + auto v347 = v345 + v346; + auto v348 = v347 * v347; + auto v349 = v348 * smt_terms::BVConst("2", &solver, 10); + auto v351 = v9 & smt_terms::BVConst("536870912", &solver, 10); + auto v352 = v351 ^ smt_terms::BVConst("1", &solver, 10); + auto v353 = v351; + auto v354 = v352; + auto v355 = v349 * v353; + auto v356 = v348 * v354; + auto v357 = v355 + v356; + auto v358 = v357 * v357; + auto v359 = v358 * smt_terms::BVConst("2", &solver, 10); + auto v361 = v9 & smt_terms::BVConst("268435456", &solver, 10); + auto v362 = v361 ^ smt_terms::BVConst("1", &solver, 10); + auto v363 = v361; + auto v364 = v362; + auto v365 = v359 * v363; + auto v366 = v358 * v364; + auto v367 = v365 + v366; + auto v368 = v367 * v367; + auto v369 = v368 * smt_terms::BVConst("2", &solver, 10); + auto v371 = v9 & smt_terms::BVConst("134217728", &solver, 10); + auto v372 = v371 ^ smt_terms::BVConst("1", &solver, 10); + auto v373 = v371; + auto v374 = v372; + auto v375 = v369 * v373; + auto v376 = v368 * v374; + auto v377 = v375 + v376; + auto v378 = v377 * v377; + auto v379 = v378 * smt_terms::BVConst("2", &solver, 10); + auto v381 = v9 & smt_terms::BVConst("67108864", &solver, 10); + auto v382 = v381 ^ smt_terms::BVConst("1", &solver, 10); + auto v383 = v381; + auto v384 = v382; + auto v385 = v379 * v383; + auto v386 = v378 * v384; + auto v387 = v385 + v386; + auto v388 = v387 * v387; + auto v389 = v388 * smt_terms::BVConst("2", &solver, 10); + auto v391 = v9 & smt_terms::BVConst("33554432", &solver, 10); + auto v392 = v391 ^ smt_terms::BVConst("1", &solver, 10); + auto v393 = v391; + auto v394 = v392; + auto v395 = v389 * v393; + auto v396 = v388 * v394; + auto v397 = v395 + v396; + auto v398 = v397 * v397; + auto v399 = v398 * smt_terms::BVConst("2", &solver, 10); + auto v401 = v9 & smt_terms::BVConst("16777216", &solver, 10); + auto v402 = v401 ^ smt_terms::BVConst("1", &solver, 10); + auto v403 = v401; + auto v404 = v402; + auto v405 = v399 * v403; + auto v406 = v398 * v404; + auto v407 = v405 + v406; + auto v408 = v407 * v407; + auto v409 = v408 * smt_terms::BVConst("2", &solver, 10); + auto v411 = v9 & smt_terms::BVConst("8388608", &solver, 10); + auto v412 = v411 ^ smt_terms::BVConst("1", &solver, 10); + auto v413 = v411; + auto v414 = v412; + auto v415 = v409 * v413; + auto v416 = v408 * v414; + auto v417 = v415 + v416; + auto v418 = v417 * v417; + auto v419 = v418 * smt_terms::BVConst("2", &solver, 10); + auto v421 = v9 & smt_terms::BVConst("4194304", &solver, 10); + auto v422 = v421 ^ smt_terms::BVConst("1", &solver, 10); + auto v423 = v421; + auto v424 = v422; + auto v425 = v419 * v423; + auto v426 = v418 * v424; + auto v427 = v425 + v426; + auto v428 = v427 * v427; + auto v429 = v428 * smt_terms::BVConst("2", &solver, 10); + auto v431 = v9 & smt_terms::BVConst("2097152", &solver, 10); + auto v432 = v431 ^ smt_terms::BVConst("1", &solver, 10); + auto v433 = v431; + auto v434 = v432; + auto v435 = v429 * v433; + auto v436 = v428 * v434; + auto v437 = v435 + v436; + auto v438 = v437 * v437; + auto v439 = v438 * smt_terms::BVConst("2", &solver, 10); + auto v441 = v9 & smt_terms::BVConst("1048576", &solver, 10); + auto v442 = v441 ^ smt_terms::BVConst("1", &solver, 10); + auto v443 = v441; + auto v444 = v442; + auto v445 = v439 * v443; + auto v446 = v438 * v444; + auto v447 = v445 + v446; + auto v448 = v447 * v447; + auto v449 = v448 * smt_terms::BVConst("2", &solver, 10); + auto v451 = v9 & smt_terms::BVConst("524288", &solver, 10); + auto v452 = v451 ^ smt_terms::BVConst("1", &solver, 10); + auto v453 = v451; + auto v454 = v452; + auto v455 = v449 * v453; + auto v456 = v448 * v454; + auto v457 = v455 + v456; + auto v458 = v457 * v457; + auto v459 = v458 * smt_terms::BVConst("2", &solver, 10); + auto v461 = v9 & smt_terms::BVConst("262144", &solver, 10); + auto v462 = v461 ^ smt_terms::BVConst("1", &solver, 10); + auto v463 = v461; + auto v464 = v462; + auto v465 = v459 * v463; + auto v466 = v458 * v464; + auto v467 = v465 + v466; + auto v468 = v467 * v467; + auto v469 = v468 * smt_terms::BVConst("2", &solver, 10); + auto v471 = v9 & smt_terms::BVConst("131072", &solver, 10); + auto v472 = v471 ^ smt_terms::BVConst("1", &solver, 10); + auto v473 = v471; + auto v474 = v472; + auto v475 = v469 * v473; + auto v476 = v468 * v474; + auto v477 = v475 + v476; + auto v478 = v477 * v477; + auto v479 = v478 * smt_terms::BVConst("2", &solver, 10); + auto v481 = v9 & smt_terms::BVConst("65536", &solver, 10); + auto v482 = v481 ^ smt_terms::BVConst("1", &solver, 10); + auto v483 = v481; + auto v484 = v482; + auto v485 = v479 * v483; + auto v486 = v478 * v484; + auto v487 = v485 + v486; + auto v488 = v487 * v487; + auto v489 = v488 * smt_terms::BVConst("2", &solver, 10); + auto v491 = v9 & smt_terms::BVConst("32768", &solver, 10); + auto v492 = v491 ^ smt_terms::BVConst("1", &solver, 10); + auto v493 = v491; + auto v494 = v492; + auto v495 = v489 * v493; + auto v496 = v488 * v494; + auto v497 = v495 + v496; + auto v498 = v497 * v497; + auto v499 = v498 * smt_terms::BVConst("2", &solver, 10); + auto v501 = v9 & smt_terms::BVConst("16384", &solver, 10); + auto v502 = v501 ^ smt_terms::BVConst("1", &solver, 10); + auto v503 = v501; + auto v504 = v502; + auto v505 = v499 * v503; + auto v506 = v498 * v504; + auto v507 = v505 + v506; + auto v508 = v507 * v507; + auto v509 = v508 * smt_terms::BVConst("2", &solver, 10); + auto v511 = v9 & smt_terms::BVConst("8192", &solver, 10); + auto v512 = v511 ^ smt_terms::BVConst("1", &solver, 10); + auto v513 = v511; + auto v514 = v512; + auto v515 = v509 * v513; + auto v516 = v508 * v514; + auto v517 = v515 + v516; + auto v518 = v517 * v517; + auto v519 = v518 * smt_terms::BVConst("2", &solver, 10); + auto v521 = v9 & smt_terms::BVConst("4096", &solver, 10); + auto v522 = v521 ^ smt_terms::BVConst("1", &solver, 10); + auto v523 = v521; + auto v524 = v522; + auto v525 = v519 * v523; + auto v526 = v518 * v524; + auto v527 = v525 + v526; + auto v528 = v527 * v527; + auto v529 = v528 * smt_terms::BVConst("2", &solver, 10); + auto v531 = v9 & smt_terms::BVConst("2048", &solver, 10); + auto v532 = v531 ^ smt_terms::BVConst("1", &solver, 10); + auto v533 = v531; + auto v534 = v532; + auto v535 = v529 * v533; + auto v536 = v528 * v534; + auto v537 = v535 + v536; + auto v538 = v537 * v537; + auto v539 = v538 * smt_terms::BVConst("2", &solver, 10); + auto v541 = v9 & smt_terms::BVConst("1024", &solver, 10); + auto v542 = v541 ^ smt_terms::BVConst("1", &solver, 10); + auto v543 = v541; + auto v544 = v542; + auto v545 = v539 * v543; + auto v546 = v538 * v544; + auto v547 = v545 + v546; + auto v548 = v547 * v547; + auto v549 = v548 * smt_terms::BVConst("2", &solver, 10); + auto v551 = v9 & smt_terms::BVConst("512", &solver, 10); + auto v552 = v551 ^ smt_terms::BVConst("1", &solver, 10); + auto v553 = v551; + auto v554 = v552; + auto v555 = v549 * v553; + auto v556 = v548 * v554; + auto v557 = v555 + v556; + auto v558 = v557 * v557; + auto v559 = v558 * smt_terms::BVConst("2", &solver, 10); + auto v561 = v9 & smt_terms::BVConst("256", &solver, 10); + auto v562 = v561 ^ smt_terms::BVConst("1", &solver, 10); + auto v563 = v561; + auto v564 = v562; + auto v565 = v559 * v563; + auto v566 = v558 * v564; + auto v567 = v565 + v566; + auto v568 = v567 * v567; + auto v569 = v568 * smt_terms::BVConst("2", &solver, 10); + auto v571 = v9 & smt_terms::BVConst("128", &solver, 10); + auto v572 = v571 ^ smt_terms::BVConst("1", &solver, 10); + auto v573 = v571; + auto v574 = v572; + auto v575 = v569 * v573; + auto v576 = v568 * v574; + auto v577 = v575 + v576; + auto v578 = v577 * v577; + auto v579 = v578 * smt_terms::BVConst("2", &solver, 10); + auto v581 = v9 & smt_terms::BVConst("64", &solver, 10); + auto v582 = v581 ^ smt_terms::BVConst("1", &solver, 10); + auto v583 = v581; + auto v584 = v582; + auto v585 = v579 * v583; + auto v586 = v578 * v584; + auto v587 = v585 + v586; + auto v588 = v587 * v587; + auto v589 = v588 * smt_terms::BVConst("2", &solver, 10); + auto v591 = v9 & smt_terms::BVConst("32", &solver, 10); + auto v592 = v591 ^ smt_terms::BVConst("1", &solver, 10); + auto v593 = v591; + auto v594 = v592; + auto v595 = v589 * v593; + auto v596 = v588 * v594; + auto v597 = v595 + v596; + auto v598 = v597 * v597; + auto v599 = v598 * smt_terms::BVConst("2", &solver, 10); + auto v601 = v9 & smt_terms::BVConst("16", &solver, 10); + auto v602 = v601 ^ smt_terms::BVConst("1", &solver, 10); + auto v603 = v601; + auto v604 = v602; + auto v605 = v599 * v603; + auto v606 = v598 * v604; + auto v607 = v605 + v606; + auto v608 = v607 * v607; + auto v609 = v608 * smt_terms::BVConst("2", &solver, 10); + auto v611 = v9 & smt_terms::BVConst("8", &solver, 10); + auto v612 = v611 ^ smt_terms::BVConst("1", &solver, 10); + auto v613 = v611; + auto v614 = v612; + auto v615 = v609 * v613; + auto v616 = v608 * v614; + auto v617 = v615 + v616; + auto v618 = v617 * v617; + auto v619 = v618 * smt_terms::BVConst("2", &solver, 10); + auto v620 = v9 & smt_terms::BVConst("4", &solver, 10); + auto v621 = v620 ^ smt_terms::BVConst("1", &solver, 10); + auto v622 = v620; + auto v623 = v621; + auto v624 = v619 * v622; + auto v625 = v618 * v623; + auto v626 = v624 + v625; + auto v627 = v626 * v626; + auto v628 = v627 * smt_terms::BVConst("2", &solver, 10); + auto v629 = v9 & smt_terms::BVConst("2", &solver, 10); + auto v630 = v629 ^ smt_terms::BVConst("1", &solver, 10); + auto v631 = v629; + auto v632 = v630; + auto v633 = v628 * v631; + auto v634 = v627 * v632; + auto v635 = v633 + v634; + auto v636 = v635 * v635; + auto v637 = v636 * smt_terms::BVConst("2", &solver, 10); + auto v639 = v9 & smt_terms::BVConst("1", &solver, 10); + auto v640 = v639 ^ smt_terms::BVConst("1", &solver, 10); + auto v641 = v639; + auto v642 = v640; + auto v643 = v637 * v641; + auto v644 = v636 * v642; + auto v645 = v643 + v644; + auto v646 = v645; + auto v647 = v6 * v646; + auto v648 = v0; + auto v649 = v647; + auto v650 = v648 * v649; + auto v651 = v650 & smt_terms::BVConst("18446744073709551615", &solver, 10); + auto v652 = v651; + auto cr = v652; \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shl.ssa b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shl.ssa new file mode 100644 index 00000000000..cad6e3bd90e --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shl.ssa @@ -0,0 +1,588 @@ +acir(inline) fn main f0 { + b0(v0: u64, v1: u8): + v5 = lt v1, u8 64 + v6 = cast v5 as u64 + v7 = cast v1 as u64 + v9 = call to_le_bits(v7) + v12 = array_get v9, index Field 63 + v13 = not v12 + v14 = cast v12 as Field + v15 = cast v13 as Field + v16 = mul Field 2, v14 + v17 = add v16, v15 + v18 = mul v17, v17 + v19 = mul v18, Field 2 + v21 = array_get v9, index Field 62 + v22 = not v21 + v23 = cast v21 as Field + v24 = cast v22 as Field + v25 = mul v19, v23 + v26 = mul v18, v24 + v27 = add v25, v26 + v28 = mul v27, v27 + v29 = mul v28, Field 2 + v31 = array_get v9, index Field 61 + v32 = not v31 + v33 = cast v31 as Field + v34 = cast v32 as Field + v35 = mul v29, v33 + v36 = mul v28, v34 + v37 = add v35, v36 + v38 = mul v37, v37 + v39 = mul v38, Field 2 + v41 = array_get v9, index Field 60 + v42 = not v41 + v43 = cast v41 as Field + v44 = cast v42 as Field + v45 = mul v39, v43 + v46 = mul v38, v44 + v47 = add v45, v46 + v48 = mul v47, v47 + v49 = mul v48, Field 2 + v51 = array_get v9, index Field 59 + v52 = not v51 + v53 = cast v51 as Field + v54 = cast v52 as Field + v55 = mul v49, v53 + v56 = mul v48, v54 + v57 = add v55, v56 + v58 = mul v57, v57 + v59 = mul v58, Field 2 + v61 = array_get v9, index Field 58 + v62 = not v61 + v63 = cast v61 as Field + v64 = cast v62 as Field + v65 = mul v59, v63 + v66 = mul v58, v64 + v67 = add v65, v66 + v68 = mul v67, v67 + v69 = mul v68, Field 2 + v71 = array_get v9, index Field 57 + v72 = not v71 + v73 = cast v71 as Field + v74 = cast v72 as Field + v75 = mul v69, v73 + v76 = mul v68, v74 + v77 = add v75, v76 + v78 = mul v77, v77 + v79 = mul v78, Field 2 + v81 = array_get v9, index Field 56 + v82 = not v81 + v83 = cast v81 as Field + v84 = cast v82 as Field + v85 = mul v79, v83 + v86 = mul v78, v84 + v87 = add v85, v86 + v88 = mul v87, v87 + v89 = mul v88, Field 2 + v91 = array_get v9, index Field 55 + v92 = not v91 + v93 = cast v91 as Field + v94 = cast v92 as Field + v95 = mul v89, v93 + v96 = mul v88, v94 + v97 = add v95, v96 + v98 = mul v97, v97 + v99 = mul v98, Field 2 + v101 = array_get v9, index Field 54 + v102 = not v101 + v103 = cast v101 as Field + v104 = cast v102 as Field + v105 = mul v99, v103 + v106 = mul v98, v104 + v107 = add v105, v106 + v108 = mul v107, v107 + v109 = mul v108, Field 2 + v111 = array_get v9, index Field 53 + v112 = not v111 + v113 = cast v111 as Field + v114 = cast v112 as Field + v115 = mul v109, v113 + v116 = mul v108, v114 + v117 = add v115, v116 + v118 = mul v117, v117 + v119 = mul v118, Field 2 + v121 = array_get v9, index Field 52 + v122 = not v121 + v123 = cast v121 as Field + v124 = cast v122 as Field + v125 = mul v119, v123 + v126 = mul v118, v124 + v127 = add v125, v126 + v128 = mul v127, v127 + v129 = mul v128, Field 2 + v131 = array_get v9, index Field 51 + v132 = not v131 + v133 = cast v131 as Field + v134 = cast v132 as Field + v135 = mul v129, v133 + v136 = mul v128, v134 + v137 = add v135, v136 + v138 = mul v137, v137 + v139 = mul v138, Field 2 + v141 = array_get v9, index Field 50 + v142 = not v141 + v143 = cast v141 as Field + v144 = cast v142 as Field + v145 = mul v139, v143 + v146 = mul v138, v144 + v147 = add v145, v146 + v148 = mul v147, v147 + v149 = mul v148, Field 2 + v151 = array_get v9, index Field 49 + v152 = not v151 + v153 = cast v151 as Field + v154 = cast v152 as Field + v155 = mul v149, v153 + v156 = mul v148, v154 + v157 = add v155, v156 + v158 = mul v157, v157 + v159 = mul v158, Field 2 + v161 = array_get v9, index Field 48 + v162 = not v161 + v163 = cast v161 as Field + v164 = cast v162 as Field + v165 = mul v159, v163 + v166 = mul v158, v164 + v167 = add v165, v166 + v168 = mul v167, v167 + v169 = mul v168, Field 2 + v171 = array_get v9, index Field 47 + v172 = not v171 + v173 = cast v171 as Field + v174 = cast v172 as Field + v175 = mul v169, v173 + v176 = mul v168, v174 + v177 = add v175, v176 + v178 = mul v177, v177 + v179 = mul v178, Field 2 + v181 = array_get v9, index Field 46 + v182 = not v181 + v183 = cast v181 as Field + v184 = cast v182 as Field + v185 = mul v179, v183 + v186 = mul v178, v184 + v187 = add v185, v186 + v188 = mul v187, v187 + v189 = mul v188, Field 2 + v191 = array_get v9, index Field 45 + v192 = not v191 + v193 = cast v191 as Field + v194 = cast v192 as Field + v195 = mul v189, v193 + v196 = mul v188, v194 + v197 = add v195, v196 + v198 = mul v197, v197 + v199 = mul v198, Field 2 + v201 = array_get v9, index Field 44 + v202 = not v201 + v203 = cast v201 as Field + v204 = cast v202 as Field + v205 = mul v199, v203 + v206 = mul v198, v204 + v207 = add v205, v206 + v208 = mul v207, v207 + v209 = mul v208, Field 2 + v211 = array_get v9, index Field 43 + v212 = not v211 + v213 = cast v211 as Field + v214 = cast v212 as Field + v215 = mul v209, v213 + v216 = mul v208, v214 + v217 = add v215, v216 + v218 = mul v217, v217 + v219 = mul v218, Field 2 + v221 = array_get v9, index Field 42 + v222 = not v221 + v223 = cast v221 as Field + v224 = cast v222 as Field + v225 = mul v219, v223 + v226 = mul v218, v224 + v227 = add v225, v226 + v228 = mul v227, v227 + v229 = mul v228, Field 2 + v231 = array_get v9, index Field 41 + v232 = not v231 + v233 = cast v231 as Field + v234 = cast v232 as Field + v235 = mul v229, v233 + v236 = mul v228, v234 + v237 = add v235, v236 + v238 = mul v237, v237 + v239 = mul v238, Field 2 + v241 = array_get v9, index Field 40 + v242 = not v241 + v243 = cast v241 as Field + v244 = cast v242 as Field + v245 = mul v239, v243 + v246 = mul v238, v244 + v247 = add v245, v246 + v248 = mul v247, v247 + v249 = mul v248, Field 2 + v251 = array_get v9, index Field 39 + v252 = not v251 + v253 = cast v251 as Field + v254 = cast v252 as Field + v255 = mul v249, v253 + v256 = mul v248, v254 + v257 = add v255, v256 + v258 = mul v257, v257 + v259 = mul v258, Field 2 + v261 = array_get v9, index Field 38 + v262 = not v261 + v263 = cast v261 as Field + v264 = cast v262 as Field + v265 = mul v259, v263 + v266 = mul v258, v264 + v267 = add v265, v266 + v268 = mul v267, v267 + v269 = mul v268, Field 2 + v271 = array_get v9, index Field 37 + v272 = not v271 + v273 = cast v271 as Field + v274 = cast v272 as Field + v275 = mul v269, v273 + v276 = mul v268, v274 + v277 = add v275, v276 + v278 = mul v277, v277 + v279 = mul v278, Field 2 + v281 = array_get v9, index Field 36 + v282 = not v281 + v283 = cast v281 as Field + v284 = cast v282 as Field + v285 = mul v279, v283 + v286 = mul v278, v284 + v287 = add v285, v286 + v288 = mul v287, v287 + v289 = mul v288, Field 2 + v291 = array_get v9, index Field 35 + v292 = not v291 + v293 = cast v291 as Field + v294 = cast v292 as Field + v295 = mul v289, v293 + v296 = mul v288, v294 + v297 = add v295, v296 + v298 = mul v297, v297 + v299 = mul v298, Field 2 + v301 = array_get v9, index Field 34 + v302 = not v301 + v303 = cast v301 as Field + v304 = cast v302 as Field + v305 = mul v299, v303 + v306 = mul v298, v304 + v307 = add v305, v306 + v308 = mul v307, v307 + v309 = mul v308, Field 2 + v311 = array_get v9, index Field 33 + v312 = not v311 + v313 = cast v311 as Field + v314 = cast v312 as Field + v315 = mul v309, v313 + v316 = mul v308, v314 + v317 = add v315, v316 + v318 = mul v317, v317 + v319 = mul v318, Field 2 + v321 = array_get v9, index Field 32 + v322 = not v321 + v323 = cast v321 as Field + v324 = cast v322 as Field + v325 = mul v319, v323 + v326 = mul v318, v324 + v327 = add v325, v326 + v328 = mul v327, v327 + v329 = mul v328, Field 2 + v331 = array_get v9, index Field 31 + v332 = not v331 + v333 = cast v331 as Field + v334 = cast v332 as Field + v335 = mul v329, v333 + v336 = mul v328, v334 + v337 = add v335, v336 + v338 = mul v337, v337 + v339 = mul v338, Field 2 + v341 = array_get v9, index Field 30 + v342 = not v341 + v343 = cast v341 as Field + v344 = cast v342 as Field + v345 = mul v339, v343 + v346 = mul v338, v344 + v347 = add v345, v346 + v348 = mul v347, v347 + v349 = mul v348, Field 2 + v351 = array_get v9, index Field 29 + v352 = not v351 + v353 = cast v351 as Field + v354 = cast v352 as Field + v355 = mul v349, v353 + v356 = mul v348, v354 + v357 = add v355, v356 + v358 = mul v357, v357 + v359 = mul v358, Field 2 + v361 = array_get v9, index Field 28 + v362 = not v361 + v363 = cast v361 as Field + v364 = cast v362 as Field + v365 = mul v359, v363 + v366 = mul v358, v364 + v367 = add v365, v366 + v368 = mul v367, v367 + v369 = mul v368, Field 2 + v371 = array_get v9, index Field 27 + v372 = not v371 + v373 = cast v371 as Field + v374 = cast v372 as Field + v375 = mul v369, v373 + v376 = mul v368, v374 + v377 = add v375, v376 + v378 = mul v377, v377 + v379 = mul v378, Field 2 + v381 = array_get v9, index Field 26 + v382 = not v381 + v383 = cast v381 as Field + v384 = cast v382 as Field + v385 = mul v379, v383 + v386 = mul v378, v384 + v387 = add v385, v386 + v388 = mul v387, v387 + v389 = mul v388, Field 2 + v391 = array_get v9, index Field 25 + v392 = not v391 + v393 = cast v391 as Field + v394 = cast v392 as Field + v395 = mul v389, v393 + v396 = mul v388, v394 + v397 = add v395, v396 + v398 = mul v397, v397 + v399 = mul v398, Field 2 + v401 = array_get v9, index Field 24 + v402 = not v401 + v403 = cast v401 as Field + v404 = cast v402 as Field + v405 = mul v399, v403 + v406 = mul v398, v404 + v407 = add v405, v406 + v408 = mul v407, v407 + v409 = mul v408, Field 2 + v411 = array_get v9, index Field 23 + v412 = not v411 + v413 = cast v411 as Field + v414 = cast v412 as Field + v415 = mul v409, v413 + v416 = mul v408, v414 + v417 = add v415, v416 + v418 = mul v417, v417 + v419 = mul v418, Field 2 + v421 = array_get v9, index Field 22 + v422 = not v421 + v423 = cast v421 as Field + v424 = cast v422 as Field + v425 = mul v419, v423 + v426 = mul v418, v424 + v427 = add v425, v426 + v428 = mul v427, v427 + v429 = mul v428, Field 2 + v431 = array_get v9, index Field 21 + v432 = not v431 + v433 = cast v431 as Field + v434 = cast v432 as Field + v435 = mul v429, v433 + v436 = mul v428, v434 + v437 = add v435, v436 + v438 = mul v437, v437 + v439 = mul v438, Field 2 + v441 = array_get v9, index Field 20 + v442 = not v441 + v443 = cast v441 as Field + v444 = cast v442 as Field + v445 = mul v439, v443 + v446 = mul v438, v444 + v447 = add v445, v446 + v448 = mul v447, v447 + v449 = mul v448, Field 2 + v451 = array_get v9, index Field 19 + v452 = not v451 + v453 = cast v451 as Field + v454 = cast v452 as Field + v455 = mul v449, v453 + v456 = mul v448, v454 + v457 = add v455, v456 + v458 = mul v457, v457 + v459 = mul v458, Field 2 + v461 = array_get v9, index Field 18 + v462 = not v461 + v463 = cast v461 as Field + v464 = cast v462 as Field + v465 = mul v459, v463 + v466 = mul v458, v464 + v467 = add v465, v466 + v468 = mul v467, v467 + v469 = mul v468, Field 2 + v471 = array_get v9, index Field 17 + v472 = not v471 + v473 = cast v471 as Field + v474 = cast v472 as Field + v475 = mul v469, v473 + v476 = mul v468, v474 + v477 = add v475, v476 + v478 = mul v477, v477 + v479 = mul v478, Field 2 + v481 = array_get v9, index Field 16 + v482 = not v481 + v483 = cast v481 as Field + v484 = cast v482 as Field + v485 = mul v479, v483 + v486 = mul v478, v484 + v487 = add v485, v486 + v488 = mul v487, v487 + v489 = mul v488, Field 2 + v491 = array_get v9, index Field 15 + v492 = not v491 + v493 = cast v491 as Field + v494 = cast v492 as Field + v495 = mul v489, v493 + v496 = mul v488, v494 + v497 = add v495, v496 + v498 = mul v497, v497 + v499 = mul v498, Field 2 + v501 = array_get v9, index Field 14 + v502 = not v501 + v503 = cast v501 as Field + v504 = cast v502 as Field + v505 = mul v499, v503 + v506 = mul v498, v504 + v507 = add v505, v506 + v508 = mul v507, v507 + v509 = mul v508, Field 2 + v511 = array_get v9, index Field 13 + v512 = not v511 + v513 = cast v511 as Field + v514 = cast v512 as Field + v515 = mul v509, v513 + v516 = mul v508, v514 + v517 = add v515, v516 + v518 = mul v517, v517 + v519 = mul v518, Field 2 + v521 = array_get v9, index Field 12 + v522 = not v521 + v523 = cast v521 as Field + v524 = cast v522 as Field + v525 = mul v519, v523 + v526 = mul v518, v524 + v527 = add v525, v526 + v528 = mul v527, v527 + v529 = mul v528, Field 2 + v531 = array_get v9, index Field 11 + v532 = not v531 + v533 = cast v531 as Field + v534 = cast v532 as Field + v535 = mul v529, v533 + v536 = mul v528, v534 + v537 = add v535, v536 + v538 = mul v537, v537 + v539 = mul v538, Field 2 + v541 = array_get v9, index Field 10 + v542 = not v541 + v543 = cast v541 as Field + v544 = cast v542 as Field + v545 = mul v539, v543 + v546 = mul v538, v544 + v547 = add v545, v546 + v548 = mul v547, v547 + v549 = mul v548, Field 2 + v551 = array_get v9, index Field 9 + v552 = not v551 + v553 = cast v551 as Field + v554 = cast v552 as Field + v555 = mul v549, v553 + v556 = mul v548, v554 + v557 = add v555, v556 + v558 = mul v557, v557 + v559 = mul v558, Field 2 + v561 = array_get v9, index Field 8 + v562 = not v561 + v563 = cast v561 as Field + v564 = cast v562 as Field + v565 = mul v559, v563 + v566 = mul v558, v564 + v567 = add v565, v566 + v568 = mul v567, v567 + v569 = mul v568, Field 2 + v571 = array_get v9, index Field 7 + v572 = not v571 + v573 = cast v571 as Field + v574 = cast v572 as Field + v575 = mul v569, v573 + v576 = mul v568, v574 + v577 = add v575, v576 + v578 = mul v577, v577 + v579 = mul v578, Field 2 + v581 = array_get v9, index Field 6 + v582 = not v581 + v583 = cast v581 as Field + v584 = cast v582 as Field + v585 = mul v579, v583 + v586 = mul v578, v584 + v587 = add v585, v586 + v588 = mul v587, v587 + v589 = mul v588, Field 2 + v591 = array_get v9, index Field 5 + v592 = not v591 + v593 = cast v591 as Field + v594 = cast v592 as Field + v595 = mul v589, v593 + v596 = mul v588, v594 + v597 = add v595, v596 + v598 = mul v597, v597 + v599 = mul v598, Field 2 + v601 = array_get v9, index Field 4 + v602 = not v601 + v603 = cast v601 as Field + v604 = cast v602 as Field + v605 = mul v599, v603 + v606 = mul v598, v604 + v607 = add v605, v606 + v608 = mul v607, v607 + v609 = mul v608, Field 2 + v611 = array_get v9, index Field 3 + v612 = not v611 + v613 = cast v611 as Field + v614 = cast v612 as Field + v615 = mul v609, v613 + v616 = mul v608, v614 + v617 = add v615, v616 + v618 = mul v617, v617 + v619 = mul v618, Field 2 + v620 = array_get v9, index Field 2 + v621 = not v620 + v622 = cast v620 as Field + v623 = cast v621 as Field + v624 = mul v619, v622 + v625 = mul v618, v623 + v626 = add v624, v625 + v627 = mul v626, v626 + v628 = mul v627, Field 2 + v629 = array_get v9, index Field 1 + v630 = not v629 + v631 = cast v629 as Field + v632 = cast v630 as Field + v633 = mul v628, v631 + v634 = mul v627, v632 + v635 = add v633, v634 + v636 = mul v635, v635 + v637 = mul v636, Field 2 + v639 = array_get v9, index Field 0 + v640 = not v639 + v641 = cast v639 as Field + v642 = cast v640 as Field + v643 = mul v637, v641 + v644 = mul v636, v642 + v645 = add v643, v644 + v646 = cast v645 as u64 + v647 = mul v6, v646 + v648 = cast v0 as Field + v649 = cast v647 as Field + v650 = mul v648, v649 + v651 = truncate v650 to 64 bits, max_bit_size: 254 + v652 = cast v651 as u64 + return v652 +} \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shr.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shr.cpp new file mode 100644 index 00000000000..1c04811916e --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shr.cpp @@ -0,0 +1,585 @@ + auto v5 = smt_terms::BVConst("1", &solver, 10); + auto v6 = v5; + auto v7 = v1; + auto v9 = v7; + auto v12 = v9 & smt_terms::BVConst("9223372036854775808", &solver, 10); + auto v13 = v12 ^ smt_terms::BVConst("1", &solver, 10); + auto v14 = v12; + auto v15 = v13; + auto v16 = v14 * smt_terms::BVConst("2", &solver, 10); + auto v17 = v16 + v15; + auto v18 = v17 * v17; + auto v19 = v18 * smt_terms::BVConst("2", &solver, 10); + auto v21 = v9 & smt_terms::BVConst("4611686018427387904", &solver, 10); + auto v22 = v21 ^ smt_terms::BVConst("1", &solver, 10); + auto v23 = v21; + auto v24 = v22; + auto v25 = v19 * v23; + auto v26 = v18 * v24; + auto v27 = v25 + v26; + auto v28 = v27 * v27; + auto v29 = v28 * smt_terms::BVConst("2", &solver, 10); + auto v31 = v9 & smt_terms::BVConst("2305843009213693952", &solver, 10); + auto v32 = v31 ^ smt_terms::BVConst("1", &solver, 10); + auto v33 = v31; + auto v34 = v32; + auto v35 = v29 * v33; + auto v36 = v28 * v34; + auto v37 = v35 + v36; + auto v38 = v37 * v37; + auto v39 = v38 * smt_terms::BVConst("2", &solver, 10); + auto v41 = v9 & smt_terms::BVConst("1152921504606846976", &solver, 10); + auto v42 = v41 ^ smt_terms::BVConst("1", &solver, 10); + auto v43 = v41; + auto v44 = v42; + auto v45 = v39 * v43; + auto v46 = v38 * v44; + auto v47 = v45 + v46; + auto v48 = v47 * v47; + auto v49 = v48 * smt_terms::BVConst("2", &solver, 10); + auto v51 = v9 & smt_terms::BVConst("576460752303423488", &solver, 10); + auto v52 = v51 ^ smt_terms::BVConst("1", &solver, 10); + auto v53 = v51; + auto v54 = v52; + auto v55 = v49 * v53; + auto v56 = v48 * v54; + auto v57 = v55 + v56; + auto v58 = v57 * v57; + auto v59 = v58 * smt_terms::BVConst("2", &solver, 10); + auto v61 = v9 & smt_terms::BVConst("288230376151711744", &solver, 10); + auto v62 = v61 ^ smt_terms::BVConst("1", &solver, 10); + auto v63 = v61; + auto v64 = v62; + auto v65 = v59 * v63; + auto v66 = v58 * v64; + auto v67 = v65 + v66; + auto v68 = v67 * v67; + auto v69 = v68 * smt_terms::BVConst("2", &solver, 10); + auto v71 = v9 & smt_terms::BVConst("144115188075855872", &solver, 10); + auto v72 = v71 ^ smt_terms::BVConst("1", &solver, 10); + auto v73 = v71; + auto v74 = v72; + auto v75 = v69 * v73; + auto v76 = v68 * v74; + auto v77 = v75 + v76; + auto v78 = v77 * v77; + auto v79 = v78 * smt_terms::BVConst("2", &solver, 10); + auto v81 = v9 & smt_terms::BVConst("72057594037927936", &solver, 10); + auto v82 = v81 ^ smt_terms::BVConst("1", &solver, 10); + auto v83 = v81; + auto v84 = v82; + auto v85 = v79 * v83; + auto v86 = v78 * v84; + auto v87 = v85 + v86; + auto v88 = v87 * v87; + auto v89 = v88 * smt_terms::BVConst("2", &solver, 10); + auto v91 = v9 & smt_terms::BVConst("36028797018963968", &solver, 10); + auto v92 = v91 ^ smt_terms::BVConst("1", &solver, 10); + auto v93 = v91; + auto v94 = v92; + auto v95 = v89 * v93; + auto v96 = v88 * v94; + auto v97 = v95 + v96; + auto v98 = v97 * v97; + auto v99 = v98 * smt_terms::BVConst("2", &solver, 10); + auto v101 = v9 & smt_terms::BVConst("18014398509481984", &solver, 10); + auto v102 = v101 ^ smt_terms::BVConst("1", &solver, 10); + auto v103 = v101; + auto v104 = v102; + auto v105 = v99 * v103; + auto v106 = v98 * v104; + auto v107 = v105 + v106; + auto v108 = v107 * v107; + auto v109 = v108 * smt_terms::BVConst("2", &solver, 10); + auto v111 = v9 & smt_terms::BVConst("9007199254740992", &solver, 10); + auto v112 = v111 ^ smt_terms::BVConst("1", &solver, 10); + auto v113 = v111; + auto v114 = v112; + auto v115 = v109 * v113; + auto v116 = v108 * v114; + auto v117 = v115 + v116; + auto v118 = v117 * v117; + auto v119 = v118 * smt_terms::BVConst("2", &solver, 10); + auto v121 = v9 & smt_terms::BVConst("4503599627370496", &solver, 10); + auto v122 = v121 ^ smt_terms::BVConst("1", &solver, 10); + auto v123 = v121; + auto v124 = v122; + auto v125 = v119 * v123; + auto v126 = v118 * v124; + auto v127 = v125 + v126; + auto v128 = v127 * v127; + auto v129 = v128 * smt_terms::BVConst("2", &solver, 10); + auto v131 = v9 & smt_terms::BVConst("2251799813685248", &solver, 10); + auto v132 = v131 ^ smt_terms::BVConst("1", &solver, 10); + auto v133 = v131; + auto v134 = v132; + auto v135 = v129 * v133; + auto v136 = v128 * v134; + auto v137 = v135 + v136; + auto v138 = v137 * v137; + auto v139 = v138 * smt_terms::BVConst("2", &solver, 10); + auto v141 = v9 & smt_terms::BVConst("1125899906842624", &solver, 10); + auto v142 = v141 ^ smt_terms::BVConst("1", &solver, 10); + auto v143 = v141; + auto v144 = v142; + auto v145 = v139 * v143; + auto v146 = v138 * v144; + auto v147 = v145 + v146; + auto v148 = v147 * v147; + auto v149 = v148 * smt_terms::BVConst("2", &solver, 10); + auto v151 = v9 & smt_terms::BVConst("562949953421312", &solver, 10); + auto v152 = v151 ^ smt_terms::BVConst("1", &solver, 10); + auto v153 = v151; + auto v154 = v152; + auto v155 = v149 * v153; + auto v156 = v148 * v154; + auto v157 = v155 + v156; + auto v158 = v157 * v157; + auto v159 = v158 * smt_terms::BVConst("2", &solver, 10); + auto v161 = v9 & smt_terms::BVConst("281474976710656", &solver, 10); + auto v162 = v161 ^ smt_terms::BVConst("1", &solver, 10); + auto v163 = v161; + auto v164 = v162; + auto v165 = v159 * v163; + auto v166 = v158 * v164; + auto v167 = v165 + v166; + auto v168 = v167 * v167; + auto v169 = v168 * smt_terms::BVConst("2", &solver, 10); + auto v171 = v9 & smt_terms::BVConst("140737488355328", &solver, 10); + auto v172 = v171 ^ smt_terms::BVConst("1", &solver, 10); + auto v173 = v171; + auto v174 = v172; + auto v175 = v169 * v173; + auto v176 = v168 * v174; + auto v177 = v175 + v176; + auto v178 = v177 * v177; + auto v179 = v178 * smt_terms::BVConst("2", &solver, 10); + auto v181 = v9 & smt_terms::BVConst("70368744177664", &solver, 10); + auto v182 = v181 ^ smt_terms::BVConst("1", &solver, 10); + auto v183 = v181; + auto v184 = v182; + auto v185 = v179 * v183; + auto v186 = v178 * v184; + auto v187 = v185 + v186; + auto v188 = v187 * v187; + auto v189 = v188 * smt_terms::BVConst("2", &solver, 10); + auto v191 = v9 & smt_terms::BVConst("35184372088832", &solver, 10); + auto v192 = v191 ^ smt_terms::BVConst("1", &solver, 10); + auto v193 = v191; + auto v194 = v192; + auto v195 = v189 * v193; + auto v196 = v188 * v194; + auto v197 = v195 + v196; + auto v198 = v197 * v197; + auto v199 = v198 * smt_terms::BVConst("2", &solver, 10); + auto v201 = v9 & smt_terms::BVConst("17592186044416", &solver, 10); + auto v202 = v201 ^ smt_terms::BVConst("1", &solver, 10); + auto v203 = v201; + auto v204 = v202; + auto v205 = v199 * v203; + auto v206 = v198 * v204; + auto v207 = v205 + v206; + auto v208 = v207 * v207; + auto v209 = v208 * smt_terms::BVConst("2", &solver, 10); + auto v211 = v9 & smt_terms::BVConst("8796093022208", &solver, 10); + auto v212 = v211 ^ smt_terms::BVConst("1", &solver, 10); + auto v213 = v211; + auto v214 = v212; + auto v215 = v209 * v213; + auto v216 = v208 * v214; + auto v217 = v215 + v216; + auto v218 = v217 * v217; + auto v219 = v218 * smt_terms::BVConst("2", &solver, 10); + auto v221 = v9 & smt_terms::BVConst("4398046511104", &solver, 10); + auto v222 = v221 ^ smt_terms::BVConst("1", &solver, 10); + auto v223 = v221; + auto v224 = v222; + auto v225 = v219 * v223; + auto v226 = v218 * v224; + auto v227 = v225 + v226; + auto v228 = v227 * v227; + auto v229 = v228 * smt_terms::BVConst("2", &solver, 10); + auto v231 = v9 & smt_terms::BVConst("2199023255552", &solver, 10); + auto v232 = v231 ^ smt_terms::BVConst("1", &solver, 10); + auto v233 = v231; + auto v234 = v232; + auto v235 = v229 * v233; + auto v236 = v228 * v234; + auto v237 = v235 + v236; + auto v238 = v237 * v237; + auto v239 = v238 * smt_terms::BVConst("2", &solver, 10); + auto v241 = v9 & smt_terms::BVConst("1099511627776", &solver, 10); + auto v242 = v241 ^ smt_terms::BVConst("1", &solver, 10); + auto v243 = v241; + auto v244 = v242; + auto v245 = v239 * v243; + auto v246 = v238 * v244; + auto v247 = v245 + v246; + auto v248 = v247 * v247; + auto v249 = v248 * smt_terms::BVConst("2", &solver, 10); + auto v251 = v9 & smt_terms::BVConst("549755813888", &solver, 10); + auto v252 = v251 ^ smt_terms::BVConst("1", &solver, 10); + auto v253 = v251; + auto v254 = v252; + auto v255 = v249 * v253; + auto v256 = v248 * v254; + auto v257 = v255 + v256; + auto v258 = v257 * v257; + auto v259 = v258 * smt_terms::BVConst("2", &solver, 10); + auto v261 = v9 & smt_terms::BVConst("274877906944", &solver, 10); + auto v262 = v261 ^ smt_terms::BVConst("1", &solver, 10); + auto v263 = v261; + auto v264 = v262; + auto v265 = v259 * v263; + auto v266 = v258 * v264; + auto v267 = v265 + v266; + auto v268 = v267 * v267; + auto v269 = v268 * smt_terms::BVConst("2", &solver, 10); + auto v271 = v9 & smt_terms::BVConst("137438953472", &solver, 10); + auto v272 = v271 ^ smt_terms::BVConst("1", &solver, 10); + auto v273 = v271; + auto v274 = v272; + auto v275 = v269 * v273; + auto v276 = v268 * v274; + auto v277 = v275 + v276; + auto v278 = v277 * v277; + auto v279 = v278 * smt_terms::BVConst("2", &solver, 10); + auto v281 = v9 & smt_terms::BVConst("68719476736", &solver, 10); + auto v282 = v281 ^ smt_terms::BVConst("1", &solver, 10); + auto v283 = v281; + auto v284 = v282; + auto v285 = v279 * v283; + auto v286 = v278 * v284; + auto v287 = v285 + v286; + auto v288 = v287 * v287; + auto v289 = v288 * smt_terms::BVConst("2", &solver, 10); + auto v291 = v9 & smt_terms::BVConst("34359738368", &solver, 10); + auto v292 = v291 ^ smt_terms::BVConst("1", &solver, 10); + auto v293 = v291; + auto v294 = v292; + auto v295 = v289 * v293; + auto v296 = v288 * v294; + auto v297 = v295 + v296; + auto v298 = v297 * v297; + auto v299 = v298 * smt_terms::BVConst("2", &solver, 10); + auto v301 = v9 & smt_terms::BVConst("17179869184", &solver, 10); + auto v302 = v301 ^ smt_terms::BVConst("1", &solver, 10); + auto v303 = v301; + auto v304 = v302; + auto v305 = v299 * v303; + auto v306 = v298 * v304; + auto v307 = v305 + v306; + auto v308 = v307 * v307; + auto v309 = v308 * smt_terms::BVConst("2", &solver, 10); + auto v311 = v9 & smt_terms::BVConst("8589934592", &solver, 10); + auto v312 = v311 ^ smt_terms::BVConst("1", &solver, 10); + auto v313 = v311; + auto v314 = v312; + auto v315 = v309 * v313; + auto v316 = v308 * v314; + auto v317 = v315 + v316; + auto v318 = v317 * v317; + auto v319 = v318 * smt_terms::BVConst("2", &solver, 10); + auto v321 = v9 & smt_terms::BVConst("4294967296", &solver, 10); + auto v322 = v321 ^ smt_terms::BVConst("1", &solver, 10); + auto v323 = v321; + auto v324 = v322; + auto v325 = v319 * v323; + auto v326 = v318 * v324; + auto v327 = v325 + v326; + auto v328 = v327 * v327; + auto v329 = v328 * smt_terms::BVConst("2", &solver, 10); + auto v331 = v9 & smt_terms::BVConst("2147483648", &solver, 10); + auto v332 = v331 ^ smt_terms::BVConst("1", &solver, 10); + auto v333 = v331; + auto v334 = v332; + auto v335 = v329 * v333; + auto v336 = v328 * v334; + auto v337 = v335 + v336; + auto v338 = v337 * v337; + auto v339 = v338 * smt_terms::BVConst("2", &solver, 10); + auto v341 = v9 & smt_terms::BVConst("1073741824", &solver, 10); + auto v342 = v341 ^ smt_terms::BVConst("1", &solver, 10); + auto v343 = v341; + auto v344 = v342; + auto v345 = v339 * v343; + auto v346 = v338 * v344; + auto v347 = v345 + v346; + auto v348 = v347 * v347; + auto v349 = v348 * smt_terms::BVConst("2", &solver, 10); + auto v351 = v9 & smt_terms::BVConst("536870912", &solver, 10); + auto v352 = v351 ^ smt_terms::BVConst("1", &solver, 10); + auto v353 = v351; + auto v354 = v352; + auto v355 = v349 * v353; + auto v356 = v348 * v354; + auto v357 = v355 + v356; + auto v358 = v357 * v357; + auto v359 = v358 * smt_terms::BVConst("2", &solver, 10); + auto v361 = v9 & smt_terms::BVConst("268435456", &solver, 10); + auto v362 = v361 ^ smt_terms::BVConst("1", &solver, 10); + auto v363 = v361; + auto v364 = v362; + auto v365 = v359 * v363; + auto v366 = v358 * v364; + auto v367 = v365 + v366; + auto v368 = v367 * v367; + auto v369 = v368 * smt_terms::BVConst("2", &solver, 10); + auto v371 = v9 & smt_terms::BVConst("134217728", &solver, 10); + auto v372 = v371 ^ smt_terms::BVConst("1", &solver, 10); + auto v373 = v371; + auto v374 = v372; + auto v375 = v369 * v373; + auto v376 = v368 * v374; + auto v377 = v375 + v376; + auto v378 = v377 * v377; + auto v379 = v378 * smt_terms::BVConst("2", &solver, 10); + auto v381 = v9 & smt_terms::BVConst("67108864", &solver, 10); + auto v382 = v381 ^ smt_terms::BVConst("1", &solver, 10); + auto v383 = v381; + auto v384 = v382; + auto v385 = v379 * v383; + auto v386 = v378 * v384; + auto v387 = v385 + v386; + auto v388 = v387 * v387; + auto v389 = v388 * smt_terms::BVConst("2", &solver, 10); + auto v391 = v9 & smt_terms::BVConst("33554432", &solver, 10); + auto v392 = v391 ^ smt_terms::BVConst("1", &solver, 10); + auto v393 = v391; + auto v394 = v392; + auto v395 = v389 * v393; + auto v396 = v388 * v394; + auto v397 = v395 + v396; + auto v398 = v397 * v397; + auto v399 = v398 * smt_terms::BVConst("2", &solver, 10); + auto v401 = v9 & smt_terms::BVConst("16777216", &solver, 10); + auto v402 = v401 ^ smt_terms::BVConst("1", &solver, 10); + auto v403 = v401; + auto v404 = v402; + auto v405 = v399 * v403; + auto v406 = v398 * v404; + auto v407 = v405 + v406; + auto v408 = v407 * v407; + auto v409 = v408 * smt_terms::BVConst("2", &solver, 10); + auto v411 = v9 & smt_terms::BVConst("8388608", &solver, 10); + auto v412 = v411 ^ smt_terms::BVConst("1", &solver, 10); + auto v413 = v411; + auto v414 = v412; + auto v415 = v409 * v413; + auto v416 = v408 * v414; + auto v417 = v415 + v416; + auto v418 = v417 * v417; + auto v419 = v418 * smt_terms::BVConst("2", &solver, 10); + auto v421 = v9 & smt_terms::BVConst("4194304", &solver, 10); + auto v422 = v421 ^ smt_terms::BVConst("1", &solver, 10); + auto v423 = v421; + auto v424 = v422; + auto v425 = v419 * v423; + auto v426 = v418 * v424; + auto v427 = v425 + v426; + auto v428 = v427 * v427; + auto v429 = v428 * smt_terms::BVConst("2", &solver, 10); + auto v431 = v9 & smt_terms::BVConst("2097152", &solver, 10); + auto v432 = v431 ^ smt_terms::BVConst("1", &solver, 10); + auto v433 = v431; + auto v434 = v432; + auto v435 = v429 * v433; + auto v436 = v428 * v434; + auto v437 = v435 + v436; + auto v438 = v437 * v437; + auto v439 = v438 * smt_terms::BVConst("2", &solver, 10); + auto v441 = v9 & smt_terms::BVConst("1048576", &solver, 10); + auto v442 = v441 ^ smt_terms::BVConst("1", &solver, 10); + auto v443 = v441; + auto v444 = v442; + auto v445 = v439 * v443; + auto v446 = v438 * v444; + auto v447 = v445 + v446; + auto v448 = v447 * v447; + auto v449 = v448 * smt_terms::BVConst("2", &solver, 10); + auto v451 = v9 & smt_terms::BVConst("524288", &solver, 10); + auto v452 = v451 ^ smt_terms::BVConst("1", &solver, 10); + auto v453 = v451; + auto v454 = v452; + auto v455 = v449 * v453; + auto v456 = v448 * v454; + auto v457 = v455 + v456; + auto v458 = v457 * v457; + auto v459 = v458 * smt_terms::BVConst("2", &solver, 10); + auto v461 = v9 & smt_terms::BVConst("262144", &solver, 10); + auto v462 = v461 ^ smt_terms::BVConst("1", &solver, 10); + auto v463 = v461; + auto v464 = v462; + auto v465 = v459 * v463; + auto v466 = v458 * v464; + auto v467 = v465 + v466; + auto v468 = v467 * v467; + auto v469 = v468 * smt_terms::BVConst("2", &solver, 10); + auto v471 = v9 & smt_terms::BVConst("131072", &solver, 10); + auto v472 = v471 ^ smt_terms::BVConst("1", &solver, 10); + auto v473 = v471; + auto v474 = v472; + auto v475 = v469 * v473; + auto v476 = v468 * v474; + auto v477 = v475 + v476; + auto v478 = v477 * v477; + auto v479 = v478 * smt_terms::BVConst("2", &solver, 10); + auto v481 = v9 & smt_terms::BVConst("65536", &solver, 10); + auto v482 = v481 ^ smt_terms::BVConst("1", &solver, 10); + auto v483 = v481; + auto v484 = v482; + auto v485 = v479 * v483; + auto v486 = v478 * v484; + auto v487 = v485 + v486; + auto v488 = v487 * v487; + auto v489 = v488 * smt_terms::BVConst("2", &solver, 10); + auto v491 = v9 & smt_terms::BVConst("32768", &solver, 10); + auto v492 = v491 ^ smt_terms::BVConst("1", &solver, 10); + auto v493 = v491; + auto v494 = v492; + auto v495 = v489 * v493; + auto v496 = v488 * v494; + auto v497 = v495 + v496; + auto v498 = v497 * v497; + auto v499 = v498 * smt_terms::BVConst("2", &solver, 10); + auto v501 = v9 & smt_terms::BVConst("16384", &solver, 10); + auto v502 = v501 ^ smt_terms::BVConst("1", &solver, 10); + auto v503 = v501; + auto v504 = v502; + auto v505 = v499 * v503; + auto v506 = v498 * v504; + auto v507 = v505 + v506; + auto v508 = v507 * v507; + auto v509 = v508 * smt_terms::BVConst("2", &solver, 10); + auto v511 = v9 & smt_terms::BVConst("8192", &solver, 10); + auto v512 = v511 ^ smt_terms::BVConst("1", &solver, 10); + auto v513 = v511; + auto v514 = v512; + auto v515 = v509 * v513; + auto v516 = v508 * v514; + auto v517 = v515 + v516; + auto v518 = v517 * v517; + auto v519 = v518 * smt_terms::BVConst("2", &solver, 10); + auto v521 = v9 & smt_terms::BVConst("4096", &solver, 10); + auto v522 = v521 ^ smt_terms::BVConst("1", &solver, 10); + auto v523 = v521; + auto v524 = v522; + auto v525 = v519 * v523; + auto v526 = v518 * v524; + auto v527 = v525 + v526; + auto v528 = v527 * v527; + auto v529 = v528 * smt_terms::BVConst("2", &solver, 10); + auto v531 = v9 & smt_terms::BVConst("2048", &solver, 10); + auto v532 = v531 ^ smt_terms::BVConst("1", &solver, 10); + auto v533 = v531; + auto v534 = v532; + auto v535 = v529 * v533; + auto v536 = v528 * v534; + auto v537 = v535 + v536; + auto v538 = v537 * v537; + auto v539 = v538 * smt_terms::BVConst("2", &solver, 10); + auto v541 = v9 & smt_terms::BVConst("1024", &solver, 10); + auto v542 = v541 ^ smt_terms::BVConst("1", &solver, 10); + auto v543 = v541; + auto v544 = v542; + auto v545 = v539 * v543; + auto v546 = v538 * v544; + auto v547 = v545 + v546; + auto v548 = v547 * v547; + auto v549 = v548 * smt_terms::BVConst("2", &solver, 10); + auto v551 = v9 & smt_terms::BVConst("512", &solver, 10); + auto v552 = v551 ^ smt_terms::BVConst("1", &solver, 10); + auto v553 = v551; + auto v554 = v552; + auto v555 = v549 * v553; + auto v556 = v548 * v554; + auto v557 = v555 + v556; + auto v558 = v557 * v557; + auto v559 = v558 * smt_terms::BVConst("2", &solver, 10); + auto v561 = v9 & smt_terms::BVConst("256", &solver, 10); + auto v562 = v561 ^ smt_terms::BVConst("1", &solver, 10); + auto v563 = v561; + auto v564 = v562; + auto v565 = v559 * v563; + auto v566 = v558 * v564; + auto v567 = v565 + v566; + auto v568 = v567 * v567; + auto v569 = v568 * smt_terms::BVConst("2", &solver, 10); + auto v571 = v9 & smt_terms::BVConst("128", &solver, 10); + auto v572 = v571 ^ smt_terms::BVConst("1", &solver, 10); + auto v573 = v571; + auto v574 = v572; + auto v575 = v569 * v573; + auto v576 = v568 * v574; + auto v577 = v575 + v576; + auto v578 = v577 * v577; + auto v579 = v578 * smt_terms::BVConst("2", &solver, 10); + auto v581 = v9 & smt_terms::BVConst("64", &solver, 10); + auto v582 = v581 ^ smt_terms::BVConst("1", &solver, 10); + auto v583 = v581; + auto v584 = v582; + auto v585 = v579 * v583; + auto v586 = v578 * v584; + auto v587 = v585 + v586; + auto v588 = v587 * v587; + auto v589 = v588 * smt_terms::BVConst("2", &solver, 10); + auto v591 = v9 & smt_terms::BVConst("32", &solver, 10); + auto v592 = v591 ^ smt_terms::BVConst("1", &solver, 10); + auto v593 = v591; + auto v594 = v592; + auto v595 = v589 * v593; + auto v596 = v588 * v594; + auto v597 = v595 + v596; + auto v598 = v597 * v597; + auto v599 = v598 * smt_terms::BVConst("2", &solver, 10); + auto v601 = v9 & smt_terms::BVConst("16", &solver, 10); + auto v602 = v601 ^ smt_terms::BVConst("1", &solver, 10); + auto v603 = v601; + auto v604 = v602; + auto v605 = v599 * v603; + auto v606 = v598 * v604; + auto v607 = v605 + v606; + auto v608 = v607 * v607; + auto v609 = v608 * smt_terms::BVConst("2", &solver, 10); + auto v611 = v9 & smt_terms::BVConst("8", &solver, 10); + auto v612 = v611 ^ smt_terms::BVConst("1", &solver, 10); + auto v613 = v611; + auto v614 = v612; + auto v615 = v609 * v613; + auto v616 = v608 * v614; + auto v617 = v615 + v616; + auto v618 = v617 * v617; + auto v619 = v618 * smt_terms::BVConst("2", &solver, 10); + auto v620 = v9 & smt_terms::BVConst("4", &solver, 10); + auto v621 = v620 ^ smt_terms::BVConst("1", &solver, 10); + auto v622 = v620; + auto v623 = v621; + auto v624 = v619 * v622; + auto v625 = v618 * v623; + auto v626 = v624 + v625; + auto v627 = v626 * v626; + auto v628 = v627 * smt_terms::BVConst("2", &solver, 10); + auto v629 = v9 & smt_terms::BVConst("2", &solver, 10); + auto v630 = v629 ^ smt_terms::BVConst("1", &solver, 10); + auto v631 = v629; + auto v632 = v630; + auto v633 = v628 * v631; + auto v634 = v627 * v632; + auto v635 = v633 + v634; + auto v636 = v635 * v635; + auto v637 = v636 * smt_terms::BVConst("2", &solver, 10); + auto v639 = v9 & smt_terms::BVConst("1", &solver, 10); + auto v640 = v639 ^ smt_terms::BVConst("1", &solver, 10); + auto v641 = v639; + auto v642 = v640; + auto v643 = v637 * v641; + auto v644 = v636 * v642; + auto v645 = v643 + v644; + auto v646 = v645; + auto v647 = v6 * v646; + auto v648 = v0; + auto v649 = v647; + auto v650 = v648 * v649; + auto v651 = v650 & smt_terms::BVConst("18446744073709551615", &solver, 10); + auto v652 = v651; + auto cr = v652; \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shr.ssa b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shr.ssa new file mode 100644 index 00000000000..b2d1ac6ec5f --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shr.ssa @@ -0,0 +1,588 @@ +acir(inline) fn main f0 { + b0(v0: u64, v1: u8): + v5 = lt v1, u8 64 + v6 = cast v5 as u64 + v7 = cast v1 as u64 + v9 = call to_le_bits(v7) -> [u1; 64] + v12 = array_get v9, index Field 63 -> u1 + v13 = not v12 + v14 = cast v12 as Field + v15 = cast v13 as Field + v16 = mul Field 2, v14 + v17 = add v16, v15 + v18 = mul v17, v17 + v19 = mul v18, Field 2 + v21 = array_get v9, index Field 62 -> u1 + v22 = not v21 + v23 = cast v21 as Field + v24 = cast v22 as Field + v25 = mul v19, v23 + v26 = mul v18, v24 + v27 = add v25, v26 + v28 = mul v27, v27 + v29 = mul v28, Field 2 + v31 = array_get v9, index Field 61 -> u1 + v32 = not v31 + v33 = cast v31 as Field + v34 = cast v32 as Field + v35 = mul v29, v33 + v36 = mul v28, v34 + v37 = add v35, v36 + v38 = mul v37, v37 + v39 = mul v38, Field 2 + v41 = array_get v9, index Field 60 -> u1 + v42 = not v41 + v43 = cast v41 as Field + v44 = cast v42 as Field + v45 = mul v39, v43 + v46 = mul v38, v44 + v47 = add v45, v46 + v48 = mul v47, v47 + v49 = mul v48, Field 2 + v51 = array_get v9, index Field 59 -> u1 + v52 = not v51 + v53 = cast v51 as Field + v54 = cast v52 as Field + v55 = mul v49, v53 + v56 = mul v48, v54 + v57 = add v55, v56 + v58 = mul v57, v57 + v59 = mul v58, Field 2 + v61 = array_get v9, index Field 58 -> u1 + v62 = not v61 + v63 = cast v61 as Field + v64 = cast v62 as Field + v65 = mul v59, v63 + v66 = mul v58, v64 + v67 = add v65, v66 + v68 = mul v67, v67 + v69 = mul v68, Field 2 + v71 = array_get v9, index Field 57 -> u1 + v72 = not v71 + v73 = cast v71 as Field + v74 = cast v72 as Field + v75 = mul v69, v73 + v76 = mul v68, v74 + v77 = add v75, v76 + v78 = mul v77, v77 + v79 = mul v78, Field 2 + v81 = array_get v9, index Field 56 -> u1 + v82 = not v81 + v83 = cast v81 as Field + v84 = cast v82 as Field + v85 = mul v79, v83 + v86 = mul v78, v84 + v87 = add v85, v86 + v88 = mul v87, v87 + v89 = mul v88, Field 2 + v91 = array_get v9, index Field 55 -> u1 + v92 = not v91 + v93 = cast v91 as Field + v94 = cast v92 as Field + v95 = mul v89, v93 + v96 = mul v88, v94 + v97 = add v95, v96 + v98 = mul v97, v97 + v99 = mul v98, Field 2 + v101 = array_get v9, index Field 54 -> u1 + v102 = not v101 + v103 = cast v101 as Field + v104 = cast v102 as Field + v105 = mul v99, v103 + v106 = mul v98, v104 + v107 = add v105, v106 + v108 = mul v107, v107 + v109 = mul v108, Field 2 + v111 = array_get v9, index Field 53 -> u1 + v112 = not v111 + v113 = cast v111 as Field + v114 = cast v112 as Field + v115 = mul v109, v113 + v116 = mul v108, v114 + v117 = add v115, v116 + v118 = mul v117, v117 + v119 = mul v118, Field 2 + v121 = array_get v9, index Field 52 -> u1 + v122 = not v121 + v123 = cast v121 as Field + v124 = cast v122 as Field + v125 = mul v119, v123 + v126 = mul v118, v124 + v127 = add v125, v126 + v128 = mul v127, v127 + v129 = mul v128, Field 2 + v131 = array_get v9, index Field 51 -> u1 + v132 = not v131 + v133 = cast v131 as Field + v134 = cast v132 as Field + v135 = mul v129, v133 + v136 = mul v128, v134 + v137 = add v135, v136 + v138 = mul v137, v137 + v139 = mul v138, Field 2 + v141 = array_get v9, index Field 50 -> u1 + v142 = not v141 + v143 = cast v141 as Field + v144 = cast v142 as Field + v145 = mul v139, v143 + v146 = mul v138, v144 + v147 = add v145, v146 + v148 = mul v147, v147 + v149 = mul v148, Field 2 + v151 = array_get v9, index Field 49 -> u1 + v152 = not v151 + v153 = cast v151 as Field + v154 = cast v152 as Field + v155 = mul v149, v153 + v156 = mul v148, v154 + v157 = add v155, v156 + v158 = mul v157, v157 + v159 = mul v158, Field 2 + v161 = array_get v9, index Field 48 -> u1 + v162 = not v161 + v163 = cast v161 as Field + v164 = cast v162 as Field + v165 = mul v159, v163 + v166 = mul v158, v164 + v167 = add v165, v166 + v168 = mul v167, v167 + v169 = mul v168, Field 2 + v171 = array_get v9, index Field 47 -> u1 + v172 = not v171 + v173 = cast v171 as Field + v174 = cast v172 as Field + v175 = mul v169, v173 + v176 = mul v168, v174 + v177 = add v175, v176 + v178 = mul v177, v177 + v179 = mul v178, Field 2 + v181 = array_get v9, index Field 46 -> u1 + v182 = not v181 + v183 = cast v181 as Field + v184 = cast v182 as Field + v185 = mul v179, v183 + v186 = mul v178, v184 + v187 = add v185, v186 + v188 = mul v187, v187 + v189 = mul v188, Field 2 + v191 = array_get v9, index Field 45 -> u1 + v192 = not v191 + v193 = cast v191 as Field + v194 = cast v192 as Field + v195 = mul v189, v193 + v196 = mul v188, v194 + v197 = add v195, v196 + v198 = mul v197, v197 + v199 = mul v198, Field 2 + v201 = array_get v9, index Field 44 -> u1 + v202 = not v201 + v203 = cast v201 as Field + v204 = cast v202 as Field + v205 = mul v199, v203 + v206 = mul v198, v204 + v207 = add v205, v206 + v208 = mul v207, v207 + v209 = mul v208, Field 2 + v211 = array_get v9, index Field 43 -> u1 + v212 = not v211 + v213 = cast v211 as Field + v214 = cast v212 as Field + v215 = mul v209, v213 + v216 = mul v208, v214 + v217 = add v215, v216 + v218 = mul v217, v217 + v219 = mul v218, Field 2 + v221 = array_get v9, index Field 42 -> u1 + v222 = not v221 + v223 = cast v221 as Field + v224 = cast v222 as Field + v225 = mul v219, v223 + v226 = mul v218, v224 + v227 = add v225, v226 + v228 = mul v227, v227 + v229 = mul v228, Field 2 + v231 = array_get v9, index Field 41 -> u1 + v232 = not v231 + v233 = cast v231 as Field + v234 = cast v232 as Field + v235 = mul v229, v233 + v236 = mul v228, v234 + v237 = add v235, v236 + v238 = mul v237, v237 + v239 = mul v238, Field 2 + v241 = array_get v9, index Field 40 -> u1 + v242 = not v241 + v243 = cast v241 as Field + v244 = cast v242 as Field + v245 = mul v239, v243 + v246 = mul v238, v244 + v247 = add v245, v246 + v248 = mul v247, v247 + v249 = mul v248, Field 2 + v251 = array_get v9, index Field 39 -> u1 + v252 = not v251 + v253 = cast v251 as Field + v254 = cast v252 as Field + v255 = mul v249, v253 + v256 = mul v248, v254 + v257 = add v255, v256 + v258 = mul v257, v257 + v259 = mul v258, Field 2 + v261 = array_get v9, index Field 38 -> u1 + v262 = not v261 + v263 = cast v261 as Field + v264 = cast v262 as Field + v265 = mul v259, v263 + v266 = mul v258, v264 + v267 = add v265, v266 + v268 = mul v267, v267 + v269 = mul v268, Field 2 + v271 = array_get v9, index Field 37 -> u1 + v272 = not v271 + v273 = cast v271 as Field + v274 = cast v272 as Field + v275 = mul v269, v273 + v276 = mul v268, v274 + v277 = add v275, v276 + v278 = mul v277, v277 + v279 = mul v278, Field 2 + v281 = array_get v9, index Field 36 -> u1 + v282 = not v281 + v283 = cast v281 as Field + v284 = cast v282 as Field + v285 = mul v279, v283 + v286 = mul v278, v284 + v287 = add v285, v286 + v288 = mul v287, v287 + v289 = mul v288, Field 2 + v291 = array_get v9, index Field 35 -> u1 + v292 = not v291 + v293 = cast v291 as Field + v294 = cast v292 as Field + v295 = mul v289, v293 + v296 = mul v288, v294 + v297 = add v295, v296 + v298 = mul v297, v297 + v299 = mul v298, Field 2 + v301 = array_get v9, index Field 34 -> u1 + v302 = not v301 + v303 = cast v301 as Field + v304 = cast v302 as Field + v305 = mul v299, v303 + v306 = mul v298, v304 + v307 = add v305, v306 + v308 = mul v307, v307 + v309 = mul v308, Field 2 + v311 = array_get v9, index Field 33 -> u1 + v312 = not v311 + v313 = cast v311 as Field + v314 = cast v312 as Field + v315 = mul v309, v313 + v316 = mul v308, v314 + v317 = add v315, v316 + v318 = mul v317, v317 + v319 = mul v318, Field 2 + v321 = array_get v9, index Field 32 -> u1 + v322 = not v321 + v323 = cast v321 as Field + v324 = cast v322 as Field + v325 = mul v319, v323 + v326 = mul v318, v324 + v327 = add v325, v326 + v328 = mul v327, v327 + v329 = mul v328, Field 2 + v331 = array_get v9, index Field 31 -> u1 + v332 = not v331 + v333 = cast v331 as Field + v334 = cast v332 as Field + v335 = mul v329, v333 + v336 = mul v328, v334 + v337 = add v335, v336 + v338 = mul v337, v337 + v339 = mul v338, Field 2 + v341 = array_get v9, index Field 30 -> u1 + v342 = not v341 + v343 = cast v341 as Field + v344 = cast v342 as Field + v345 = mul v339, v343 + v346 = mul v338, v344 + v347 = add v345, v346 + v348 = mul v347, v347 + v349 = mul v348, Field 2 + v351 = array_get v9, index Field 29 -> u1 + v352 = not v351 + v353 = cast v351 as Field + v354 = cast v352 as Field + v355 = mul v349, v353 + v356 = mul v348, v354 + v357 = add v355, v356 + v358 = mul v357, v357 + v359 = mul v358, Field 2 + v361 = array_get v9, index Field 28 -> u1 + v362 = not v361 + v363 = cast v361 as Field + v364 = cast v362 as Field + v365 = mul v359, v363 + v366 = mul v358, v364 + v367 = add v365, v366 + v368 = mul v367, v367 + v369 = mul v368, Field 2 + v371 = array_get v9, index Field 27 -> u1 + v372 = not v371 + v373 = cast v371 as Field + v374 = cast v372 as Field + v375 = mul v369, v373 + v376 = mul v368, v374 + v377 = add v375, v376 + v378 = mul v377, v377 + v379 = mul v378, Field 2 + v381 = array_get v9, index Field 26 -> u1 + v382 = not v381 + v383 = cast v381 as Field + v384 = cast v382 as Field + v385 = mul v379, v383 + v386 = mul v378, v384 + v387 = add v385, v386 + v388 = mul v387, v387 + v389 = mul v388, Field 2 + v391 = array_get v9, index Field 25 -> u1 + v392 = not v391 + v393 = cast v391 as Field + v394 = cast v392 as Field + v395 = mul v389, v393 + v396 = mul v388, v394 + v397 = add v395, v396 + v398 = mul v397, v397 + v399 = mul v398, Field 2 + v401 = array_get v9, index Field 24 -> u1 + v402 = not v401 + v403 = cast v401 as Field + v404 = cast v402 as Field + v405 = mul v399, v403 + v406 = mul v398, v404 + v407 = add v405, v406 + v408 = mul v407, v407 + v409 = mul v408, Field 2 + v411 = array_get v9, index Field 23 -> u1 + v412 = not v411 + v413 = cast v411 as Field + v414 = cast v412 as Field + v415 = mul v409, v413 + v416 = mul v408, v414 + v417 = add v415, v416 + v418 = mul v417, v417 + v419 = mul v418, Field 2 + v421 = array_get v9, index Field 22 -> u1 + v422 = not v421 + v423 = cast v421 as Field + v424 = cast v422 as Field + v425 = mul v419, v423 + v426 = mul v418, v424 + v427 = add v425, v426 + v428 = mul v427, v427 + v429 = mul v428, Field 2 + v431 = array_get v9, index Field 21 -> u1 + v432 = not v431 + v433 = cast v431 as Field + v434 = cast v432 as Field + v435 = mul v429, v433 + v436 = mul v428, v434 + v437 = add v435, v436 + v438 = mul v437, v437 + v439 = mul v438, Field 2 + v441 = array_get v9, index Field 20 -> u1 + v442 = not v441 + v443 = cast v441 as Field + v444 = cast v442 as Field + v445 = mul v439, v443 + v446 = mul v438, v444 + v447 = add v445, v446 + v448 = mul v447, v447 + v449 = mul v448, Field 2 + v451 = array_get v9, index Field 19 -> u1 + v452 = not v451 + v453 = cast v451 as Field + v454 = cast v452 as Field + v455 = mul v449, v453 + v456 = mul v448, v454 + v457 = add v455, v456 + v458 = mul v457, v457 + v459 = mul v458, Field 2 + v461 = array_get v9, index Field 18 -> u1 + v462 = not v461 + v463 = cast v461 as Field + v464 = cast v462 as Field + v465 = mul v459, v463 + v466 = mul v458, v464 + v467 = add v465, v466 + v468 = mul v467, v467 + v469 = mul v468, Field 2 + v471 = array_get v9, index Field 17 -> u1 + v472 = not v471 + v473 = cast v471 as Field + v474 = cast v472 as Field + v475 = mul v469, v473 + v476 = mul v468, v474 + v477 = add v475, v476 + v478 = mul v477, v477 + v479 = mul v478, Field 2 + v481 = array_get v9, index Field 16 -> u1 + v482 = not v481 + v483 = cast v481 as Field + v484 = cast v482 as Field + v485 = mul v479, v483 + v486 = mul v478, v484 + v487 = add v485, v486 + v488 = mul v487, v487 + v489 = mul v488, Field 2 + v491 = array_get v9, index Field 15 -> u1 + v492 = not v491 + v493 = cast v491 as Field + v494 = cast v492 as Field + v495 = mul v489, v493 + v496 = mul v488, v494 + v497 = add v495, v496 + v498 = mul v497, v497 + v499 = mul v498, Field 2 + v501 = array_get v9, index Field 14 -> u1 + v502 = not v501 + v503 = cast v501 as Field + v504 = cast v502 as Field + v505 = mul v499, v503 + v506 = mul v498, v504 + v507 = add v505, v506 + v508 = mul v507, v507 + v509 = mul v508, Field 2 + v511 = array_get v9, index Field 13 -> u1 + v512 = not v511 + v513 = cast v511 as Field + v514 = cast v512 as Field + v515 = mul v509, v513 + v516 = mul v508, v514 + v517 = add v515, v516 + v518 = mul v517, v517 + v519 = mul v518, Field 2 + v521 = array_get v9, index Field 12 -> u1 + v522 = not v521 + v523 = cast v521 as Field + v524 = cast v522 as Field + v525 = mul v519, v523 + v526 = mul v518, v524 + v527 = add v525, v526 + v528 = mul v527, v527 + v529 = mul v528, Field 2 + v531 = array_get v9, index Field 11 -> u1 + v532 = not v531 + v533 = cast v531 as Field + v534 = cast v532 as Field + v535 = mul v529, v533 + v536 = mul v528, v534 + v537 = add v535, v536 + v538 = mul v537, v537 + v539 = mul v538, Field 2 + v541 = array_get v9, index Field 10 -> u1 + v542 = not v541 + v543 = cast v541 as Field + v544 = cast v542 as Field + v545 = mul v539, v543 + v546 = mul v538, v544 + v547 = add v545, v546 + v548 = mul v547, v547 + v549 = mul v548, Field 2 + v551 = array_get v9, index Field 9 -> u1 + v552 = not v551 + v553 = cast v551 as Field + v554 = cast v552 as Field + v555 = mul v549, v553 + v556 = mul v548, v554 + v557 = add v555, v556 + v558 = mul v557, v557 + v559 = mul v558, Field 2 + v561 = array_get v9, index Field 8 -> u1 + v562 = not v561 + v563 = cast v561 as Field + v564 = cast v562 as Field + v565 = mul v559, v563 + v566 = mul v558, v564 + v567 = add v565, v566 + v568 = mul v567, v567 + v569 = mul v568, Field 2 + v571 = array_get v9, index Field 7 -> u1 + v572 = not v571 + v573 = cast v571 as Field + v574 = cast v572 as Field + v575 = mul v569, v573 + v576 = mul v568, v574 + v577 = add v575, v576 + v578 = mul v577, v577 + v579 = mul v578, Field 2 + v581 = array_get v9, index Field 6 -> u1 + v582 = not v581 + v583 = cast v581 as Field + v584 = cast v582 as Field + v585 = mul v579, v583 + v586 = mul v578, v584 + v587 = add v585, v586 + v588 = mul v587, v587 + v589 = mul v588, Field 2 + v591 = array_get v9, index Field 5 -> u1 + v592 = not v591 + v593 = cast v591 as Field + v594 = cast v592 as Field + v595 = mul v589, v593 + v596 = mul v588, v594 + v597 = add v595, v596 + v598 = mul v597, v597 + v599 = mul v598, Field 2 + v601 = array_get v9, index Field 4 -> u1 + v602 = not v601 + v603 = cast v601 as Field + v604 = cast v602 as Field + v605 = mul v599, v603 + v606 = mul v598, v604 + v607 = add v605, v606 + v608 = mul v607, v607 + v609 = mul v608, Field 2 + v611 = array_get v9, index Field 3 -> u1 + v612 = not v611 + v613 = cast v611 as Field + v614 = cast v612 as Field + v615 = mul v609, v613 + v616 = mul v608, v614 + v617 = add v615, v616 + v618 = mul v617, v617 + v619 = mul v618, Field 2 + v620 = array_get v9, index Field 2 -> u1 + v621 = not v620 + v622 = cast v620 as Field + v623 = cast v621 as Field + v624 = mul v619, v622 + v625 = mul v618, v623 + v626 = add v624, v625 + v627 = mul v626, v626 + v628 = mul v627, Field 2 + v629 = array_get v9, index Field 1 -> u1 + v630 = not v629 + v631 = cast v629 as Field + v632 = cast v630 as Field + v633 = mul v628, v631 + v634 = mul v627, v632 + v635 = add v633, v634 + v636 = mul v635, v635 + v637 = mul v636, Field 2 + v639 = array_get v9, index Field 0 -> u1 + v640 = not v639 + v641 = cast v639 as Field + v642 = cast v640 as Field + v643 = mul v637, v641 + v644 = mul v636, v642 + v645 = add v643, v644 + v646 = cast v645 as u64 + v647 = mul v6, v646 + v648 = cast v0 as Field + v649 = cast v647 as Field + v650 = mul v648, v649 + v651 = truncate v650 to 64 bits, max_bit_size: 254 + v652 = cast v651 as u64 + return v652 +} \ No newline at end of file From d7dd95d39751c3ea93c73a7713baf0f19661b781 Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Thu, 12 Dec 2024 15:35:28 +0000 Subject: [PATCH 20/32] deleted codegen + shl + shr --- .../acir_formal_proofs/CMakeLists.txt | 2 +- .../acir_formal_proofs/acir_loader.cpp | 3 +- .../acir_formal_proofs/acir_loader.test.cpp | 1211 +---------------- .../acir_formal_proofs/helpers.cpp | 64 + .../acir_formal_proofs/helpers.hpp | 25 + .../acir_formal_proofs/helpers.test.cpp | 94 ++ .../shift_codegen/codegen.py | 161 --- .../acir_formal_proofs/shift_codegen/shl.cpp | 585 -------- .../acir_formal_proofs/shift_codegen/shl.ssa | 588 -------- .../acir_formal_proofs/shift_codegen/shr.cpp | 585 -------- .../acir_formal_proofs/shift_codegen/shr.ssa | 588 -------- .../src/acir_instruction_builder.rs | 2 +- 12 files changed, 222 insertions(+), 3686 deletions(-) create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.cpp create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.hpp create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.test.cpp delete mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/codegen.py delete mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shl.cpp delete mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shl.ssa delete mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shr.cpp delete mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shr.ssa diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/CMakeLists.txt index 43b9fc20ca7..fcd338d4072 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/CMakeLists.txt @@ -1 +1 @@ -barretenberg_module(acir_formal_proofs dsl circuit_checker smt_verification) \ No newline at end of file +barretenberg_module(acir_formal_proofs dsl circuit_checker smt_verification common) \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp index cb6e9fe67d5..6286651bfe3 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp @@ -46,7 +46,8 @@ bb::UltraCircuitBuilder AcirToSmtLoader::get_circuit_builder() smt_solver::Solver AcirToSmtLoader::get_smt_solver() { smt_circuit::CircuitSchema circuit_info = smt_circuit_schema::unpack_from_buffer(this->circuit_buf); - return smt_solver::Solver(circuit_info.modulus); + // for shl i have variable with bit length 197... for some reason + return smt_solver::Solver(circuit_info.modulus, smt_circuit::default_solver_config, 16, 240); } smt_circuit::UltraCircuit AcirToSmtLoader::get_smt_circuit(smt_solver::Solver* solver) diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp index 0611bba4684..2df8b080bb0 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp @@ -7,6 +7,7 @@ #include "barretenberg/smt_verification/util/smt_util.hpp" #include "barretenberg/stdlib/client_ivc_verifier/client_ivc_recursive_verifier.hpp" #include "barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp" +#include "helpers.hpp" #include // defkit/print_assertions TODO delete all print_assertions from tests @@ -259,7 +260,7 @@ TEST(acir_formal_proofs, uint_terms_or) } } -TEST(acir_formal_proofs, uint_terms_shl) +TEST(acir_formal_proofs, uint_terms_shl64) { AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Shl.acir"); smt_solver::Solver solver = loader.get_smt_solver(); @@ -267,593 +268,24 @@ TEST(acir_formal_proofs, uint_terms_shl) auto a = smt_circuit::BVVar("a", &solver); auto b = smt_circuit::BVVar("b", &solver); auto c = smt_circuit::BVVar("c", &solver); - auto v0 = a; - auto v1 = b; - auto v5 = smt_terms::BVConst("1", &solver, 10); - auto v6 = v5; - auto v7 = v1; - auto v9 = v7; - auto v12 = v9 & smt_terms::BVConst("9223372036854775808", &solver, 10); - auto v13 = v12 ^ smt_terms::BVConst("1", &solver, 10); - auto v14 = v12; - auto v15 = v13; - auto v16 = v14 * smt_terms::BVConst("2", &solver, 10); - auto v17 = v16 + v15; - auto v18 = v17 * v17; - auto v19 = v18 * smt_terms::BVConst("2", &solver, 10); - auto v21 = v9 & smt_terms::BVConst("4611686018427387904", &solver, 10); - auto v22 = v21 ^ smt_terms::BVConst("1", &solver, 10); - auto v23 = v21; - auto v24 = v22; - auto v25 = v19 * v23; - auto v26 = v18 * v24; - auto v27 = v25 + v26; - auto v28 = v27 * v27; - auto v29 = v28 * smt_terms::BVConst("2", &solver, 10); - auto v31 = v9 & smt_terms::BVConst("2305843009213693952", &solver, 10); - auto v32 = v31 ^ smt_terms::BVConst("1", &solver, 10); - auto v33 = v31; - auto v34 = v32; - auto v35 = v29 * v33; - auto v36 = v28 * v34; - auto v37 = v35 + v36; - auto v38 = v37 * v37; - auto v39 = v38 * smt_terms::BVConst("2", &solver, 10); - auto v41 = v9 & smt_terms::BVConst("1152921504606846976", &solver, 10); - auto v42 = v41 ^ smt_terms::BVConst("1", &solver, 10); - auto v43 = v41; - auto v44 = v42; - auto v45 = v39 * v43; - auto v46 = v38 * v44; - auto v47 = v45 + v46; - auto v48 = v47 * v47; - auto v49 = v48 * smt_terms::BVConst("2", &solver, 10); - auto v51 = v9 & smt_terms::BVConst("576460752303423488", &solver, 10); - auto v52 = v51 ^ smt_terms::BVConst("1", &solver, 10); - auto v53 = v51; - auto v54 = v52; - auto v55 = v49 * v53; - auto v56 = v48 * v54; - auto v57 = v55 + v56; - auto v58 = v57 * v57; - auto v59 = v58 * smt_terms::BVConst("2", &solver, 10); - auto v61 = v9 & smt_terms::BVConst("288230376151711744", &solver, 10); - auto v62 = v61 ^ smt_terms::BVConst("1", &solver, 10); - auto v63 = v61; - auto v64 = v62; - auto v65 = v59 * v63; - auto v66 = v58 * v64; - auto v67 = v65 + v66; - auto v68 = v67 * v67; - auto v69 = v68 * smt_terms::BVConst("2", &solver, 10); - auto v71 = v9 & smt_terms::BVConst("144115188075855872", &solver, 10); - auto v72 = v71 ^ smt_terms::BVConst("1", &solver, 10); - auto v73 = v71; - auto v74 = v72; - auto v75 = v69 * v73; - auto v76 = v68 * v74; - auto v77 = v75 + v76; - auto v78 = v77 * v77; - auto v79 = v78 * smt_terms::BVConst("2", &solver, 10); - auto v81 = v9 & smt_terms::BVConst("72057594037927936", &solver, 10); - auto v82 = v81 ^ smt_terms::BVConst("1", &solver, 10); - auto v83 = v81; - auto v84 = v82; - auto v85 = v79 * v83; - auto v86 = v78 * v84; - auto v87 = v85 + v86; - auto v88 = v87 * v87; - auto v89 = v88 * smt_terms::BVConst("2", &solver, 10); - auto v91 = v9 & smt_terms::BVConst("36028797018963968", &solver, 10); - auto v92 = v91 ^ smt_terms::BVConst("1", &solver, 10); - auto v93 = v91; - auto v94 = v92; - auto v95 = v89 * v93; - auto v96 = v88 * v94; - auto v97 = v95 + v96; - auto v98 = v97 * v97; - auto v99 = v98 * smt_terms::BVConst("2", &solver, 10); - auto v101 = v9 & smt_terms::BVConst("18014398509481984", &solver, 10); - auto v102 = v101 ^ smt_terms::BVConst("1", &solver, 10); - auto v103 = v101; - auto v104 = v102; - auto v105 = v99 * v103; - auto v106 = v98 * v104; - auto v107 = v105 + v106; - auto v108 = v107 * v107; - auto v109 = v108 * smt_terms::BVConst("2", &solver, 10); - auto v111 = v9 & smt_terms::BVConst("9007199254740992", &solver, 10); - auto v112 = v111 ^ smt_terms::BVConst("1", &solver, 10); - auto v113 = v111; - auto v114 = v112; - auto v115 = v109 * v113; - auto v116 = v108 * v114; - auto v117 = v115 + v116; - auto v118 = v117 * v117; - auto v119 = v118 * smt_terms::BVConst("2", &solver, 10); - auto v121 = v9 & smt_terms::BVConst("4503599627370496", &solver, 10); - auto v122 = v121 ^ smt_terms::BVConst("1", &solver, 10); - auto v123 = v121; - auto v124 = v122; - auto v125 = v119 * v123; - auto v126 = v118 * v124; - auto v127 = v125 + v126; - auto v128 = v127 * v127; - auto v129 = v128 * smt_terms::BVConst("2", &solver, 10); - auto v131 = v9 & smt_terms::BVConst("2251799813685248", &solver, 10); - auto v132 = v131 ^ smt_terms::BVConst("1", &solver, 10); - auto v133 = v131; - auto v134 = v132; - auto v135 = v129 * v133; - auto v136 = v128 * v134; - auto v137 = v135 + v136; - auto v138 = v137 * v137; - auto v139 = v138 * smt_terms::BVConst("2", &solver, 10); - auto v141 = v9 & smt_terms::BVConst("1125899906842624", &solver, 10); - auto v142 = v141 ^ smt_terms::BVConst("1", &solver, 10); - auto v143 = v141; - auto v144 = v142; - auto v145 = v139 * v143; - auto v146 = v138 * v144; - auto v147 = v145 + v146; - auto v148 = v147 * v147; - auto v149 = v148 * smt_terms::BVConst("2", &solver, 10); - auto v151 = v9 & smt_terms::BVConst("562949953421312", &solver, 10); - auto v152 = v151 ^ smt_terms::BVConst("1", &solver, 10); - auto v153 = v151; - auto v154 = v152; - auto v155 = v149 * v153; - auto v156 = v148 * v154; - auto v157 = v155 + v156; - auto v158 = v157 * v157; - auto v159 = v158 * smt_terms::BVConst("2", &solver, 10); - auto v161 = v9 & smt_terms::BVConst("281474976710656", &solver, 10); - auto v162 = v161 ^ smt_terms::BVConst("1", &solver, 10); - auto v163 = v161; - auto v164 = v162; - auto v165 = v159 * v163; - auto v166 = v158 * v164; - auto v167 = v165 + v166; - auto v168 = v167 * v167; - auto v169 = v168 * smt_terms::BVConst("2", &solver, 10); - auto v171 = v9 & smt_terms::BVConst("140737488355328", &solver, 10); - auto v172 = v171 ^ smt_terms::BVConst("1", &solver, 10); - auto v173 = v171; - auto v174 = v172; - auto v175 = v169 * v173; - auto v176 = v168 * v174; - auto v177 = v175 + v176; - auto v178 = v177 * v177; - auto v179 = v178 * smt_terms::BVConst("2", &solver, 10); - auto v181 = v9 & smt_terms::BVConst("70368744177664", &solver, 10); - auto v182 = v181 ^ smt_terms::BVConst("1", &solver, 10); - auto v183 = v181; - auto v184 = v182; - auto v185 = v179 * v183; - auto v186 = v178 * v184; - auto v187 = v185 + v186; - auto v188 = v187 * v187; - auto v189 = v188 * smt_terms::BVConst("2", &solver, 10); - auto v191 = v9 & smt_terms::BVConst("35184372088832", &solver, 10); - auto v192 = v191 ^ smt_terms::BVConst("1", &solver, 10); - auto v193 = v191; - auto v194 = v192; - auto v195 = v189 * v193; - auto v196 = v188 * v194; - auto v197 = v195 + v196; - auto v198 = v197 * v197; - auto v199 = v198 * smt_terms::BVConst("2", &solver, 10); - auto v201 = v9 & smt_terms::BVConst("17592186044416", &solver, 10); - auto v202 = v201 ^ smt_terms::BVConst("1", &solver, 10); - auto v203 = v201; - auto v204 = v202; - auto v205 = v199 * v203; - auto v206 = v198 * v204; - auto v207 = v205 + v206; - auto v208 = v207 * v207; - auto v209 = v208 * smt_terms::BVConst("2", &solver, 10); - auto v211 = v9 & smt_terms::BVConst("8796093022208", &solver, 10); - auto v212 = v211 ^ smt_terms::BVConst("1", &solver, 10); - auto v213 = v211; - auto v214 = v212; - auto v215 = v209 * v213; - auto v216 = v208 * v214; - auto v217 = v215 + v216; - auto v218 = v217 * v217; - auto v219 = v218 * smt_terms::BVConst("2", &solver, 10); - auto v221 = v9 & smt_terms::BVConst("4398046511104", &solver, 10); - auto v222 = v221 ^ smt_terms::BVConst("1", &solver, 10); - auto v223 = v221; - auto v224 = v222; - auto v225 = v219 * v223; - auto v226 = v218 * v224; - auto v227 = v225 + v226; - auto v228 = v227 * v227; - auto v229 = v228 * smt_terms::BVConst("2", &solver, 10); - auto v231 = v9 & smt_terms::BVConst("2199023255552", &solver, 10); - auto v232 = v231 ^ smt_terms::BVConst("1", &solver, 10); - auto v233 = v231; - auto v234 = v232; - auto v235 = v229 * v233; - auto v236 = v228 * v234; - auto v237 = v235 + v236; - auto v238 = v237 * v237; - auto v239 = v238 * smt_terms::BVConst("2", &solver, 10); - auto v241 = v9 & smt_terms::BVConst("1099511627776", &solver, 10); - auto v242 = v241 ^ smt_terms::BVConst("1", &solver, 10); - auto v243 = v241; - auto v244 = v242; - auto v245 = v239 * v243; - auto v246 = v238 * v244; - auto v247 = v245 + v246; - auto v248 = v247 * v247; - auto v249 = v248 * smt_terms::BVConst("2", &solver, 10); - auto v251 = v9 & smt_terms::BVConst("549755813888", &solver, 10); - auto v252 = v251 ^ smt_terms::BVConst("1", &solver, 10); - auto v253 = v251; - auto v254 = v252; - auto v255 = v249 * v253; - auto v256 = v248 * v254; - auto v257 = v255 + v256; - auto v258 = v257 * v257; - auto v259 = v258 * smt_terms::BVConst("2", &solver, 10); - auto v261 = v9 & smt_terms::BVConst("274877906944", &solver, 10); - auto v262 = v261 ^ smt_terms::BVConst("1", &solver, 10); - auto v263 = v261; - auto v264 = v262; - auto v265 = v259 * v263; - auto v266 = v258 * v264; - auto v267 = v265 + v266; - auto v268 = v267 * v267; - auto v269 = v268 * smt_terms::BVConst("2", &solver, 10); - auto v271 = v9 & smt_terms::BVConst("137438953472", &solver, 10); - auto v272 = v271 ^ smt_terms::BVConst("1", &solver, 10); - auto v273 = v271; - auto v274 = v272; - auto v275 = v269 * v273; - auto v276 = v268 * v274; - auto v277 = v275 + v276; - auto v278 = v277 * v277; - auto v279 = v278 * smt_terms::BVConst("2", &solver, 10); - auto v281 = v9 & smt_terms::BVConst("68719476736", &solver, 10); - auto v282 = v281 ^ smt_terms::BVConst("1", &solver, 10); - auto v283 = v281; - auto v284 = v282; - auto v285 = v279 * v283; - auto v286 = v278 * v284; - auto v287 = v285 + v286; - auto v288 = v287 * v287; - auto v289 = v288 * smt_terms::BVConst("2", &solver, 10); - auto v291 = v9 & smt_terms::BVConst("34359738368", &solver, 10); - auto v292 = v291 ^ smt_terms::BVConst("1", &solver, 10); - auto v293 = v291; - auto v294 = v292; - auto v295 = v289 * v293; - auto v296 = v288 * v294; - auto v297 = v295 + v296; - auto v298 = v297 * v297; - auto v299 = v298 * smt_terms::BVConst("2", &solver, 10); - auto v301 = v9 & smt_terms::BVConst("17179869184", &solver, 10); - auto v302 = v301 ^ smt_terms::BVConst("1", &solver, 10); - auto v303 = v301; - auto v304 = v302; - auto v305 = v299 * v303; - auto v306 = v298 * v304; - auto v307 = v305 + v306; - auto v308 = v307 * v307; - auto v309 = v308 * smt_terms::BVConst("2", &solver, 10); - auto v311 = v9 & smt_terms::BVConst("8589934592", &solver, 10); - auto v312 = v311 ^ smt_terms::BVConst("1", &solver, 10); - auto v313 = v311; - auto v314 = v312; - auto v315 = v309 * v313; - auto v316 = v308 * v314; - auto v317 = v315 + v316; - auto v318 = v317 * v317; - auto v319 = v318 * smt_terms::BVConst("2", &solver, 10); - auto v321 = v9 & smt_terms::BVConst("4294967296", &solver, 10); - auto v322 = v321 ^ smt_terms::BVConst("1", &solver, 10); - auto v323 = v321; - auto v324 = v322; - auto v325 = v319 * v323; - auto v326 = v318 * v324; - auto v327 = v325 + v326; - auto v328 = v327 * v327; - auto v329 = v328 * smt_terms::BVConst("2", &solver, 10); - auto v331 = v9 & smt_terms::BVConst("2147483648", &solver, 10); - auto v332 = v331 ^ smt_terms::BVConst("1", &solver, 10); - auto v333 = v331; - auto v334 = v332; - auto v335 = v329 * v333; - auto v336 = v328 * v334; - auto v337 = v335 + v336; - auto v338 = v337 * v337; - auto v339 = v338 * smt_terms::BVConst("2", &solver, 10); - auto v341 = v9 & smt_terms::BVConst("1073741824", &solver, 10); - auto v342 = v341 ^ smt_terms::BVConst("1", &solver, 10); - auto v343 = v341; - auto v344 = v342; - auto v345 = v339 * v343; - auto v346 = v338 * v344; - auto v347 = v345 + v346; - auto v348 = v347 * v347; - auto v349 = v348 * smt_terms::BVConst("2", &solver, 10); - auto v351 = v9 & smt_terms::BVConst("536870912", &solver, 10); - auto v352 = v351 ^ smt_terms::BVConst("1", &solver, 10); - auto v353 = v351; - auto v354 = v352; - auto v355 = v349 * v353; - auto v356 = v348 * v354; - auto v357 = v355 + v356; - auto v358 = v357 * v357; - auto v359 = v358 * smt_terms::BVConst("2", &solver, 10); - auto v361 = v9 & smt_terms::BVConst("268435456", &solver, 10); - auto v362 = v361 ^ smt_terms::BVConst("1", &solver, 10); - auto v363 = v361; - auto v364 = v362; - auto v365 = v359 * v363; - auto v366 = v358 * v364; - auto v367 = v365 + v366; - auto v368 = v367 * v367; - auto v369 = v368 * smt_terms::BVConst("2", &solver, 10); - auto v371 = v9 & smt_terms::BVConst("134217728", &solver, 10); - auto v372 = v371 ^ smt_terms::BVConst("1", &solver, 10); - auto v373 = v371; - auto v374 = v372; - auto v375 = v369 * v373; - auto v376 = v368 * v374; - auto v377 = v375 + v376; - auto v378 = v377 * v377; - auto v379 = v378 * smt_terms::BVConst("2", &solver, 10); - auto v381 = v9 & smt_terms::BVConst("67108864", &solver, 10); - auto v382 = v381 ^ smt_terms::BVConst("1", &solver, 10); - auto v383 = v381; - auto v384 = v382; - auto v385 = v379 * v383; - auto v386 = v378 * v384; - auto v387 = v385 + v386; - auto v388 = v387 * v387; - auto v389 = v388 * smt_terms::BVConst("2", &solver, 10); - auto v391 = v9 & smt_terms::BVConst("33554432", &solver, 10); - auto v392 = v391 ^ smt_terms::BVConst("1", &solver, 10); - auto v393 = v391; - auto v394 = v392; - auto v395 = v389 * v393; - auto v396 = v388 * v394; - auto v397 = v395 + v396; - auto v398 = v397 * v397; - auto v399 = v398 * smt_terms::BVConst("2", &solver, 10); - auto v401 = v9 & smt_terms::BVConst("16777216", &solver, 10); - auto v402 = v401 ^ smt_terms::BVConst("1", &solver, 10); - auto v403 = v401; - auto v404 = v402; - auto v405 = v399 * v403; - auto v406 = v398 * v404; - auto v407 = v405 + v406; - auto v408 = v407 * v407; - auto v409 = v408 * smt_terms::BVConst("2", &solver, 10); - auto v411 = v9 & smt_terms::BVConst("8388608", &solver, 10); - auto v412 = v411 ^ smt_terms::BVConst("1", &solver, 10); - auto v413 = v411; - auto v414 = v412; - auto v415 = v409 * v413; - auto v416 = v408 * v414; - auto v417 = v415 + v416; - auto v418 = v417 * v417; - auto v419 = v418 * smt_terms::BVConst("2", &solver, 10); - auto v421 = v9 & smt_terms::BVConst("4194304", &solver, 10); - auto v422 = v421 ^ smt_terms::BVConst("1", &solver, 10); - auto v423 = v421; - auto v424 = v422; - auto v425 = v419 * v423; - auto v426 = v418 * v424; - auto v427 = v425 + v426; - auto v428 = v427 * v427; - auto v429 = v428 * smt_terms::BVConst("2", &solver, 10); - auto v431 = v9 & smt_terms::BVConst("2097152", &solver, 10); - auto v432 = v431 ^ smt_terms::BVConst("1", &solver, 10); - auto v433 = v431; - auto v434 = v432; - auto v435 = v429 * v433; - auto v436 = v428 * v434; - auto v437 = v435 + v436; - auto v438 = v437 * v437; - auto v439 = v438 * smt_terms::BVConst("2", &solver, 10); - auto v441 = v9 & smt_terms::BVConst("1048576", &solver, 10); - auto v442 = v441 ^ smt_terms::BVConst("1", &solver, 10); - auto v443 = v441; - auto v444 = v442; - auto v445 = v439 * v443; - auto v446 = v438 * v444; - auto v447 = v445 + v446; - auto v448 = v447 * v447; - auto v449 = v448 * smt_terms::BVConst("2", &solver, 10); - auto v451 = v9 & smt_terms::BVConst("524288", &solver, 10); - auto v452 = v451 ^ smt_terms::BVConst("1", &solver, 10); - auto v453 = v451; - auto v454 = v452; - auto v455 = v449 * v453; - auto v456 = v448 * v454; - auto v457 = v455 + v456; - auto v458 = v457 * v457; - auto v459 = v458 * smt_terms::BVConst("2", &solver, 10); - auto v461 = v9 & smt_terms::BVConst("262144", &solver, 10); - auto v462 = v461 ^ smt_terms::BVConst("1", &solver, 10); - auto v463 = v461; - auto v464 = v462; - auto v465 = v459 * v463; - auto v466 = v458 * v464; - auto v467 = v465 + v466; - auto v468 = v467 * v467; - auto v469 = v468 * smt_terms::BVConst("2", &solver, 10); - auto v471 = v9 & smt_terms::BVConst("131072", &solver, 10); - auto v472 = v471 ^ smt_terms::BVConst("1", &solver, 10); - auto v473 = v471; - auto v474 = v472; - auto v475 = v469 * v473; - auto v476 = v468 * v474; - auto v477 = v475 + v476; - auto v478 = v477 * v477; - auto v479 = v478 * smt_terms::BVConst("2", &solver, 10); - auto v481 = v9 & smt_terms::BVConst("65536", &solver, 10); - auto v482 = v481 ^ smt_terms::BVConst("1", &solver, 10); - auto v483 = v481; - auto v484 = v482; - auto v485 = v479 * v483; - auto v486 = v478 * v484; - auto v487 = v485 + v486; - auto v488 = v487 * v487; - auto v489 = v488 * smt_terms::BVConst("2", &solver, 10); - auto v491 = v9 & smt_terms::BVConst("32768", &solver, 10); - auto v492 = v491 ^ smt_terms::BVConst("1", &solver, 10); - auto v493 = v491; - auto v494 = v492; - auto v495 = v489 * v493; - auto v496 = v488 * v494; - auto v497 = v495 + v496; - auto v498 = v497 * v497; - auto v499 = v498 * smt_terms::BVConst("2", &solver, 10); - auto v501 = v9 & smt_terms::BVConst("16384", &solver, 10); - auto v502 = v501 ^ smt_terms::BVConst("1", &solver, 10); - auto v503 = v501; - auto v504 = v502; - auto v505 = v499 * v503; - auto v506 = v498 * v504; - auto v507 = v505 + v506; - auto v508 = v507 * v507; - auto v509 = v508 * smt_terms::BVConst("2", &solver, 10); - auto v511 = v9 & smt_terms::BVConst("8192", &solver, 10); - auto v512 = v511 ^ smt_terms::BVConst("1", &solver, 10); - auto v513 = v511; - auto v514 = v512; - auto v515 = v509 * v513; - auto v516 = v508 * v514; - auto v517 = v515 + v516; - auto v518 = v517 * v517; - auto v519 = v518 * smt_terms::BVConst("2", &solver, 10); - auto v521 = v9 & smt_terms::BVConst("4096", &solver, 10); - auto v522 = v521 ^ smt_terms::BVConst("1", &solver, 10); - auto v523 = v521; - auto v524 = v522; - auto v525 = v519 * v523; - auto v526 = v518 * v524; - auto v527 = v525 + v526; - auto v528 = v527 * v527; - auto v529 = v528 * smt_terms::BVConst("2", &solver, 10); - auto v531 = v9 & smt_terms::BVConst("2048", &solver, 10); - auto v532 = v531 ^ smt_terms::BVConst("1", &solver, 10); - auto v533 = v531; - auto v534 = v532; - auto v535 = v529 * v533; - auto v536 = v528 * v534; - auto v537 = v535 + v536; - auto v538 = v537 * v537; - auto v539 = v538 * smt_terms::BVConst("2", &solver, 10); - auto v541 = v9 & smt_terms::BVConst("1024", &solver, 10); - auto v542 = v541 ^ smt_terms::BVConst("1", &solver, 10); - auto v543 = v541; - auto v544 = v542; - auto v545 = v539 * v543; - auto v546 = v538 * v544; - auto v547 = v545 + v546; - auto v548 = v547 * v547; - auto v549 = v548 * smt_terms::BVConst("2", &solver, 10); - auto v551 = v9 & smt_terms::BVConst("512", &solver, 10); - auto v552 = v551 ^ smt_terms::BVConst("1", &solver, 10); - auto v553 = v551; - auto v554 = v552; - auto v555 = v549 * v553; - auto v556 = v548 * v554; - auto v557 = v555 + v556; - auto v558 = v557 * v557; - auto v559 = v558 * smt_terms::BVConst("2", &solver, 10); - auto v561 = v9 & smt_terms::BVConst("256", &solver, 10); - auto v562 = v561 ^ smt_terms::BVConst("1", &solver, 10); - auto v563 = v561; - auto v564 = v562; - auto v565 = v559 * v563; - auto v566 = v558 * v564; - auto v567 = v565 + v566; - auto v568 = v567 * v567; - auto v569 = v568 * smt_terms::BVConst("2", &solver, 10); - auto v571 = v9 & smt_terms::BVConst("128", &solver, 10); - auto v572 = v571 ^ smt_terms::BVConst("1", &solver, 10); - auto v573 = v571; - auto v574 = v572; - auto v575 = v569 * v573; - auto v576 = v568 * v574; - auto v577 = v575 + v576; - auto v578 = v577 * v577; - auto v579 = v578 * smt_terms::BVConst("2", &solver, 10); - auto v581 = v9 & smt_terms::BVConst("64", &solver, 10); - auto v582 = v581 ^ smt_terms::BVConst("1", &solver, 10); - auto v583 = v581; - auto v584 = v582; - auto v585 = v579 * v583; - auto v586 = v578 * v584; - auto v587 = v585 + v586; - auto v588 = v587 * v587; - auto v589 = v588 * smt_terms::BVConst("2", &solver, 10); - auto v591 = v9 & smt_terms::BVConst("32", &solver, 10); - auto v592 = v591 ^ smt_terms::BVConst("1", &solver, 10); - auto v593 = v591; - auto v594 = v592; - auto v595 = v589 * v593; - auto v596 = v588 * v594; - auto v597 = v595 + v596; - auto v598 = v597 * v597; - auto v599 = v598 * smt_terms::BVConst("2", &solver, 10); - auto v601 = v9 & smt_terms::BVConst("16", &solver, 10); - auto v602 = v601 ^ smt_terms::BVConst("1", &solver, 10); - auto v603 = v601; - auto v604 = v602; - auto v605 = v599 * v603; - auto v606 = v598 * v604; - auto v607 = v605 + v606; - auto v608 = v607 * v607; - auto v609 = v608 * smt_terms::BVConst("2", &solver, 10); - auto v611 = v9 & smt_terms::BVConst("8", &solver, 10); - auto v612 = v611 ^ smt_terms::BVConst("1", &solver, 10); - auto v613 = v611; - auto v614 = v612; - auto v615 = v609 * v613; - auto v616 = v608 * v614; - auto v617 = v615 + v616; - auto v618 = v617 * v617; - auto v619 = v618 * smt_terms::BVConst("2", &solver, 10); - auto v620 = v9 & smt_terms::BVConst("4", &solver, 10); - auto v621 = v620 ^ smt_terms::BVConst("1", &solver, 10); - auto v622 = v620; - auto v623 = v621; - auto v624 = v619 * v622; - auto v625 = v618 * v623; - auto v626 = v624 + v625; - auto v627 = v626 * v626; - auto v628 = v627 * smt_terms::BVConst("2", &solver, 10); - auto v629 = v9 & smt_terms::BVConst("2", &solver, 10); - auto v630 = v629 ^ smt_terms::BVConst("1", &solver, 10); - auto v631 = v629; - auto v632 = v630; - auto v633 = v628 * v631; - auto v634 = v627 * v632; - auto v635 = v633 + v634; - auto v636 = v635 * v635; - auto v637 = v636 * smt_terms::BVConst("2", &solver, 10); - auto v639 = v9 & smt_terms::BVConst("1", &solver, 10); - auto v640 = v639 ^ smt_terms::BVConst("1", &solver, 10); - auto v641 = v639; - auto v642 = v640; - auto v643 = v637 * v641; - auto v644 = v636 * v642; - auto v645 = v643 + v644; - auto v646 = v645; - auto v647 = v6 * v646; - auto v648 = v0; - auto v649 = v647; - auto v650 = v648 * v649; - auto v651 = v650 & smt_terms::BVConst("18446744073709551615", &solver, 10); - auto v652 = v651; - auto cr = v652; + auto cr = shl64(a, b, &solver); + c != cr; + bool res = solver.check(); + if (res) { + save_buggy_witness("Binary::Shl", circuit); + } + EXPECT_FALSE(res); +} + +TEST(acir_formal_proofs, uint_terms_shl32) +{ + AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Shl.acir"); + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); + auto a = smt_circuit::BVVar("a", &solver); + auto b = smt_circuit::BVVar("b", &solver); + auto c = smt_circuit::BVVar("c", &solver); + auto cr = shl32(a, b, &solver); c != cr; bool res = solver.check(); if (res) { @@ -870,597 +302,17 @@ TEST(acir_formal_proofs, uint_terms_shr) auto a = circuit["a"]; auto b = circuit["b"]; auto c = circuit["c"]; - auto v0 = a; - auto v1 = b; - auto v5 = smt_terms::BVConst("1", &solver, 10); - auto v6 = v5; - auto v7 = v1; - auto v9 = v7; - auto v12 = v9 & smt_terms::BVConst("9223372036854775808", &solver, 10); - auto v13 = v12 ^ smt_terms::BVConst("1", &solver, 10); - auto v14 = v12; - auto v15 = v13; - auto v16 = v14 * smt_terms::BVConst("2", &solver, 10); - auto v17 = v16 + v15; - auto v18 = v17 * v17; - auto v19 = v18 * smt_terms::BVConst("2", &solver, 10); - auto v21 = v9 & smt_terms::BVConst("4611686018427387904", &solver, 10); - auto v22 = v21 ^ smt_terms::BVConst("1", &solver, 10); - auto v23 = v21; - auto v24 = v22; - auto v25 = v19 * v23; - auto v26 = v18 * v24; - auto v27 = v25 + v26; - auto v28 = v27 * v27; - auto v29 = v28 * smt_terms::BVConst("2", &solver, 10); - auto v31 = v9 & smt_terms::BVConst("2305843009213693952", &solver, 10); - auto v32 = v31 ^ smt_terms::BVConst("1", &solver, 10); - auto v33 = v31; - auto v34 = v32; - auto v35 = v29 * v33; - auto v36 = v28 * v34; - auto v37 = v35 + v36; - auto v38 = v37 * v37; - auto v39 = v38 * smt_terms::BVConst("2", &solver, 10); - auto v41 = v9 & smt_terms::BVConst("1152921504606846976", &solver, 10); - auto v42 = v41 ^ smt_terms::BVConst("1", &solver, 10); - auto v43 = v41; - auto v44 = v42; - auto v45 = v39 * v43; - auto v46 = v38 * v44; - auto v47 = v45 + v46; - auto v48 = v47 * v47; - auto v49 = v48 * smt_terms::BVConst("2", &solver, 10); - auto v51 = v9 & smt_terms::BVConst("576460752303423488", &solver, 10); - auto v52 = v51 ^ smt_terms::BVConst("1", &solver, 10); - auto v53 = v51; - auto v54 = v52; - auto v55 = v49 * v53; - auto v56 = v48 * v54; - auto v57 = v55 + v56; - auto v58 = v57 * v57; - auto v59 = v58 * smt_terms::BVConst("2", &solver, 10); - auto v61 = v9 & smt_terms::BVConst("288230376151711744", &solver, 10); - auto v62 = v61 ^ smt_terms::BVConst("1", &solver, 10); - auto v63 = v61; - auto v64 = v62; - auto v65 = v59 * v63; - auto v66 = v58 * v64; - auto v67 = v65 + v66; - auto v68 = v67 * v67; - auto v69 = v68 * smt_terms::BVConst("2", &solver, 10); - auto v71 = v9 & smt_terms::BVConst("144115188075855872", &solver, 10); - auto v72 = v71 ^ smt_terms::BVConst("1", &solver, 10); - auto v73 = v71; - auto v74 = v72; - auto v75 = v69 * v73; - auto v76 = v68 * v74; - auto v77 = v75 + v76; - auto v78 = v77 * v77; - auto v79 = v78 * smt_terms::BVConst("2", &solver, 10); - auto v81 = v9 & smt_terms::BVConst("72057594037927936", &solver, 10); - auto v82 = v81 ^ smt_terms::BVConst("1", &solver, 10); - auto v83 = v81; - auto v84 = v82; - auto v85 = v79 * v83; - auto v86 = v78 * v84; - auto v87 = v85 + v86; - auto v88 = v87 * v87; - auto v89 = v88 * smt_terms::BVConst("2", &solver, 10); - auto v91 = v9 & smt_terms::BVConst("36028797018963968", &solver, 10); - auto v92 = v91 ^ smt_terms::BVConst("1", &solver, 10); - auto v93 = v91; - auto v94 = v92; - auto v95 = v89 * v93; - auto v96 = v88 * v94; - auto v97 = v95 + v96; - auto v98 = v97 * v97; - auto v99 = v98 * smt_terms::BVConst("2", &solver, 10); - auto v101 = v9 & smt_terms::BVConst("18014398509481984", &solver, 10); - auto v102 = v101 ^ smt_terms::BVConst("1", &solver, 10); - auto v103 = v101; - auto v104 = v102; - auto v105 = v99 * v103; - auto v106 = v98 * v104; - auto v107 = v105 + v106; - auto v108 = v107 * v107; - auto v109 = v108 * smt_terms::BVConst("2", &solver, 10); - auto v111 = v9 & smt_terms::BVConst("9007199254740992", &solver, 10); - auto v112 = v111 ^ smt_terms::BVConst("1", &solver, 10); - auto v113 = v111; - auto v114 = v112; - auto v115 = v109 * v113; - auto v116 = v108 * v114; - auto v117 = v115 + v116; - auto v118 = v117 * v117; - auto v119 = v118 * smt_terms::BVConst("2", &solver, 10); - auto v121 = v9 & smt_terms::BVConst("4503599627370496", &solver, 10); - auto v122 = v121 ^ smt_terms::BVConst("1", &solver, 10); - auto v123 = v121; - auto v124 = v122; - auto v125 = v119 * v123; - auto v126 = v118 * v124; - auto v127 = v125 + v126; - auto v128 = v127 * v127; - auto v129 = v128 * smt_terms::BVConst("2", &solver, 10); - auto v131 = v9 & smt_terms::BVConst("2251799813685248", &solver, 10); - auto v132 = v131 ^ smt_terms::BVConst("1", &solver, 10); - auto v133 = v131; - auto v134 = v132; - auto v135 = v129 * v133; - auto v136 = v128 * v134; - auto v137 = v135 + v136; - auto v138 = v137 * v137; - auto v139 = v138 * smt_terms::BVConst("2", &solver, 10); - auto v141 = v9 & smt_terms::BVConst("1125899906842624", &solver, 10); - auto v142 = v141 ^ smt_terms::BVConst("1", &solver, 10); - auto v143 = v141; - auto v144 = v142; - auto v145 = v139 * v143; - auto v146 = v138 * v144; - auto v147 = v145 + v146; - auto v148 = v147 * v147; - auto v149 = v148 * smt_terms::BVConst("2", &solver, 10); - auto v151 = v9 & smt_terms::BVConst("562949953421312", &solver, 10); - auto v152 = v151 ^ smt_terms::BVConst("1", &solver, 10); - auto v153 = v151; - auto v154 = v152; - auto v155 = v149 * v153; - auto v156 = v148 * v154; - auto v157 = v155 + v156; - auto v158 = v157 * v157; - auto v159 = v158 * smt_terms::BVConst("2", &solver, 10); - auto v161 = v9 & smt_terms::BVConst("281474976710656", &solver, 10); - auto v162 = v161 ^ smt_terms::BVConst("1", &solver, 10); - auto v163 = v161; - auto v164 = v162; - auto v165 = v159 * v163; - auto v166 = v158 * v164; - auto v167 = v165 + v166; - auto v168 = v167 * v167; - auto v169 = v168 * smt_terms::BVConst("2", &solver, 10); - auto v171 = v9 & smt_terms::BVConst("140737488355328", &solver, 10); - auto v172 = v171 ^ smt_terms::BVConst("1", &solver, 10); - auto v173 = v171; - auto v174 = v172; - auto v175 = v169 * v173; - auto v176 = v168 * v174; - auto v177 = v175 + v176; - auto v178 = v177 * v177; - auto v179 = v178 * smt_terms::BVConst("2", &solver, 10); - auto v181 = v9 & smt_terms::BVConst("70368744177664", &solver, 10); - auto v182 = v181 ^ smt_terms::BVConst("1", &solver, 10); - auto v183 = v181; - auto v184 = v182; - auto v185 = v179 * v183; - auto v186 = v178 * v184; - auto v187 = v185 + v186; - auto v188 = v187 * v187; - auto v189 = v188 * smt_terms::BVConst("2", &solver, 10); - auto v191 = v9 & smt_terms::BVConst("35184372088832", &solver, 10); - auto v192 = v191 ^ smt_terms::BVConst("1", &solver, 10); - auto v193 = v191; - auto v194 = v192; - auto v195 = v189 * v193; - auto v196 = v188 * v194; - auto v197 = v195 + v196; - auto v198 = v197 * v197; - auto v199 = v198 * smt_terms::BVConst("2", &solver, 10); - auto v201 = v9 & smt_terms::BVConst("17592186044416", &solver, 10); - auto v202 = v201 ^ smt_terms::BVConst("1", &solver, 10); - auto v203 = v201; - auto v204 = v202; - auto v205 = v199 * v203; - auto v206 = v198 * v204; - auto v207 = v205 + v206; - auto v208 = v207 * v207; - auto v209 = v208 * smt_terms::BVConst("2", &solver, 10); - auto v211 = v9 & smt_terms::BVConst("8796093022208", &solver, 10); - auto v212 = v211 ^ smt_terms::BVConst("1", &solver, 10); - auto v213 = v211; - auto v214 = v212; - auto v215 = v209 * v213; - auto v216 = v208 * v214; - auto v217 = v215 + v216; - auto v218 = v217 * v217; - auto v219 = v218 * smt_terms::BVConst("2", &solver, 10); - auto v221 = v9 & smt_terms::BVConst("4398046511104", &solver, 10); - auto v222 = v221 ^ smt_terms::BVConst("1", &solver, 10); - auto v223 = v221; - auto v224 = v222; - auto v225 = v219 * v223; - auto v226 = v218 * v224; - auto v227 = v225 + v226; - auto v228 = v227 * v227; - auto v229 = v228 * smt_terms::BVConst("2", &solver, 10); - auto v231 = v9 & smt_terms::BVConst("2199023255552", &solver, 10); - auto v232 = v231 ^ smt_terms::BVConst("1", &solver, 10); - auto v233 = v231; - auto v234 = v232; - auto v235 = v229 * v233; - auto v236 = v228 * v234; - auto v237 = v235 + v236; - auto v238 = v237 * v237; - auto v239 = v238 * smt_terms::BVConst("2", &solver, 10); - auto v241 = v9 & smt_terms::BVConst("1099511627776", &solver, 10); - auto v242 = v241 ^ smt_terms::BVConst("1", &solver, 10); - auto v243 = v241; - auto v244 = v242; - auto v245 = v239 * v243; - auto v246 = v238 * v244; - auto v247 = v245 + v246; - auto v248 = v247 * v247; - auto v249 = v248 * smt_terms::BVConst("2", &solver, 10); - auto v251 = v9 & smt_terms::BVConst("549755813888", &solver, 10); - auto v252 = v251 ^ smt_terms::BVConst("1", &solver, 10); - auto v253 = v251; - auto v254 = v252; - auto v255 = v249 * v253; - auto v256 = v248 * v254; - auto v257 = v255 + v256; - auto v258 = v257 * v257; - auto v259 = v258 * smt_terms::BVConst("2", &solver, 10); - auto v261 = v9 & smt_terms::BVConst("274877906944", &solver, 10); - auto v262 = v261 ^ smt_terms::BVConst("1", &solver, 10); - auto v263 = v261; - auto v264 = v262; - auto v265 = v259 * v263; - auto v266 = v258 * v264; - auto v267 = v265 + v266; - auto v268 = v267 * v267; - auto v269 = v268 * smt_terms::BVConst("2", &solver, 10); - auto v271 = v9 & smt_terms::BVConst("137438953472", &solver, 10); - auto v272 = v271 ^ smt_terms::BVConst("1", &solver, 10); - auto v273 = v271; - auto v274 = v272; - auto v275 = v269 * v273; - auto v276 = v268 * v274; - auto v277 = v275 + v276; - auto v278 = v277 * v277; - auto v279 = v278 * smt_terms::BVConst("2", &solver, 10); - auto v281 = v9 & smt_terms::BVConst("68719476736", &solver, 10); - auto v282 = v281 ^ smt_terms::BVConst("1", &solver, 10); - auto v283 = v281; - auto v284 = v282; - auto v285 = v279 * v283; - auto v286 = v278 * v284; - auto v287 = v285 + v286; - auto v288 = v287 * v287; - auto v289 = v288 * smt_terms::BVConst("2", &solver, 10); - auto v291 = v9 & smt_terms::BVConst("34359738368", &solver, 10); - auto v292 = v291 ^ smt_terms::BVConst("1", &solver, 10); - auto v293 = v291; - auto v294 = v292; - auto v295 = v289 * v293; - auto v296 = v288 * v294; - auto v297 = v295 + v296; - auto v298 = v297 * v297; - auto v299 = v298 * smt_terms::BVConst("2", &solver, 10); - auto v301 = v9 & smt_terms::BVConst("17179869184", &solver, 10); - auto v302 = v301 ^ smt_terms::BVConst("1", &solver, 10); - auto v303 = v301; - auto v304 = v302; - auto v305 = v299 * v303; - auto v306 = v298 * v304; - auto v307 = v305 + v306; - auto v308 = v307 * v307; - auto v309 = v308 * smt_terms::BVConst("2", &solver, 10); - auto v311 = v9 & smt_terms::BVConst("8589934592", &solver, 10); - auto v312 = v311 ^ smt_terms::BVConst("1", &solver, 10); - auto v313 = v311; - auto v314 = v312; - auto v315 = v309 * v313; - auto v316 = v308 * v314; - auto v317 = v315 + v316; - auto v318 = v317 * v317; - auto v319 = v318 * smt_terms::BVConst("2", &solver, 10); - auto v321 = v9 & smt_terms::BVConst("4294967296", &solver, 10); - auto v322 = v321 ^ smt_terms::BVConst("1", &solver, 10); - auto v323 = v321; - auto v324 = v322; - auto v325 = v319 * v323; - auto v326 = v318 * v324; - auto v327 = v325 + v326; - auto v328 = v327 * v327; - auto v329 = v328 * smt_terms::BVConst("2", &solver, 10); - auto v331 = v9 & smt_terms::BVConst("2147483648", &solver, 10); - auto v332 = v331 ^ smt_terms::BVConst("1", &solver, 10); - auto v333 = v331; - auto v334 = v332; - auto v335 = v329 * v333; - auto v336 = v328 * v334; - auto v337 = v335 + v336; - auto v338 = v337 * v337; - auto v339 = v338 * smt_terms::BVConst("2", &solver, 10); - auto v341 = v9 & smt_terms::BVConst("1073741824", &solver, 10); - auto v342 = v341 ^ smt_terms::BVConst("1", &solver, 10); - auto v343 = v341; - auto v344 = v342; - auto v345 = v339 * v343; - auto v346 = v338 * v344; - auto v347 = v345 + v346; - auto v348 = v347 * v347; - auto v349 = v348 * smt_terms::BVConst("2", &solver, 10); - auto v351 = v9 & smt_terms::BVConst("536870912", &solver, 10); - auto v352 = v351 ^ smt_terms::BVConst("1", &solver, 10); - auto v353 = v351; - auto v354 = v352; - auto v355 = v349 * v353; - auto v356 = v348 * v354; - auto v357 = v355 + v356; - auto v358 = v357 * v357; - auto v359 = v358 * smt_terms::BVConst("2", &solver, 10); - auto v361 = v9 & smt_terms::BVConst("268435456", &solver, 10); - auto v362 = v361 ^ smt_terms::BVConst("1", &solver, 10); - auto v363 = v361; - auto v364 = v362; - auto v365 = v359 * v363; - auto v366 = v358 * v364; - auto v367 = v365 + v366; - auto v368 = v367 * v367; - auto v369 = v368 * smt_terms::BVConst("2", &solver, 10); - auto v371 = v9 & smt_terms::BVConst("134217728", &solver, 10); - auto v372 = v371 ^ smt_terms::BVConst("1", &solver, 10); - auto v373 = v371; - auto v374 = v372; - auto v375 = v369 * v373; - auto v376 = v368 * v374; - auto v377 = v375 + v376; - auto v378 = v377 * v377; - auto v379 = v378 * smt_terms::BVConst("2", &solver, 10); - auto v381 = v9 & smt_terms::BVConst("67108864", &solver, 10); - auto v382 = v381 ^ smt_terms::BVConst("1", &solver, 10); - auto v383 = v381; - auto v384 = v382; - auto v385 = v379 * v383; - auto v386 = v378 * v384; - auto v387 = v385 + v386; - auto v388 = v387 * v387; - auto v389 = v388 * smt_terms::BVConst("2", &solver, 10); - auto v391 = v9 & smt_terms::BVConst("33554432", &solver, 10); - auto v392 = v391 ^ smt_terms::BVConst("1", &solver, 10); - auto v393 = v391; - auto v394 = v392; - auto v395 = v389 * v393; - auto v396 = v388 * v394; - auto v397 = v395 + v396; - auto v398 = v397 * v397; - auto v399 = v398 * smt_terms::BVConst("2", &solver, 10); - auto v401 = v9 & smt_terms::BVConst("16777216", &solver, 10); - auto v402 = v401 ^ smt_terms::BVConst("1", &solver, 10); - auto v403 = v401; - auto v404 = v402; - auto v405 = v399 * v403; - auto v406 = v398 * v404; - auto v407 = v405 + v406; - auto v408 = v407 * v407; - auto v409 = v408 * smt_terms::BVConst("2", &solver, 10); - auto v411 = v9 & smt_terms::BVConst("8388608", &solver, 10); - auto v412 = v411 ^ smt_terms::BVConst("1", &solver, 10); - auto v413 = v411; - auto v414 = v412; - auto v415 = v409 * v413; - auto v416 = v408 * v414; - auto v417 = v415 + v416; - auto v418 = v417 * v417; - auto v419 = v418 * smt_terms::BVConst("2", &solver, 10); - auto v421 = v9 & smt_terms::BVConst("4194304", &solver, 10); - auto v422 = v421 ^ smt_terms::BVConst("1", &solver, 10); - auto v423 = v421; - auto v424 = v422; - auto v425 = v419 * v423; - auto v426 = v418 * v424; - auto v427 = v425 + v426; - auto v428 = v427 * v427; - auto v429 = v428 * smt_terms::BVConst("2", &solver, 10); - auto v431 = v9 & smt_terms::BVConst("2097152", &solver, 10); - auto v432 = v431 ^ smt_terms::BVConst("1", &solver, 10); - auto v433 = v431; - auto v434 = v432; - auto v435 = v429 * v433; - auto v436 = v428 * v434; - auto v437 = v435 + v436; - auto v438 = v437 * v437; - auto v439 = v438 * smt_terms::BVConst("2", &solver, 10); - auto v441 = v9 & smt_terms::BVConst("1048576", &solver, 10); - auto v442 = v441 ^ smt_terms::BVConst("1", &solver, 10); - auto v443 = v441; - auto v444 = v442; - auto v445 = v439 * v443; - auto v446 = v438 * v444; - auto v447 = v445 + v446; - auto v448 = v447 * v447; - auto v449 = v448 * smt_terms::BVConst("2", &solver, 10); - auto v451 = v9 & smt_terms::BVConst("524288", &solver, 10); - auto v452 = v451 ^ smt_terms::BVConst("1", &solver, 10); - auto v453 = v451; - auto v454 = v452; - auto v455 = v449 * v453; - auto v456 = v448 * v454; - auto v457 = v455 + v456; - auto v458 = v457 * v457; - auto v459 = v458 * smt_terms::BVConst("2", &solver, 10); - auto v461 = v9 & smt_terms::BVConst("262144", &solver, 10); - auto v462 = v461 ^ smt_terms::BVConst("1", &solver, 10); - auto v463 = v461; - auto v464 = v462; - auto v465 = v459 * v463; - auto v466 = v458 * v464; - auto v467 = v465 + v466; - auto v468 = v467 * v467; - auto v469 = v468 * smt_terms::BVConst("2", &solver, 10); - auto v471 = v9 & smt_terms::BVConst("131072", &solver, 10); - auto v472 = v471 ^ smt_terms::BVConst("1", &solver, 10); - auto v473 = v471; - auto v474 = v472; - auto v475 = v469 * v473; - auto v476 = v468 * v474; - auto v477 = v475 + v476; - auto v478 = v477 * v477; - auto v479 = v478 * smt_terms::BVConst("2", &solver, 10); - auto v481 = v9 & smt_terms::BVConst("65536", &solver, 10); - auto v482 = v481 ^ smt_terms::BVConst("1", &solver, 10); - auto v483 = v481; - auto v484 = v482; - auto v485 = v479 * v483; - auto v486 = v478 * v484; - auto v487 = v485 + v486; - auto v488 = v487 * v487; - auto v489 = v488 * smt_terms::BVConst("2", &solver, 10); - auto v491 = v9 & smt_terms::BVConst("32768", &solver, 10); - auto v492 = v491 ^ smt_terms::BVConst("1", &solver, 10); - auto v493 = v491; - auto v494 = v492; - auto v495 = v489 * v493; - auto v496 = v488 * v494; - auto v497 = v495 + v496; - auto v498 = v497 * v497; - auto v499 = v498 * smt_terms::BVConst("2", &solver, 10); - auto v501 = v9 & smt_terms::BVConst("16384", &solver, 10); - auto v502 = v501 ^ smt_terms::BVConst("1", &solver, 10); - auto v503 = v501; - auto v504 = v502; - auto v505 = v499 * v503; - auto v506 = v498 * v504; - auto v507 = v505 + v506; - auto v508 = v507 * v507; - auto v509 = v508 * smt_terms::BVConst("2", &solver, 10); - auto v511 = v9 & smt_terms::BVConst("8192", &solver, 10); - auto v512 = v511 ^ smt_terms::BVConst("1", &solver, 10); - auto v513 = v511; - auto v514 = v512; - auto v515 = v509 * v513; - auto v516 = v508 * v514; - auto v517 = v515 + v516; - auto v518 = v517 * v517; - auto v519 = v518 * smt_terms::BVConst("2", &solver, 10); - auto v521 = v9 & smt_terms::BVConst("4096", &solver, 10); - auto v522 = v521 ^ smt_terms::BVConst("1", &solver, 10); - auto v523 = v521; - auto v524 = v522; - auto v525 = v519 * v523; - auto v526 = v518 * v524; - auto v527 = v525 + v526; - auto v528 = v527 * v527; - auto v529 = v528 * smt_terms::BVConst("2", &solver, 10); - auto v531 = v9 & smt_terms::BVConst("2048", &solver, 10); - auto v532 = v531 ^ smt_terms::BVConst("1", &solver, 10); - auto v533 = v531; - auto v534 = v532; - auto v535 = v529 * v533; - auto v536 = v528 * v534; - auto v537 = v535 + v536; - auto v538 = v537 * v537; - auto v539 = v538 * smt_terms::BVConst("2", &solver, 10); - auto v541 = v9 & smt_terms::BVConst("1024", &solver, 10); - auto v542 = v541 ^ smt_terms::BVConst("1", &solver, 10); - auto v543 = v541; - auto v544 = v542; - auto v545 = v539 * v543; - auto v546 = v538 * v544; - auto v547 = v545 + v546; - auto v548 = v547 * v547; - auto v549 = v548 * smt_terms::BVConst("2", &solver, 10); - auto v551 = v9 & smt_terms::BVConst("512", &solver, 10); - auto v552 = v551 ^ smt_terms::BVConst("1", &solver, 10); - auto v553 = v551; - auto v554 = v552; - auto v555 = v549 * v553; - auto v556 = v548 * v554; - auto v557 = v555 + v556; - auto v558 = v557 * v557; - auto v559 = v558 * smt_terms::BVConst("2", &solver, 10); - auto v561 = v9 & smt_terms::BVConst("256", &solver, 10); - auto v562 = v561 ^ smt_terms::BVConst("1", &solver, 10); - auto v563 = v561; - auto v564 = v562; - auto v565 = v559 * v563; - auto v566 = v558 * v564; - auto v567 = v565 + v566; - auto v568 = v567 * v567; - auto v569 = v568 * smt_terms::BVConst("2", &solver, 10); - auto v571 = v9 & smt_terms::BVConst("128", &solver, 10); - auto v572 = v571 ^ smt_terms::BVConst("1", &solver, 10); - auto v573 = v571; - auto v574 = v572; - auto v575 = v569 * v573; - auto v576 = v568 * v574; - auto v577 = v575 + v576; - auto v578 = v577 * v577; - auto v579 = v578 * smt_terms::BVConst("2", &solver, 10); - auto v581 = v9 & smt_terms::BVConst("64", &solver, 10); - auto v582 = v581 ^ smt_terms::BVConst("1", &solver, 10); - auto v583 = v581; - auto v584 = v582; - auto v585 = v579 * v583; - auto v586 = v578 * v584; - auto v587 = v585 + v586; - auto v588 = v587 * v587; - auto v589 = v588 * smt_terms::BVConst("2", &solver, 10); - auto v591 = v9 & smt_terms::BVConst("32", &solver, 10); - auto v592 = v591 ^ smt_terms::BVConst("1", &solver, 10); - auto v593 = v591; - auto v594 = v592; - auto v595 = v589 * v593; - auto v596 = v588 * v594; - auto v597 = v595 + v596; - auto v598 = v597 * v597; - auto v599 = v598 * smt_terms::BVConst("2", &solver, 10); - auto v601 = v9 & smt_terms::BVConst("16", &solver, 10); - auto v602 = v601 ^ smt_terms::BVConst("1", &solver, 10); - auto v603 = v601; - auto v604 = v602; - auto v605 = v599 * v603; - auto v606 = v598 * v604; - auto v607 = v605 + v606; - auto v608 = v607 * v607; - auto v609 = v608 * smt_terms::BVConst("2", &solver, 10); - auto v611 = v9 & smt_terms::BVConst("8", &solver, 10); - auto v612 = v611 ^ smt_terms::BVConst("1", &solver, 10); - auto v613 = v611; - auto v614 = v612; - auto v615 = v609 * v613; - auto v616 = v608 * v614; - auto v617 = v615 + v616; - auto v618 = v617 * v617; - auto v619 = v618 * smt_terms::BVConst("2", &solver, 10); - auto v620 = v9 & smt_terms::BVConst("4", &solver, 10); - auto v621 = v620 ^ smt_terms::BVConst("1", &solver, 10); - auto v622 = v620; - auto v623 = v621; - auto v624 = v619 * v622; - auto v625 = v618 * v623; - auto v626 = v624 + v625; - auto v627 = v626 * v626; - auto v628 = v627 * smt_terms::BVConst("2", &solver, 10); - auto v629 = v9 & smt_terms::BVConst("2", &solver, 10); - auto v630 = v629 ^ smt_terms::BVConst("1", &solver, 10); - auto v631 = v629; - auto v632 = v630; - auto v633 = v628 * v631; - auto v634 = v627 * v632; - auto v635 = v633 + v634; - auto v636 = v635 * v635; - auto v637 = v636 * smt_terms::BVConst("2", &solver, 10); - auto v639 = v9 & smt_terms::BVConst("1", &solver, 10); - auto v640 = v639 ^ smt_terms::BVConst("1", &solver, 10); - auto v641 = v639; - auto v642 = v640; - auto v643 = v637 * v641; - auto v644 = v636 * v642; - auto v645 = v643 + v644; - auto v646 = v645; - auto v647 = v6 * v646; - auto v648 = v0; - auto v649 = v647; - auto v650 = v648 * v649; - auto v651 = v650 & smt_terms::BVConst("18446744073709551615", &solver, 10); - auto v652 = v651; - auto cr = v652; + auto cr = shr(a, b, &solver); c != cr; bool res = solver.check(); if (res) { - save_buggy_witness("Binary::Shl", circuit); + save_buggy_witness("Binary::Shr", circuit); + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + std::unordered_map vals = solver.model(terms); + info("a = ", vals["a"]); + info("b = ", vals["b"]); + info("c = ", vals["c"]); + info("c_res = ", vals["cr"]); } EXPECT_FALSE(res); } @@ -1541,6 +393,13 @@ TEST(acir_formal_proofs, uint_terms_and_verify_bug) EXPECT_TRUE(verify_buggy_witness("Binary::And")); } +// if failed, bug NOT verified +// fali on file not found or check circuit +TEST(acir_formal_proofs, uint_terms_shr_verify_bug) +{ + EXPECT_TRUE(verify_buggy_witness("Binary::Shr")); +} + /*TEST(acir_circuit_check, uint_terms_add) { AcirToSmtLoader loader = diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.cpp new file mode 100644 index 00000000000..05e0b2bb944 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.cpp @@ -0,0 +1,64 @@ +#include "barretenberg/smt_verification/circuit/ultra_circuit.hpp" +#include "barretenberg/smt_verification/solver/solver.hpp" +#include "barretenberg/smt_verification/util/smt_util.hpp" + +// used for base = 2 exp < 256 so its okay +uint32_t pow_num(uint32_t base, uint32_t exp) +{ + uint32_t res = 1; + for (uint32_t i = 0; i < exp; i++) { + res *= base; + } + return res; +} + +// returns 2^v0 +smt_circuit::STerm pow2_8(smt_circuit::STerm v0, smt_solver::Solver* solver) +{ + uint32_t BIT_SIZE = 8; + auto one = smt_terms::BVConst("1", solver, 10); + auto two = smt_terms::BVConst("2", solver, 10); + smt_circuit::STerm res = smt_circuit::BVVar("res", solver); + res = one; + auto exp = v0; + for (uint32_t i = 1; i < BIT_SIZE + 1; i++) { + auto r2 = res * res; + auto mask = pow_num(2, BIT_SIZE - i); + info(mask); + // same thing as taking ith bit in little endian + auto b = (v0 & mask) >> (BIT_SIZE - i); + res = (r2 * two * b) + (1 - b) * r2; + } + return res; +} + +smt_circuit::STerm shl(smt_circuit::STerm v0, smt_circuit::STerm v1, smt_solver::Solver* solver) +{ + auto pow2_v1 = pow2_8(v1, solver); + return v0 * pow2_v1; +} + +smt_circuit::STerm shr(smt_circuit::STerm v0, smt_circuit::STerm v1, smt_solver::Solver* solver) +{ + auto pow2_v1 = pow2_8(v1, solver); + auto res = v0 / pow2_v1; + return res; +} + +smt_circuit::STerm shl64(smt_circuit::STerm v0, smt_circuit::STerm v1, smt_solver::Solver* solver) +{ + auto shifted = shl(v0, v1, solver); + // 2^64 - 1 + auto mask = smt_terms::BVConst("18446744073709551615", solver, 10); + auto res = shifted & mask; + return res; +} + +smt_circuit::STerm shl32(smt_circuit::STerm v0, smt_circuit::STerm v1, smt_solver::Solver* solver) +{ + auto shifted = shl(v0, v1, solver); + // 2^32 - 1 + auto mask = smt_terms::BVConst("4294967295", solver, 10); + auto res = shifted & mask; + return res; +} diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.hpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.hpp new file mode 100644 index 00000000000..e5f9d9f8d02 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.hpp @@ -0,0 +1,25 @@ +#include "barretenberg/smt_verification/circuit/ultra_circuit.hpp" +#include "barretenberg/smt_verification/solver/solver.hpp" +#include "barretenberg/smt_verification/terms/term.hpp" + +// reurns a << b +// b 8 bit +// result is truncated to 64 bit +smt_circuit::STerm shl64(smt_circuit::STerm v0, smt_circuit::STerm v1, smt_solver::Solver* solver); + +// reurns a << b +// b 8 bit +// result is truncated to 32 bit +smt_circuit::STerm shl32(smt_circuit::STerm v0, smt_circuit::STerm v1, smt_solver::Solver* solver); + +// retuns 2^v0, v0 8 bit +smt_circuit::STerm pow2_8(smt_circuit::STerm v0, smt_solver::Solver* solver); + +// returns a >> b +// b 8 bit +smt_circuit::STerm shr(smt_circuit::STerm v0, smt_circuit::STerm v1, smt_solver::Solver* solver); + +// returns a << b +// b 8 bit +// result is NOT truncated +smt_circuit::STerm shl(smt_circuit::STerm v0, smt_circuit::STerm v1, smt_solver::Solver* solver); \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.test.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.test.cpp new file mode 100644 index 00000000000..73a8935e88c --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.test.cpp @@ -0,0 +1,94 @@ +#include "helpers.hpp" +#include "barretenberg/common/test.hpp" +#include "barretenberg/smt_verification/circuit/ultra_circuit.hpp" +#include "barretenberg/smt_verification/solver/solver.hpp" +#include "barretenberg/smt_verification/util/smt_util.hpp" +#include "barretenberg/stdlib/primitives/uint/uint.hpp" +#include "barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp" + +using namespace bb; +using witness_ct = stdlib::witness_t; +using uint_ct = stdlib::uint32; + +using namespace smt_terms; + +TEST(helpers, shl) +{ + Solver s("30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001", default_solver_config, 16, 32); + + STerm x = BVVar("x", &s); + STerm y = BVVar("y", &s); + STerm z = shl(x, y, &s); + x == 5; + y == 1; + // z should be z == 10; + s.check(); + std::unordered_map terms({ { "x", x }, { "y", y }, { "z", z } }); + std::unordered_map vals = s.model(terms); + info("x = ", vals["x"]); + info("y = ", vals["y"]); + info("z = ", vals["z"]); + // z == 1010 in binary + EXPECT_TRUE(vals["z"] == "00000000000000000000000000001010"); +} + +TEST(helpers, shr) +{ + Solver s("30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001", default_solver_config, 16, 32); + + STerm x = BVVar("x", &s); + STerm y = BVVar("y", &s); + STerm z = shr(x, y, &s); + x == 5; + y == 1; + // z should be z == 2; + s.check(); + std::unordered_map terms({ { "x", x }, { "y", y }, { "z", z } }); + std::unordered_map vals = s.model(terms); + info("x = ", vals["x"]); + info("y = ", vals["y"]); + info("z = ", vals["z"]); + // z == 10 in binary + EXPECT_TRUE(vals["z"] == "00000000000000000000000000000010"); +} + +TEST(helpers, buggy_shr) +{ + // using smt solver i found that 1879048194 >> 16 == 0 + // its strange... + Solver s("30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001", default_solver_config, 16, 32); + + STerm x = BVVar("x", &s); + STerm y = BVVar("y", &s); + STerm z = shr(x, y, &s); + x == 1879048194; + y == 16; + // z should be z == 28672; + s.check(); + std::unordered_map terms({ { "x", x }, { "y", y }, { "z", z } }); + std::unordered_map vals = s.model(terms); + info("x = ", vals["x"]); + info("y = ", vals["y"]); + info("z = ", vals["z"]); + // z == 28672 in binary + EXPECT_TRUE(vals["z"] == "00000000000000000111000000000000"); +} + +TEST(helpers, pow2) +{ + // using smt solver i found that 1879048194 >> 16 == 0 + // its strange... + Solver s("30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001", default_solver_config, 16, 32); + + STerm x = BVVar("x", &s); + STerm z = pow2_8(x, &s); + x == 11; + // z should be z == 2048; + s.check(); + std::unordered_map terms({ { "x", x }, { "z", z } }); + std::unordered_map vals = s.model(terms); + info("x = ", vals["x"]); + info("z = ", vals["z"]); + // z == 2048 in binary + EXPECT_TRUE(vals["z"] == "00000000000000000000100000000000"); +} \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/codegen.py b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/codegen.py deleted file mode 100644 index 61178d0b0fd..00000000000 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/codegen.py +++ /dev/null @@ -1,161 +0,0 @@ -import re - - -def parse_op(line: str) -> str: - # VAR1 = OP VAR2 ... ALMOST ALWAYS! - # only with return var doesnt work - t = line.split(' ') - if len(t) == 2: - return t[0] - return t[2] - - -def not_call(line: str) -> str: - # VARIABLE one should be defined - # v13 = not v12, without fields, only for one-bits - names = line.split(' ') - vars = (names[0], names[3]) - return f'auto {vars[0]} = {vars[1]} ^ smt_terms::BVConst("1", &solver, 10);' - - -def add_call(line: str) -> str: - # v17 = add v16, v15 always like this - line = line.replace(",", "") - names = line.split(' ') - vars = (names[0], names[3], names[4]) - return f"auto {vars[0]} = {vars[1]} + {vars[2]};" - - -def array_get_call(line: str) -> str: - # v12 = array_get v9, index Field 63 -> u1 - # we take it from little endian - # so getting by index 63 is VAR & (2 ** 63) - line = line.replace(",", "") - names = line.split(' ') - vars = (names[0], names[3], names[6]) - index = int(vars[2]) - mask = f'smt_terms::BVConst("{2**index}", &solver, 10)' - return f"auto {vars[0]} = {vars[1]} & {mask};" - - -def mul_call(line: str) -> str: - # v16 = mul Field 2, v14 - # v18 = mul v17, v17 - # v19 = mul v18, Field 2 - # so we have 3 cases - line = line.replace(",", "") - names = line.split(' ') - if len(names) == 5: - # case v18 = mul v17, v17 - vars = (names[0], names[3], names[4]) - elif names[3] == 'Field': - # case v16 = mul Field 2, v14 - vars = (names[0], names[5], 'smt_terms::BVConst("2", &solver, 10)') - elif names[4] == 'Field': - # case v19 = mul v18, Field 2 - vars = (names[0], names[3], 'smt_terms::BVConst("2", &solver, 10)') - else: - raise ValueError("Something strange with mul call", line) - - return f"auto {vars[0]} = {vars[1]} * {vars[2]};" - - -def truncate_call(line: str) -> str: - # v651 = truncate v650 to 64 bits, max_bit_size: 254 - line = line.replace(",", "") - names = line.split(' ') - vars = (names[0], names[3], names[5]) - t = 2 ** int(vars[2]) - 1 - return f'auto {vars[0]} = {vars[1]} & smt_terms::BVConst("{t}", &solver, 10);' - - -def cast_call(line: str) -> str: - # v641 = cast v639 as Field - # type doesnt matter i think - line = line.replace(",", "") - names = line.split(' ') - vars = (names[0], names[3]) - return f'auto {vars[0]} = {vars[1]};' - - -def lt_call(line: str) -> str: - # in shl it ignored i dont know how it works - # in shr it used for multiplying result - # if it shift >= 64 result multiplied by 0 - # but it should be 0 itself... - # so i leave it equal to 1 - line = line.replace(",", "") - names = line.split(' ') - vars = (names[0], ) - return f'auto {vars[0]} = smt_terms::BVConst("{1}", &solver, 10);' - - -def call_call(line: str) -> str: - # v9 = call to_le_bits(v7) -> [u1; 64] - line = line.replace(",", "") - names = line.split(' ') - name_in_func = re.findall( - r'to_le_bits\((.*)\)', names[3] - )[0] - vars = (names[0], name_in_func) - return f'auto {vars[0]} = {vars[1]};' - - -def return_call(line: str) -> str: - # return v652 - line = line.replace(",", "") - names = line.split(' ') - vars = (names[1], ) - return f'auto cr = {vars[0]};' - - -MAPPING = { - "add": add_call, - "array_get": array_get_call, - "call": call_call, - "cast": cast_call, - "lt": lt_call, - "mul": mul_call, - "not": not_call, - "truncate": truncate_call, - "return": return_call -} - - -def generate_by_line(line: str) -> str: - op = parse_op(line) - # throws expcetion on unknown op - return MAPPING.get(op, None)(line) - - -def parse_formatted_ssa(ssa: str) -> str: - # starts with acir(inline) fn main f0 { - # b0(v0: u64, v1: u8): - # so skip first two lines - # ends with }, skipping last line - ssa_lines = ssa.split('\n')[2:-1] - cpp_generated_lines = [] - for ssa_line in ssa_lines: - cpp_generated_lines.append( - generate_by_line(ssa_line.strip()) - ) - return '\t' + '\n\t'.join(cpp_generated_lines) - - -def main(): - with open('./shl.ssa', 'r') as f: - ssa = f.read() - - with open('./shl.cpp', 'w') as f: - f.write(parse_formatted_ssa(ssa)) - - with open('./shr.ssa', 'r') as f: - ssa = f.read() - - with open('./shr.cpp', 'w') as f: - f.write(parse_formatted_ssa(ssa)) - - - -if __name__ == "__main__": - main() diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shl.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shl.cpp deleted file mode 100644 index 1c04811916e..00000000000 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shl.cpp +++ /dev/null @@ -1,585 +0,0 @@ - auto v5 = smt_terms::BVConst("1", &solver, 10); - auto v6 = v5; - auto v7 = v1; - auto v9 = v7; - auto v12 = v9 & smt_terms::BVConst("9223372036854775808", &solver, 10); - auto v13 = v12 ^ smt_terms::BVConst("1", &solver, 10); - auto v14 = v12; - auto v15 = v13; - auto v16 = v14 * smt_terms::BVConst("2", &solver, 10); - auto v17 = v16 + v15; - auto v18 = v17 * v17; - auto v19 = v18 * smt_terms::BVConst("2", &solver, 10); - auto v21 = v9 & smt_terms::BVConst("4611686018427387904", &solver, 10); - auto v22 = v21 ^ smt_terms::BVConst("1", &solver, 10); - auto v23 = v21; - auto v24 = v22; - auto v25 = v19 * v23; - auto v26 = v18 * v24; - auto v27 = v25 + v26; - auto v28 = v27 * v27; - auto v29 = v28 * smt_terms::BVConst("2", &solver, 10); - auto v31 = v9 & smt_terms::BVConst("2305843009213693952", &solver, 10); - auto v32 = v31 ^ smt_terms::BVConst("1", &solver, 10); - auto v33 = v31; - auto v34 = v32; - auto v35 = v29 * v33; - auto v36 = v28 * v34; - auto v37 = v35 + v36; - auto v38 = v37 * v37; - auto v39 = v38 * smt_terms::BVConst("2", &solver, 10); - auto v41 = v9 & smt_terms::BVConst("1152921504606846976", &solver, 10); - auto v42 = v41 ^ smt_terms::BVConst("1", &solver, 10); - auto v43 = v41; - auto v44 = v42; - auto v45 = v39 * v43; - auto v46 = v38 * v44; - auto v47 = v45 + v46; - auto v48 = v47 * v47; - auto v49 = v48 * smt_terms::BVConst("2", &solver, 10); - auto v51 = v9 & smt_terms::BVConst("576460752303423488", &solver, 10); - auto v52 = v51 ^ smt_terms::BVConst("1", &solver, 10); - auto v53 = v51; - auto v54 = v52; - auto v55 = v49 * v53; - auto v56 = v48 * v54; - auto v57 = v55 + v56; - auto v58 = v57 * v57; - auto v59 = v58 * smt_terms::BVConst("2", &solver, 10); - auto v61 = v9 & smt_terms::BVConst("288230376151711744", &solver, 10); - auto v62 = v61 ^ smt_terms::BVConst("1", &solver, 10); - auto v63 = v61; - auto v64 = v62; - auto v65 = v59 * v63; - auto v66 = v58 * v64; - auto v67 = v65 + v66; - auto v68 = v67 * v67; - auto v69 = v68 * smt_terms::BVConst("2", &solver, 10); - auto v71 = v9 & smt_terms::BVConst("144115188075855872", &solver, 10); - auto v72 = v71 ^ smt_terms::BVConst("1", &solver, 10); - auto v73 = v71; - auto v74 = v72; - auto v75 = v69 * v73; - auto v76 = v68 * v74; - auto v77 = v75 + v76; - auto v78 = v77 * v77; - auto v79 = v78 * smt_terms::BVConst("2", &solver, 10); - auto v81 = v9 & smt_terms::BVConst("72057594037927936", &solver, 10); - auto v82 = v81 ^ smt_terms::BVConst("1", &solver, 10); - auto v83 = v81; - auto v84 = v82; - auto v85 = v79 * v83; - auto v86 = v78 * v84; - auto v87 = v85 + v86; - auto v88 = v87 * v87; - auto v89 = v88 * smt_terms::BVConst("2", &solver, 10); - auto v91 = v9 & smt_terms::BVConst("36028797018963968", &solver, 10); - auto v92 = v91 ^ smt_terms::BVConst("1", &solver, 10); - auto v93 = v91; - auto v94 = v92; - auto v95 = v89 * v93; - auto v96 = v88 * v94; - auto v97 = v95 + v96; - auto v98 = v97 * v97; - auto v99 = v98 * smt_terms::BVConst("2", &solver, 10); - auto v101 = v9 & smt_terms::BVConst("18014398509481984", &solver, 10); - auto v102 = v101 ^ smt_terms::BVConst("1", &solver, 10); - auto v103 = v101; - auto v104 = v102; - auto v105 = v99 * v103; - auto v106 = v98 * v104; - auto v107 = v105 + v106; - auto v108 = v107 * v107; - auto v109 = v108 * smt_terms::BVConst("2", &solver, 10); - auto v111 = v9 & smt_terms::BVConst("9007199254740992", &solver, 10); - auto v112 = v111 ^ smt_terms::BVConst("1", &solver, 10); - auto v113 = v111; - auto v114 = v112; - auto v115 = v109 * v113; - auto v116 = v108 * v114; - auto v117 = v115 + v116; - auto v118 = v117 * v117; - auto v119 = v118 * smt_terms::BVConst("2", &solver, 10); - auto v121 = v9 & smt_terms::BVConst("4503599627370496", &solver, 10); - auto v122 = v121 ^ smt_terms::BVConst("1", &solver, 10); - auto v123 = v121; - auto v124 = v122; - auto v125 = v119 * v123; - auto v126 = v118 * v124; - auto v127 = v125 + v126; - auto v128 = v127 * v127; - auto v129 = v128 * smt_terms::BVConst("2", &solver, 10); - auto v131 = v9 & smt_terms::BVConst("2251799813685248", &solver, 10); - auto v132 = v131 ^ smt_terms::BVConst("1", &solver, 10); - auto v133 = v131; - auto v134 = v132; - auto v135 = v129 * v133; - auto v136 = v128 * v134; - auto v137 = v135 + v136; - auto v138 = v137 * v137; - auto v139 = v138 * smt_terms::BVConst("2", &solver, 10); - auto v141 = v9 & smt_terms::BVConst("1125899906842624", &solver, 10); - auto v142 = v141 ^ smt_terms::BVConst("1", &solver, 10); - auto v143 = v141; - auto v144 = v142; - auto v145 = v139 * v143; - auto v146 = v138 * v144; - auto v147 = v145 + v146; - auto v148 = v147 * v147; - auto v149 = v148 * smt_terms::BVConst("2", &solver, 10); - auto v151 = v9 & smt_terms::BVConst("562949953421312", &solver, 10); - auto v152 = v151 ^ smt_terms::BVConst("1", &solver, 10); - auto v153 = v151; - auto v154 = v152; - auto v155 = v149 * v153; - auto v156 = v148 * v154; - auto v157 = v155 + v156; - auto v158 = v157 * v157; - auto v159 = v158 * smt_terms::BVConst("2", &solver, 10); - auto v161 = v9 & smt_terms::BVConst("281474976710656", &solver, 10); - auto v162 = v161 ^ smt_terms::BVConst("1", &solver, 10); - auto v163 = v161; - auto v164 = v162; - auto v165 = v159 * v163; - auto v166 = v158 * v164; - auto v167 = v165 + v166; - auto v168 = v167 * v167; - auto v169 = v168 * smt_terms::BVConst("2", &solver, 10); - auto v171 = v9 & smt_terms::BVConst("140737488355328", &solver, 10); - auto v172 = v171 ^ smt_terms::BVConst("1", &solver, 10); - auto v173 = v171; - auto v174 = v172; - auto v175 = v169 * v173; - auto v176 = v168 * v174; - auto v177 = v175 + v176; - auto v178 = v177 * v177; - auto v179 = v178 * smt_terms::BVConst("2", &solver, 10); - auto v181 = v9 & smt_terms::BVConst("70368744177664", &solver, 10); - auto v182 = v181 ^ smt_terms::BVConst("1", &solver, 10); - auto v183 = v181; - auto v184 = v182; - auto v185 = v179 * v183; - auto v186 = v178 * v184; - auto v187 = v185 + v186; - auto v188 = v187 * v187; - auto v189 = v188 * smt_terms::BVConst("2", &solver, 10); - auto v191 = v9 & smt_terms::BVConst("35184372088832", &solver, 10); - auto v192 = v191 ^ smt_terms::BVConst("1", &solver, 10); - auto v193 = v191; - auto v194 = v192; - auto v195 = v189 * v193; - auto v196 = v188 * v194; - auto v197 = v195 + v196; - auto v198 = v197 * v197; - auto v199 = v198 * smt_terms::BVConst("2", &solver, 10); - auto v201 = v9 & smt_terms::BVConst("17592186044416", &solver, 10); - auto v202 = v201 ^ smt_terms::BVConst("1", &solver, 10); - auto v203 = v201; - auto v204 = v202; - auto v205 = v199 * v203; - auto v206 = v198 * v204; - auto v207 = v205 + v206; - auto v208 = v207 * v207; - auto v209 = v208 * smt_terms::BVConst("2", &solver, 10); - auto v211 = v9 & smt_terms::BVConst("8796093022208", &solver, 10); - auto v212 = v211 ^ smt_terms::BVConst("1", &solver, 10); - auto v213 = v211; - auto v214 = v212; - auto v215 = v209 * v213; - auto v216 = v208 * v214; - auto v217 = v215 + v216; - auto v218 = v217 * v217; - auto v219 = v218 * smt_terms::BVConst("2", &solver, 10); - auto v221 = v9 & smt_terms::BVConst("4398046511104", &solver, 10); - auto v222 = v221 ^ smt_terms::BVConst("1", &solver, 10); - auto v223 = v221; - auto v224 = v222; - auto v225 = v219 * v223; - auto v226 = v218 * v224; - auto v227 = v225 + v226; - auto v228 = v227 * v227; - auto v229 = v228 * smt_terms::BVConst("2", &solver, 10); - auto v231 = v9 & smt_terms::BVConst("2199023255552", &solver, 10); - auto v232 = v231 ^ smt_terms::BVConst("1", &solver, 10); - auto v233 = v231; - auto v234 = v232; - auto v235 = v229 * v233; - auto v236 = v228 * v234; - auto v237 = v235 + v236; - auto v238 = v237 * v237; - auto v239 = v238 * smt_terms::BVConst("2", &solver, 10); - auto v241 = v9 & smt_terms::BVConst("1099511627776", &solver, 10); - auto v242 = v241 ^ smt_terms::BVConst("1", &solver, 10); - auto v243 = v241; - auto v244 = v242; - auto v245 = v239 * v243; - auto v246 = v238 * v244; - auto v247 = v245 + v246; - auto v248 = v247 * v247; - auto v249 = v248 * smt_terms::BVConst("2", &solver, 10); - auto v251 = v9 & smt_terms::BVConst("549755813888", &solver, 10); - auto v252 = v251 ^ smt_terms::BVConst("1", &solver, 10); - auto v253 = v251; - auto v254 = v252; - auto v255 = v249 * v253; - auto v256 = v248 * v254; - auto v257 = v255 + v256; - auto v258 = v257 * v257; - auto v259 = v258 * smt_terms::BVConst("2", &solver, 10); - auto v261 = v9 & smt_terms::BVConst("274877906944", &solver, 10); - auto v262 = v261 ^ smt_terms::BVConst("1", &solver, 10); - auto v263 = v261; - auto v264 = v262; - auto v265 = v259 * v263; - auto v266 = v258 * v264; - auto v267 = v265 + v266; - auto v268 = v267 * v267; - auto v269 = v268 * smt_terms::BVConst("2", &solver, 10); - auto v271 = v9 & smt_terms::BVConst("137438953472", &solver, 10); - auto v272 = v271 ^ smt_terms::BVConst("1", &solver, 10); - auto v273 = v271; - auto v274 = v272; - auto v275 = v269 * v273; - auto v276 = v268 * v274; - auto v277 = v275 + v276; - auto v278 = v277 * v277; - auto v279 = v278 * smt_terms::BVConst("2", &solver, 10); - auto v281 = v9 & smt_terms::BVConst("68719476736", &solver, 10); - auto v282 = v281 ^ smt_terms::BVConst("1", &solver, 10); - auto v283 = v281; - auto v284 = v282; - auto v285 = v279 * v283; - auto v286 = v278 * v284; - auto v287 = v285 + v286; - auto v288 = v287 * v287; - auto v289 = v288 * smt_terms::BVConst("2", &solver, 10); - auto v291 = v9 & smt_terms::BVConst("34359738368", &solver, 10); - auto v292 = v291 ^ smt_terms::BVConst("1", &solver, 10); - auto v293 = v291; - auto v294 = v292; - auto v295 = v289 * v293; - auto v296 = v288 * v294; - auto v297 = v295 + v296; - auto v298 = v297 * v297; - auto v299 = v298 * smt_terms::BVConst("2", &solver, 10); - auto v301 = v9 & smt_terms::BVConst("17179869184", &solver, 10); - auto v302 = v301 ^ smt_terms::BVConst("1", &solver, 10); - auto v303 = v301; - auto v304 = v302; - auto v305 = v299 * v303; - auto v306 = v298 * v304; - auto v307 = v305 + v306; - auto v308 = v307 * v307; - auto v309 = v308 * smt_terms::BVConst("2", &solver, 10); - auto v311 = v9 & smt_terms::BVConst("8589934592", &solver, 10); - auto v312 = v311 ^ smt_terms::BVConst("1", &solver, 10); - auto v313 = v311; - auto v314 = v312; - auto v315 = v309 * v313; - auto v316 = v308 * v314; - auto v317 = v315 + v316; - auto v318 = v317 * v317; - auto v319 = v318 * smt_terms::BVConst("2", &solver, 10); - auto v321 = v9 & smt_terms::BVConst("4294967296", &solver, 10); - auto v322 = v321 ^ smt_terms::BVConst("1", &solver, 10); - auto v323 = v321; - auto v324 = v322; - auto v325 = v319 * v323; - auto v326 = v318 * v324; - auto v327 = v325 + v326; - auto v328 = v327 * v327; - auto v329 = v328 * smt_terms::BVConst("2", &solver, 10); - auto v331 = v9 & smt_terms::BVConst("2147483648", &solver, 10); - auto v332 = v331 ^ smt_terms::BVConst("1", &solver, 10); - auto v333 = v331; - auto v334 = v332; - auto v335 = v329 * v333; - auto v336 = v328 * v334; - auto v337 = v335 + v336; - auto v338 = v337 * v337; - auto v339 = v338 * smt_terms::BVConst("2", &solver, 10); - auto v341 = v9 & smt_terms::BVConst("1073741824", &solver, 10); - auto v342 = v341 ^ smt_terms::BVConst("1", &solver, 10); - auto v343 = v341; - auto v344 = v342; - auto v345 = v339 * v343; - auto v346 = v338 * v344; - auto v347 = v345 + v346; - auto v348 = v347 * v347; - auto v349 = v348 * smt_terms::BVConst("2", &solver, 10); - auto v351 = v9 & smt_terms::BVConst("536870912", &solver, 10); - auto v352 = v351 ^ smt_terms::BVConst("1", &solver, 10); - auto v353 = v351; - auto v354 = v352; - auto v355 = v349 * v353; - auto v356 = v348 * v354; - auto v357 = v355 + v356; - auto v358 = v357 * v357; - auto v359 = v358 * smt_terms::BVConst("2", &solver, 10); - auto v361 = v9 & smt_terms::BVConst("268435456", &solver, 10); - auto v362 = v361 ^ smt_terms::BVConst("1", &solver, 10); - auto v363 = v361; - auto v364 = v362; - auto v365 = v359 * v363; - auto v366 = v358 * v364; - auto v367 = v365 + v366; - auto v368 = v367 * v367; - auto v369 = v368 * smt_terms::BVConst("2", &solver, 10); - auto v371 = v9 & smt_terms::BVConst("134217728", &solver, 10); - auto v372 = v371 ^ smt_terms::BVConst("1", &solver, 10); - auto v373 = v371; - auto v374 = v372; - auto v375 = v369 * v373; - auto v376 = v368 * v374; - auto v377 = v375 + v376; - auto v378 = v377 * v377; - auto v379 = v378 * smt_terms::BVConst("2", &solver, 10); - auto v381 = v9 & smt_terms::BVConst("67108864", &solver, 10); - auto v382 = v381 ^ smt_terms::BVConst("1", &solver, 10); - auto v383 = v381; - auto v384 = v382; - auto v385 = v379 * v383; - auto v386 = v378 * v384; - auto v387 = v385 + v386; - auto v388 = v387 * v387; - auto v389 = v388 * smt_terms::BVConst("2", &solver, 10); - auto v391 = v9 & smt_terms::BVConst("33554432", &solver, 10); - auto v392 = v391 ^ smt_terms::BVConst("1", &solver, 10); - auto v393 = v391; - auto v394 = v392; - auto v395 = v389 * v393; - auto v396 = v388 * v394; - auto v397 = v395 + v396; - auto v398 = v397 * v397; - auto v399 = v398 * smt_terms::BVConst("2", &solver, 10); - auto v401 = v9 & smt_terms::BVConst("16777216", &solver, 10); - auto v402 = v401 ^ smt_terms::BVConst("1", &solver, 10); - auto v403 = v401; - auto v404 = v402; - auto v405 = v399 * v403; - auto v406 = v398 * v404; - auto v407 = v405 + v406; - auto v408 = v407 * v407; - auto v409 = v408 * smt_terms::BVConst("2", &solver, 10); - auto v411 = v9 & smt_terms::BVConst("8388608", &solver, 10); - auto v412 = v411 ^ smt_terms::BVConst("1", &solver, 10); - auto v413 = v411; - auto v414 = v412; - auto v415 = v409 * v413; - auto v416 = v408 * v414; - auto v417 = v415 + v416; - auto v418 = v417 * v417; - auto v419 = v418 * smt_terms::BVConst("2", &solver, 10); - auto v421 = v9 & smt_terms::BVConst("4194304", &solver, 10); - auto v422 = v421 ^ smt_terms::BVConst("1", &solver, 10); - auto v423 = v421; - auto v424 = v422; - auto v425 = v419 * v423; - auto v426 = v418 * v424; - auto v427 = v425 + v426; - auto v428 = v427 * v427; - auto v429 = v428 * smt_terms::BVConst("2", &solver, 10); - auto v431 = v9 & smt_terms::BVConst("2097152", &solver, 10); - auto v432 = v431 ^ smt_terms::BVConst("1", &solver, 10); - auto v433 = v431; - auto v434 = v432; - auto v435 = v429 * v433; - auto v436 = v428 * v434; - auto v437 = v435 + v436; - auto v438 = v437 * v437; - auto v439 = v438 * smt_terms::BVConst("2", &solver, 10); - auto v441 = v9 & smt_terms::BVConst("1048576", &solver, 10); - auto v442 = v441 ^ smt_terms::BVConst("1", &solver, 10); - auto v443 = v441; - auto v444 = v442; - auto v445 = v439 * v443; - auto v446 = v438 * v444; - auto v447 = v445 + v446; - auto v448 = v447 * v447; - auto v449 = v448 * smt_terms::BVConst("2", &solver, 10); - auto v451 = v9 & smt_terms::BVConst("524288", &solver, 10); - auto v452 = v451 ^ smt_terms::BVConst("1", &solver, 10); - auto v453 = v451; - auto v454 = v452; - auto v455 = v449 * v453; - auto v456 = v448 * v454; - auto v457 = v455 + v456; - auto v458 = v457 * v457; - auto v459 = v458 * smt_terms::BVConst("2", &solver, 10); - auto v461 = v9 & smt_terms::BVConst("262144", &solver, 10); - auto v462 = v461 ^ smt_terms::BVConst("1", &solver, 10); - auto v463 = v461; - auto v464 = v462; - auto v465 = v459 * v463; - auto v466 = v458 * v464; - auto v467 = v465 + v466; - auto v468 = v467 * v467; - auto v469 = v468 * smt_terms::BVConst("2", &solver, 10); - auto v471 = v9 & smt_terms::BVConst("131072", &solver, 10); - auto v472 = v471 ^ smt_terms::BVConst("1", &solver, 10); - auto v473 = v471; - auto v474 = v472; - auto v475 = v469 * v473; - auto v476 = v468 * v474; - auto v477 = v475 + v476; - auto v478 = v477 * v477; - auto v479 = v478 * smt_terms::BVConst("2", &solver, 10); - auto v481 = v9 & smt_terms::BVConst("65536", &solver, 10); - auto v482 = v481 ^ smt_terms::BVConst("1", &solver, 10); - auto v483 = v481; - auto v484 = v482; - auto v485 = v479 * v483; - auto v486 = v478 * v484; - auto v487 = v485 + v486; - auto v488 = v487 * v487; - auto v489 = v488 * smt_terms::BVConst("2", &solver, 10); - auto v491 = v9 & smt_terms::BVConst("32768", &solver, 10); - auto v492 = v491 ^ smt_terms::BVConst("1", &solver, 10); - auto v493 = v491; - auto v494 = v492; - auto v495 = v489 * v493; - auto v496 = v488 * v494; - auto v497 = v495 + v496; - auto v498 = v497 * v497; - auto v499 = v498 * smt_terms::BVConst("2", &solver, 10); - auto v501 = v9 & smt_terms::BVConst("16384", &solver, 10); - auto v502 = v501 ^ smt_terms::BVConst("1", &solver, 10); - auto v503 = v501; - auto v504 = v502; - auto v505 = v499 * v503; - auto v506 = v498 * v504; - auto v507 = v505 + v506; - auto v508 = v507 * v507; - auto v509 = v508 * smt_terms::BVConst("2", &solver, 10); - auto v511 = v9 & smt_terms::BVConst("8192", &solver, 10); - auto v512 = v511 ^ smt_terms::BVConst("1", &solver, 10); - auto v513 = v511; - auto v514 = v512; - auto v515 = v509 * v513; - auto v516 = v508 * v514; - auto v517 = v515 + v516; - auto v518 = v517 * v517; - auto v519 = v518 * smt_terms::BVConst("2", &solver, 10); - auto v521 = v9 & smt_terms::BVConst("4096", &solver, 10); - auto v522 = v521 ^ smt_terms::BVConst("1", &solver, 10); - auto v523 = v521; - auto v524 = v522; - auto v525 = v519 * v523; - auto v526 = v518 * v524; - auto v527 = v525 + v526; - auto v528 = v527 * v527; - auto v529 = v528 * smt_terms::BVConst("2", &solver, 10); - auto v531 = v9 & smt_terms::BVConst("2048", &solver, 10); - auto v532 = v531 ^ smt_terms::BVConst("1", &solver, 10); - auto v533 = v531; - auto v534 = v532; - auto v535 = v529 * v533; - auto v536 = v528 * v534; - auto v537 = v535 + v536; - auto v538 = v537 * v537; - auto v539 = v538 * smt_terms::BVConst("2", &solver, 10); - auto v541 = v9 & smt_terms::BVConst("1024", &solver, 10); - auto v542 = v541 ^ smt_terms::BVConst("1", &solver, 10); - auto v543 = v541; - auto v544 = v542; - auto v545 = v539 * v543; - auto v546 = v538 * v544; - auto v547 = v545 + v546; - auto v548 = v547 * v547; - auto v549 = v548 * smt_terms::BVConst("2", &solver, 10); - auto v551 = v9 & smt_terms::BVConst("512", &solver, 10); - auto v552 = v551 ^ smt_terms::BVConst("1", &solver, 10); - auto v553 = v551; - auto v554 = v552; - auto v555 = v549 * v553; - auto v556 = v548 * v554; - auto v557 = v555 + v556; - auto v558 = v557 * v557; - auto v559 = v558 * smt_terms::BVConst("2", &solver, 10); - auto v561 = v9 & smt_terms::BVConst("256", &solver, 10); - auto v562 = v561 ^ smt_terms::BVConst("1", &solver, 10); - auto v563 = v561; - auto v564 = v562; - auto v565 = v559 * v563; - auto v566 = v558 * v564; - auto v567 = v565 + v566; - auto v568 = v567 * v567; - auto v569 = v568 * smt_terms::BVConst("2", &solver, 10); - auto v571 = v9 & smt_terms::BVConst("128", &solver, 10); - auto v572 = v571 ^ smt_terms::BVConst("1", &solver, 10); - auto v573 = v571; - auto v574 = v572; - auto v575 = v569 * v573; - auto v576 = v568 * v574; - auto v577 = v575 + v576; - auto v578 = v577 * v577; - auto v579 = v578 * smt_terms::BVConst("2", &solver, 10); - auto v581 = v9 & smt_terms::BVConst("64", &solver, 10); - auto v582 = v581 ^ smt_terms::BVConst("1", &solver, 10); - auto v583 = v581; - auto v584 = v582; - auto v585 = v579 * v583; - auto v586 = v578 * v584; - auto v587 = v585 + v586; - auto v588 = v587 * v587; - auto v589 = v588 * smt_terms::BVConst("2", &solver, 10); - auto v591 = v9 & smt_terms::BVConst("32", &solver, 10); - auto v592 = v591 ^ smt_terms::BVConst("1", &solver, 10); - auto v593 = v591; - auto v594 = v592; - auto v595 = v589 * v593; - auto v596 = v588 * v594; - auto v597 = v595 + v596; - auto v598 = v597 * v597; - auto v599 = v598 * smt_terms::BVConst("2", &solver, 10); - auto v601 = v9 & smt_terms::BVConst("16", &solver, 10); - auto v602 = v601 ^ smt_terms::BVConst("1", &solver, 10); - auto v603 = v601; - auto v604 = v602; - auto v605 = v599 * v603; - auto v606 = v598 * v604; - auto v607 = v605 + v606; - auto v608 = v607 * v607; - auto v609 = v608 * smt_terms::BVConst("2", &solver, 10); - auto v611 = v9 & smt_terms::BVConst("8", &solver, 10); - auto v612 = v611 ^ smt_terms::BVConst("1", &solver, 10); - auto v613 = v611; - auto v614 = v612; - auto v615 = v609 * v613; - auto v616 = v608 * v614; - auto v617 = v615 + v616; - auto v618 = v617 * v617; - auto v619 = v618 * smt_terms::BVConst("2", &solver, 10); - auto v620 = v9 & smt_terms::BVConst("4", &solver, 10); - auto v621 = v620 ^ smt_terms::BVConst("1", &solver, 10); - auto v622 = v620; - auto v623 = v621; - auto v624 = v619 * v622; - auto v625 = v618 * v623; - auto v626 = v624 + v625; - auto v627 = v626 * v626; - auto v628 = v627 * smt_terms::BVConst("2", &solver, 10); - auto v629 = v9 & smt_terms::BVConst("2", &solver, 10); - auto v630 = v629 ^ smt_terms::BVConst("1", &solver, 10); - auto v631 = v629; - auto v632 = v630; - auto v633 = v628 * v631; - auto v634 = v627 * v632; - auto v635 = v633 + v634; - auto v636 = v635 * v635; - auto v637 = v636 * smt_terms::BVConst("2", &solver, 10); - auto v639 = v9 & smt_terms::BVConst("1", &solver, 10); - auto v640 = v639 ^ smt_terms::BVConst("1", &solver, 10); - auto v641 = v639; - auto v642 = v640; - auto v643 = v637 * v641; - auto v644 = v636 * v642; - auto v645 = v643 + v644; - auto v646 = v645; - auto v647 = v6 * v646; - auto v648 = v0; - auto v649 = v647; - auto v650 = v648 * v649; - auto v651 = v650 & smt_terms::BVConst("18446744073709551615", &solver, 10); - auto v652 = v651; - auto cr = v652; \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shl.ssa b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shl.ssa deleted file mode 100644 index cad6e3bd90e..00000000000 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shl.ssa +++ /dev/null @@ -1,588 +0,0 @@ -acir(inline) fn main f0 { - b0(v0: u64, v1: u8): - v5 = lt v1, u8 64 - v6 = cast v5 as u64 - v7 = cast v1 as u64 - v9 = call to_le_bits(v7) - v12 = array_get v9, index Field 63 - v13 = not v12 - v14 = cast v12 as Field - v15 = cast v13 as Field - v16 = mul Field 2, v14 - v17 = add v16, v15 - v18 = mul v17, v17 - v19 = mul v18, Field 2 - v21 = array_get v9, index Field 62 - v22 = not v21 - v23 = cast v21 as Field - v24 = cast v22 as Field - v25 = mul v19, v23 - v26 = mul v18, v24 - v27 = add v25, v26 - v28 = mul v27, v27 - v29 = mul v28, Field 2 - v31 = array_get v9, index Field 61 - v32 = not v31 - v33 = cast v31 as Field - v34 = cast v32 as Field - v35 = mul v29, v33 - v36 = mul v28, v34 - v37 = add v35, v36 - v38 = mul v37, v37 - v39 = mul v38, Field 2 - v41 = array_get v9, index Field 60 - v42 = not v41 - v43 = cast v41 as Field - v44 = cast v42 as Field - v45 = mul v39, v43 - v46 = mul v38, v44 - v47 = add v45, v46 - v48 = mul v47, v47 - v49 = mul v48, Field 2 - v51 = array_get v9, index Field 59 - v52 = not v51 - v53 = cast v51 as Field - v54 = cast v52 as Field - v55 = mul v49, v53 - v56 = mul v48, v54 - v57 = add v55, v56 - v58 = mul v57, v57 - v59 = mul v58, Field 2 - v61 = array_get v9, index Field 58 - v62 = not v61 - v63 = cast v61 as Field - v64 = cast v62 as Field - v65 = mul v59, v63 - v66 = mul v58, v64 - v67 = add v65, v66 - v68 = mul v67, v67 - v69 = mul v68, Field 2 - v71 = array_get v9, index Field 57 - v72 = not v71 - v73 = cast v71 as Field - v74 = cast v72 as Field - v75 = mul v69, v73 - v76 = mul v68, v74 - v77 = add v75, v76 - v78 = mul v77, v77 - v79 = mul v78, Field 2 - v81 = array_get v9, index Field 56 - v82 = not v81 - v83 = cast v81 as Field - v84 = cast v82 as Field - v85 = mul v79, v83 - v86 = mul v78, v84 - v87 = add v85, v86 - v88 = mul v87, v87 - v89 = mul v88, Field 2 - v91 = array_get v9, index Field 55 - v92 = not v91 - v93 = cast v91 as Field - v94 = cast v92 as Field - v95 = mul v89, v93 - v96 = mul v88, v94 - v97 = add v95, v96 - v98 = mul v97, v97 - v99 = mul v98, Field 2 - v101 = array_get v9, index Field 54 - v102 = not v101 - v103 = cast v101 as Field - v104 = cast v102 as Field - v105 = mul v99, v103 - v106 = mul v98, v104 - v107 = add v105, v106 - v108 = mul v107, v107 - v109 = mul v108, Field 2 - v111 = array_get v9, index Field 53 - v112 = not v111 - v113 = cast v111 as Field - v114 = cast v112 as Field - v115 = mul v109, v113 - v116 = mul v108, v114 - v117 = add v115, v116 - v118 = mul v117, v117 - v119 = mul v118, Field 2 - v121 = array_get v9, index Field 52 - v122 = not v121 - v123 = cast v121 as Field - v124 = cast v122 as Field - v125 = mul v119, v123 - v126 = mul v118, v124 - v127 = add v125, v126 - v128 = mul v127, v127 - v129 = mul v128, Field 2 - v131 = array_get v9, index Field 51 - v132 = not v131 - v133 = cast v131 as Field - v134 = cast v132 as Field - v135 = mul v129, v133 - v136 = mul v128, v134 - v137 = add v135, v136 - v138 = mul v137, v137 - v139 = mul v138, Field 2 - v141 = array_get v9, index Field 50 - v142 = not v141 - v143 = cast v141 as Field - v144 = cast v142 as Field - v145 = mul v139, v143 - v146 = mul v138, v144 - v147 = add v145, v146 - v148 = mul v147, v147 - v149 = mul v148, Field 2 - v151 = array_get v9, index Field 49 - v152 = not v151 - v153 = cast v151 as Field - v154 = cast v152 as Field - v155 = mul v149, v153 - v156 = mul v148, v154 - v157 = add v155, v156 - v158 = mul v157, v157 - v159 = mul v158, Field 2 - v161 = array_get v9, index Field 48 - v162 = not v161 - v163 = cast v161 as Field - v164 = cast v162 as Field - v165 = mul v159, v163 - v166 = mul v158, v164 - v167 = add v165, v166 - v168 = mul v167, v167 - v169 = mul v168, Field 2 - v171 = array_get v9, index Field 47 - v172 = not v171 - v173 = cast v171 as Field - v174 = cast v172 as Field - v175 = mul v169, v173 - v176 = mul v168, v174 - v177 = add v175, v176 - v178 = mul v177, v177 - v179 = mul v178, Field 2 - v181 = array_get v9, index Field 46 - v182 = not v181 - v183 = cast v181 as Field - v184 = cast v182 as Field - v185 = mul v179, v183 - v186 = mul v178, v184 - v187 = add v185, v186 - v188 = mul v187, v187 - v189 = mul v188, Field 2 - v191 = array_get v9, index Field 45 - v192 = not v191 - v193 = cast v191 as Field - v194 = cast v192 as Field - v195 = mul v189, v193 - v196 = mul v188, v194 - v197 = add v195, v196 - v198 = mul v197, v197 - v199 = mul v198, Field 2 - v201 = array_get v9, index Field 44 - v202 = not v201 - v203 = cast v201 as Field - v204 = cast v202 as Field - v205 = mul v199, v203 - v206 = mul v198, v204 - v207 = add v205, v206 - v208 = mul v207, v207 - v209 = mul v208, Field 2 - v211 = array_get v9, index Field 43 - v212 = not v211 - v213 = cast v211 as Field - v214 = cast v212 as Field - v215 = mul v209, v213 - v216 = mul v208, v214 - v217 = add v215, v216 - v218 = mul v217, v217 - v219 = mul v218, Field 2 - v221 = array_get v9, index Field 42 - v222 = not v221 - v223 = cast v221 as Field - v224 = cast v222 as Field - v225 = mul v219, v223 - v226 = mul v218, v224 - v227 = add v225, v226 - v228 = mul v227, v227 - v229 = mul v228, Field 2 - v231 = array_get v9, index Field 41 - v232 = not v231 - v233 = cast v231 as Field - v234 = cast v232 as Field - v235 = mul v229, v233 - v236 = mul v228, v234 - v237 = add v235, v236 - v238 = mul v237, v237 - v239 = mul v238, Field 2 - v241 = array_get v9, index Field 40 - v242 = not v241 - v243 = cast v241 as Field - v244 = cast v242 as Field - v245 = mul v239, v243 - v246 = mul v238, v244 - v247 = add v245, v246 - v248 = mul v247, v247 - v249 = mul v248, Field 2 - v251 = array_get v9, index Field 39 - v252 = not v251 - v253 = cast v251 as Field - v254 = cast v252 as Field - v255 = mul v249, v253 - v256 = mul v248, v254 - v257 = add v255, v256 - v258 = mul v257, v257 - v259 = mul v258, Field 2 - v261 = array_get v9, index Field 38 - v262 = not v261 - v263 = cast v261 as Field - v264 = cast v262 as Field - v265 = mul v259, v263 - v266 = mul v258, v264 - v267 = add v265, v266 - v268 = mul v267, v267 - v269 = mul v268, Field 2 - v271 = array_get v9, index Field 37 - v272 = not v271 - v273 = cast v271 as Field - v274 = cast v272 as Field - v275 = mul v269, v273 - v276 = mul v268, v274 - v277 = add v275, v276 - v278 = mul v277, v277 - v279 = mul v278, Field 2 - v281 = array_get v9, index Field 36 - v282 = not v281 - v283 = cast v281 as Field - v284 = cast v282 as Field - v285 = mul v279, v283 - v286 = mul v278, v284 - v287 = add v285, v286 - v288 = mul v287, v287 - v289 = mul v288, Field 2 - v291 = array_get v9, index Field 35 - v292 = not v291 - v293 = cast v291 as Field - v294 = cast v292 as Field - v295 = mul v289, v293 - v296 = mul v288, v294 - v297 = add v295, v296 - v298 = mul v297, v297 - v299 = mul v298, Field 2 - v301 = array_get v9, index Field 34 - v302 = not v301 - v303 = cast v301 as Field - v304 = cast v302 as Field - v305 = mul v299, v303 - v306 = mul v298, v304 - v307 = add v305, v306 - v308 = mul v307, v307 - v309 = mul v308, Field 2 - v311 = array_get v9, index Field 33 - v312 = not v311 - v313 = cast v311 as Field - v314 = cast v312 as Field - v315 = mul v309, v313 - v316 = mul v308, v314 - v317 = add v315, v316 - v318 = mul v317, v317 - v319 = mul v318, Field 2 - v321 = array_get v9, index Field 32 - v322 = not v321 - v323 = cast v321 as Field - v324 = cast v322 as Field - v325 = mul v319, v323 - v326 = mul v318, v324 - v327 = add v325, v326 - v328 = mul v327, v327 - v329 = mul v328, Field 2 - v331 = array_get v9, index Field 31 - v332 = not v331 - v333 = cast v331 as Field - v334 = cast v332 as Field - v335 = mul v329, v333 - v336 = mul v328, v334 - v337 = add v335, v336 - v338 = mul v337, v337 - v339 = mul v338, Field 2 - v341 = array_get v9, index Field 30 - v342 = not v341 - v343 = cast v341 as Field - v344 = cast v342 as Field - v345 = mul v339, v343 - v346 = mul v338, v344 - v347 = add v345, v346 - v348 = mul v347, v347 - v349 = mul v348, Field 2 - v351 = array_get v9, index Field 29 - v352 = not v351 - v353 = cast v351 as Field - v354 = cast v352 as Field - v355 = mul v349, v353 - v356 = mul v348, v354 - v357 = add v355, v356 - v358 = mul v357, v357 - v359 = mul v358, Field 2 - v361 = array_get v9, index Field 28 - v362 = not v361 - v363 = cast v361 as Field - v364 = cast v362 as Field - v365 = mul v359, v363 - v366 = mul v358, v364 - v367 = add v365, v366 - v368 = mul v367, v367 - v369 = mul v368, Field 2 - v371 = array_get v9, index Field 27 - v372 = not v371 - v373 = cast v371 as Field - v374 = cast v372 as Field - v375 = mul v369, v373 - v376 = mul v368, v374 - v377 = add v375, v376 - v378 = mul v377, v377 - v379 = mul v378, Field 2 - v381 = array_get v9, index Field 26 - v382 = not v381 - v383 = cast v381 as Field - v384 = cast v382 as Field - v385 = mul v379, v383 - v386 = mul v378, v384 - v387 = add v385, v386 - v388 = mul v387, v387 - v389 = mul v388, Field 2 - v391 = array_get v9, index Field 25 - v392 = not v391 - v393 = cast v391 as Field - v394 = cast v392 as Field - v395 = mul v389, v393 - v396 = mul v388, v394 - v397 = add v395, v396 - v398 = mul v397, v397 - v399 = mul v398, Field 2 - v401 = array_get v9, index Field 24 - v402 = not v401 - v403 = cast v401 as Field - v404 = cast v402 as Field - v405 = mul v399, v403 - v406 = mul v398, v404 - v407 = add v405, v406 - v408 = mul v407, v407 - v409 = mul v408, Field 2 - v411 = array_get v9, index Field 23 - v412 = not v411 - v413 = cast v411 as Field - v414 = cast v412 as Field - v415 = mul v409, v413 - v416 = mul v408, v414 - v417 = add v415, v416 - v418 = mul v417, v417 - v419 = mul v418, Field 2 - v421 = array_get v9, index Field 22 - v422 = not v421 - v423 = cast v421 as Field - v424 = cast v422 as Field - v425 = mul v419, v423 - v426 = mul v418, v424 - v427 = add v425, v426 - v428 = mul v427, v427 - v429 = mul v428, Field 2 - v431 = array_get v9, index Field 21 - v432 = not v431 - v433 = cast v431 as Field - v434 = cast v432 as Field - v435 = mul v429, v433 - v436 = mul v428, v434 - v437 = add v435, v436 - v438 = mul v437, v437 - v439 = mul v438, Field 2 - v441 = array_get v9, index Field 20 - v442 = not v441 - v443 = cast v441 as Field - v444 = cast v442 as Field - v445 = mul v439, v443 - v446 = mul v438, v444 - v447 = add v445, v446 - v448 = mul v447, v447 - v449 = mul v448, Field 2 - v451 = array_get v9, index Field 19 - v452 = not v451 - v453 = cast v451 as Field - v454 = cast v452 as Field - v455 = mul v449, v453 - v456 = mul v448, v454 - v457 = add v455, v456 - v458 = mul v457, v457 - v459 = mul v458, Field 2 - v461 = array_get v9, index Field 18 - v462 = not v461 - v463 = cast v461 as Field - v464 = cast v462 as Field - v465 = mul v459, v463 - v466 = mul v458, v464 - v467 = add v465, v466 - v468 = mul v467, v467 - v469 = mul v468, Field 2 - v471 = array_get v9, index Field 17 - v472 = not v471 - v473 = cast v471 as Field - v474 = cast v472 as Field - v475 = mul v469, v473 - v476 = mul v468, v474 - v477 = add v475, v476 - v478 = mul v477, v477 - v479 = mul v478, Field 2 - v481 = array_get v9, index Field 16 - v482 = not v481 - v483 = cast v481 as Field - v484 = cast v482 as Field - v485 = mul v479, v483 - v486 = mul v478, v484 - v487 = add v485, v486 - v488 = mul v487, v487 - v489 = mul v488, Field 2 - v491 = array_get v9, index Field 15 - v492 = not v491 - v493 = cast v491 as Field - v494 = cast v492 as Field - v495 = mul v489, v493 - v496 = mul v488, v494 - v497 = add v495, v496 - v498 = mul v497, v497 - v499 = mul v498, Field 2 - v501 = array_get v9, index Field 14 - v502 = not v501 - v503 = cast v501 as Field - v504 = cast v502 as Field - v505 = mul v499, v503 - v506 = mul v498, v504 - v507 = add v505, v506 - v508 = mul v507, v507 - v509 = mul v508, Field 2 - v511 = array_get v9, index Field 13 - v512 = not v511 - v513 = cast v511 as Field - v514 = cast v512 as Field - v515 = mul v509, v513 - v516 = mul v508, v514 - v517 = add v515, v516 - v518 = mul v517, v517 - v519 = mul v518, Field 2 - v521 = array_get v9, index Field 12 - v522 = not v521 - v523 = cast v521 as Field - v524 = cast v522 as Field - v525 = mul v519, v523 - v526 = mul v518, v524 - v527 = add v525, v526 - v528 = mul v527, v527 - v529 = mul v528, Field 2 - v531 = array_get v9, index Field 11 - v532 = not v531 - v533 = cast v531 as Field - v534 = cast v532 as Field - v535 = mul v529, v533 - v536 = mul v528, v534 - v537 = add v535, v536 - v538 = mul v537, v537 - v539 = mul v538, Field 2 - v541 = array_get v9, index Field 10 - v542 = not v541 - v543 = cast v541 as Field - v544 = cast v542 as Field - v545 = mul v539, v543 - v546 = mul v538, v544 - v547 = add v545, v546 - v548 = mul v547, v547 - v549 = mul v548, Field 2 - v551 = array_get v9, index Field 9 - v552 = not v551 - v553 = cast v551 as Field - v554 = cast v552 as Field - v555 = mul v549, v553 - v556 = mul v548, v554 - v557 = add v555, v556 - v558 = mul v557, v557 - v559 = mul v558, Field 2 - v561 = array_get v9, index Field 8 - v562 = not v561 - v563 = cast v561 as Field - v564 = cast v562 as Field - v565 = mul v559, v563 - v566 = mul v558, v564 - v567 = add v565, v566 - v568 = mul v567, v567 - v569 = mul v568, Field 2 - v571 = array_get v9, index Field 7 - v572 = not v571 - v573 = cast v571 as Field - v574 = cast v572 as Field - v575 = mul v569, v573 - v576 = mul v568, v574 - v577 = add v575, v576 - v578 = mul v577, v577 - v579 = mul v578, Field 2 - v581 = array_get v9, index Field 6 - v582 = not v581 - v583 = cast v581 as Field - v584 = cast v582 as Field - v585 = mul v579, v583 - v586 = mul v578, v584 - v587 = add v585, v586 - v588 = mul v587, v587 - v589 = mul v588, Field 2 - v591 = array_get v9, index Field 5 - v592 = not v591 - v593 = cast v591 as Field - v594 = cast v592 as Field - v595 = mul v589, v593 - v596 = mul v588, v594 - v597 = add v595, v596 - v598 = mul v597, v597 - v599 = mul v598, Field 2 - v601 = array_get v9, index Field 4 - v602 = not v601 - v603 = cast v601 as Field - v604 = cast v602 as Field - v605 = mul v599, v603 - v606 = mul v598, v604 - v607 = add v605, v606 - v608 = mul v607, v607 - v609 = mul v608, Field 2 - v611 = array_get v9, index Field 3 - v612 = not v611 - v613 = cast v611 as Field - v614 = cast v612 as Field - v615 = mul v609, v613 - v616 = mul v608, v614 - v617 = add v615, v616 - v618 = mul v617, v617 - v619 = mul v618, Field 2 - v620 = array_get v9, index Field 2 - v621 = not v620 - v622 = cast v620 as Field - v623 = cast v621 as Field - v624 = mul v619, v622 - v625 = mul v618, v623 - v626 = add v624, v625 - v627 = mul v626, v626 - v628 = mul v627, Field 2 - v629 = array_get v9, index Field 1 - v630 = not v629 - v631 = cast v629 as Field - v632 = cast v630 as Field - v633 = mul v628, v631 - v634 = mul v627, v632 - v635 = add v633, v634 - v636 = mul v635, v635 - v637 = mul v636, Field 2 - v639 = array_get v9, index Field 0 - v640 = not v639 - v641 = cast v639 as Field - v642 = cast v640 as Field - v643 = mul v637, v641 - v644 = mul v636, v642 - v645 = add v643, v644 - v646 = cast v645 as u64 - v647 = mul v6, v646 - v648 = cast v0 as Field - v649 = cast v647 as Field - v650 = mul v648, v649 - v651 = truncate v650 to 64 bits, max_bit_size: 254 - v652 = cast v651 as u64 - return v652 -} \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shr.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shr.cpp deleted file mode 100644 index 1c04811916e..00000000000 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shr.cpp +++ /dev/null @@ -1,585 +0,0 @@ - auto v5 = smt_terms::BVConst("1", &solver, 10); - auto v6 = v5; - auto v7 = v1; - auto v9 = v7; - auto v12 = v9 & smt_terms::BVConst("9223372036854775808", &solver, 10); - auto v13 = v12 ^ smt_terms::BVConst("1", &solver, 10); - auto v14 = v12; - auto v15 = v13; - auto v16 = v14 * smt_terms::BVConst("2", &solver, 10); - auto v17 = v16 + v15; - auto v18 = v17 * v17; - auto v19 = v18 * smt_terms::BVConst("2", &solver, 10); - auto v21 = v9 & smt_terms::BVConst("4611686018427387904", &solver, 10); - auto v22 = v21 ^ smt_terms::BVConst("1", &solver, 10); - auto v23 = v21; - auto v24 = v22; - auto v25 = v19 * v23; - auto v26 = v18 * v24; - auto v27 = v25 + v26; - auto v28 = v27 * v27; - auto v29 = v28 * smt_terms::BVConst("2", &solver, 10); - auto v31 = v9 & smt_terms::BVConst("2305843009213693952", &solver, 10); - auto v32 = v31 ^ smt_terms::BVConst("1", &solver, 10); - auto v33 = v31; - auto v34 = v32; - auto v35 = v29 * v33; - auto v36 = v28 * v34; - auto v37 = v35 + v36; - auto v38 = v37 * v37; - auto v39 = v38 * smt_terms::BVConst("2", &solver, 10); - auto v41 = v9 & smt_terms::BVConst("1152921504606846976", &solver, 10); - auto v42 = v41 ^ smt_terms::BVConst("1", &solver, 10); - auto v43 = v41; - auto v44 = v42; - auto v45 = v39 * v43; - auto v46 = v38 * v44; - auto v47 = v45 + v46; - auto v48 = v47 * v47; - auto v49 = v48 * smt_terms::BVConst("2", &solver, 10); - auto v51 = v9 & smt_terms::BVConst("576460752303423488", &solver, 10); - auto v52 = v51 ^ smt_terms::BVConst("1", &solver, 10); - auto v53 = v51; - auto v54 = v52; - auto v55 = v49 * v53; - auto v56 = v48 * v54; - auto v57 = v55 + v56; - auto v58 = v57 * v57; - auto v59 = v58 * smt_terms::BVConst("2", &solver, 10); - auto v61 = v9 & smt_terms::BVConst("288230376151711744", &solver, 10); - auto v62 = v61 ^ smt_terms::BVConst("1", &solver, 10); - auto v63 = v61; - auto v64 = v62; - auto v65 = v59 * v63; - auto v66 = v58 * v64; - auto v67 = v65 + v66; - auto v68 = v67 * v67; - auto v69 = v68 * smt_terms::BVConst("2", &solver, 10); - auto v71 = v9 & smt_terms::BVConst("144115188075855872", &solver, 10); - auto v72 = v71 ^ smt_terms::BVConst("1", &solver, 10); - auto v73 = v71; - auto v74 = v72; - auto v75 = v69 * v73; - auto v76 = v68 * v74; - auto v77 = v75 + v76; - auto v78 = v77 * v77; - auto v79 = v78 * smt_terms::BVConst("2", &solver, 10); - auto v81 = v9 & smt_terms::BVConst("72057594037927936", &solver, 10); - auto v82 = v81 ^ smt_terms::BVConst("1", &solver, 10); - auto v83 = v81; - auto v84 = v82; - auto v85 = v79 * v83; - auto v86 = v78 * v84; - auto v87 = v85 + v86; - auto v88 = v87 * v87; - auto v89 = v88 * smt_terms::BVConst("2", &solver, 10); - auto v91 = v9 & smt_terms::BVConst("36028797018963968", &solver, 10); - auto v92 = v91 ^ smt_terms::BVConst("1", &solver, 10); - auto v93 = v91; - auto v94 = v92; - auto v95 = v89 * v93; - auto v96 = v88 * v94; - auto v97 = v95 + v96; - auto v98 = v97 * v97; - auto v99 = v98 * smt_terms::BVConst("2", &solver, 10); - auto v101 = v9 & smt_terms::BVConst("18014398509481984", &solver, 10); - auto v102 = v101 ^ smt_terms::BVConst("1", &solver, 10); - auto v103 = v101; - auto v104 = v102; - auto v105 = v99 * v103; - auto v106 = v98 * v104; - auto v107 = v105 + v106; - auto v108 = v107 * v107; - auto v109 = v108 * smt_terms::BVConst("2", &solver, 10); - auto v111 = v9 & smt_terms::BVConst("9007199254740992", &solver, 10); - auto v112 = v111 ^ smt_terms::BVConst("1", &solver, 10); - auto v113 = v111; - auto v114 = v112; - auto v115 = v109 * v113; - auto v116 = v108 * v114; - auto v117 = v115 + v116; - auto v118 = v117 * v117; - auto v119 = v118 * smt_terms::BVConst("2", &solver, 10); - auto v121 = v9 & smt_terms::BVConst("4503599627370496", &solver, 10); - auto v122 = v121 ^ smt_terms::BVConst("1", &solver, 10); - auto v123 = v121; - auto v124 = v122; - auto v125 = v119 * v123; - auto v126 = v118 * v124; - auto v127 = v125 + v126; - auto v128 = v127 * v127; - auto v129 = v128 * smt_terms::BVConst("2", &solver, 10); - auto v131 = v9 & smt_terms::BVConst("2251799813685248", &solver, 10); - auto v132 = v131 ^ smt_terms::BVConst("1", &solver, 10); - auto v133 = v131; - auto v134 = v132; - auto v135 = v129 * v133; - auto v136 = v128 * v134; - auto v137 = v135 + v136; - auto v138 = v137 * v137; - auto v139 = v138 * smt_terms::BVConst("2", &solver, 10); - auto v141 = v9 & smt_terms::BVConst("1125899906842624", &solver, 10); - auto v142 = v141 ^ smt_terms::BVConst("1", &solver, 10); - auto v143 = v141; - auto v144 = v142; - auto v145 = v139 * v143; - auto v146 = v138 * v144; - auto v147 = v145 + v146; - auto v148 = v147 * v147; - auto v149 = v148 * smt_terms::BVConst("2", &solver, 10); - auto v151 = v9 & smt_terms::BVConst("562949953421312", &solver, 10); - auto v152 = v151 ^ smt_terms::BVConst("1", &solver, 10); - auto v153 = v151; - auto v154 = v152; - auto v155 = v149 * v153; - auto v156 = v148 * v154; - auto v157 = v155 + v156; - auto v158 = v157 * v157; - auto v159 = v158 * smt_terms::BVConst("2", &solver, 10); - auto v161 = v9 & smt_terms::BVConst("281474976710656", &solver, 10); - auto v162 = v161 ^ smt_terms::BVConst("1", &solver, 10); - auto v163 = v161; - auto v164 = v162; - auto v165 = v159 * v163; - auto v166 = v158 * v164; - auto v167 = v165 + v166; - auto v168 = v167 * v167; - auto v169 = v168 * smt_terms::BVConst("2", &solver, 10); - auto v171 = v9 & smt_terms::BVConst("140737488355328", &solver, 10); - auto v172 = v171 ^ smt_terms::BVConst("1", &solver, 10); - auto v173 = v171; - auto v174 = v172; - auto v175 = v169 * v173; - auto v176 = v168 * v174; - auto v177 = v175 + v176; - auto v178 = v177 * v177; - auto v179 = v178 * smt_terms::BVConst("2", &solver, 10); - auto v181 = v9 & smt_terms::BVConst("70368744177664", &solver, 10); - auto v182 = v181 ^ smt_terms::BVConst("1", &solver, 10); - auto v183 = v181; - auto v184 = v182; - auto v185 = v179 * v183; - auto v186 = v178 * v184; - auto v187 = v185 + v186; - auto v188 = v187 * v187; - auto v189 = v188 * smt_terms::BVConst("2", &solver, 10); - auto v191 = v9 & smt_terms::BVConst("35184372088832", &solver, 10); - auto v192 = v191 ^ smt_terms::BVConst("1", &solver, 10); - auto v193 = v191; - auto v194 = v192; - auto v195 = v189 * v193; - auto v196 = v188 * v194; - auto v197 = v195 + v196; - auto v198 = v197 * v197; - auto v199 = v198 * smt_terms::BVConst("2", &solver, 10); - auto v201 = v9 & smt_terms::BVConst("17592186044416", &solver, 10); - auto v202 = v201 ^ smt_terms::BVConst("1", &solver, 10); - auto v203 = v201; - auto v204 = v202; - auto v205 = v199 * v203; - auto v206 = v198 * v204; - auto v207 = v205 + v206; - auto v208 = v207 * v207; - auto v209 = v208 * smt_terms::BVConst("2", &solver, 10); - auto v211 = v9 & smt_terms::BVConst("8796093022208", &solver, 10); - auto v212 = v211 ^ smt_terms::BVConst("1", &solver, 10); - auto v213 = v211; - auto v214 = v212; - auto v215 = v209 * v213; - auto v216 = v208 * v214; - auto v217 = v215 + v216; - auto v218 = v217 * v217; - auto v219 = v218 * smt_terms::BVConst("2", &solver, 10); - auto v221 = v9 & smt_terms::BVConst("4398046511104", &solver, 10); - auto v222 = v221 ^ smt_terms::BVConst("1", &solver, 10); - auto v223 = v221; - auto v224 = v222; - auto v225 = v219 * v223; - auto v226 = v218 * v224; - auto v227 = v225 + v226; - auto v228 = v227 * v227; - auto v229 = v228 * smt_terms::BVConst("2", &solver, 10); - auto v231 = v9 & smt_terms::BVConst("2199023255552", &solver, 10); - auto v232 = v231 ^ smt_terms::BVConst("1", &solver, 10); - auto v233 = v231; - auto v234 = v232; - auto v235 = v229 * v233; - auto v236 = v228 * v234; - auto v237 = v235 + v236; - auto v238 = v237 * v237; - auto v239 = v238 * smt_terms::BVConst("2", &solver, 10); - auto v241 = v9 & smt_terms::BVConst("1099511627776", &solver, 10); - auto v242 = v241 ^ smt_terms::BVConst("1", &solver, 10); - auto v243 = v241; - auto v244 = v242; - auto v245 = v239 * v243; - auto v246 = v238 * v244; - auto v247 = v245 + v246; - auto v248 = v247 * v247; - auto v249 = v248 * smt_terms::BVConst("2", &solver, 10); - auto v251 = v9 & smt_terms::BVConst("549755813888", &solver, 10); - auto v252 = v251 ^ smt_terms::BVConst("1", &solver, 10); - auto v253 = v251; - auto v254 = v252; - auto v255 = v249 * v253; - auto v256 = v248 * v254; - auto v257 = v255 + v256; - auto v258 = v257 * v257; - auto v259 = v258 * smt_terms::BVConst("2", &solver, 10); - auto v261 = v9 & smt_terms::BVConst("274877906944", &solver, 10); - auto v262 = v261 ^ smt_terms::BVConst("1", &solver, 10); - auto v263 = v261; - auto v264 = v262; - auto v265 = v259 * v263; - auto v266 = v258 * v264; - auto v267 = v265 + v266; - auto v268 = v267 * v267; - auto v269 = v268 * smt_terms::BVConst("2", &solver, 10); - auto v271 = v9 & smt_terms::BVConst("137438953472", &solver, 10); - auto v272 = v271 ^ smt_terms::BVConst("1", &solver, 10); - auto v273 = v271; - auto v274 = v272; - auto v275 = v269 * v273; - auto v276 = v268 * v274; - auto v277 = v275 + v276; - auto v278 = v277 * v277; - auto v279 = v278 * smt_terms::BVConst("2", &solver, 10); - auto v281 = v9 & smt_terms::BVConst("68719476736", &solver, 10); - auto v282 = v281 ^ smt_terms::BVConst("1", &solver, 10); - auto v283 = v281; - auto v284 = v282; - auto v285 = v279 * v283; - auto v286 = v278 * v284; - auto v287 = v285 + v286; - auto v288 = v287 * v287; - auto v289 = v288 * smt_terms::BVConst("2", &solver, 10); - auto v291 = v9 & smt_terms::BVConst("34359738368", &solver, 10); - auto v292 = v291 ^ smt_terms::BVConst("1", &solver, 10); - auto v293 = v291; - auto v294 = v292; - auto v295 = v289 * v293; - auto v296 = v288 * v294; - auto v297 = v295 + v296; - auto v298 = v297 * v297; - auto v299 = v298 * smt_terms::BVConst("2", &solver, 10); - auto v301 = v9 & smt_terms::BVConst("17179869184", &solver, 10); - auto v302 = v301 ^ smt_terms::BVConst("1", &solver, 10); - auto v303 = v301; - auto v304 = v302; - auto v305 = v299 * v303; - auto v306 = v298 * v304; - auto v307 = v305 + v306; - auto v308 = v307 * v307; - auto v309 = v308 * smt_terms::BVConst("2", &solver, 10); - auto v311 = v9 & smt_terms::BVConst("8589934592", &solver, 10); - auto v312 = v311 ^ smt_terms::BVConst("1", &solver, 10); - auto v313 = v311; - auto v314 = v312; - auto v315 = v309 * v313; - auto v316 = v308 * v314; - auto v317 = v315 + v316; - auto v318 = v317 * v317; - auto v319 = v318 * smt_terms::BVConst("2", &solver, 10); - auto v321 = v9 & smt_terms::BVConst("4294967296", &solver, 10); - auto v322 = v321 ^ smt_terms::BVConst("1", &solver, 10); - auto v323 = v321; - auto v324 = v322; - auto v325 = v319 * v323; - auto v326 = v318 * v324; - auto v327 = v325 + v326; - auto v328 = v327 * v327; - auto v329 = v328 * smt_terms::BVConst("2", &solver, 10); - auto v331 = v9 & smt_terms::BVConst("2147483648", &solver, 10); - auto v332 = v331 ^ smt_terms::BVConst("1", &solver, 10); - auto v333 = v331; - auto v334 = v332; - auto v335 = v329 * v333; - auto v336 = v328 * v334; - auto v337 = v335 + v336; - auto v338 = v337 * v337; - auto v339 = v338 * smt_terms::BVConst("2", &solver, 10); - auto v341 = v9 & smt_terms::BVConst("1073741824", &solver, 10); - auto v342 = v341 ^ smt_terms::BVConst("1", &solver, 10); - auto v343 = v341; - auto v344 = v342; - auto v345 = v339 * v343; - auto v346 = v338 * v344; - auto v347 = v345 + v346; - auto v348 = v347 * v347; - auto v349 = v348 * smt_terms::BVConst("2", &solver, 10); - auto v351 = v9 & smt_terms::BVConst("536870912", &solver, 10); - auto v352 = v351 ^ smt_terms::BVConst("1", &solver, 10); - auto v353 = v351; - auto v354 = v352; - auto v355 = v349 * v353; - auto v356 = v348 * v354; - auto v357 = v355 + v356; - auto v358 = v357 * v357; - auto v359 = v358 * smt_terms::BVConst("2", &solver, 10); - auto v361 = v9 & smt_terms::BVConst("268435456", &solver, 10); - auto v362 = v361 ^ smt_terms::BVConst("1", &solver, 10); - auto v363 = v361; - auto v364 = v362; - auto v365 = v359 * v363; - auto v366 = v358 * v364; - auto v367 = v365 + v366; - auto v368 = v367 * v367; - auto v369 = v368 * smt_terms::BVConst("2", &solver, 10); - auto v371 = v9 & smt_terms::BVConst("134217728", &solver, 10); - auto v372 = v371 ^ smt_terms::BVConst("1", &solver, 10); - auto v373 = v371; - auto v374 = v372; - auto v375 = v369 * v373; - auto v376 = v368 * v374; - auto v377 = v375 + v376; - auto v378 = v377 * v377; - auto v379 = v378 * smt_terms::BVConst("2", &solver, 10); - auto v381 = v9 & smt_terms::BVConst("67108864", &solver, 10); - auto v382 = v381 ^ smt_terms::BVConst("1", &solver, 10); - auto v383 = v381; - auto v384 = v382; - auto v385 = v379 * v383; - auto v386 = v378 * v384; - auto v387 = v385 + v386; - auto v388 = v387 * v387; - auto v389 = v388 * smt_terms::BVConst("2", &solver, 10); - auto v391 = v9 & smt_terms::BVConst("33554432", &solver, 10); - auto v392 = v391 ^ smt_terms::BVConst("1", &solver, 10); - auto v393 = v391; - auto v394 = v392; - auto v395 = v389 * v393; - auto v396 = v388 * v394; - auto v397 = v395 + v396; - auto v398 = v397 * v397; - auto v399 = v398 * smt_terms::BVConst("2", &solver, 10); - auto v401 = v9 & smt_terms::BVConst("16777216", &solver, 10); - auto v402 = v401 ^ smt_terms::BVConst("1", &solver, 10); - auto v403 = v401; - auto v404 = v402; - auto v405 = v399 * v403; - auto v406 = v398 * v404; - auto v407 = v405 + v406; - auto v408 = v407 * v407; - auto v409 = v408 * smt_terms::BVConst("2", &solver, 10); - auto v411 = v9 & smt_terms::BVConst("8388608", &solver, 10); - auto v412 = v411 ^ smt_terms::BVConst("1", &solver, 10); - auto v413 = v411; - auto v414 = v412; - auto v415 = v409 * v413; - auto v416 = v408 * v414; - auto v417 = v415 + v416; - auto v418 = v417 * v417; - auto v419 = v418 * smt_terms::BVConst("2", &solver, 10); - auto v421 = v9 & smt_terms::BVConst("4194304", &solver, 10); - auto v422 = v421 ^ smt_terms::BVConst("1", &solver, 10); - auto v423 = v421; - auto v424 = v422; - auto v425 = v419 * v423; - auto v426 = v418 * v424; - auto v427 = v425 + v426; - auto v428 = v427 * v427; - auto v429 = v428 * smt_terms::BVConst("2", &solver, 10); - auto v431 = v9 & smt_terms::BVConst("2097152", &solver, 10); - auto v432 = v431 ^ smt_terms::BVConst("1", &solver, 10); - auto v433 = v431; - auto v434 = v432; - auto v435 = v429 * v433; - auto v436 = v428 * v434; - auto v437 = v435 + v436; - auto v438 = v437 * v437; - auto v439 = v438 * smt_terms::BVConst("2", &solver, 10); - auto v441 = v9 & smt_terms::BVConst("1048576", &solver, 10); - auto v442 = v441 ^ smt_terms::BVConst("1", &solver, 10); - auto v443 = v441; - auto v444 = v442; - auto v445 = v439 * v443; - auto v446 = v438 * v444; - auto v447 = v445 + v446; - auto v448 = v447 * v447; - auto v449 = v448 * smt_terms::BVConst("2", &solver, 10); - auto v451 = v9 & smt_terms::BVConst("524288", &solver, 10); - auto v452 = v451 ^ smt_terms::BVConst("1", &solver, 10); - auto v453 = v451; - auto v454 = v452; - auto v455 = v449 * v453; - auto v456 = v448 * v454; - auto v457 = v455 + v456; - auto v458 = v457 * v457; - auto v459 = v458 * smt_terms::BVConst("2", &solver, 10); - auto v461 = v9 & smt_terms::BVConst("262144", &solver, 10); - auto v462 = v461 ^ smt_terms::BVConst("1", &solver, 10); - auto v463 = v461; - auto v464 = v462; - auto v465 = v459 * v463; - auto v466 = v458 * v464; - auto v467 = v465 + v466; - auto v468 = v467 * v467; - auto v469 = v468 * smt_terms::BVConst("2", &solver, 10); - auto v471 = v9 & smt_terms::BVConst("131072", &solver, 10); - auto v472 = v471 ^ smt_terms::BVConst("1", &solver, 10); - auto v473 = v471; - auto v474 = v472; - auto v475 = v469 * v473; - auto v476 = v468 * v474; - auto v477 = v475 + v476; - auto v478 = v477 * v477; - auto v479 = v478 * smt_terms::BVConst("2", &solver, 10); - auto v481 = v9 & smt_terms::BVConst("65536", &solver, 10); - auto v482 = v481 ^ smt_terms::BVConst("1", &solver, 10); - auto v483 = v481; - auto v484 = v482; - auto v485 = v479 * v483; - auto v486 = v478 * v484; - auto v487 = v485 + v486; - auto v488 = v487 * v487; - auto v489 = v488 * smt_terms::BVConst("2", &solver, 10); - auto v491 = v9 & smt_terms::BVConst("32768", &solver, 10); - auto v492 = v491 ^ smt_terms::BVConst("1", &solver, 10); - auto v493 = v491; - auto v494 = v492; - auto v495 = v489 * v493; - auto v496 = v488 * v494; - auto v497 = v495 + v496; - auto v498 = v497 * v497; - auto v499 = v498 * smt_terms::BVConst("2", &solver, 10); - auto v501 = v9 & smt_terms::BVConst("16384", &solver, 10); - auto v502 = v501 ^ smt_terms::BVConst("1", &solver, 10); - auto v503 = v501; - auto v504 = v502; - auto v505 = v499 * v503; - auto v506 = v498 * v504; - auto v507 = v505 + v506; - auto v508 = v507 * v507; - auto v509 = v508 * smt_terms::BVConst("2", &solver, 10); - auto v511 = v9 & smt_terms::BVConst("8192", &solver, 10); - auto v512 = v511 ^ smt_terms::BVConst("1", &solver, 10); - auto v513 = v511; - auto v514 = v512; - auto v515 = v509 * v513; - auto v516 = v508 * v514; - auto v517 = v515 + v516; - auto v518 = v517 * v517; - auto v519 = v518 * smt_terms::BVConst("2", &solver, 10); - auto v521 = v9 & smt_terms::BVConst("4096", &solver, 10); - auto v522 = v521 ^ smt_terms::BVConst("1", &solver, 10); - auto v523 = v521; - auto v524 = v522; - auto v525 = v519 * v523; - auto v526 = v518 * v524; - auto v527 = v525 + v526; - auto v528 = v527 * v527; - auto v529 = v528 * smt_terms::BVConst("2", &solver, 10); - auto v531 = v9 & smt_terms::BVConst("2048", &solver, 10); - auto v532 = v531 ^ smt_terms::BVConst("1", &solver, 10); - auto v533 = v531; - auto v534 = v532; - auto v535 = v529 * v533; - auto v536 = v528 * v534; - auto v537 = v535 + v536; - auto v538 = v537 * v537; - auto v539 = v538 * smt_terms::BVConst("2", &solver, 10); - auto v541 = v9 & smt_terms::BVConst("1024", &solver, 10); - auto v542 = v541 ^ smt_terms::BVConst("1", &solver, 10); - auto v543 = v541; - auto v544 = v542; - auto v545 = v539 * v543; - auto v546 = v538 * v544; - auto v547 = v545 + v546; - auto v548 = v547 * v547; - auto v549 = v548 * smt_terms::BVConst("2", &solver, 10); - auto v551 = v9 & smt_terms::BVConst("512", &solver, 10); - auto v552 = v551 ^ smt_terms::BVConst("1", &solver, 10); - auto v553 = v551; - auto v554 = v552; - auto v555 = v549 * v553; - auto v556 = v548 * v554; - auto v557 = v555 + v556; - auto v558 = v557 * v557; - auto v559 = v558 * smt_terms::BVConst("2", &solver, 10); - auto v561 = v9 & smt_terms::BVConst("256", &solver, 10); - auto v562 = v561 ^ smt_terms::BVConst("1", &solver, 10); - auto v563 = v561; - auto v564 = v562; - auto v565 = v559 * v563; - auto v566 = v558 * v564; - auto v567 = v565 + v566; - auto v568 = v567 * v567; - auto v569 = v568 * smt_terms::BVConst("2", &solver, 10); - auto v571 = v9 & smt_terms::BVConst("128", &solver, 10); - auto v572 = v571 ^ smt_terms::BVConst("1", &solver, 10); - auto v573 = v571; - auto v574 = v572; - auto v575 = v569 * v573; - auto v576 = v568 * v574; - auto v577 = v575 + v576; - auto v578 = v577 * v577; - auto v579 = v578 * smt_terms::BVConst("2", &solver, 10); - auto v581 = v9 & smt_terms::BVConst("64", &solver, 10); - auto v582 = v581 ^ smt_terms::BVConst("1", &solver, 10); - auto v583 = v581; - auto v584 = v582; - auto v585 = v579 * v583; - auto v586 = v578 * v584; - auto v587 = v585 + v586; - auto v588 = v587 * v587; - auto v589 = v588 * smt_terms::BVConst("2", &solver, 10); - auto v591 = v9 & smt_terms::BVConst("32", &solver, 10); - auto v592 = v591 ^ smt_terms::BVConst("1", &solver, 10); - auto v593 = v591; - auto v594 = v592; - auto v595 = v589 * v593; - auto v596 = v588 * v594; - auto v597 = v595 + v596; - auto v598 = v597 * v597; - auto v599 = v598 * smt_terms::BVConst("2", &solver, 10); - auto v601 = v9 & smt_terms::BVConst("16", &solver, 10); - auto v602 = v601 ^ smt_terms::BVConst("1", &solver, 10); - auto v603 = v601; - auto v604 = v602; - auto v605 = v599 * v603; - auto v606 = v598 * v604; - auto v607 = v605 + v606; - auto v608 = v607 * v607; - auto v609 = v608 * smt_terms::BVConst("2", &solver, 10); - auto v611 = v9 & smt_terms::BVConst("8", &solver, 10); - auto v612 = v611 ^ smt_terms::BVConst("1", &solver, 10); - auto v613 = v611; - auto v614 = v612; - auto v615 = v609 * v613; - auto v616 = v608 * v614; - auto v617 = v615 + v616; - auto v618 = v617 * v617; - auto v619 = v618 * smt_terms::BVConst("2", &solver, 10); - auto v620 = v9 & smt_terms::BVConst("4", &solver, 10); - auto v621 = v620 ^ smt_terms::BVConst("1", &solver, 10); - auto v622 = v620; - auto v623 = v621; - auto v624 = v619 * v622; - auto v625 = v618 * v623; - auto v626 = v624 + v625; - auto v627 = v626 * v626; - auto v628 = v627 * smt_terms::BVConst("2", &solver, 10); - auto v629 = v9 & smt_terms::BVConst("2", &solver, 10); - auto v630 = v629 ^ smt_terms::BVConst("1", &solver, 10); - auto v631 = v629; - auto v632 = v630; - auto v633 = v628 * v631; - auto v634 = v627 * v632; - auto v635 = v633 + v634; - auto v636 = v635 * v635; - auto v637 = v636 * smt_terms::BVConst("2", &solver, 10); - auto v639 = v9 & smt_terms::BVConst("1", &solver, 10); - auto v640 = v639 ^ smt_terms::BVConst("1", &solver, 10); - auto v641 = v639; - auto v642 = v640; - auto v643 = v637 * v641; - auto v644 = v636 * v642; - auto v645 = v643 + v644; - auto v646 = v645; - auto v647 = v6 * v646; - auto v648 = v0; - auto v649 = v647; - auto v650 = v648 * v649; - auto v651 = v650 & smt_terms::BVConst("18446744073709551615", &solver, 10); - auto v652 = v651; - auto cr = v652; \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shr.ssa b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shr.ssa deleted file mode 100644 index b2d1ac6ec5f..00000000000 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/shift_codegen/shr.ssa +++ /dev/null @@ -1,588 +0,0 @@ -acir(inline) fn main f0 { - b0(v0: u64, v1: u8): - v5 = lt v1, u8 64 - v6 = cast v5 as u64 - v7 = cast v1 as u64 - v9 = call to_le_bits(v7) -> [u1; 64] - v12 = array_get v9, index Field 63 -> u1 - v13 = not v12 - v14 = cast v12 as Field - v15 = cast v13 as Field - v16 = mul Field 2, v14 - v17 = add v16, v15 - v18 = mul v17, v17 - v19 = mul v18, Field 2 - v21 = array_get v9, index Field 62 -> u1 - v22 = not v21 - v23 = cast v21 as Field - v24 = cast v22 as Field - v25 = mul v19, v23 - v26 = mul v18, v24 - v27 = add v25, v26 - v28 = mul v27, v27 - v29 = mul v28, Field 2 - v31 = array_get v9, index Field 61 -> u1 - v32 = not v31 - v33 = cast v31 as Field - v34 = cast v32 as Field - v35 = mul v29, v33 - v36 = mul v28, v34 - v37 = add v35, v36 - v38 = mul v37, v37 - v39 = mul v38, Field 2 - v41 = array_get v9, index Field 60 -> u1 - v42 = not v41 - v43 = cast v41 as Field - v44 = cast v42 as Field - v45 = mul v39, v43 - v46 = mul v38, v44 - v47 = add v45, v46 - v48 = mul v47, v47 - v49 = mul v48, Field 2 - v51 = array_get v9, index Field 59 -> u1 - v52 = not v51 - v53 = cast v51 as Field - v54 = cast v52 as Field - v55 = mul v49, v53 - v56 = mul v48, v54 - v57 = add v55, v56 - v58 = mul v57, v57 - v59 = mul v58, Field 2 - v61 = array_get v9, index Field 58 -> u1 - v62 = not v61 - v63 = cast v61 as Field - v64 = cast v62 as Field - v65 = mul v59, v63 - v66 = mul v58, v64 - v67 = add v65, v66 - v68 = mul v67, v67 - v69 = mul v68, Field 2 - v71 = array_get v9, index Field 57 -> u1 - v72 = not v71 - v73 = cast v71 as Field - v74 = cast v72 as Field - v75 = mul v69, v73 - v76 = mul v68, v74 - v77 = add v75, v76 - v78 = mul v77, v77 - v79 = mul v78, Field 2 - v81 = array_get v9, index Field 56 -> u1 - v82 = not v81 - v83 = cast v81 as Field - v84 = cast v82 as Field - v85 = mul v79, v83 - v86 = mul v78, v84 - v87 = add v85, v86 - v88 = mul v87, v87 - v89 = mul v88, Field 2 - v91 = array_get v9, index Field 55 -> u1 - v92 = not v91 - v93 = cast v91 as Field - v94 = cast v92 as Field - v95 = mul v89, v93 - v96 = mul v88, v94 - v97 = add v95, v96 - v98 = mul v97, v97 - v99 = mul v98, Field 2 - v101 = array_get v9, index Field 54 -> u1 - v102 = not v101 - v103 = cast v101 as Field - v104 = cast v102 as Field - v105 = mul v99, v103 - v106 = mul v98, v104 - v107 = add v105, v106 - v108 = mul v107, v107 - v109 = mul v108, Field 2 - v111 = array_get v9, index Field 53 -> u1 - v112 = not v111 - v113 = cast v111 as Field - v114 = cast v112 as Field - v115 = mul v109, v113 - v116 = mul v108, v114 - v117 = add v115, v116 - v118 = mul v117, v117 - v119 = mul v118, Field 2 - v121 = array_get v9, index Field 52 -> u1 - v122 = not v121 - v123 = cast v121 as Field - v124 = cast v122 as Field - v125 = mul v119, v123 - v126 = mul v118, v124 - v127 = add v125, v126 - v128 = mul v127, v127 - v129 = mul v128, Field 2 - v131 = array_get v9, index Field 51 -> u1 - v132 = not v131 - v133 = cast v131 as Field - v134 = cast v132 as Field - v135 = mul v129, v133 - v136 = mul v128, v134 - v137 = add v135, v136 - v138 = mul v137, v137 - v139 = mul v138, Field 2 - v141 = array_get v9, index Field 50 -> u1 - v142 = not v141 - v143 = cast v141 as Field - v144 = cast v142 as Field - v145 = mul v139, v143 - v146 = mul v138, v144 - v147 = add v145, v146 - v148 = mul v147, v147 - v149 = mul v148, Field 2 - v151 = array_get v9, index Field 49 -> u1 - v152 = not v151 - v153 = cast v151 as Field - v154 = cast v152 as Field - v155 = mul v149, v153 - v156 = mul v148, v154 - v157 = add v155, v156 - v158 = mul v157, v157 - v159 = mul v158, Field 2 - v161 = array_get v9, index Field 48 -> u1 - v162 = not v161 - v163 = cast v161 as Field - v164 = cast v162 as Field - v165 = mul v159, v163 - v166 = mul v158, v164 - v167 = add v165, v166 - v168 = mul v167, v167 - v169 = mul v168, Field 2 - v171 = array_get v9, index Field 47 -> u1 - v172 = not v171 - v173 = cast v171 as Field - v174 = cast v172 as Field - v175 = mul v169, v173 - v176 = mul v168, v174 - v177 = add v175, v176 - v178 = mul v177, v177 - v179 = mul v178, Field 2 - v181 = array_get v9, index Field 46 -> u1 - v182 = not v181 - v183 = cast v181 as Field - v184 = cast v182 as Field - v185 = mul v179, v183 - v186 = mul v178, v184 - v187 = add v185, v186 - v188 = mul v187, v187 - v189 = mul v188, Field 2 - v191 = array_get v9, index Field 45 -> u1 - v192 = not v191 - v193 = cast v191 as Field - v194 = cast v192 as Field - v195 = mul v189, v193 - v196 = mul v188, v194 - v197 = add v195, v196 - v198 = mul v197, v197 - v199 = mul v198, Field 2 - v201 = array_get v9, index Field 44 -> u1 - v202 = not v201 - v203 = cast v201 as Field - v204 = cast v202 as Field - v205 = mul v199, v203 - v206 = mul v198, v204 - v207 = add v205, v206 - v208 = mul v207, v207 - v209 = mul v208, Field 2 - v211 = array_get v9, index Field 43 -> u1 - v212 = not v211 - v213 = cast v211 as Field - v214 = cast v212 as Field - v215 = mul v209, v213 - v216 = mul v208, v214 - v217 = add v215, v216 - v218 = mul v217, v217 - v219 = mul v218, Field 2 - v221 = array_get v9, index Field 42 -> u1 - v222 = not v221 - v223 = cast v221 as Field - v224 = cast v222 as Field - v225 = mul v219, v223 - v226 = mul v218, v224 - v227 = add v225, v226 - v228 = mul v227, v227 - v229 = mul v228, Field 2 - v231 = array_get v9, index Field 41 -> u1 - v232 = not v231 - v233 = cast v231 as Field - v234 = cast v232 as Field - v235 = mul v229, v233 - v236 = mul v228, v234 - v237 = add v235, v236 - v238 = mul v237, v237 - v239 = mul v238, Field 2 - v241 = array_get v9, index Field 40 -> u1 - v242 = not v241 - v243 = cast v241 as Field - v244 = cast v242 as Field - v245 = mul v239, v243 - v246 = mul v238, v244 - v247 = add v245, v246 - v248 = mul v247, v247 - v249 = mul v248, Field 2 - v251 = array_get v9, index Field 39 -> u1 - v252 = not v251 - v253 = cast v251 as Field - v254 = cast v252 as Field - v255 = mul v249, v253 - v256 = mul v248, v254 - v257 = add v255, v256 - v258 = mul v257, v257 - v259 = mul v258, Field 2 - v261 = array_get v9, index Field 38 -> u1 - v262 = not v261 - v263 = cast v261 as Field - v264 = cast v262 as Field - v265 = mul v259, v263 - v266 = mul v258, v264 - v267 = add v265, v266 - v268 = mul v267, v267 - v269 = mul v268, Field 2 - v271 = array_get v9, index Field 37 -> u1 - v272 = not v271 - v273 = cast v271 as Field - v274 = cast v272 as Field - v275 = mul v269, v273 - v276 = mul v268, v274 - v277 = add v275, v276 - v278 = mul v277, v277 - v279 = mul v278, Field 2 - v281 = array_get v9, index Field 36 -> u1 - v282 = not v281 - v283 = cast v281 as Field - v284 = cast v282 as Field - v285 = mul v279, v283 - v286 = mul v278, v284 - v287 = add v285, v286 - v288 = mul v287, v287 - v289 = mul v288, Field 2 - v291 = array_get v9, index Field 35 -> u1 - v292 = not v291 - v293 = cast v291 as Field - v294 = cast v292 as Field - v295 = mul v289, v293 - v296 = mul v288, v294 - v297 = add v295, v296 - v298 = mul v297, v297 - v299 = mul v298, Field 2 - v301 = array_get v9, index Field 34 -> u1 - v302 = not v301 - v303 = cast v301 as Field - v304 = cast v302 as Field - v305 = mul v299, v303 - v306 = mul v298, v304 - v307 = add v305, v306 - v308 = mul v307, v307 - v309 = mul v308, Field 2 - v311 = array_get v9, index Field 33 -> u1 - v312 = not v311 - v313 = cast v311 as Field - v314 = cast v312 as Field - v315 = mul v309, v313 - v316 = mul v308, v314 - v317 = add v315, v316 - v318 = mul v317, v317 - v319 = mul v318, Field 2 - v321 = array_get v9, index Field 32 -> u1 - v322 = not v321 - v323 = cast v321 as Field - v324 = cast v322 as Field - v325 = mul v319, v323 - v326 = mul v318, v324 - v327 = add v325, v326 - v328 = mul v327, v327 - v329 = mul v328, Field 2 - v331 = array_get v9, index Field 31 -> u1 - v332 = not v331 - v333 = cast v331 as Field - v334 = cast v332 as Field - v335 = mul v329, v333 - v336 = mul v328, v334 - v337 = add v335, v336 - v338 = mul v337, v337 - v339 = mul v338, Field 2 - v341 = array_get v9, index Field 30 -> u1 - v342 = not v341 - v343 = cast v341 as Field - v344 = cast v342 as Field - v345 = mul v339, v343 - v346 = mul v338, v344 - v347 = add v345, v346 - v348 = mul v347, v347 - v349 = mul v348, Field 2 - v351 = array_get v9, index Field 29 -> u1 - v352 = not v351 - v353 = cast v351 as Field - v354 = cast v352 as Field - v355 = mul v349, v353 - v356 = mul v348, v354 - v357 = add v355, v356 - v358 = mul v357, v357 - v359 = mul v358, Field 2 - v361 = array_get v9, index Field 28 -> u1 - v362 = not v361 - v363 = cast v361 as Field - v364 = cast v362 as Field - v365 = mul v359, v363 - v366 = mul v358, v364 - v367 = add v365, v366 - v368 = mul v367, v367 - v369 = mul v368, Field 2 - v371 = array_get v9, index Field 27 -> u1 - v372 = not v371 - v373 = cast v371 as Field - v374 = cast v372 as Field - v375 = mul v369, v373 - v376 = mul v368, v374 - v377 = add v375, v376 - v378 = mul v377, v377 - v379 = mul v378, Field 2 - v381 = array_get v9, index Field 26 -> u1 - v382 = not v381 - v383 = cast v381 as Field - v384 = cast v382 as Field - v385 = mul v379, v383 - v386 = mul v378, v384 - v387 = add v385, v386 - v388 = mul v387, v387 - v389 = mul v388, Field 2 - v391 = array_get v9, index Field 25 -> u1 - v392 = not v391 - v393 = cast v391 as Field - v394 = cast v392 as Field - v395 = mul v389, v393 - v396 = mul v388, v394 - v397 = add v395, v396 - v398 = mul v397, v397 - v399 = mul v398, Field 2 - v401 = array_get v9, index Field 24 -> u1 - v402 = not v401 - v403 = cast v401 as Field - v404 = cast v402 as Field - v405 = mul v399, v403 - v406 = mul v398, v404 - v407 = add v405, v406 - v408 = mul v407, v407 - v409 = mul v408, Field 2 - v411 = array_get v9, index Field 23 -> u1 - v412 = not v411 - v413 = cast v411 as Field - v414 = cast v412 as Field - v415 = mul v409, v413 - v416 = mul v408, v414 - v417 = add v415, v416 - v418 = mul v417, v417 - v419 = mul v418, Field 2 - v421 = array_get v9, index Field 22 -> u1 - v422 = not v421 - v423 = cast v421 as Field - v424 = cast v422 as Field - v425 = mul v419, v423 - v426 = mul v418, v424 - v427 = add v425, v426 - v428 = mul v427, v427 - v429 = mul v428, Field 2 - v431 = array_get v9, index Field 21 -> u1 - v432 = not v431 - v433 = cast v431 as Field - v434 = cast v432 as Field - v435 = mul v429, v433 - v436 = mul v428, v434 - v437 = add v435, v436 - v438 = mul v437, v437 - v439 = mul v438, Field 2 - v441 = array_get v9, index Field 20 -> u1 - v442 = not v441 - v443 = cast v441 as Field - v444 = cast v442 as Field - v445 = mul v439, v443 - v446 = mul v438, v444 - v447 = add v445, v446 - v448 = mul v447, v447 - v449 = mul v448, Field 2 - v451 = array_get v9, index Field 19 -> u1 - v452 = not v451 - v453 = cast v451 as Field - v454 = cast v452 as Field - v455 = mul v449, v453 - v456 = mul v448, v454 - v457 = add v455, v456 - v458 = mul v457, v457 - v459 = mul v458, Field 2 - v461 = array_get v9, index Field 18 -> u1 - v462 = not v461 - v463 = cast v461 as Field - v464 = cast v462 as Field - v465 = mul v459, v463 - v466 = mul v458, v464 - v467 = add v465, v466 - v468 = mul v467, v467 - v469 = mul v468, Field 2 - v471 = array_get v9, index Field 17 -> u1 - v472 = not v471 - v473 = cast v471 as Field - v474 = cast v472 as Field - v475 = mul v469, v473 - v476 = mul v468, v474 - v477 = add v475, v476 - v478 = mul v477, v477 - v479 = mul v478, Field 2 - v481 = array_get v9, index Field 16 -> u1 - v482 = not v481 - v483 = cast v481 as Field - v484 = cast v482 as Field - v485 = mul v479, v483 - v486 = mul v478, v484 - v487 = add v485, v486 - v488 = mul v487, v487 - v489 = mul v488, Field 2 - v491 = array_get v9, index Field 15 -> u1 - v492 = not v491 - v493 = cast v491 as Field - v494 = cast v492 as Field - v495 = mul v489, v493 - v496 = mul v488, v494 - v497 = add v495, v496 - v498 = mul v497, v497 - v499 = mul v498, Field 2 - v501 = array_get v9, index Field 14 -> u1 - v502 = not v501 - v503 = cast v501 as Field - v504 = cast v502 as Field - v505 = mul v499, v503 - v506 = mul v498, v504 - v507 = add v505, v506 - v508 = mul v507, v507 - v509 = mul v508, Field 2 - v511 = array_get v9, index Field 13 -> u1 - v512 = not v511 - v513 = cast v511 as Field - v514 = cast v512 as Field - v515 = mul v509, v513 - v516 = mul v508, v514 - v517 = add v515, v516 - v518 = mul v517, v517 - v519 = mul v518, Field 2 - v521 = array_get v9, index Field 12 -> u1 - v522 = not v521 - v523 = cast v521 as Field - v524 = cast v522 as Field - v525 = mul v519, v523 - v526 = mul v518, v524 - v527 = add v525, v526 - v528 = mul v527, v527 - v529 = mul v528, Field 2 - v531 = array_get v9, index Field 11 -> u1 - v532 = not v531 - v533 = cast v531 as Field - v534 = cast v532 as Field - v535 = mul v529, v533 - v536 = mul v528, v534 - v537 = add v535, v536 - v538 = mul v537, v537 - v539 = mul v538, Field 2 - v541 = array_get v9, index Field 10 -> u1 - v542 = not v541 - v543 = cast v541 as Field - v544 = cast v542 as Field - v545 = mul v539, v543 - v546 = mul v538, v544 - v547 = add v545, v546 - v548 = mul v547, v547 - v549 = mul v548, Field 2 - v551 = array_get v9, index Field 9 -> u1 - v552 = not v551 - v553 = cast v551 as Field - v554 = cast v552 as Field - v555 = mul v549, v553 - v556 = mul v548, v554 - v557 = add v555, v556 - v558 = mul v557, v557 - v559 = mul v558, Field 2 - v561 = array_get v9, index Field 8 -> u1 - v562 = not v561 - v563 = cast v561 as Field - v564 = cast v562 as Field - v565 = mul v559, v563 - v566 = mul v558, v564 - v567 = add v565, v566 - v568 = mul v567, v567 - v569 = mul v568, Field 2 - v571 = array_get v9, index Field 7 -> u1 - v572 = not v571 - v573 = cast v571 as Field - v574 = cast v572 as Field - v575 = mul v569, v573 - v576 = mul v568, v574 - v577 = add v575, v576 - v578 = mul v577, v577 - v579 = mul v578, Field 2 - v581 = array_get v9, index Field 6 -> u1 - v582 = not v581 - v583 = cast v581 as Field - v584 = cast v582 as Field - v585 = mul v579, v583 - v586 = mul v578, v584 - v587 = add v585, v586 - v588 = mul v587, v587 - v589 = mul v588, Field 2 - v591 = array_get v9, index Field 5 -> u1 - v592 = not v591 - v593 = cast v591 as Field - v594 = cast v592 as Field - v595 = mul v589, v593 - v596 = mul v588, v594 - v597 = add v595, v596 - v598 = mul v597, v597 - v599 = mul v598, Field 2 - v601 = array_get v9, index Field 4 -> u1 - v602 = not v601 - v603 = cast v601 as Field - v604 = cast v602 as Field - v605 = mul v599, v603 - v606 = mul v598, v604 - v607 = add v605, v606 - v608 = mul v607, v607 - v609 = mul v608, Field 2 - v611 = array_get v9, index Field 3 -> u1 - v612 = not v611 - v613 = cast v611 as Field - v614 = cast v612 as Field - v615 = mul v609, v613 - v616 = mul v608, v614 - v617 = add v615, v616 - v618 = mul v617, v617 - v619 = mul v618, Field 2 - v620 = array_get v9, index Field 2 -> u1 - v621 = not v620 - v622 = cast v620 as Field - v623 = cast v621 as Field - v624 = mul v619, v622 - v625 = mul v618, v623 - v626 = add v624, v625 - v627 = mul v626, v626 - v628 = mul v627, Field 2 - v629 = array_get v9, index Field 1 -> u1 - v630 = not v629 - v631 = cast v629 as Field - v632 = cast v630 as Field - v633 = mul v628, v631 - v634 = mul v627, v632 - v635 = add v633, v634 - v636 = mul v635, v635 - v637 = mul v636, Field 2 - v639 = array_get v9, index Field 0 -> u1 - v640 = not v639 - v641 = cast v639 as Field - v642 = cast v640 as Field - v643 = mul v637, v641 - v644 = mul v636, v642 - v645 = add v643, v644 - v646 = cast v645 as u64 - v647 = mul v6, v646 - v648 = cast v0 as Field - v649 = cast v647 as Field - v650 = mul v648, v649 - v651 = truncate v650 to 64 bits, max_bit_size: 254 - v652 = cast v651 as u64 - return v652 -} \ No newline at end of file diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs index 7c290b52df4..94012b684e0 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs @@ -153,7 +153,7 @@ impl InstructionArtifacts { } pub fn new_shr(first_variable: &Variable, second_variable: &Variable) -> Self { - return Self::new_binary(BinaryOp::Shl, "Binary::Shl".into(), first_variable, second_variable); + return Self::new_binary(BinaryOp::Shr, "Binary::Shr".into(), first_variable, second_variable); } } From 2cf19f08c63eb32a208d533c34f50666baf34cdc Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Thu, 12 Dec 2024 15:36:53 +0000 Subject: [PATCH 21/32] bug in acir builder --- barretenberg/cpp/src/CMakeLists.txt | 6 +++--- .../noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/barretenberg/cpp/src/CMakeLists.txt b/barretenberg/cpp/src/CMakeLists.txt index 7f2265e1f8f..7228ca38950 100644 --- a/barretenberg/cpp/src/CMakeLists.txt +++ b/barretenberg/cpp/src/CMakeLists.txt @@ -98,9 +98,9 @@ add_subdirectory(barretenberg/wasi) add_subdirectory(barretenberg/world_state) add_subdirectory(barretenberg/acir_formal_proofs) -if(SMT) - add_subdirectory(barretenberg/smt_verification) -endif() + +add_subdirectory(barretenberg/smt_verification) + add_subdirectory(barretenberg/benchmark) diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs index b6e74865391..da9352298e8 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs @@ -35,7 +35,7 @@ fn save_artifacts(all_artifacts: Vec) { fn main() { let mut all_artifacts: Vec = Vec::new(); - let u64_var = Variable{ variable_type: VariableType::Unsigned, variable_size: 64}; + let u64_var = Variable{ variable_type: VariableType::Unsigned, variable_size: 32}; let u8_var = Variable{ variable_type: VariableType::Unsigned, variable_size: 8}; all_artifacts.push(InstructionArtifacts::new_add(&u64_var, &u64_var)); all_artifacts.push(InstructionArtifacts::new_sub(&u64_var, &u64_var)); From 10b361f2f99f31ad47ee55f1861959acff3343f5 Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Mon, 16 Dec 2024 12:42:46 +0000 Subject: [PATCH 22/32] recaftor --- .../acir_formal_proofs/acir_loader.test.cpp | 218 ++++-------------- .../acir_formal_proofs/formal_proofs.hpp | 214 +++++++++++++++++ .../acir_formal_proofs/helpers.cpp | 1 - 3 files changed, 254 insertions(+), 179 deletions(-) create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.hpp diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp index 2df8b080bb0..d6d3e39755c 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp @@ -7,6 +7,7 @@ #include "barretenberg/smt_verification/util/smt_util.hpp" #include "barretenberg/stdlib/client_ivc_verifier/client_ivc_recursive_verifier.hpp" #include "barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp" +#include "formal_proofs.hpp" #include "helpers.hpp" #include @@ -41,14 +42,7 @@ TEST(acir_formal_proofs, uint_terms_add) AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Add.acir"); smt_solver::Solver solver = loader.get_smt_solver(); smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - auto cr = a + b; - c != cr; - bool res = solver.check(); - solver.print_assertions(); - info(solver.getResult()); + bool res = verify_add(&solver, circuit); EXPECT_FALSE(res); if (res) { @@ -61,14 +55,7 @@ TEST(acir_formal_proofs, uint_terms_mul) AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Mul.acir"); smt_solver::Solver solver = loader.get_smt_solver(); smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - auto cr = a * b; - c != cr; - bool res = solver.check(); - solver.print_assertions(); - info(solver.getResult()); + bool res = verify_mul(&solver, circuit); EXPECT_FALSE(res); if (res) { save_buggy_witness("Binary::Mul", circuit); @@ -80,100 +67,47 @@ TEST(acir_formal_proofs, uint_terms_and) AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::And.acir"); smt_solver::Solver solver = loader.get_smt_solver(); smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - auto cr = a & b; - c != cr; - bool res = solver.check(); - solver.print_assertions(); - info(solver.getResult()); + bool res = verify_and(&solver, circuit); EXPECT_FALSE(res); if (res) { save_buggy_witness("Binary::And", circuit); - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); - std::unordered_map vals = solver.model(terms); - info("a = ", vals["a"]); - info("b = ", vals["b"]); - info("c = ", vals["c"]); - info("c_res = ", vals["cr"]); } } TEST(acir_formal_proofs, uint_terms_div) { - AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Div.acir"); + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Div.acir"); smt_solver::Solver solver = loader.get_smt_solver(); smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - auto cr = a / b; - c == cr; - bool res = solver.check(); - solver.print_assertions(); - info(solver.getResult()); + bool res = verify_div(&solver, circuit); EXPECT_FALSE(res); if (res) { save_buggy_witness("Binary::Div", circuit); - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); - std::unordered_map vals = solver.model(terms); - info("a = ", vals["a"]); - info("b = ", vals["b"]); - info("c = ", vals["c"]); - info("c_res = ", vals["cr"]); } } // checks to times // if a == b c must be 0 // if a != b must be 1 -TEST(acir_formal_proofs, uint_terms_eq_on_equality) +TEST(acir_formal_proofs, uint_terms_eq) { - AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Eq.acir"); - smt_solver::Solver solver = loader.get_smt_solver(); - smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - a == b; - c != 1; - bool res = solver.check(); - solver.print_assertions(); - info(solver.getResult()); - EXPECT_FALSE(res); - if (res) { - save_buggy_witness("Binary::Eq", circuit); - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c } }); - std::unordered_map vals = solver.model(terms); - info("a = ", vals["a"]); - info("b = ", vals["b"]); - info("c = ", vals["c"]); + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Eq.acir"); + smt_solver::Solver solver1 = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit1 = loader.get_smt_circuit(&solver1); + + bool res1 = verify_eq_on_equlaity(&solver1, circuit1); + EXPECT_FALSE(res1); + if (res1) { + save_buggy_witness("Binary::Eq", circuit1); } -} -TEST(acir_formal_proofs, uint_terms_eq_on_inequality) -{ - AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Eq.acir"); - smt_solver::Solver solver = loader.get_smt_solver(); - smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - a != b; - c != 0; - bool res = solver.check(); - solver.print_assertions(); + smt_solver::Solver solver2 = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit2 = loader.get_smt_circuit(&solver2); - info(solver.getResult()); - EXPECT_FALSE(res); - if (res) { - save_buggy_witness("Binary::Eq", circuit); - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c } }); - std::unordered_map vals = solver.model(terms); - info("a = ", vals["a"]); - info("b = ", vals["b"]); - info("c = ", vals["c"]); + bool res2 = verify_eq_on_inequlaity(&solver2, circuit2); + EXPECT_FALSE(res2); + if (res2) { + save_buggy_witness("Binary::Eq", circuit2); } } @@ -215,20 +149,8 @@ TEST(acir_formal_proofs, uint_terms_mod) AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Mod.acir"); smt_solver::Solver solver = loader.get_smt_solver(); smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); - // c = a mod b - // k * b + c = a - // k = (a - c) / b - // (a - c) * b + c * b == a * b - smt_circuit::STerm a = circuit["a"]; - smt_circuit::STerm b = circuit["b"]; - smt_circuit::STerm c = circuit["c"]; - smt_circuit::STerm c1 = (a - c) * b + c * b; - smt_circuit::STerm c2 = a * b; - - c1 != c2; - bool res = solver.check(); + bool res = verify_mod(&solver, circuit); solver.print_assertions(); - info(solver.getResult()); EXPECT_FALSE(res); if (res) { save_buggy_witness("Binary::Mod", circuit); @@ -240,54 +162,31 @@ TEST(acir_formal_proofs, uint_terms_or) AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Or.acir"); smt_solver::Solver solver = loader.get_smt_solver(); smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - auto cr = a | b; - c != cr; - bool res = solver.check(); - solver.print_assertions(); - info(solver.getResult()); + bool res = verify_or(&solver, circuit); EXPECT_FALSE(res); if (res) { save_buggy_witness("Binary::Or", circuit); - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); - std::unordered_map vals = solver.model(terms); - info("a = ", vals["a"]); - info("b = ", vals["b"]); - info("c = ", vals["c"]); - info("c_res = ", vals["cr"]); } } -TEST(acir_formal_proofs, uint_terms_shl64) +/*TEST(acir_formal_proofs, uint_terms_shl64) { - AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Shl.acir"); + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Shl.acir"); smt_solver::Solver solver = loader.get_smt_solver(); smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); - auto a = smt_circuit::BVVar("a", &solver); - auto b = smt_circuit::BVVar("b", &solver); - auto c = smt_circuit::BVVar("c", &solver); - auto cr = shl64(a, b, &solver); - c != cr; - bool res = solver.check(); + bool res = verify_shl32(&solver, circuit); if (res) { save_buggy_witness("Binary::Shl", circuit); } EXPECT_FALSE(res); -} +}*/ TEST(acir_formal_proofs, uint_terms_shl32) { - AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Shl.acir"); + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Shl.acir"); smt_solver::Solver solver = loader.get_smt_solver(); smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); - auto a = smt_circuit::BVVar("a", &solver); - auto b = smt_circuit::BVVar("b", &solver); - auto c = smt_circuit::BVVar("c", &solver); - auto cr = shl32(a, b, &solver); - c != cr; - bool res = solver.check(); + bool res = verify_shl32(&solver, circuit); if (res) { save_buggy_witness("Binary::Shl", circuit); } @@ -296,23 +195,12 @@ TEST(acir_formal_proofs, uint_terms_shl32) TEST(acir_formal_proofs, uint_terms_shr) { - AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Shr.acir"); + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Shr.acir"); smt_solver::Solver solver = loader.get_smt_solver(); smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - auto cr = shr(a, b, &solver); - c != cr; - bool res = solver.check(); + bool res = verify_shr(&solver, circuit); if (res) { - save_buggy_witness("Binary::Shr", circuit); - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); - std::unordered_map vals = solver.model(terms); - info("a = ", vals["a"]); - info("b = ", vals["b"]); - info("c = ", vals["c"]); - info("c_res = ", vals["cr"]); + save_buggy_witness("Binary::Shl", circuit); } EXPECT_FALSE(res); } @@ -322,14 +210,7 @@ TEST(acir_formal_proofs, uint_terms_sub) AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Sub.acir"); smt_solver::Solver solver = loader.get_smt_solver(); smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - auto cr = a - b; - c != cr; - bool res = solver.check(); - solver.print_assertions(); - info(solver.getResult()); + bool res = verify_sub(&solver, circuit); EXPECT_FALSE(res); if (res) { save_buggy_witness("Binary::Sub", circuit); @@ -341,23 +222,10 @@ TEST(acir_formal_proofs, uint_terms_xor) AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Xor.acir"); smt_solver::Solver solver = loader.get_smt_solver(); smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - auto cr = a ^ b; - c != cr; - bool res = solver.check(); - solver.print_assertions(); - info(solver.getResult()); + bool res = verify_xor(&solver, circuit); EXPECT_FALSE(res); if (res) { save_buggy_witness("Binary::Xor", circuit); - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); - std::unordered_map vals = solver.model(terms); - info("a = ", vals["a"]); - info("b = ", vals["b"]); - info("c = ", vals["c"]); - info("c_res = ", vals["cr"]); } } @@ -368,21 +236,10 @@ TEST(acir_formal_proofs, uint_terms_not) smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); auto a = circuit["a"]; auto b = circuit["b"]; - // 2**64 - 1 - auto mask = smt_terms::BVConst("18446744073709551615", &solver, 10); - auto br = a ^ mask; - br != b; - bool res = solver.check(); - solver.print_assertions(); - info(solver.getResult()); + bool res = verify_not_64(&solver, circuit); EXPECT_FALSE(res); if (res) { save_buggy_witness("Binary::Not", circuit); - std::unordered_map terms({ { "a", a }, { "b", b }, { "br", br } }); - std::unordered_map vals = solver.model(terms); - info("a = ", vals["a"]); - info("b = ", vals["b"]); - info("br = ", vals["br"]); } } @@ -400,6 +257,11 @@ TEST(acir_formal_proofs, uint_terms_shr_verify_bug) EXPECT_TRUE(verify_buggy_witness("Binary::Shr")); } +TEST(acir_formal_proofs, uint_terms_shl_verify_bug) +{ + EXPECT_TRUE(verify_buggy_witness("Binary::Shl")); +} + /*TEST(acir_circuit_check, uint_terms_add) { AcirToSmtLoader loader = diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.hpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.hpp new file mode 100644 index 00000000000..4f98b5df9e3 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.hpp @@ -0,0 +1,214 @@ +#include "barretenberg/smt_verification/circuit/ultra_circuit.hpp" +#include "barretenberg/smt_verification/solver/solver.hpp" +#include "barretenberg/smt_verification/util/smt_util.hpp" +#include "helpers.hpp" + +void debug_solution(smt_solver::Solver* solver, std::unordered_map terms) +{ + solver->print_assertions(); + std::unordered_map vals = solver->model(terms); + for (auto const& i : vals) { + info(i.first, " = ", i.second); + } +} + +bool verify_add(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a + b; + c != cr; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_sub(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a - b; + c != cr; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_mul(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a * b; + c != cr; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_div(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a / b; + c != cr; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_mod(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + // c = a mod b + // k * b + c = a + // k = (a - c) / b + // (a - c) * b + c * b == a * b + smt_circuit::STerm c1 = (a - c) * b + c * b; + smt_circuit::STerm c2 = a * b; + c1 != c2; + bool res = solver->check(); + if (res) { + std::unordered_map terms( + { { "a", a }, { "b", b }, { "c", c }, { "c1", c1 }, { "c2", c2 } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_or(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a | b; + c != cr; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_and(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a & b; + c != cr; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_xor(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a ^ b; + c != cr; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_not_64(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + // 2**64 - 1 + auto mask = smt_terms::BVConst("18446744073709551615", solver, 10); + auto br = a ^ mask; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "br", br } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_shl32(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = shl32(a, b, solver); + c != cr; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_shr(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = shr(a, b, solver); + c != cr; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_eq_on_equlaity(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + a == b; + c != 1; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_eq_on_inequlaity(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + a != b; + c != 0; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c } }); + debug_solution(solver, terms); + } + return res; +} \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.cpp index 05e0b2bb944..511b64c2481 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.cpp @@ -24,7 +24,6 @@ smt_circuit::STerm pow2_8(smt_circuit::STerm v0, smt_solver::Solver* solver) for (uint32_t i = 1; i < BIT_SIZE + 1; i++) { auto r2 = res * res; auto mask = pow_num(2, BIT_SIZE - i); - info(mask); // same thing as taking ith bit in little endian auto b = (v0 & mask) >> (BIT_SIZE - i); res = (r2 * two * b) + (1 - b) * r2; From 3cc7f444281444938802b274baa6751c6a1f9795 Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Fri, 27 Dec 2024 13:46:55 +0000 Subject: [PATCH 23/32] docs + small refactor --- .../acir_formal_proofs/.gitignore | 1 - .../barretenberg/acir_formal_proofs/README.md | 50 ++- .../acir_formal_proofs/acir_loader.cpp | 14 +- .../acir_formal_proofs/acir_loader.hpp | 77 +++- .../acir_formal_proofs/acir_loader.test.cpp | 367 ++++++++++++------ .../check_circuits.test.cpp | 0 .../acir_formal_proofs/formal_proofs.cpp | 282 ++++++++++++++ .../acir_formal_proofs/formal_proofs.hpp | 359 +++++++---------- .../acir_formal_proofs/helpers.hpp | 46 ++- .../acir_formal_proofs/helpers.test.cpp | 2 - .../smt_verification/terms/term.cpp | 33 ++ .../smt_verification/terms/term.hpp | 9 +- .../src/acir_instruction_builder.rs | 63 ++- .../noirc_evaluator/ssa_test/.gitignore | 1 - .../noirc_evaluator/ssa_test/README.md | 28 +- .../noirc_evaluator/ssa_test/src/main.rs | 73 +++- 16 files changed, 1009 insertions(+), 396 deletions(-) delete mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/check_circuits.test.cpp create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.cpp diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/.gitignore b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/.gitignore index 62dd1ddc077..e69de29bb2d 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/.gitignore +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/.gitignore @@ -1 +0,0 @@ -artifacts/* diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md index 89f1fd52a9c..8b33dd642ec 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md @@ -1,11 +1,45 @@ -# Formal verifier of instructions produced by the conversion from Noir SSA to ACIR. +# Formal Verification of ACIR Instructions -## +This module provides formal verification capabilities for ACIR (Arithmetic Circuit Intermediate Representation) instructions generated from Noir SSA code. -## how +## Overview -1. generate instructions' acir [with this](../../../../../noir/noir-repo/compiler/noirc_evaluator/ssa_test/) -2. move artifacts to this directory -3. ??? -4. ??? -5. verified +The verifier uses SMT (Satisfiability Modulo Theories) solving to formally verify the correctness of ACIR instructions. It supports verification of: + +- Arithmetic operations (add, subtract, multiply, divide) +- Bitwise operations (AND, OR, XOR, NOT) +- Shifts (left shift, right shift) +- Comparisons (equality, less than, greater than) +- Field arithmetic + +## Tests + +The test suite verifies correctness of ACIR operations through SMT solving: + +### Arithmetic Tests +- `uint_terms_add`: Tests 127-bit unsigned addition. Execution time: ~2.8s +- `uint_terms_sub`: Tests 127-bit unsigned subtraction. Execution time: ~2.6s +- `uint_terms_mul`: Tests 127-bit unsigned multiplication. Execution time: ~10.0s +- `uint_terms_div`: Tests 126-bit unsigned division +- `integer_terms_div`: Tests 126-bit signed division. Execution time: >10 days +- `field_terms_div`: Tests field division. Execution time: ~0.22s +- `uint_terms_mod`: Tests 126-bit unsigned modulo. Execution time: ~0.354s + +### Bitwise Tests +- `uint_terms_and`: Tests 127-bit unsigned bitwise AND DOESNT WORK* +- `uint_terms_or`: Tests 127-bit unsigned bitwise OR DOESNT WORK* +- `uint_terms_xor`: Tests 127-bit unsigned bitwise XOR DOESNT WORK* +- `uint_terms_not`: Tests 127-bit unsigned bitwise NOT + +### Shift Tests +- `uint_terms_shl32`: Tests 32-bit left shift. Execution time: ~4574s, Memory: ~30GB +- `uint_terms_shl64`: Tests 64-bit left shift. Execution time: ~4588s, Memory: ~30GB +- `uint_terms_shr`: Tests right shift. Execution time: ~3927.88s, Memory: ~10GB + +### Comparison Tests +- `uint_terms_eq`: Tests 127-bit unsigned equality comparison. Verifies both equal and unequal cases. Execution time: ~22.8s +- `uint_terms_lt`: Tests 127-bit unsigned less than comparison. Verifies both a < b and a >= b cases. Execution time: ~56.7s + +Each test attempts to find counterexamples that violate the expected behavior. A failing test indicates the operation is correctly implemented, while a passing test reveals potential issues. + +*Note: The bitwise tests are not working yet. (probably because of bug in the SMT solver). It works only for variables with 32 bits. diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp index 6286651bfe3..be5bdeb3e55 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp @@ -50,8 +50,20 @@ smt_solver::Solver AcirToSmtLoader::get_smt_solver() return smt_solver::Solver(circuit_info.modulus, smt_circuit::default_solver_config, 16, 240); } -smt_circuit::UltraCircuit AcirToSmtLoader::get_smt_circuit(smt_solver::Solver* solver) +smt_circuit::UltraCircuit AcirToSmtLoader::get_bitvec_smt_circuit(smt_solver::Solver* solver) { smt_circuit::CircuitSchema circuit_info = smt_circuit_schema::unpack_from_buffer(this->circuit_buf); return smt_circuit::UltraCircuit(circuit_info, solver, smt_terms::TermType::BVTerm); +} + +smt_circuit::UltraCircuit AcirToSmtLoader::get_field_smt_circuit(smt_solver::Solver* solver) +{ + smt_circuit::CircuitSchema circuit_info = smt_circuit_schema::unpack_from_buffer(this->circuit_buf); + return smt_circuit::UltraCircuit(circuit_info, solver, smt_terms::TermType::FFTerm); +} + +smt_circuit::UltraCircuit AcirToSmtLoader::get_integer_smt_circuit(smt_solver::Solver* solver) +{ + smt_circuit::CircuitSchema circuit_info = smt_circuit_schema::unpack_from_buffer(this->circuit_buf); + return smt_circuit::UltraCircuit(circuit_info, solver, smt_terms::TermType::ITerm); } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp index eb4d50aa41d..a201aa8bb1d 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.hpp @@ -2,11 +2,25 @@ #include "barretenberg/dsl/acir_format/acir_format.hpp" #include "barretenberg/smt_verification/circuit/ultra_circuit.hpp" #include "msgpack/v3/sbuffer_decl.hpp" +#include #include #include +/** + * @brief Class for loading ACIR (Arithmetic Circuit Intermediate Representation) programs and converting them to SMT + * format + * + * This class handles loading ACIR programs from files and provides functionality to: + * - Convert the ACIR program to various SMT circuit representations + * - Access the underlying constraint systems + * - Build circuits for verification + * + * The loader reads an ACIR program file, creates constraint systems, and allows conversion + * to different SMT circuit types (bitvector, field, integer) for formal verification. + */ class AcirToSmtLoader { public: + // Deleted constructors/operators to prevent copying/moving AcirToSmtLoader() = delete; AcirToSmtLoader(const AcirToSmtLoader& other) = delete; AcirToSmtLoader(AcirToSmtLoader&& other) = delete; @@ -14,16 +28,69 @@ class AcirToSmtLoader { AcirToSmtLoader&& operator=(AcirToSmtLoader&& other) = delete; ~AcirToSmtLoader() = default; + + /** + * @brief Constructs loader from an ACIR program file + * @param filename Path to the ACIR program file to load + * + * Reads the ACIR program from file, initializes the constraint system, + * and prepares the circuit buffer for later use. + */ AcirToSmtLoader(std::string filename); + /** + * @brief Gets the constraint systems from the loaded ACIR program + * @return Reference to the ACIR format constraint systems + */ acir_format::AcirFormat& get_constraint_systems() { return this->constraint_system; } + + /** + * @brief Creates a circuit builder for the loaded program + * @return UltraCircuitBuilder instance + * + * Creates and returns a circuit builder with predefined variable names: + * - Variable 0 named "a" + * - Variable 1 named "b" + * - Variable 2 named "c" + */ bb::UltraCircuitBuilder get_circuit_builder(); + + /** + * @brief Gets an SMT solver instance + * @return Solver instance for SMT solving + * + * Creates a solver configured with: + * - Circuit modulus from schema + * - Default solver configuration + * - Minimum bit width of 16 + * - Maximum bit width of 240 + */ smt_solver::Solver get_smt_solver(); - smt_circuit::UltraCircuit get_smt_circuit(smt_solver::Solver* solver); + + /** + * @brief Creates an SMT circuit for bitvector operations + * @param solver Pointer to SMT solver to use + * @return UltraCircuit configured for bitvector operations + */ + smt_circuit::UltraCircuit get_bitvec_smt_circuit(smt_solver::Solver* solver); + + /** + * @brief Creates an SMT circuit for field operations + * @param solver Pointer to SMT solver to use + * @return UltraCircuit configured for field operations + */ + smt_circuit::UltraCircuit get_field_smt_circuit(smt_solver::Solver* solver); + + /** + * @brief Creates an SMT circuit for integer operations + * @param solver Pointer to SMT solver to use + * @return UltraCircuit configured for integer operations + */ + smt_circuit::UltraCircuit get_integer_smt_circuit(smt_solver::Solver* solver); private: - std::string instruction_name; - std::vector acir_program_buf; - acir_format::AcirFormat constraint_system; - msgpack::sbuffer circuit_buf; + std::string instruction_name; ///< Name of the instruction/filename being processed + std::vector acir_program_buf; ///< Buffer containing the raw ACIR program data read from file + acir_format::AcirFormat constraint_system; ///< The parsed constraint system from the ACIR program + msgpack::sbuffer circuit_buf; ///< Buffer for circuit serialization using MessagePack }; \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp index d6d3e39755c..6e2a4eab9d0 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp @@ -1,3 +1,11 @@ +/** + * @file acir_loader.test.cpp + * @brief Tests for verifying ACIR (Arithmetic Circuit Intermediate Representation) operations + * + * This test suite verifies the correctness of various arithmetic, logical, and bitwise operations + * implemented in ACIR format. It uses SMT solvers to formally verify the operations. + */ + #include "acir_loader.hpp" #include "barretenberg/circuit_checker/circuit_checker.hpp" #include "barretenberg/common/test.hpp" @@ -11,18 +19,30 @@ #include "helpers.hpp" #include -// defkit/print_assertions TODO delete all print_assertions from tests +// Path to test artifacts containing ACIR programs and witness files const std::string ARTIFACTS_PATH = "../src/barretenberg/acir_formal_proofs/artifacts/"; -// saves to ARTIFACTS_PATH/{instruction_name}.witness +/** + * @brief Saves witness data when a bug is found during verification + * @param instruction_name Name of the instruction being tested + * @param circuit The circuit containing the bug + * + * Saves witness data to a file named {instruction_name}.witness in the artifacts directory + */ void save_buggy_witness(std::string instruction_name, smt_circuit::UltraCircuit circuit) { - // stay it empty, dont want to see them in stdout std::vector special_names; info("Saving bug for op ", instruction_name); default_model_single(special_names, circuit, ARTIFACTS_PATH + instruction_name + ".witness"); } +/** + * @brief Verifies a previously saved witness file for correctness + * @param instruction_name Name of the instruction to verify + * @return true if witness is valid, false otherwise + * + * Loads a witness file and verifies it against the corresponding ACIR program + */ bool verify_buggy_witness(std::string instruction_name) { std::vector witness = import_witness_single(ARTIFACTS_PATH + instruction_name + ".witness.pack"); @@ -37,249 +57,356 @@ bool verify_buggy_witness(std::string instruction_name) return bb::CircuitChecker::check(builder); } +/** + * @brief Tests 127-bit unsigned addition + * Verifies that the ACIR implementation of addition is correct + * Execution time: ~2.8 seconds on SMTBOX + */ TEST(acir_formal_proofs, uint_terms_add) { - AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Add.acir"); + std::string TESTNAME = "Binary::Add_Unsigned_127_Unsigned_127"; + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); smt_solver::Solver solver = loader.get_smt_solver(); - smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); + smt_circuit::UltraCircuit circuit = loader.get_bitvec_smt_circuit(&solver); bool res = verify_add(&solver, circuit); EXPECT_FALSE(res); if (res) { - save_buggy_witness("Binary::Add", circuit); - } -} - -TEST(acir_formal_proofs, uint_terms_mul) -{ - AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Mul.acir"); - smt_solver::Solver solver = loader.get_smt_solver(); - smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); - bool res = verify_mul(&solver, circuit); - EXPECT_FALSE(res); - if (res) { - save_buggy_witness("Binary::Mul", circuit); + save_buggy_witness(TESTNAME, circuit); } } +/** + * @brief Tests 127-bit unsigned bitwise AND + * Verifies that the ACIR implementation of AND is correct + */ TEST(acir_formal_proofs, uint_terms_and) { - AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::And.acir"); + std::string TESTNAME = "Binary::And_Unsigned_127_Unsigned_127"; + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); smt_solver::Solver solver = loader.get_smt_solver(); - smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); + smt_circuit::UltraCircuit circuit = loader.get_bitvec_smt_circuit(&solver); bool res = verify_and(&solver, circuit); EXPECT_FALSE(res); if (res) { - save_buggy_witness("Binary::And", circuit); + save_buggy_witness(TESTNAME, circuit); } } +/** + * @brief Tests 126-bit unsigned division + * Verifies that the ACIR implementation of division is correct + */ TEST(acir_formal_proofs, uint_terms_div) { - AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Div.acir"); + std::string TESTNAME = "Binary::Div_Unsigned_126_Unsigned_126"; + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); smt_solver::Solver solver = loader.get_smt_solver(); - smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); + smt_circuit::UltraCircuit circuit = loader.get_bitvec_smt_circuit(&solver); bool res = verify_div(&solver, circuit); EXPECT_FALSE(res); if (res) { - save_buggy_witness("Binary::Div", circuit); + save_buggy_witness(TESTNAME, circuit); } } -// checks to times -// if a == b c must be 0 -// if a != b must be 1 +/** + * @brief Tests 127-bit unsigned equality comparison + * Verifies two cases: + * 1. When operands are equal, result must be 0 + * 2. When operands are not equal, result must be 1 + * Execution time: ~22.8 seconds on SMTBOX + */ TEST(acir_formal_proofs, uint_terms_eq) { - AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Eq.acir"); + std::string TESTNAME = "Binary::Eq_Unsigned_127_Unsigned_127"; + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); smt_solver::Solver solver1 = loader.get_smt_solver(); - smt_circuit::UltraCircuit circuit1 = loader.get_smt_circuit(&solver1); + smt_circuit::UltraCircuit circuit1 = loader.get_bitvec_smt_circuit(&solver1); bool res1 = verify_eq_on_equlaity(&solver1, circuit1); EXPECT_FALSE(res1); if (res1) { - save_buggy_witness("Binary::Eq", circuit1); + save_buggy_witness(TESTNAME, circuit1); } smt_solver::Solver solver2 = loader.get_smt_solver(); - smt_circuit::UltraCircuit circuit2 = loader.get_smt_circuit(&solver2); + smt_circuit::UltraCircuit circuit2 = loader.get_bitvec_smt_circuit(&solver2); bool res2 = verify_eq_on_inequlaity(&solver2, circuit2); EXPECT_FALSE(res2); if (res2) { - save_buggy_witness("Binary::Eq", circuit2); + save_buggy_witness(TESTNAME, circuit2); } } -/*TEST(acir_formal_proofs, uint_terms_lt) +/** + * @brief Tests 127-bit unsigned less than comparison + * Verifies two cases: + * 1. When a < b, result must be 0 + * 2. When a >= b, result must be 1 + * Execution time: ~56.7 seconds on SMTBOX + */ +TEST(acir_formal_proofs, uint_terms_lt) { - AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Lt.acir"); - smt_solver::Solver solver = loader.get_smt_solver(); - smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); - auto a = smt_circuit::BVVar("a", &solver); - auto b = smt_circuit::BVVar("b", &solver); - auto c = smt_circuit::BVVar("c", &solver); - a < b; - c != 1; - bool res = solver.check(); - solver.print_assertions(); - info(solver.getResult()); - EXPECT_FALSE(res); -}*/ + std::string TESTNAME = "Binary::Lt_Unsigned_127_Unsigned_127"; + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); + smt_solver::Solver solver1 = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit1 = loader.get_bitvec_smt_circuit(&solver1); -/*TEST(acir_formal_proofs, uint_terms_gt) -{ - AcirToSmtLoader loader = AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Lt.acir"); - smt_solver::Solver solver = loader.get_smt_solver(); - smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); + bool res1 = verify_lt(&solver1, circuit1); + EXPECT_FALSE(res1); + if (res1) { + save_buggy_witness(TESTNAME, circuit1); + } - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - a > b; - c != 0; - bool res = solver.check(); - solver.print_assertions(); - info(solver.getResult()); - EXPECT_FALSE(res); -}*/ + smt_solver::Solver solver2 = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit2 = loader.get_bitvec_smt_circuit(&solver2); + bool res2 = verify_gt(&solver2, circuit2); + EXPECT_FALSE(res2); + if (res2) { + save_buggy_witness(TESTNAME, circuit2); + } +} + +/** + * @brief Tests 126-bit unsigned modulo + * Verifies that the ACIR implementation of modulo is correct + * Execution time: ~0.354 seconds on SMTBOX + */ TEST(acir_formal_proofs, uint_terms_mod) { - AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Mod.acir"); + std::string TESTNAME = "Binary::Mod_Unsigned_126_Unsigned_126"; + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); smt_solver::Solver solver = loader.get_smt_solver(); - smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); + smt_circuit::UltraCircuit circuit = loader.get_bitvec_smt_circuit(&solver); bool res = verify_mod(&solver, circuit); solver.print_assertions(); EXPECT_FALSE(res); if (res) { - save_buggy_witness("Binary::Mod", circuit); + save_buggy_witness(TESTNAME, circuit); } } +/** + * @brief Tests 127-bit unsigned multiplication + * Verifies that the ACIR implementation of multiplication is correct + * Execution time: ~10.0 seconds on SMTBOX + */ +TEST(acir_formal_proofs, uint_terms_mul) +{ + std::string TESTNAME = "Binary::Mul_Unsigned_127_Unsigned_127"; + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_bitvec_smt_circuit(&solver); + bool res = verify_mul(&solver, circuit); + EXPECT_FALSE(res); + if (res) { + save_buggy_witness(TESTNAME, circuit); + } +} + +/** + * @brief Tests 127-bit unsigned bitwise OR + * Verifies that the ACIR implementation of OR is correct + */ TEST(acir_formal_proofs, uint_terms_or) { - AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Or.acir"); + std::string TESTNAME = "Binary::Or_Unsigned_127_Unsigned_127"; + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); smt_solver::Solver solver = loader.get_smt_solver(); - smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); + smt_circuit::UltraCircuit circuit = loader.get_bitvec_smt_circuit(&solver); bool res = verify_or(&solver, circuit); EXPECT_FALSE(res); if (res) { - save_buggy_witness("Binary::Or", circuit); + save_buggy_witness(TESTNAME, circuit); } } -/*TEST(acir_formal_proofs, uint_terms_shl64) +/** + * @brief Tests 64-bit left shift + * Verifies that the ACIR implementation of left shift is correct + * Execution time: ~4588 seconds on SMTBOX + * Memory usage: ~30GB RAM + */ +TEST(acir_formal_proofs, uint_terms_shl64) { - AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Shl.acir"); + std::string TESTNAME = "Binary::Shl_Unsigned_32_Unsigned_8"; + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); smt_solver::Solver solver = loader.get_smt_solver(); - smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); - bool res = verify_shl32(&solver, circuit); + smt_circuit::UltraCircuit circuit = loader.get_bitvec_smt_circuit(&solver); + bool res = verify_shl64(&solver, circuit); if (res) { - save_buggy_witness("Binary::Shl", circuit); + save_buggy_witness(TESTNAME, circuit); } EXPECT_FALSE(res); -}*/ +} +/** + * @brief Tests 32-bit left shift + * Verifies that the ACIR implementation of left shift is correct + * Execution time: ~4574 seconds on SMTBOX + * Memory usage: ~30GB RAM + */ TEST(acir_formal_proofs, uint_terms_shl32) { - AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Shl.acir"); + std::string TESTNAME = "Binary::Shl_Unsigned_32_Unsigned_8"; + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); smt_solver::Solver solver = loader.get_smt_solver(); - smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); + smt_circuit::UltraCircuit circuit = loader.get_bitvec_smt_circuit(&solver); bool res = verify_shl32(&solver, circuit); if (res) { - save_buggy_witness("Binary::Shl", circuit); + save_buggy_witness(TESTNAME, circuit); } EXPECT_FALSE(res); } +/** + * @brief Tests right shift operation + * Verifies that the ACIR implementation of right shift is correct + * Execution time: ~3927.88 seconds on SMTBOX + * Memory usage: ~10GB RAM + */ TEST(acir_formal_proofs, uint_terms_shr) { - AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Shr.acir"); + std::string TESTNAME = "Binary::Shr_Unsigned_64_Unsigned_8"; + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); smt_solver::Solver solver = loader.get_smt_solver(); - smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); + smt_circuit::UltraCircuit circuit = loader.get_bitvec_smt_circuit(&solver); bool res = verify_shr(&solver, circuit); if (res) { - save_buggy_witness("Binary::Shl", circuit); + save_buggy_witness(TESTNAME, circuit); } EXPECT_FALSE(res); } +/** + * @brief Tests 127-bit unsigned subtraction + * Verifies that the ACIR implementation of subtraction is correct + * Execution time: ~2.6 seconds on SMTBOX + */ TEST(acir_formal_proofs, uint_terms_sub) { - AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Sub.acir"); + std::string TESTNAME = "Binary::Sub_Unsigned_127_Unsigned_127"; + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); smt_solver::Solver solver = loader.get_smt_solver(); - smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); + smt_circuit::UltraCircuit circuit = loader.get_bitvec_smt_circuit(&solver); bool res = verify_sub(&solver, circuit); EXPECT_FALSE(res); if (res) { - save_buggy_witness("Binary::Sub", circuit); + save_buggy_witness(TESTNAME, circuit); } } +/** + * @brief Tests 127-bit unsigned bitwise XOR + * Verifies that the ACIR implementation of XOR is correct + */ TEST(acir_formal_proofs, uint_terms_xor) { - AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Binary::Xor.acir"); + std::string TESTNAME = "Binary::Xor_Unsigned_127_Unsigned_127"; + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); smt_solver::Solver solver = loader.get_smt_solver(); - smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); + smt_circuit::UltraCircuit circuit = loader.get_bitvec_smt_circuit(&solver); bool res = verify_xor(&solver, circuit); EXPECT_FALSE(res); if (res) { - save_buggy_witness("Binary::Xor", circuit); + save_buggy_witness(TESTNAME, circuit); } } +/** + * @brief Tests 127-bit unsigned bitwise NOT + * Verifies that the ACIR implementation of NOT is correct + */ TEST(acir_formal_proofs, uint_terms_not) { - AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + "Not.acir"); + std::string TESTNAME = "Not_Unsigned_127"; + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); smt_solver::Solver solver = loader.get_smt_solver(); - smt_circuit::UltraCircuit circuit = loader.get_smt_circuit(&solver); - auto a = circuit["a"]; - auto b = circuit["b"]; - bool res = verify_not_64(&solver, circuit); + smt_circuit::UltraCircuit circuit = loader.get_bitvec_smt_circuit(&solver); + bool res = verify_not_127(&solver, circuit); EXPECT_FALSE(res); if (res) { - save_buggy_witness("Binary::Not", circuit); + save_buggy_witness(TESTNAME, circuit); } } -// if failed, bug NOT verified -// fali on file not found or check circuit -TEST(acir_formal_proofs, uint_terms_and_verify_bug) +/** + * @brief Tests field addition + * Verifies that the ACIR implementation of field addition is correct + * Execution time: ~0.22 seconds on SMTBOX + */ +TEST(acir_formal_proofs, field_terms_add) { - EXPECT_TRUE(verify_buggy_witness("Binary::And")); + std::string TESTNAME = "Binary::Add_Field_0_Field_0"; + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_field_smt_circuit(&solver); + bool res = verify_add(&solver, circuit); + EXPECT_FALSE(res); + if (res) { + save_buggy_witness(TESTNAME, circuit); + } } -// if failed, bug NOT verified -// fali on file not found or check circuit -TEST(acir_formal_proofs, uint_terms_shr_verify_bug) +/** + * @brief Tests field division + * Verifies that the ACIR implementation of field division is correct + * Execution time: ~0.22 seconds on SMTBOX + */ +TEST(acir_formal_proofs, field_terms_div) { - EXPECT_TRUE(verify_buggy_witness("Binary::Shr")); + std::string TESTNAME = "Binary::Div_Field_0_Field_0"; + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_field_smt_circuit(&solver); + bool res = verify_div_field(&solver, circuit); + EXPECT_FALSE(res); + if (res) { + save_buggy_witness(TESTNAME, circuit); + } } -TEST(acir_formal_proofs, uint_terms_shl_verify_bug) +/** + * @brief Tests field multiplication + * Verifies that the ACIR implementation of field multiplication is correct + * Execution time: ~0.22 seconds on SMTBOX + */ +TEST(acir_formal_proofs, field_terms_mul) { - EXPECT_TRUE(verify_buggy_witness("Binary::Shl")); + std::string TESTNAME = "Binary::Mul_Field_0_Field_0"; + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_field_smt_circuit(&solver); + bool res = verify_mul(&solver, circuit); + EXPECT_FALSE(res); + if (res) { + save_buggy_witness(TESTNAME, circuit); + } } -/*TEST(acir_circuit_check, uint_terms_add) +/** + * @brief Tests 126-bit signed division + * Verifies that the ACIR implementation of signed division is correct + * Execution time: >10 DAYS on SMTBOX + */ +TEST(acir_formal_proofs, integer_terms_div) { - AcirToSmtLoader loader = - AcirToSmtLoader("../src/barretenberg/acir_formal_proofs/artifacts/Binary::Add.public.acir"); - bb::UltraCircuitBuilder builder = acir_format::create_circuit(loader.get_constraint_systems(), false); - // naming first three variables - // for binary noir sets indices as 0 1 2 - // for unary noir sets indices as 0 1 - info(builder.public_inputs); - info(builder.zero_idx); - builder.set_variable_name(0, "a"); - builder.set_variable_name(1, "b"); - builder.set_variable_name(2, "c"); - builder.set_variable_name(3, "d"); - builder.variables[0] = 1; - builder.variables[1] = 1; - builder.variables[3] = 2; - // builder.variables[4] = 1; - EXPECT_TRUE(bb::CircuitChecker::check(builder)); + std::string TESTNAME = "Binary::Div_Signed_126_Signed_126"; + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_integer_smt_circuit(&solver); + bool res = verify_div(&solver, circuit); + EXPECT_FALSE(res); + if (res) { + save_buggy_witness(TESTNAME, circuit); + } } -*/ \ No newline at end of file + +TEST(acir_formal_proofs, verify_div_bug) +{ + std::string name = "Binary::Div_Unsigned_126_Unsigned_126"; + EXPECT_TRUE(verify_buggy_witness(name)); +} \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/check_circuits.test.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/check_circuits.test.cpp deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.cpp new file mode 100644 index 00000000000..0102efe5d3a --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.cpp @@ -0,0 +1,282 @@ +#include "barretenberg/smt_verification/circuit/ultra_circuit.hpp" +#include "barretenberg/smt_verification/solver/solver.hpp" +#include "barretenberg/smt_verification/util/smt_util.hpp" +#include "helpers.hpp" + +void debug_solution(smt_solver::Solver* solver, std::unordered_map terms) +{ + solver->print_assertions(); + std::unordered_map vals = solver->model(terms); + for (auto const& i : vals) { + info(i.first, " = ", i.second); + } +} + +bool verify_add(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a + b; + c != cr; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_sub(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a - b; + c != cr; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_mul(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a * b; + c != cr; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_div(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + // c = a / b + // a - c * b = a mod b + // t = a % b + // a - c * b == t + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a / b; + c != cr; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_div_field(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + // c = a / b + // c * b = a + auto cr = c * b; + a != cr; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_mod(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + // c = a mod b + // k * b + c = a + // k = (a - c) / b + // (a - c) * b + c * b == a * b + smt_circuit::STerm c1 = (a - c) * b + c * b; + smt_circuit::STerm c2 = a * b; + c1 != c2; + bool res = solver->check(); + if (res) { + std::unordered_map terms( + { { "a", a }, { "b", b }, { "c", c }, { "c1", c1 }, { "c2", c2 } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_or(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a | b; + c != cr; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_and(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a & b; + c != cr; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_xor(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = a ^ b; + c != cr; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + debug_solution(solver, terms); + } + return res; +} + +// takes 0.346 seconds on SMTBOX +bool verify_not_127(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + // 2**127 - 1 + auto mask = smt_terms::BVConst("170141183460469231731687303715884105727", solver, 10); + auto br = a ^ mask; + b != br; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "br", br } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_shl32(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = shl32(a, b, solver); + c != cr; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_shl64(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = shl32(a, b, solver); + c != cr; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_shr(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + auto cr = shr(a, b, solver); + c != cr; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_eq_on_equlaity(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + a == b; + c != 1; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_eq_on_inequlaity(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + a != b; + c != 0; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_lt(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + a < b; + c != 1; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c } }); + debug_solution(solver, terms); + } + return res; +} + +bool verify_gt(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) +{ + auto a = circuit["a"]; + auto b = circuit["b"]; + auto c = circuit["c"]; + a > b; + c != 0; + bool res = solver->check(); + if (res) { + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c } }); + debug_solution(solver, terms); + } + return res; +} \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.hpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.hpp index 4f98b5df9e3..6992c1d0386 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.hpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.hpp @@ -1,214 +1,149 @@ +#pragma once #include "barretenberg/smt_verification/circuit/ultra_circuit.hpp" #include "barretenberg/smt_verification/solver/solver.hpp" -#include "barretenberg/smt_verification/util/smt_util.hpp" -#include "helpers.hpp" - -void debug_solution(smt_solver::Solver* solver, std::unordered_map terms) -{ - solver->print_assertions(); - std::unordered_map vals = solver->model(terms); - for (auto const& i : vals) { - info(i.first, " = ", i.second); - } -} - -bool verify_add(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) -{ - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - auto cr = a + b; - c != cr; - bool res = solver->check(); - if (res) { - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); - debug_solution(solver, terms); - } - return res; -} - -bool verify_sub(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) -{ - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - auto cr = a - b; - c != cr; - bool res = solver->check(); - if (res) { - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); - debug_solution(solver, terms); - } - return res; -} - -bool verify_mul(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) -{ - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - auto cr = a * b; - c != cr; - bool res = solver->check(); - if (res) { - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); - debug_solution(solver, terms); - } - return res; -} - -bool verify_div(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) -{ - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - auto cr = a / b; - c != cr; - bool res = solver->check(); - if (res) { - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); - debug_solution(solver, terms); - } - return res; -} - -bool verify_mod(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) -{ - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - // c = a mod b - // k * b + c = a - // k = (a - c) / b - // (a - c) * b + c * b == a * b - smt_circuit::STerm c1 = (a - c) * b + c * b; - smt_circuit::STerm c2 = a * b; - c1 != c2; - bool res = solver->check(); - if (res) { - std::unordered_map terms( - { { "a", a }, { "b", b }, { "c", c }, { "c1", c1 }, { "c2", c2 } }); - debug_solution(solver, terms); - } - return res; -} - -bool verify_or(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) -{ - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - auto cr = a | b; - c != cr; - bool res = solver->check(); - if (res) { - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); - debug_solution(solver, terms); - } - return res; -} - -bool verify_and(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) -{ - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - auto cr = a & b; - c != cr; - bool res = solver->check(); - if (res) { - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); - debug_solution(solver, terms); - } - return res; -} - -bool verify_xor(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) -{ - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - auto cr = a ^ b; - c != cr; - bool res = solver->check(); - if (res) { - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); - debug_solution(solver, terms); - } - return res; -} - -bool verify_not_64(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) -{ - auto a = circuit["a"]; - auto b = circuit["b"]; - // 2**64 - 1 - auto mask = smt_terms::BVConst("18446744073709551615", solver, 10); - auto br = a ^ mask; - bool res = solver->check(); - if (res) { - std::unordered_map terms({ { "a", a }, { "b", b }, { "br", br } }); - debug_solution(solver, terms); - } - return res; -} - -bool verify_shl32(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) -{ - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - auto cr = shl32(a, b, solver); - c != cr; - bool res = solver->check(); - if (res) { - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); - debug_solution(solver, terms); - } - return res; -} - -bool verify_shr(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) -{ - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - auto cr = shr(a, b, solver); - c != cr; - bool res = solver->check(); - if (res) { - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "cr", cr } }); - debug_solution(solver, terms); - } - return res; -} - -bool verify_eq_on_equlaity(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) -{ - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - a == b; - c != 1; - bool res = solver->check(); - if (res) { - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c } }); - debug_solution(solver, terms); - } - return res; -} - -bool verify_eq_on_inequlaity(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) -{ - auto a = circuit["a"]; - auto b = circuit["b"]; - auto c = circuit["c"]; - a != b; - c != 0; - bool res = solver->check(); - if (res) { - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c } }); - debug_solution(solver, terms); - } - return res; -} \ No newline at end of file +#include "cvc5/cvc5.h" +#include +#include + +/** + * @brief Debug helper to print solver assertions and model values + * @param solver SMT solver instance + * @param terms Map of term names to CVC5 terms to evaluate + */ +void debug_solution(smt_solver::Solver* solver, std::unordered_map terms); + +/** + * @brief Verify addition operation: c = a + b + * @param solver SMT solver instance + * @param circuit Circuit containing variables a, b, c + * @return true if a counterexample is found (verification fails) + */ +bool verify_add(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit); + +/** + * @brief Verify subtraction operation: c = a - b + * @param solver SMT solver instance + * @param circuit Circuit containing variables a, b, c + * @return true if a counterexample is found (verification fails) + */ +bool verify_sub(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit); + +/** + * @brief Verify multiplication operation: c = a * b + * @param solver SMT solver instance + * @param circuit Circuit containing variables a, b, c + * @return true if a counterexample is found (verification fails) + */ +bool verify_mul(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit); + +/** + * @brief Verify integer division operation: c = a / b + * @param solver SMT solver instance + * @param circuit Circuit containing variables a, b, c + * @return true if a counterexample is found (verification fails) + */ +bool verify_div(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit); + +/** + * @brief Verify field division operation: c = a / b (in field) + * @param solver SMT solver instance + * @param circuit Circuit containing variables a, b, c + * @return true if a counterexample is found (verification fails) + */ +bool verify_div_field(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit); + +/** + * @brief Verify modulo operation: c = a mod b + * @param solver SMT solver instance + * @param circuit Circuit containing variables a, b, c + * @return true if a counterexample is found (verification fails) + */ +bool verify_mod(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit); + +/** + * @brief Verify bitwise OR operation: c = a | b + * @param solver SMT solver instance + * @param circuit Circuit containing variables a, b, c + * @return true if a counterexample is found (verification fails) + */ +bool verify_or(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit); + +/** + * @brief Verify bitwise AND operation: c = a & b + * @param solver SMT solver instance + * @param circuit Circuit containing variables a, b, c + * @return true if a counterexample is found (verification fails) + */ +bool verify_and(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit); + +/** + * @brief Verify bitwise XOR operation: c = a ^ b + * @param solver SMT solver instance + * @param circuit Circuit containing variables a, b, c + * @return true if a counterexample is found (verification fails) + */ +bool verify_xor(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit); + +/** + * @brief Verify NOT operation on 127 bits: b = ~a + * @param solver SMT solver instance + * @param circuit Circuit containing variables a, b + * @return true if a counterexample is found (verification fails) + */ +bool verify_not_127(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit); + +/** + * @brief Verify 32-bit left shift operation: c = a << b + * @param solver SMT solver instance + * @param circuit Circuit containing variables a, b, c + * @return true if a counterexample is found (verification fails) + */ +bool verify_shl32(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit); + +/** + * @brief Verify 64-bit left shift operation: c = a << b + * @param solver SMT solver instance + * @param circuit Circuit containing variables a, b, c + * @return true if a counterexample is found (verification fails) + */ +bool verify_shl64(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit); + +/** + * @brief Verify right shift operation: c = a >> b + * @param solver SMT solver instance + * @param circuit Circuit containing variables a, b, c + * @return true if a counterexample is found (verification fails) + */ +bool verify_shr(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit); + +/** + * @brief Verify equality comparison when values are equal + * @param solver SMT solver instance + * @param circuit Circuit containing variables a, b, c + * @return true if a counterexample is found (verification fails) + */ +bool verify_eq_on_equlaity(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit); + +/** + * @brief Verify equality comparison when values are not equal + * @param solver SMT solver instance + * @param circuit Circuit containing variables a, b, c + * @return true if a counterexample is found (verification fails) + */ +bool verify_eq_on_inequlaity(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit); + +/** + * @brief Verify less than comparison: a < b + * @param solver SMT solver instance + * @param circuit Circuit containing variables a, b, c + * @return true if a counterexample is found (verification fails) + */ +bool verify_lt(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit); + +/** + * @brief Verify greater than comparison: a > b + * @param solver SMT solver instance + * @param circuit Circuit containing variables a, b, c + * @return true if a counterexample is found (verification fails) + */ +bool verify_gt(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit); diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.hpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.hpp index e5f9d9f8d02..d1e6fe4ab45 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.hpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.hpp @@ -2,24 +2,46 @@ #include "barretenberg/smt_verification/solver/solver.hpp" #include "barretenberg/smt_verification/terms/term.hpp" -// reurns a << b -// b 8 bit -// result is truncated to 64 bit +/** + * @brief Left shift operation with 64-bit truncation + * @param v0 Value to shift + * @param v1 Number of bits to shift (8-bit value) + * @param solver SMT solver instance + * @return Result of (v0 << v1) truncated to 64 bits + */ smt_circuit::STerm shl64(smt_circuit::STerm v0, smt_circuit::STerm v1, smt_solver::Solver* solver); -// reurns a << b -// b 8 bit -// result is truncated to 32 bit +/** + * @brief Left shift operation with 32-bit truncation + * @param v0 Value to shift + * @param v1 Number of bits to shift (8-bit value) + * @param solver SMT solver instance + * @return Result of (v0 << v1) truncated to 32 bits + */ smt_circuit::STerm shl32(smt_circuit::STerm v0, smt_circuit::STerm v1, smt_solver::Solver* solver); -// retuns 2^v0, v0 8 bit +/** + * @brief Calculates power of 2 + * @param v0 Exponent (8-bit value) + * @param solver SMT solver instance + * @return 2^v0 + */ smt_circuit::STerm pow2_8(smt_circuit::STerm v0, smt_solver::Solver* solver); -// returns a >> b -// b 8 bit +/** + * @brief Right shift operation + * @param v0 Value to shift + * @param v1 Number of bits to shift (8-bit value) + * @param solver SMT solver instance + * @return Result of (v0 >> v1) + */ smt_circuit::STerm shr(smt_circuit::STerm v0, smt_circuit::STerm v1, smt_solver::Solver* solver); -// returns a << b -// b 8 bit -// result is NOT truncated +/** + * @brief Left shift operation without truncation + * @param v0 Value to shift + * @param v1 Number of bits to shift (8-bit value) + * @param solver SMT solver instance + * @return Result of (v0 << v1) without truncation + */ smt_circuit::STerm shl(smt_circuit::STerm v0, smt_circuit::STerm v1, smt_solver::Solver* solver); \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.test.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.test.cpp index 73a8935e88c..9918dcb6947 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.test.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.test.cpp @@ -76,8 +76,6 @@ TEST(helpers, buggy_shr) TEST(helpers, pow2) { - // using smt solver i found that 1879048194 >> 16 == 0 - // its strange... Solver s("30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001", default_solver_config, 16, 32); STerm x = BVVar("x", &s); diff --git a/barretenberg/cpp/src/barretenberg/smt_verification/terms/term.cpp b/barretenberg/cpp/src/barretenberg/smt_verification/terms/term.cpp index 8d2bc596703..d47851d5bef 100644 --- a/barretenberg/cpp/src/barretenberg/smt_verification/terms/term.cpp +++ b/barretenberg/cpp/src/barretenberg/smt_verification/terms/term.cpp @@ -1,4 +1,5 @@ #include "barretenberg/smt_verification/terms/term.hpp" +#include "term.hpp" namespace smt_terms { @@ -313,6 +314,38 @@ STerm STerm::operator|(const STerm& other) const return { res, this->solver, this->type }; } +void STerm::operator<(const STerm& other) const +{ + STerm left = *this; + STerm right = other; + left = this->type == TermType::FFITerm && left.term.getNumChildren() > 1 ? left.mod() : left; + right = this->type == TermType::FFITerm && right.term.getNumChildren() > 1 ? right.mod() : right; + + cvc5::Term eq = this->solver->term_manager.mkTerm(this->operations.at(OpType::LT), { left.term, right.term }); + this->solver->assertFormula(eq); +} + +void STerm::operator>(const STerm& other) const +{ + STerm left = *this; + STerm right = other; + left = this->type == TermType::FFITerm && left.term.getNumChildren() > 1 ? left.mod() : left; + right = this->type == TermType::FFITerm && right.term.getNumChildren() > 1 ? right.mod() : right; + + cvc5::Term eq = this->solver->term_manager.mkTerm(this->operations.at(OpType::GT), { left.term, right.term }); + this->solver->assertFormula(eq); +} + +STerm STerm::operator~() const +{ + if (!this->operations.contains(OpType::NOT)) { + info("NOT is not compatible with ", this->type); + return *this; + } + cvc5::Term res = solver->term_manager.mkTerm(this->operations.at(OpType::NOT), { this->term }); + return { res, this->solver, this->type }; +} + void STerm::operator|=(const STerm& other) { if (!this->operations.contains(OpType::OR)) { diff --git a/barretenberg/cpp/src/barretenberg/smt_verification/terms/term.hpp b/barretenberg/cpp/src/barretenberg/smt_verification/terms/term.hpp index 35aff409795..1803e7825fd 100644 --- a/barretenberg/cpp/src/barretenberg/smt_verification/terms/term.hpp +++ b/barretenberg/cpp/src/barretenberg/smt_verification/terms/term.hpp @@ -15,7 +15,7 @@ using namespace smt_solver; enum class TermType { FFTerm, FFITerm, BVTerm, ITerm }; std::ostream& operator<<(std::ostream& os, TermType type); -enum class OpType : int32_t { ADD, SUB, MUL, DIV, NEG, XOR, AND, OR, GT, GE, LT, LE, MOD, RSH, LSH, ROTR, ROTL }; +enum class OpType : int32_t { ADD, SUB, MUL, DIV, NEG, XOR, AND, OR, GT, GE, LT, LE, MOD, RSH, LSH, ROTR, ROTL, NOT }; /** * @brief precomputed map that contains allowed @@ -73,7 +73,9 @@ const std::unordered_map> typed { OpType::ROTL, cvc5::Kind::BITVECTOR_ROTATE_LEFT }, { OpType::ROTR, cvc5::Kind::BITVECTOR_ROTATE_RIGHT }, { OpType::MOD, cvc5::Kind::BITVECTOR_UREM }, - { OpType::DIV, cvc5::Kind::BITVECTOR_UDIV } } } + { OpType::DIV, cvc5::Kind::BITVECTOR_UDIV }, + { OpType::NOT, cvc5::Kind::BITVECTOR_NOT }, + } } }; /** @@ -160,6 +162,9 @@ class STerm { void operator&=(const STerm& other); STerm operator|(const STerm& other) const; void operator|=(const STerm& other); + void operator<(const STerm& other) const; + void operator>(const STerm& other) const; + STerm operator~() const; STerm operator<<(const uint32_t& n) const; void operator<<=(const uint32_t& n); STerm operator>>(const uint32_t& n) const; diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs index 94012b684e0..04dedcdcac3 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs @@ -20,34 +20,50 @@ use crate::ssa::{ use crate::brillig::Brillig; use serde::{Deserialize, Serialize}; +/// Represents artifacts generated from compiling an instruction #[derive(Serialize, Deserialize)] pub struct InstructionArtifacts { - // name of used instruction + /// Name of the instruction pub instruction_name: String, - // ssa represented as format string acir(inline) {...} + /// SSA representation formatted as "acir(inline) {...}" pub formatted_ssa: String, - // serde_json serialized ssa + /// JSON serialized SSA pub serialized_ssa: String, - // bytes of acir program. Gzipped!! + /// Gzipped bytes of ACIR program pub serialized_acir: Vec, } +/// Represents the type of a variable in the instruction +#[derive(Debug)] pub enum VariableType { - Field, + /// Field element type + Field, + /// Unsigned integer type Unsigned, + /// Signed integer type Signed } +/// Represents a variable with its type and size information pub struct Variable { + /// Type of the variable (Field, Unsigned, or Signed) pub variable_type: VariableType, - // ignored on Field type - pub variable_size: u32 + /// Bit size of the variable (ignored for Field type) + pub variable_size: u32, +} + +impl Variable { + /// Gets a string representation of the variable's type and size + pub fn get_name(&self) -> String { + return format!("{:?}_{}", self.variable_type, self.variable_size) + } } impl InstructionArtifacts { + /// Converts a Variable into its corresponding SSA Type fn get_type(variable: &Variable) -> Type { match variable.variable_type { VariableType::Field => Type::field(), @@ -56,6 +72,7 @@ impl InstructionArtifacts { } } + /// Creates a new binary operation instruction artifact fn new_binary(op: BinaryOp, instruction_name: String, first_variable: &Variable, second_variable: &Variable) -> Self { let first_variable_type = Self::get_type(first_variable); let second_variable_type = Self::get_type(second_variable); @@ -65,15 +82,17 @@ impl InstructionArtifacts { let program = ssa_to_acir_program(ssa); let serialized_program = AcirProgram::serialize_program(&program); + let name = format!("{}_{}_{}", instruction_name, first_variable.get_name(), second_variable.get_name()); Self { - instruction_name: instruction_name, + instruction_name: name, formatted_ssa: formatted_ssa, serialized_ssa: serialized_ssa.to_string(), serialized_acir: serialized_program } } + /// Creates a new instruction artifact using a provided SSA generation function fn new_by_func(ssa_generate_function: fn(Type) -> Ssa, instruction_name: String, variable: &Variable) -> Self { let variable_type = Self::get_type(variable); let ssa = ssa_generate_function(variable_type); @@ -82,81 +101,98 @@ impl InstructionArtifacts { let program = ssa_to_acir_program(ssa); let serialized_program = AcirProgram::serialize_program(&program); + let name = format!("{}_{}", instruction_name, variable.get_name()); Self { - instruction_name: instruction_name, + instruction_name: name, formatted_ssa: formatted_ssa, serialized_ssa: serialized_ssa.to_string(), serialized_acir: serialized_program } - } + /// Creates a new constrain instruction artifact pub fn new_constrain(variable: &Variable) -> Self { return Self::new_by_func(constrain_function, "Constrain".into(), variable) } + /// Creates a new NOT operation instruction artifact pub fn new_not(variable: &Variable) -> Self { return Self::new_by_func(not_function, "Not".into(), variable) } + /// Creates a new range check instruction artifact pub fn new_range_check(variable: &Variable) -> Self { return Self::new_by_func(range_check_function, "RangeCheck".into(), variable) } + /// Creates a new truncate instruction artifact pub fn new_truncate(variable: &Variable) -> Self { return Self::new_by_func(truncate_function, "Truncate".into(), variable) } + /// Creates a new ADD operation instruction artifact pub fn new_add(first_variable: &Variable, second_variable: &Variable) -> Self { return Self::new_binary(BinaryOp::Add, "Binary::Add".into(), first_variable, second_variable); } + /// Creates a new SUB operation instruction artifact pub fn new_sub(first_variable: &Variable, second_variable: &Variable) -> Self { return Self::new_binary(BinaryOp::Sub, "Binary::Sub".into(), first_variable, second_variable); } + /// Creates a new XOR operation instruction artifact pub fn new_xor(first_variable: &Variable, second_variable: &Variable) -> Self { return Self::new_binary(BinaryOp::Xor, "Binary::Xor".into(), first_variable, second_variable); } + /// Creates a new AND operation instruction artifact pub fn new_and(first_variable: &Variable, second_variable: &Variable) -> Self { return Self::new_binary(BinaryOp::And, "Binary::And".into(), first_variable, second_variable); } + /// Creates a new OR operation instruction artifact pub fn new_or(first_variable: &Variable, second_variable: &Variable) -> Self { return Self::new_binary(BinaryOp::Or, "Binary::Or".into(), first_variable, second_variable); } + /// Creates a new less than operation instruction artifact pub fn new_lt(first_variable: &Variable, second_variable: &Variable) -> Self { return Self::new_binary(BinaryOp::Lt, "Binary::Lt".into(), first_variable, second_variable); } + /// Creates a new equals operation instruction artifact pub fn new_eq(first_variable: &Variable, second_variable: &Variable) -> Self { return Self::new_binary(BinaryOp::Eq, "Binary::Eq".into(), first_variable, second_variable); } + /// Creates a new modulo operation instruction artifact pub fn new_mod(first_variable: &Variable, second_variable: &Variable) -> Self { return Self::new_binary(BinaryOp::Mod, "Binary::Mod".into(), first_variable, second_variable); } + /// Creates a new multiply operation instruction artifact pub fn new_mul(first_variable: &Variable, second_variable: &Variable) -> Self { return Self::new_binary(BinaryOp::Mul, "Binary::Mul".into(), first_variable, second_variable); } + /// Creates a new divide operation instruction artifact pub fn new_div(first_variable: &Variable, second_variable: &Variable) -> Self { return Self::new_binary(BinaryOp::Div, "Binary::Div".into(), first_variable, second_variable); } + /// Creates a new shift left operation instruction artifact pub fn new_shl(first_variable: &Variable, second_variable: &Variable) -> Self { return Self::new_binary(BinaryOp::Shl, "Binary::Shl".into(), first_variable, second_variable); } + /// Creates a new shift right operation instruction artifact pub fn new_shr(first_variable: &Variable, second_variable: &Variable) -> Self { return Self::new_binary(BinaryOp::Shr, "Binary::Shr".into(), first_variable, second_variable); } } +/// Converts SSA to ACIR program fn ssa_to_acir_program(ssa: Ssa) -> AcirProgram { // third brillig names, fourth errors let (acir_functions, brillig, _, _) = ssa @@ -181,6 +217,7 @@ fn ssa_to_acir_program(ssa: Ssa) -> AcirProgram { return AcirProgram { functions: functions, unconstrained_functions: brillig }; } +/// Creates an SSA function for binary operations fn binary_function(op: BinaryOp, first_variable_type: Type, second_variable_type: Type) -> Ssa { // returns v0 op v1 let main_id = Id::new(0); @@ -191,11 +228,12 @@ fn binary_function(op: BinaryOp, first_variable_type: Type, second_variable_type builder.terminate_with_return(vec![v2]); let func = builder.finish(); - // remove_bit_shifts doesnt remove bit shifts, it replaces it with something smart + // remove_bit_shifts replaces bit shifts with equivalent arithmetic operations let cleared_func = func.remove_bit_shifts(); return cleared_func; } +/// Creates an SSA function for constraint operations fn constrain_function(variable_type: Type) -> Ssa { // constrains v0 == v1, returns v1 let main_id = Id::new(0); @@ -209,6 +247,7 @@ fn constrain_function(variable_type: Type) -> Ssa { return builder.finish(); } +/// Creates an SSA function for range check operations fn range_check_function(variable_type: Type) -> Ssa { let main_id = Id::new(0); let mut builder = FunctionBuilder::new("main".into(), main_id); @@ -220,6 +259,7 @@ fn range_check_function(variable_type: Type) -> Ssa { return builder.finish() } +/// Creates an SSA function for truncate operations fn truncate_function(variable_type: Type) -> Ssa { // truncate v0: field 10, 20?.. let main_id = Id::new(0); @@ -232,6 +272,7 @@ fn truncate_function(variable_type: Type) -> Ssa { return builder.finish(); } +/// Creates an SSA function for NOT operations fn not_function(variable_type: Type) -> Ssa { // returns not v0 let main_id = Id::new(0); diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/.gitignore b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/.gitignore index 6c7b7f9b99c..03314f77b5a 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/.gitignore +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/.gitignore @@ -1,2 +1 @@ Cargo.lock -artifacts/* diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md index 886659cb5d0..dc1bbd8ec5e 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md @@ -1,5 +1,25 @@ -# WHY -USED FOR FORMAL VERIFYING SSA INSTRUCTIONS PRODUCED BY THE CONVERSION SSA->ACIR +# SSA Test Generator -# how -`mkdir artifacts && cargo run && mkdir ../../../../../barretenberg/cpp/src/barretenberg/acir_formal_proofs/artifacts/ && cp artifacts/* ../../../../../barretenberg/cpp/src/barretenberg/acir_formal_proofs/artifacts/` +This tool generates test artifacts for formally verifying SSA instructions and their conversion to ACIR . + +## Purpose + +The test generator creates test cases for: + +- Bitvector operations (up to 127 bits): add, sub, mul, mod, xor, and, div, eq, lt, not, etc. +- Shift operations (tested with smaller bit sizes 32 and 64): shl, shr +- Binary operations (32-bit): xor, and, or +- Field operations: add, mul, div +- Signed integer operations: div (126-bit) + +Each test case generates: +- Formatted SSA representation +- Serialized ACIR output + +## Usage + +Run the generator and copy artifacts to barretenberg: + +```bash +cargo run && cp artifacts/* ../../../../../barretenberg/cpp/src/barretenberg/acir_formal_proofs/artifacts/ +``` diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs index da9352298e8..3e7e1655a5f 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs @@ -7,6 +7,7 @@ use::noirc_evaluator::acir_instruction_builder::{ InstructionArtifacts, VariableType, Variable }; +/// Decompresses gzipped data into a byte vector fn ungzip(compressed_data: Vec) -> Vec { let mut decompressed_data: Vec = Vec::new(); let mut decoder = GzDecoder::new(&compressed_data[..]); @@ -14,6 +15,7 @@ fn ungzip(compressed_data: Vec) -> Vec { return decompressed_data; } +/// Saves byte data to a file at the specified path fn save_to_file(data: &[u8], filename: &str) -> Result<(), std::io::Error> { let path = Path::new(filename); let mut file = File::create(path)?; @@ -21,6 +23,8 @@ fn save_to_file(data: &[u8], filename: &str) -> Result<(), std::io::Error> { Ok(()) } +/// Saves instruction artifacts to files in the artifacts directory +/// Prints the formatted SSA for each artifact and saves the decompressed ACIR fn save_artifacts(all_artifacts: Vec) { for artifacts in all_artifacts.iter() { println!("{}", artifacts.formatted_ssa); @@ -33,27 +37,62 @@ fn save_artifacts(all_artifacts: Vec) { } } +/// Main function that generates test artifacts for SSA instructions +/// Creates test cases for various operations with different variable types and bit sizes fn main() { let mut all_artifacts: Vec = Vec::new(); - let u64_var = Variable{ variable_type: VariableType::Unsigned, variable_size: 32}; + + // Define test variables with different types and sizes + let field_var = Variable{ variable_type: VariableType::Field, variable_size: 0}; + // max bit size for signed and unsigned + let u127_var = Variable{ variable_type: VariableType::Unsigned, variable_size: 127}; + // max bit size allowed by mod and div + let u126_var = Variable{ variable_type: VariableType::Unsigned, variable_size: 126}; + let i126_var = Variable{ variable_type: VariableType::Signed, variable_size: 126}; + // 64 bit unsigned + let u64_var = Variable{ variable_type: VariableType::Unsigned, variable_size: 64}; + // 32 bit unsigned + let u32_var = Variable{ variable_type: VariableType::Unsigned, variable_size: 32}; + // 8 bit unsigned let u8_var = Variable{ variable_type: VariableType::Unsigned, variable_size: 8}; - all_artifacts.push(InstructionArtifacts::new_add(&u64_var, &u64_var)); - all_artifacts.push(InstructionArtifacts::new_sub(&u64_var, &u64_var)); - all_artifacts.push(InstructionArtifacts::new_mul(&u64_var, &u64_var)); - all_artifacts.push(InstructionArtifacts::new_mod(&u64_var, &u64_var)); - all_artifacts.push(InstructionArtifacts::new_xor(&u64_var, &u64_var)); - all_artifacts.push(InstructionArtifacts::new_and(&u64_var, &u64_var)); - all_artifacts.push(InstructionArtifacts::new_div(&u64_var, &u64_var)); - all_artifacts.push(InstructionArtifacts::new_eq(&u64_var, &u64_var)); - all_artifacts.push(InstructionArtifacts::new_lt(&u64_var, &u64_var)); - all_artifacts.push(InstructionArtifacts::new_and(&u64_var, &u64_var)); - all_artifacts.push(InstructionArtifacts::new_xor(&u64_var, &u64_var)); - all_artifacts.push(InstructionArtifacts::new_or(&u64_var, &u64_var)); + + // Test bitvector operations with max bit size (127 bits) + all_artifacts.push(InstructionArtifacts::new_add(&u127_var, &u127_var)); + all_artifacts.push(InstructionArtifacts::new_sub(&u127_var, &u127_var)); + all_artifacts.push(InstructionArtifacts::new_mul(&u127_var, &u127_var)); + all_artifacts.push(InstructionArtifacts::new_mod(&u126_var, &u126_var)); + all_artifacts.push(InstructionArtifacts::new_xor(&u127_var, &u127_var)); + all_artifacts.push(InstructionArtifacts::new_and(&u127_var, &u127_var)); + all_artifacts.push(InstructionArtifacts::new_div(&u126_var, &u126_var)); + all_artifacts.push(InstructionArtifacts::new_eq(&u127_var, &u127_var)); + all_artifacts.push(InstructionArtifacts::new_lt(&u127_var, &u127_var)); + all_artifacts.push(InstructionArtifacts::new_xor(&u127_var, &u127_var)); + all_artifacts.push(InstructionArtifacts::new_or(&u127_var, &u127_var)); + all_artifacts.push(InstructionArtifacts::new_not(&u127_var)); + all_artifacts.push(InstructionArtifacts::new_constrain(&u127_var)); + all_artifacts.push(InstructionArtifacts::new_truncate(&u127_var)); + all_artifacts.push(InstructionArtifacts::new_range_check(&u127_var)); + + // Test shift operations with smaller bit sizes + // shl truncates variable, so test different sizes + // Too heavy to test 127 bits, but it just multiplies or divides by 2^rhs + // Should work the same if div and mul are verified all_artifacts.push(InstructionArtifacts::new_shl(&u64_var, &u8_var)); all_artifacts.push(InstructionArtifacts::new_shr(&u64_var, &u8_var)); - all_artifacts.push(InstructionArtifacts::new_not(&u64_var)); - all_artifacts.push(InstructionArtifacts::new_constrain(&u64_var)); - all_artifacts.push(InstructionArtifacts::new_truncate(&u64_var)); - all_artifacts.push(InstructionArtifacts::new_range_check(&u64_var)); + all_artifacts.push(InstructionArtifacts::new_shl(&u32_var, &u8_var)); + + // Test binary operations with 32 bits + all_artifacts.push(InstructionArtifacts::new_xor(&u32_var, &u32_var)); + all_artifacts.push(InstructionArtifacts::new_and(&u32_var, &u32_var)); + all_artifacts.push(InstructionArtifacts::new_or(&u32_var, &u32_var)); + + // Test field operations + all_artifacts.push(InstructionArtifacts::new_add(&field_var, &field_var)); + all_artifacts.push(InstructionArtifacts::new_mul(&field_var, &field_var)); + all_artifacts.push(InstructionArtifacts::new_div(&field_var, &field_var)); + + // Test signed division (only operation that differs for signed integers) + all_artifacts.push(InstructionArtifacts::new_div(&i126_var, &i126_var)); + save_artifacts(all_artifacts); } From 884b2aaa0023999d5483d920e7790f92c38e0f70 Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Fri, 27 Dec 2024 13:56:09 +0000 Subject: [PATCH 24/32] readme mistake, artifacts dirs --- barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md | 3 ++- .../src/barretenberg/acir_formal_proofs/artifacts/.gitignore | 3 +++ .../compiler/noirc_evaluator/ssa_test/artifacts/.gitignore | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/artifacts/.gitignore create mode 100644 noir/noir-repo/compiler/noirc_evaluator/ssa_test/artifacts/.gitignore diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md index 8b33dd642ec..8df798a6a4f 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md @@ -14,6 +14,7 @@ The verifier uses SMT (Satisfiability Modulo Theories) solving to formally verif ## Tests +⚠️ **WARNING**: Do not run these tests on a local machine without sufficient memory (>32GB RAM). The tests can consume large amounts of memory and CPU resources. Some tests like integer division can run for multiple days. It is recommended to run these tests in a controlled environment with adequate resources. The test suite verifies correctness of ACIR operations through SMT solving: ### Arithmetic Tests @@ -40,6 +41,6 @@ The test suite verifies correctness of ACIR operations through SMT solving: - `uint_terms_eq`: Tests 127-bit unsigned equality comparison. Verifies both equal and unequal cases. Execution time: ~22.8s - `uint_terms_lt`: Tests 127-bit unsigned less than comparison. Verifies both a < b and a >= b cases. Execution time: ~56.7s -Each test attempts to find counterexamples that violate the expected behavior. A failing test indicates the operation is correctly implemented, while a passing test reveals potential issues. +Each test attempts to find counterexamples that violate the expected behavior. A passing test indicates the operation is correctly implemented, while a failing test reveals potential issues. *Note: The bitwise tests are not working yet. (probably because of bug in the SMT solver). It works only for variables with 32 bits. diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/artifacts/.gitignore b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/artifacts/.gitignore new file mode 100644 index 00000000000..25a0286f10d --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/artifacts/.gitignore @@ -0,0 +1,3 @@ +*acir* +*witness* +!.gitignore diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/artifacts/.gitignore b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/artifacts/.gitignore new file mode 100644 index 00000000000..25a0286f10d --- /dev/null +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/artifacts/.gitignore @@ -0,0 +1,3 @@ +*acir* +*witness* +!.gitignore From ef9c730f9387d24c8bf49dc3fb8d57d50eaada0f Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Fri, 27 Dec 2024 14:06:29 +0000 Subject: [PATCH 25/32] restore cmake list --- barretenberg/cpp/src/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/barretenberg/cpp/src/CMakeLists.txt b/barretenberg/cpp/src/CMakeLists.txt index 7228ca38950..7f2265e1f8f 100644 --- a/barretenberg/cpp/src/CMakeLists.txt +++ b/barretenberg/cpp/src/CMakeLists.txt @@ -98,9 +98,9 @@ add_subdirectory(barretenberg/wasi) add_subdirectory(barretenberg/world_state) add_subdirectory(barretenberg/acir_formal_proofs) - -add_subdirectory(barretenberg/smt_verification) - +if(SMT) + add_subdirectory(barretenberg/smt_verification) +endif() add_subdirectory(barretenberg/benchmark) From 208f9cef776d29d71d2bb997ffee344097b509fb Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Fri, 27 Dec 2024 14:28:01 +0000 Subject: [PATCH 26/32] bug in verify_mod --- .../barretenberg/acir_formal_proofs/README.md | 14 +++++++++----- .../acir_formal_proofs/acir_loader.test.cpp | 2 +- .../acir_formal_proofs/formal_proofs.cpp | 16 +++------------- .../barretenberg/acir_formal_proofs/helpers.cpp | 2 +- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md index 8df798a6a4f..ae8fb7154b1 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md @@ -18,29 +18,33 @@ The verifier uses SMT (Satisfiability Modulo Theories) solving to formally verif The test suite verifies correctness of ACIR operations through SMT solving: ### Arithmetic Tests + - `uint_terms_add`: Tests 127-bit unsigned addition. Execution time: ~2.8s - `uint_terms_sub`: Tests 127-bit unsigned subtraction. Execution time: ~2.6s - `uint_terms_mul`: Tests 127-bit unsigned multiplication. Execution time: ~10.0s - `uint_terms_div`: Tests 126-bit unsigned division - `integer_terms_div`: Tests 126-bit signed division. Execution time: >10 days - `field_terms_div`: Tests field division. Execution time: ~0.22s -- `uint_terms_mod`: Tests 126-bit unsigned modulo. Execution time: ~0.354s +- `uint_terms_mod`: Tests 126-bit unsigned modulo. Execution time: ??? ### Bitwise Tests -- `uint_terms_and`: Tests 127-bit unsigned bitwise AND DOESNT WORK* -- `uint_terms_or`: Tests 127-bit unsigned bitwise OR DOESNT WORK* -- `uint_terms_xor`: Tests 127-bit unsigned bitwise XOR DOESNT WORK* + +- `uint_terms_and`: Tests 127-bit unsigned bitwise AND DOESNT WORK\* +- `uint_terms_or`: Tests 127-bit unsigned bitwise OR DOESNT WORK\* +- `uint_terms_xor`: Tests 127-bit unsigned bitwise XOR DOESNT WORK\* - `uint_terms_not`: Tests 127-bit unsigned bitwise NOT ### Shift Tests + - `uint_terms_shl32`: Tests 32-bit left shift. Execution time: ~4574s, Memory: ~30GB - `uint_terms_shl64`: Tests 64-bit left shift. Execution time: ~4588s, Memory: ~30GB - `uint_terms_shr`: Tests right shift. Execution time: ~3927.88s, Memory: ~10GB ### Comparison Tests + - `uint_terms_eq`: Tests 127-bit unsigned equality comparison. Verifies both equal and unequal cases. Execution time: ~22.8s - `uint_terms_lt`: Tests 127-bit unsigned less than comparison. Verifies both a < b and a >= b cases. Execution time: ~56.7s Each test attempts to find counterexamples that violate the expected behavior. A passing test indicates the operation is correctly implemented, while a failing test reveals potential issues. -*Note: The bitwise tests are not working yet. (probably because of bug in the SMT solver). It works only for variables with 32 bits. +\*Note: The bitwise tests are not working yet. (probably because of bug in the SMT solver). It works only for variables with 32 bits. diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp index 6e2a4eab9d0..75bdfe52d1c 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp @@ -173,7 +173,7 @@ TEST(acir_formal_proofs, uint_terms_lt) /** * @brief Tests 126-bit unsigned modulo * Verifies that the ACIR implementation of modulo is correct - * Execution time: ~0.354 seconds on SMTBOX + * Execution time: ??? seconds on SMTBOX */ TEST(acir_formal_proofs, uint_terms_mod) { diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.cpp index 0102efe5d3a..84a13e2ec17 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.cpp @@ -59,10 +59,6 @@ bool verify_mul(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) bool verify_div(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) { - // c = a / b - // a - c * b = a mod b - // t = a % b - // a - c * b == t auto a = circuit["a"]; auto b = circuit["b"]; auto c = circuit["c"]; @@ -98,17 +94,11 @@ bool verify_mod(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) auto a = circuit["a"]; auto b = circuit["b"]; auto c = circuit["c"]; - // c = a mod b - // k * b + c = a - // k = (a - c) / b - // (a - c) * b + c * b == a * b - smt_circuit::STerm c1 = (a - c) * b + c * b; - smt_circuit::STerm c2 = a * b; - c1 != c2; + smt_circuit::STerm c1 = a % b; + c != c1; bool res = solver->check(); if (res) { - std::unordered_map terms( - { { "a", a }, { "b", b }, { "c", c }, { "c1", c1 }, { "c2", c2 } }); + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "c1", c1 } }); debug_solution(solver, terms); } return res; diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.cpp index 511b64c2481..a3ab02b5f58 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/helpers.cpp @@ -2,7 +2,7 @@ #include "barretenberg/smt_verification/solver/solver.hpp" #include "barretenberg/smt_verification/util/smt_util.hpp" -// used for base = 2 exp < 256 so its okay +// used for base = 2; exp <= 8 so its okay uint32_t pow_num(uint32_t base, uint32_t exp) { uint32_t res = 1; From 97bfad15a0d3780cae42fa23af7cc2a4f95b3f32 Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Fri, 27 Dec 2024 14:31:39 +0000 Subject: [PATCH 27/32] still bug in verify_mod --- .../cpp/src/barretenberg/acir_formal_proofs/README.md | 2 +- .../src/barretenberg/acir_formal_proofs/formal_proofs.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md index ae8fb7154b1..0c8fc5a41c2 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md @@ -25,7 +25,7 @@ The test suite verifies correctness of ACIR operations through SMT solving: - `uint_terms_div`: Tests 126-bit unsigned division - `integer_terms_div`: Tests 126-bit signed division. Execution time: >10 days - `field_terms_div`: Tests field division. Execution time: ~0.22s -- `uint_terms_mod`: Tests 126-bit unsigned modulo. Execution time: ??? +- `uint_terms_mod`: Tests 126-bit unsigned modulo. Execution time: ???. Unknown time due to bug found during reviewing. ### Bitwise Tests diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.cpp index 84a13e2ec17..9fca18e3815 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.cpp @@ -94,11 +94,13 @@ bool verify_mod(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) auto a = circuit["a"]; auto b = circuit["b"]; auto c = circuit["c"]; - smt_circuit::STerm c1 = a % b; - c != c1; + smt_circuit::STerm c1 = a / b; + smt_circuit::STerm c2 = a - c1 * b; + c != c2; bool res = solver->check(); if (res) { - std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "c1", c1 } }); + std::unordered_map terms( + { { "a", a }, { "b", b }, { "c", c }, { "c1", c1 }, { "c2", c2 } }); debug_solution(solver, terms); } return res; From 1c908455f212468a2e7fca692455ba1f708cf9b6 Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Mon, 6 Jan 2025 09:00:47 +0000 Subject: [PATCH 28/32] deleted gitignores + table + shl64 bug + directory flag for binary --- .../acir_formal_proofs/.gitignore | 0 .../barretenberg/acir_formal_proofs/README.md | 28 +++++ .../acir_formal_proofs/acir_loader.test.cpp | 96 +++++++++++++-- .../acir_formal_proofs/artifacts/.gitignore | 3 - .../acir_formal_proofs/formal_proofs.cpp | 10 +- .../smt_verification/solver/solver.cpp | 6 + .../smt_verification/terms/term.cpp | 10 ++ .../smt_verification/terms/term.hpp | 1 + .../noirc_evaluator/ssa_test/Cargo.lock | 116 +++++++++++++++++- .../noirc_evaluator/ssa_test/Cargo.toml | 1 + .../noirc_evaluator/ssa_test/README.md | 8 +- .../ssa_test/artifacts/.gitignore | 3 - .../noirc_evaluator/ssa_test/src/main.rs | 19 ++- 13 files changed, 273 insertions(+), 28 deletions(-) delete mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/.gitignore delete mode 100644 barretenberg/cpp/src/barretenberg/acir_formal_proofs/artifacts/.gitignore delete mode 100644 noir/noir-repo/compiler/noirc_evaluator/ssa_test/artifacts/.gitignore diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/.gitignore b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/.gitignore deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md index 0c8fc5a41c2..87ae91212b5 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md @@ -15,6 +15,34 @@ The verifier uses SMT (Satisfiability Modulo Theories) solving to formally verif ## Tests ⚠️ **WARNING**: Do not run these tests on a local machine without sufficient memory (>32GB RAM). The tests can consume large amounts of memory and CPU resources. Some tests like integer division can run for multiple days. It is recommended to run these tests in a controlled environment with adequate resources. + +### Results + +| Opcode | Lhs type/size | Rhs type/size | Time/seconds | Memory/GB | Success | SMT Term Type | Reason | +| ----------- | ------------- | ------------- | ------------ | --------- | ------- | ---------------- | -------------------------- | +| Binary::Add | Field | Field | 0.024 | - | ✓ | TermType::FFTerm | | +| Binary::Add | Unsigned_127 | Unsigned_127 | 2.8 | - | ✓ | TermType::BVTerm | | +| Binary::And | Unsigned_32 | Unsigned_32 | 6.7 | - | ✓ | TermType::BVTerm | | +| Binary::And | Unsigned_127 | Unsigned_127 | 7.5 | - | ✗ | TermType::BVTerm | Probably bug in smt solver | +| Binary::Div | Field | Field | 0.024 | - | ✓ | TermType::FFTerm | | +| Binary::Div | Unsigned_126 | Unsigned_126 | 402.7 | 3.5 | ✗ | TermType::BVTerm | ?? | +| Binary::Div | Signed_126 | Signed_126 | >17 days | 5.1 | ✗ | TermType::ITerm | Test takes too long | +| Binary::Eq | Field | Field | 19.2 | - | ✓ | TermType::FFTerm | | +| Binary::Eq | Unsigned_127 | Unsigned_127 | 22.8 | - | ✓ | TermType::BVTerm | | +| Binary::Lt | Unsigned_127 | Unsigned_127 | 56.7 | - | ✓ | TermType::BVTerm | | +| Binary::Mod | Unsigned_127 | Unsigned_127 | - | 3.2 | ✗ | TermType::BVTerm | ?? | +| Binary::Mul | Field | Field | 0.024 | - | ✓ | TermType::FFTerm | | +| Binary::Mul | Unsigned_127 | Unsigned_127 | 10.0 | - | ✓ | TermType::BVTerm | | +| Binary::Or | Unsigned_32 | Unsigned_32 | 18.0 | - | ✓ | TermType::BVTerm | | +| Binary::Or | Unsigned_127 | Unsigned_127 | 7.5 | - | ✗ | TermType::BVTerm | Probably bug in smt solver | +| Binary::Shl | Unsigned_64 | Unsigned_8 | 42331.61 | 63.2 | ✓ | TermType::BVTerm | | +| Binary::Shl | Unsigned_32 | Unsigned_8 | 4574.0 | 30 | ✓ | TermType::BVTerm | | +| Binary::Shr | Unsigned_64 | Unsigned_8 | 3927.88 | 10 | ✓ | TermType::BVTerm | | +| Binary::Sub | Unsigned_127 | Unsigned_127 | 3.3 | - | ✓ | TermType::BVTerm | | +| Binary::Xor | Unsigned_32 | Unsigned_32 | 14.7 | - | ✓ | TermType::BVTerm | | +| Binary::Xor | Unsigned_127 | Unsigned_127 | 7.5 | - | ✗ | TermType::BVTerm | Probably bug in smt solver | +| Not | Unsigned_127 | - | 0.2 | - | ✓ | TermType::BVTerm | | + The test suite verifies correctness of ACIR operations through SMT solving: ### Arithmetic Tests diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp index 75bdfe52d1c..67cf4ac6457 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp @@ -93,6 +93,24 @@ TEST(acir_formal_proofs, uint_terms_and) } } +/** + * @brief Tests 32-bit unsigned bitwise AND + * Verifies that the ACIR implementation of AND is correct + * Execution time: ~6.7 seconds on SMTBOX + */ +TEST(acir_formal_proofs, uint_terms_and32) +{ + std::string TESTNAME = "Binary::And_Unsigned_32_Unsigned_32"; + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_bitvec_smt_circuit(&solver); + bool res = verify_and(&solver, circuit); + EXPECT_FALSE(res); + if (res) { + save_buggy_witness(TESTNAME, circuit); + } +} + /** * @brief Tests 126-bit unsigned division * Verifies that the ACIR implementation of division is correct @@ -145,7 +163,7 @@ TEST(acir_formal_proofs, uint_terms_eq) * Verifies two cases: * 1. When a < b, result must be 0 * 2. When a >= b, result must be 1 - * Execution time: ~56.7 seconds on SMTBOX + * Execution time: ~81.7 seconds on SMTBOX */ TEST(acir_formal_proofs, uint_terms_lt) { @@ -224,6 +242,24 @@ TEST(acir_formal_proofs, uint_terms_or) } } +/** + * @brief Tests 32-bit unsigned bitwise OR + * Verifies that the ACIR implementation of OR is correct + * Execution time: ~20.3 seconds on SMTBOX + */ +TEST(acir_formal_proofs, uint_terms_or32) +{ + std::string TESTNAME = "Binary::Or_Unsigned_32_Unsigned_32"; + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_bitvec_smt_circuit(&solver); + bool res = verify_or(&solver, circuit); + EXPECT_FALSE(res); + if (res) { + save_buggy_witness(TESTNAME, circuit); + } +} + /** * @brief Tests 64-bit left shift * Verifies that the ACIR implementation of left shift is correct @@ -232,7 +268,7 @@ TEST(acir_formal_proofs, uint_terms_or) */ TEST(acir_formal_proofs, uint_terms_shl64) { - std::string TESTNAME = "Binary::Shl_Unsigned_32_Unsigned_8"; + std::string TESTNAME = "Binary::Shl_Unsigned_64_Unsigned_8"; AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); smt_solver::Solver solver = loader.get_smt_solver(); smt_circuit::UltraCircuit circuit = loader.get_bitvec_smt_circuit(&solver); @@ -316,9 +352,27 @@ TEST(acir_formal_proofs, uint_terms_xor) } } +/** + * @brief Tests 32-bit unsigned bitwise XOR + * Verifies that the ACIR implementation of XOR is correct + */ +TEST(acir_formal_proofs, uint_terms_xor32) +{ + std::string TESTNAME = "Binary::Xor_Unsigned_32_Unsigned_32"; + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); + smt_solver::Solver solver = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit = loader.get_bitvec_smt_circuit(&solver); + bool res = verify_xor(&solver, circuit); + EXPECT_FALSE(res); + if (res) { + save_buggy_witness(TESTNAME, circuit); + } +} + /** * @brief Tests 127-bit unsigned bitwise NOT * Verifies that the ACIR implementation of NOT is correct + * Execution time: ~21.3 seconds on SMTBOX */ TEST(acir_formal_proofs, uint_terms_not) { @@ -369,6 +423,36 @@ TEST(acir_formal_proofs, field_terms_div) } } +/** + * @brief Tests field equality comparison + * Verifies two cases: + * 1. When operands are equal, result must be 0 + * 2. When operands are not equal, result must be 1 + * Execution time: ~19.2 seconds on SMTBOX + */ +TEST(acir_formal_proofs, field_terms_eq) +{ + std::string TESTNAME = "Binary::Eq_Field_0_Field_0"; + AcirToSmtLoader loader = AcirToSmtLoader(ARTIFACTS_PATH + TESTNAME + ".acir"); + smt_solver::Solver solver1 = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit1 = loader.get_field_smt_circuit(&solver1); + + bool res1 = verify_eq_on_equlaity(&solver1, circuit1); + EXPECT_FALSE(res1); + if (res1) { + save_buggy_witness(TESTNAME, circuit1); + } + + smt_solver::Solver solver2 = loader.get_smt_solver(); + smt_circuit::UltraCircuit circuit2 = loader.get_field_smt_circuit(&solver2); + + bool res2 = verify_eq_on_inequlaity(&solver2, circuit2); + EXPECT_FALSE(res2); + if (res2) { + save_buggy_witness(TESTNAME, circuit2); + } +} + /** * @brief Tests field multiplication * Verifies that the ACIR implementation of field multiplication is correct @@ -390,7 +474,7 @@ TEST(acir_formal_proofs, field_terms_mul) /** * @brief Tests 126-bit signed division * Verifies that the ACIR implementation of signed division is correct - * Execution time: >10 DAYS on SMTBOX + * Execution time: >17 DAYS on SMTBOX */ TEST(acir_formal_proofs, integer_terms_div) { @@ -403,10 +487,4 @@ TEST(acir_formal_proofs, integer_terms_div) if (res) { save_buggy_witness(TESTNAME, circuit); } -} - -TEST(acir_formal_proofs, verify_div_bug) -{ - std::string name = "Binary::Div_Unsigned_126_Unsigned_126"; - EXPECT_TRUE(verify_buggy_witness(name)); } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/artifacts/.gitignore b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/artifacts/.gitignore deleted file mode 100644 index 25a0286f10d..00000000000 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/artifacts/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*acir* -*witness* -!.gitignore diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.cpp index 9fca18e3815..4c8bc12ee6b 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/formal_proofs.cpp @@ -94,13 +94,11 @@ bool verify_mod(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) auto a = circuit["a"]; auto b = circuit["b"]; auto c = circuit["c"]; - smt_circuit::STerm c1 = a / b; - smt_circuit::STerm c2 = a - c1 * b; - c != c2; + smt_circuit::STerm c1 = a % b; + c != c1; bool res = solver->check(); if (res) { - std::unordered_map terms( - { { "a", a }, { "b", b }, { "c", c }, { "c1", c1 }, { "c2", c2 } }); + std::unordered_map terms({ { "a", a }, { "b", b }, { "c", c }, { "c1", c1 } }); debug_solution(solver, terms); } return res; @@ -188,7 +186,7 @@ bool verify_shl64(smt_solver::Solver* solver, smt_circuit::UltraCircuit circuit) auto a = circuit["a"]; auto b = circuit["b"]; auto c = circuit["c"]; - auto cr = shl32(a, b, solver); + auto cr = shl64(a, b, solver); c != cr; bool res = solver->check(); if (res) { diff --git a/barretenberg/cpp/src/barretenberg/smt_verification/solver/solver.cpp b/barretenberg/cpp/src/barretenberg/smt_verification/solver/solver.cpp index 2219a05b0d4..943291bbf63 100644 --- a/barretenberg/cpp/src/barretenberg/smt_verification/solver/solver.cpp +++ b/barretenberg/cpp/src/barretenberg/smt_verification/solver/solver.cpp @@ -172,6 +172,9 @@ std::string Solver::stringify_term(const cvc5::Term& term, bool parenthesis) child_parenthesis = false; break; case cvc5::Kind::LT: + case cvc5::Kind::BITVECTOR_UDIV: + op = " / "; + break; case cvc5::Kind::BITVECTOR_ULT: op = " < "; break; @@ -187,6 +190,9 @@ std::string Solver::stringify_term(const cvc5::Term& term, bool parenthesis) case cvc5::Kind::BITVECTOR_UGE: op = " >= "; break; + case cvc5::Kind::BITVECTOR_UREM: + op = " % "; + break; case cvc5::Kind::XOR: case cvc5::Kind::BITVECTOR_XOR: op = " ^ "; diff --git a/barretenberg/cpp/src/barretenberg/smt_verification/terms/term.cpp b/barretenberg/cpp/src/barretenberg/smt_verification/terms/term.cpp index d47851d5bef..cb55e0eed65 100644 --- a/barretenberg/cpp/src/barretenberg/smt_verification/terms/term.cpp +++ b/barretenberg/cpp/src/barretenberg/smt_verification/terms/term.cpp @@ -266,6 +266,16 @@ void STerm::operator>=(const bb::fr& other) const this->solver->assertFormula(ge); } +STerm STerm::operator%(const STerm& other) const +{ + if (!this->operations.contains(OpType::MOD)) { + info("MOD is not compatible with ", this->type); + return *this; + } + cvc5::Term res = solver->term_manager.mkTerm(this->operations.at(OpType::MOD), { this->term, other.term }); + return { res, this->solver, this->type }; +} + STerm STerm::operator^(const STerm& other) const { if (!this->operations.contains(OpType::XOR)) { diff --git a/barretenberg/cpp/src/barretenberg/smt_verification/terms/term.hpp b/barretenberg/cpp/src/barretenberg/smt_verification/terms/term.hpp index 1803e7825fd..a9ac3b56a47 100644 --- a/barretenberg/cpp/src/barretenberg/smt_verification/terms/term.hpp +++ b/barretenberg/cpp/src/barretenberg/smt_verification/terms/term.hpp @@ -164,6 +164,7 @@ class STerm { void operator|=(const STerm& other); void operator<(const STerm& other) const; void operator>(const STerm& other) const; + STerm operator%(const STerm& other) const; STerm operator~() const; STerm operator<<(const uint32_t& n) const; void operator<<=(const uint32_t& n); diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock index 4b76160736d..256f99475b9 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock @@ -99,6 +99,55 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" + +[[package]] +name = "anstyle-parse" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" +dependencies = [ + "anstyle", + "windows-sys", +] + [[package]] name = "ark-bn254" version = "0.4.0" @@ -389,6 +438,46 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "clap" +version = "4.5.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "clap_lex" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" + [[package]] name = "codespan" version = "0.11.1" @@ -410,6 +499,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "colorchoice" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" + [[package]] name = "const-oid" version = "0.9.6" @@ -723,6 +818,12 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hex" version = "0.4.3" @@ -804,6 +905,12 @@ dependencies = [ "serde", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "iter-extended" version = "0.39.0" @@ -1425,6 +1532,7 @@ dependencies = [ name = "ssa_test" version = "0.1.0" dependencies = [ + "clap", "flate2", "noirc_evaluator", "serde", @@ -1449,7 +1557,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", @@ -1593,6 +1701,12 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "version_check" version = "0.9.5" diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml index 2655d46fb7d..497f1baeab2 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml @@ -8,4 +8,5 @@ noirc_evaluator = {path = "../"} serde = "1.0.214" serde_json = "1.0.120" flate2 = "1.0.35" +clap = { version = "4.4.11", features = ["derive"] } [workspace] diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md index dc1bbd8ec5e..a2e3b47af72 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md @@ -1,6 +1,6 @@ # SSA Test Generator -This tool generates test artifacts for formally verifying SSA instructions and their conversion to ACIR . +This tool generates test artifacts for formally verifying SSA instructions and their conversion to ACIR. ## Purpose @@ -18,8 +18,10 @@ Each test case generates: ## Usage -Run the generator and copy artifacts to barretenberg: +Run the generator with the desired output directory. The directory can be specified using the `-d` or `--dir` flag: ```bash -cargo run && cp artifacts/* ../../../../../barretenberg/cpp/src/barretenberg/acir_formal_proofs/artifacts/ +cargo run -- -d /path/to/output/directory/ ``` + +DON'T FORGET TO CHANGE ARTIFACTS_PATH IN barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp TO THE NEW OUTPUT DIRECTORY. \ No newline at end of file diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/artifacts/.gitignore b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/artifacts/.gitignore deleted file mode 100644 index 25a0286f10d..00000000000 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/artifacts/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*acir* -*witness* -!.gitignore diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs index 3e7e1655a5f..dc02e9b3aa6 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs @@ -6,6 +6,14 @@ use flate2::read::GzDecoder; use::noirc_evaluator::acir_instruction_builder::{ InstructionArtifacts, VariableType, Variable }; +use clap::Parser; + +#[derive(Parser)] +#[command(author, version, about, long_about = None)] +struct Args { + #[arg(short, long, default_value = "../../../../../barretenberg/cpp/src/barretenberg/acir_formal_proofs/artifacts/")] + dir: String, +} /// Decompresses gzipped data into a byte vector fn ungzip(compressed_data: Vec) -> Vec { @@ -25,10 +33,10 @@ fn save_to_file(data: &[u8], filename: &str) -> Result<(), std::io::Error> { /// Saves instruction artifacts to files in the artifacts directory /// Prints the formatted SSA for each artifact and saves the decompressed ACIR -fn save_artifacts(all_artifacts: Vec) { +fn save_artifacts(all_artifacts: Vec, dir: &str) { for artifacts in all_artifacts.iter() { println!("{}", artifacts.formatted_ssa); - let filename = format!("artifacts/{}{}", artifacts.instruction_name, ".acir"); + let filename = format!("{}{}{}", dir, artifacts.instruction_name, ".acir"); let acir = &artifacts.serialized_acir; match save_to_file(&ungzip(acir.clone()), &filename) { Ok(_) => (), @@ -40,12 +48,15 @@ fn save_artifacts(all_artifacts: Vec) { /// Main function that generates test artifacts for SSA instructions /// Creates test cases for various operations with different variable types and bit sizes fn main() { + let args = Args::parse(); + let mut all_artifacts: Vec = Vec::new(); // Define test variables with different types and sizes let field_var = Variable{ variable_type: VariableType::Field, variable_size: 0}; // max bit size for signed and unsigned let u127_var = Variable{ variable_type: VariableType::Unsigned, variable_size: 127}; + let i127_var = Variable{ variable_type: VariableType::Signed, variable_size: 127}; // max bit size allowed by mod and div let u126_var = Variable{ variable_type: VariableType::Unsigned, variable_size: 126}; let i126_var = Variable{ variable_type: VariableType::Signed, variable_size: 126}; @@ -90,9 +101,11 @@ fn main() { all_artifacts.push(InstructionArtifacts::new_add(&field_var, &field_var)); all_artifacts.push(InstructionArtifacts::new_mul(&field_var, &field_var)); all_artifacts.push(InstructionArtifacts::new_div(&field_var, &field_var)); + all_artifacts.push(InstructionArtifacts::new_eq(&field_var, &field_var)); // Test signed division (only operation that differs for signed integers) all_artifacts.push(InstructionArtifacts::new_div(&i126_var, &i126_var)); + all_artifacts.push(InstructionArtifacts::new_lt(&i127_var, &i127_var)); - save_artifacts(all_artifacts); + save_artifacts(all_artifacts, &args.dir); } From 442e38762c36ec75f8379e79349e182fdad94f6f Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Mon, 6 Jan 2025 14:21:30 +0000 Subject: [PATCH 29/32] readme mistake, deleted all noir stuff --- .../barretenberg/acir_formal_proofs/README.md | 6 +- .../acir_formal_proofs/acir_loader.cpp | 3 +- .../src/acir_instruction_builder.rs | 286 --- .../compiler/noirc_evaluator/src/lib.rs | 4 - .../noirc_evaluator/ssa_test/.gitignore | 1 - .../noirc_evaluator/ssa_test/Cargo.lock | 1907 ----------------- .../noirc_evaluator/ssa_test/Cargo.toml | 12 - .../noirc_evaluator/ssa_test/README.md | 27 - .../noirc_evaluator/ssa_test/src/main.rs | 111 - 9 files changed, 5 insertions(+), 2352 deletions(-) delete mode 100644 noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs delete mode 100644 noir/noir-repo/compiler/noirc_evaluator/ssa_test/.gitignore delete mode 100644 noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock delete mode 100644 noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml delete mode 100644 noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md delete mode 100644 noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md index 87ae91212b5..2ef9bdff692 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md @@ -19,18 +19,18 @@ The verifier uses SMT (Satisfiability Modulo Theories) solving to formally verif ### Results | Opcode | Lhs type/size | Rhs type/size | Time/seconds | Memory/GB | Success | SMT Term Type | Reason | -| ----------- | ------------- | ------------- | ------------ | --------- | ------- | ---------------- | -------------------------- | +| ----------- | ------------- | ------------- | ------------ | --------- | ------- | ---------------- | -------------------------- | --- | | Binary::Add | Field | Field | 0.024 | - | ✓ | TermType::FFTerm | | | Binary::Add | Unsigned_127 | Unsigned_127 | 2.8 | - | ✓ | TermType::BVTerm | | | Binary::And | Unsigned_32 | Unsigned_32 | 6.7 | - | ✓ | TermType::BVTerm | | | Binary::And | Unsigned_127 | Unsigned_127 | 7.5 | - | ✗ | TermType::BVTerm | Probably bug in smt solver | | Binary::Div | Field | Field | 0.024 | - | ✓ | TermType::FFTerm | | -| Binary::Div | Unsigned_126 | Unsigned_126 | 402.7 | 3.5 | ✗ | TermType::BVTerm | ?? | +| Binary::Div | Unsigned_126 | Unsigned_126 | 402.7 | 3.5 | ✗ | TermType::BVTerm | Analysis in progress | | Binary::Div | Signed_126 | Signed_126 | >17 days | 5.1 | ✗ | TermType::ITerm | Test takes too long | | Binary::Eq | Field | Field | 19.2 | - | ✓ | TermType::FFTerm | | | Binary::Eq | Unsigned_127 | Unsigned_127 | 22.8 | - | ✓ | TermType::BVTerm | | | Binary::Lt | Unsigned_127 | Unsigned_127 | 56.7 | - | ✓ | TermType::BVTerm | | -| Binary::Mod | Unsigned_127 | Unsigned_127 | - | 3.2 | ✗ | TermType::BVTerm | ?? | +| Binary::Mod | Unsigned_127 | Unsigned_127 | - | 3.2 | ✗ | TermType::BVTerm | Analysis in progress | | Binary::Mul | Field | Field | 0.024 | - | ✓ | TermType::FFTerm | | | Binary::Mul | Unsigned_127 | Unsigned_127 | 10.0 | - | ✓ | TermType::BVTerm | | | Binary::Or | Unsigned_32 | Unsigned_32 | 18.0 | - | ✓ | TermType::BVTerm | | diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp index be5bdeb3e55..f45f9e7aba8 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.cpp @@ -46,7 +46,8 @@ bb::UltraCircuitBuilder AcirToSmtLoader::get_circuit_builder() smt_solver::Solver AcirToSmtLoader::get_smt_solver() { smt_circuit::CircuitSchema circuit_info = smt_circuit_schema::unpack_from_buffer(this->circuit_buf); - // for shl i have variable with bit length 197... for some reason + // In circuits generated by the shift left (shl) opcode, there is a variable with bit length 197. + // This is likely because the shl operation internally calls truncate opcode to handle overflow return smt_solver::Solver(circuit_info.modulus, smt_circuit::default_solver_config, 16, 240); } diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs b/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs deleted file mode 100644 index 04dedcdcac3..00000000000 --- a/noir/noir-repo/compiler/noirc_evaluator/src/acir_instruction_builder.rs +++ /dev/null @@ -1,286 +0,0 @@ -use std::collections::BTreeSet; -use acvm::{ - acir::{ - circuit::{ - Circuit, ExpressionWidth, - Program as AcirProgram - }, - native_types::Witness, - }, - FieldElement, -}; - -use crate::ssa::ssa_gen::Ssa; -use crate::ssa::ir::map::Id; - -use crate::ssa::{ - function_builder::FunctionBuilder, - ir::{instruction::BinaryOp, types::Type}, -}; -use crate::brillig::Brillig; -use serde::{Deserialize, Serialize}; - -/// Represents artifacts generated from compiling an instruction -#[derive(Serialize, Deserialize)] -pub struct InstructionArtifacts { - /// Name of the instruction - pub instruction_name: String, - - /// SSA representation formatted as "acir(inline) {...}" - pub formatted_ssa: String, - - /// JSON serialized SSA - pub serialized_ssa: String, - - /// Gzipped bytes of ACIR program - pub serialized_acir: Vec, -} - -/// Represents the type of a variable in the instruction -#[derive(Debug)] -pub enum VariableType { - /// Field element type - Field, - /// Unsigned integer type - Unsigned, - /// Signed integer type - Signed -} - -/// Represents a variable with its type and size information -pub struct Variable { - /// Type of the variable (Field, Unsigned, or Signed) - pub variable_type: VariableType, - /// Bit size of the variable (ignored for Field type) - pub variable_size: u32, -} - -impl Variable { - /// Gets a string representation of the variable's type and size - pub fn get_name(&self) -> String { - return format!("{:?}_{}", self.variable_type, self.variable_size) - } -} - -impl InstructionArtifacts { - /// Converts a Variable into its corresponding SSA Type - fn get_type(variable: &Variable) -> Type { - match variable.variable_type { - VariableType::Field => Type::field(), - VariableType::Signed => Type::signed(variable.variable_size), - VariableType::Unsigned => Type::unsigned(variable.variable_size) - } - } - - /// Creates a new binary operation instruction artifact - fn new_binary(op: BinaryOp, instruction_name: String, first_variable: &Variable, second_variable: &Variable) -> Self { - let first_variable_type = Self::get_type(first_variable); - let second_variable_type = Self::get_type(second_variable); - let ssa = binary_function(op, first_variable_type, second_variable_type); - let serialized_ssa = &serde_json::to_string(&ssa).unwrap(); - let formatted_ssa = format!("{}", ssa); - - let program = ssa_to_acir_program(ssa); - let serialized_program = AcirProgram::serialize_program(&program); - let name = format!("{}_{}_{}", instruction_name, first_variable.get_name(), second_variable.get_name()); - - Self { - instruction_name: name, - formatted_ssa: formatted_ssa, - serialized_ssa: serialized_ssa.to_string(), - serialized_acir: serialized_program - } - } - - /// Creates a new instruction artifact using a provided SSA generation function - fn new_by_func(ssa_generate_function: fn(Type) -> Ssa, instruction_name: String, variable: &Variable) -> Self { - let variable_type = Self::get_type(variable); - let ssa = ssa_generate_function(variable_type); - let serialized_ssa = &serde_json::to_string(&ssa).unwrap(); - let formatted_ssa = format!("{}", ssa); - - let program = ssa_to_acir_program(ssa); - let serialized_program = AcirProgram::serialize_program(&program); - let name = format!("{}_{}", instruction_name, variable.get_name()); - - Self { - instruction_name: name, - formatted_ssa: formatted_ssa, - serialized_ssa: serialized_ssa.to_string(), - serialized_acir: serialized_program - } - } - - /// Creates a new constrain instruction artifact - pub fn new_constrain(variable: &Variable) -> Self { - return Self::new_by_func(constrain_function, "Constrain".into(), variable) - } - - /// Creates a new NOT operation instruction artifact - pub fn new_not(variable: &Variable) -> Self { - return Self::new_by_func(not_function, "Not".into(), variable) - } - - /// Creates a new range check instruction artifact - pub fn new_range_check(variable: &Variable) -> Self { - return Self::new_by_func(range_check_function, "RangeCheck".into(), variable) - } - - /// Creates a new truncate instruction artifact - pub fn new_truncate(variable: &Variable) -> Self { - return Self::new_by_func(truncate_function, "Truncate".into(), variable) - } - - /// Creates a new ADD operation instruction artifact - pub fn new_add(first_variable: &Variable, second_variable: &Variable) -> Self { - return Self::new_binary(BinaryOp::Add, "Binary::Add".into(), first_variable, second_variable); - } - - /// Creates a new SUB operation instruction artifact - pub fn new_sub(first_variable: &Variable, second_variable: &Variable) -> Self { - return Self::new_binary(BinaryOp::Sub, "Binary::Sub".into(), first_variable, second_variable); - } - - /// Creates a new XOR operation instruction artifact - pub fn new_xor(first_variable: &Variable, second_variable: &Variable) -> Self { - return Self::new_binary(BinaryOp::Xor, "Binary::Xor".into(), first_variable, second_variable); - } - - /// Creates a new AND operation instruction artifact - pub fn new_and(first_variable: &Variable, second_variable: &Variable) -> Self { - return Self::new_binary(BinaryOp::And, "Binary::And".into(), first_variable, second_variable); - } - - /// Creates a new OR operation instruction artifact - pub fn new_or(first_variable: &Variable, second_variable: &Variable) -> Self { - return Self::new_binary(BinaryOp::Or, "Binary::Or".into(), first_variable, second_variable); - } - - /// Creates a new less than operation instruction artifact - pub fn new_lt(first_variable: &Variable, second_variable: &Variable) -> Self { - return Self::new_binary(BinaryOp::Lt, "Binary::Lt".into(), first_variable, second_variable); - } - - /// Creates a new equals operation instruction artifact - pub fn new_eq(first_variable: &Variable, second_variable: &Variable) -> Self { - return Self::new_binary(BinaryOp::Eq, "Binary::Eq".into(), first_variable, second_variable); - } - - /// Creates a new modulo operation instruction artifact - pub fn new_mod(first_variable: &Variable, second_variable: &Variable) -> Self { - return Self::new_binary(BinaryOp::Mod, "Binary::Mod".into(), first_variable, second_variable); - } - - /// Creates a new multiply operation instruction artifact - pub fn new_mul(first_variable: &Variable, second_variable: &Variable) -> Self { - return Self::new_binary(BinaryOp::Mul, "Binary::Mul".into(), first_variable, second_variable); - } - - /// Creates a new divide operation instruction artifact - pub fn new_div(first_variable: &Variable, second_variable: &Variable) -> Self { - return Self::new_binary(BinaryOp::Div, "Binary::Div".into(), first_variable, second_variable); - } - - /// Creates a new shift left operation instruction artifact - pub fn new_shl(first_variable: &Variable, second_variable: &Variable) -> Self { - return Self::new_binary(BinaryOp::Shl, "Binary::Shl".into(), first_variable, second_variable); - } - - /// Creates a new shift right operation instruction artifact - pub fn new_shr(first_variable: &Variable, second_variable: &Variable) -> Self { - return Self::new_binary(BinaryOp::Shr, "Binary::Shr".into(), first_variable, second_variable); - } -} - -/// Converts SSA to ACIR program -fn ssa_to_acir_program(ssa: Ssa) -> AcirProgram { - // third brillig names, fourth errors - let (acir_functions, brillig, _, _) = ssa - .into_acir(&Brillig::default(), ExpressionWidth::default()) - .expect("Should compile manually written SSA into ACIR"); - - let mut functions: Vec> = Vec::new(); - - for acir_func in acir_functions.iter() { - let mut private_params: BTreeSet = acir_func.input_witnesses.clone().into_iter().collect(); - let ret_values: BTreeSet = acir_func.return_witnesses.clone().into_iter().collect(); - let circuit: Circuit; - private_params.extend(ret_values.iter().cloned()); - circuit = Circuit { - current_witness_index: acir_func.current_witness_index().witness_index(), - opcodes: acir_func.opcodes().to_vec(), - private_parameters: private_params.clone(), - ..Circuit::::default() - }; - functions.push(circuit); - } - return AcirProgram { functions: functions, unconstrained_functions: brillig }; -} - -/// Creates an SSA function for binary operations -fn binary_function(op: BinaryOp, first_variable_type: Type, second_variable_type: Type) -> Ssa { - // returns v0 op v1 - let main_id = Id::new(0); - let mut builder = FunctionBuilder::new("main".into(), main_id); - let v0 = builder.add_parameter(first_variable_type); - let v1 = builder.add_parameter(second_variable_type); - let v2 = builder.insert_binary(v0, op, v1); - builder.terminate_with_return(vec![v2]); - - let func = builder.finish(); - // remove_bit_shifts replaces bit shifts with equivalent arithmetic operations - let cleared_func = func.remove_bit_shifts(); - return cleared_func; -} - -/// Creates an SSA function for constraint operations -fn constrain_function(variable_type: Type) -> Ssa { - // constrains v0 == v1, returns v1 - let main_id = Id::new(0); - let mut builder = FunctionBuilder::new("main".into(), main_id); - - let v0 = builder.add_parameter(variable_type.clone()); - let v1 = builder.add_parameter(variable_type); - builder.insert_constrain(v0, v1, None); - builder.terminate_with_return(vec![v1]); - - return builder.finish(); -} - -/// Creates an SSA function for range check operations -fn range_check_function(variable_type: Type) -> Ssa { - let main_id = Id::new(0); - let mut builder = FunctionBuilder::new("main".into(), main_id); - - let v0 = builder.add_parameter(variable_type); - builder.insert_range_check(v0, 64, Some("Range Check failed".to_string())); - builder.terminate_with_return(vec![v0]); - - return builder.finish() -} - -/// Creates an SSA function for truncate operations -fn truncate_function(variable_type: Type) -> Ssa { - // truncate v0: field 10, 20?.. - let main_id = Id::new(0); - let mut builder = FunctionBuilder::new("main".into(), main_id); - - let v0 = builder.add_parameter(variable_type); - let v1 = builder.insert_truncate(v0, 10, 20); - builder.terminate_with_return(vec![v1]); - - return builder.finish(); -} - -/// Creates an SSA function for NOT operations -fn not_function(variable_type: Type) -> Ssa { - // returns not v0 - let main_id = Id::new(0); - let mut builder = FunctionBuilder::new("main".into(), main_id); - - let v0 = builder.add_parameter(variable_type); - let v1 = builder.insert_not(v0); - builder.terminate_with_return(vec![v1]); - - return builder.finish() -} diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/lib.rs b/noir/noir-repo/compiler/noirc_evaluator/src/lib.rs index 8c0445455b1..8127e3d03ef 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/lib.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/lib.rs @@ -11,10 +11,6 @@ pub mod ssa; pub use ssa::create_program; pub use ssa::ir::instruction::ErrorType; -pub mod acir_instruction_builder; -pub use acir_instruction_builder::{ - InstructionArtifacts, VariableType, Variable -}; /// Trims leading whitespace from each line of the input string, according to /// how much leading whitespace there is on the first non-empty line. diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/.gitignore b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/.gitignore deleted file mode 100644 index 03314f77b5a..00000000000 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/.gitignore +++ /dev/null @@ -1 +0,0 @@ -Cargo.lock diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock deleted file mode 100644 index 256f99475b9..00000000000 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.lock +++ /dev/null @@ -1,1907 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "acir" -version = "0.55.0" -dependencies = [ - "acir_field", - "base64 0.21.7", - "bincode", - "brillig", - "flate2", - "serde", - "serde-big-array", - "thiserror", -] - -[[package]] -name = "acir_field" -version = "0.55.0" -dependencies = [ - "ark-bn254", - "ark-ff", - "cfg-if", - "hex", - "num-bigint", - "serde", -] - -[[package]] -name = "acvm" -version = "0.55.0" -dependencies = [ - "acir", - "acvm_blackbox_solver", - "brillig_vm", - "indexmap 1.9.3", - "serde", - "thiserror", - "tracing", -] - -[[package]] -name = "acvm_blackbox_solver" -version = "0.55.0" -dependencies = [ - "acir", - "blake2", - "blake3", - "k256", - "keccak", - "libaes", - "num-bigint", - "p256", - "sha2", - "thiserror", -] - -[[package]] -name = "adler2" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" - -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", -] - -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - -[[package]] -name = "anstream" -version = "0.6.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "is_terminal_polyfill", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" - -[[package]] -name = "anstyle-parse" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" -dependencies = [ - "anstyle", - "windows-sys", -] - -[[package]] -name = "ark-bn254" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a22f4561524cd949590d78d7d4c5df8f592430d221f7f3c9497bbafd8972120f" -dependencies = [ - "ark-ec", - "ark-ff", - "ark-std", -] - -[[package]] -name = "ark-ec" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" -dependencies = [ - "ark-ff", - "ark-poly", - "ark-serialize", - "ark-std", - "derivative", - "hashbrown 0.13.2", - "itertools", - "num-traits", - "zeroize", -] - -[[package]] -name = "ark-ff" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" -dependencies = [ - "ark-ff-asm", - "ark-ff-macros", - "ark-serialize", - "ark-std", - "derivative", - "digest", - "itertools", - "num-bigint", - "num-traits", - "paste", - "rustc_version", - "zeroize", -] - -[[package]] -name = "ark-ff-asm" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" -dependencies = [ - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ark-ff-macros" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" -dependencies = [ - "num-bigint", - "num-traits", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ark-poly" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" -dependencies = [ - "ark-ff", - "ark-serialize", - "ark-std", - "derivative", - "hashbrown 0.13.2", -] - -[[package]] -name = "ark-serialize" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" -dependencies = [ - "ark-serialize-derive", - "ark-std", - "digest", - "num-bigint", -] - -[[package]] -name = "ark-serialize-derive" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ark-std" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" -dependencies = [ - "num-traits", - "rand", -] - -[[package]] -name = "arrayref" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" - -[[package]] -name = "arrayvec" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" - -[[package]] -name = "autocfg" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" - -[[package]] -name = "base16ct" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" - -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - -[[package]] -name = "base64" -version = "0.21.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" - -[[package]] -name = "base64" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] - -[[package]] -name = "bitmaps" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "031043d04099746d8db04daf1fa424b2bc8bd69d92b25962dcde24da39ab64a2" -dependencies = [ - "typenum", -] - -[[package]] -name = "blake2" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" -dependencies = [ - "digest", -] - -[[package]] -name = "blake3" -version = "1.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82033247fd8e890df8f740e407ad4d038debb9eb1f40533fffb32e7d17dc6f7" -dependencies = [ - "arrayref", - "arrayvec", - "cc", - "cfg-if", - "constant_time_eq", -] - -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - -[[package]] -name = "bn254_blackbox_solver" -version = "0.55.0" -dependencies = [ - "acir", - "acvm_blackbox_solver", - "ark-bn254", - "ark-ec", - "ark-ff", - "hex", - "lazy_static", - "noir_grumpkin", - "num-bigint", -] - -[[package]] -name = "brillig" -version = "0.55.0" -dependencies = [ - "acir_field", - "serde", -] - -[[package]] -name = "brillig_vm" -version = "0.55.0" -dependencies = [ - "acir", - "acvm_blackbox_solver", - "num-bigint", - "num-traits", - "thiserror", -] - -[[package]] -name = "bumpalo" -version = "3.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "cc" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" -dependencies = [ - "shlex", -] - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "chrono" -version = "0.4.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" -dependencies = [ - "android-tzdata", - "iana-time-zone", - "js-sys", - "num-traits", - "serde", - "wasm-bindgen", - "windows-targets", -] - -[[package]] -name = "clap" -version = "4.5.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" -dependencies = [ - "clap_builder", - "clap_derive", -] - -[[package]] -name = "clap_builder" -version = "4.5.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" -dependencies = [ - "anstream", - "anstyle", - "clap_lex", - "strsim", -] - -[[package]] -name = "clap_derive" -version = "4.5.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" -dependencies = [ - "heck 0.5.0", - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "clap_lex" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" - -[[package]] -name = "codespan" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3362992a0d9f1dd7c3d0e89e0ab2bb540b7a95fea8cd798090e758fda2899b5e" -dependencies = [ - "codespan-reporting", - "serde", -] - -[[package]] -name = "codespan-reporting" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "serde", - "termcolor", - "unicode-width", -] - -[[package]] -name = "colorchoice" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" - -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - -[[package]] -name = "constant_time_eq" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" - -[[package]] -name = "core-foundation-sys" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" - -[[package]] -name = "cpufeatures" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" -dependencies = [ - "libc", -] - -[[package]] -name = "crc32fast" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" -dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" - -[[package]] -name = "crypto-bigint" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "darling" -version = "0.20.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.20.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 2.0.87", -] - -[[package]] -name = "darling_macro" -version = "0.20.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" -dependencies = [ - "darling_core", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "der" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "deranged" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" -dependencies = [ - "powerfmt", - "serde", -] - -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer", - "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.14.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" -dependencies = [ - "der", - "elliptic-curve", - "rfc6979", - "signature", -] - -[[package]] -name = "either" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" - -[[package]] -name = "elliptic-curve" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" -dependencies = [ - "base16ct", - "crypto-bigint", - "der", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" -dependencies = [ - "rand_core", - "subtle", -] - -[[package]] -name = "fixedbitset" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" - -[[package]] -name = "flate2" -version = "1.0.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" -dependencies = [ - "crc32fast", - "miniz_oxide", -] - -[[package]] -name = "fm" -version = "0.39.0" -dependencies = [ - "codespan-reporting", - "iter-extended", - "serde", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "fxhash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" -dependencies = [ - "byteorder", -] - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "group" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash", -] - -[[package]] -name = "hashbrown" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" - -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - -[[package]] -name = "heck" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "iana-time-zone" -version = "0.1.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "im" -version = "15.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0acd33ff0285af998aaf9b57342af478078f53492322fafc47450e09397e0e9" -dependencies = [ - "bitmaps", - "rand_core", - "rand_xoshiro", - "serde", - "sized-chunks", - "typenum", - "version_check", -] - -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "serde", -] - -[[package]] -name = "indexmap" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" -dependencies = [ - "equivalent", - "hashbrown 0.15.1", - "serde", -] - -[[package]] -name = "is_terminal_polyfill" -version = "1.70.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" - -[[package]] -name = "iter-extended" -version = "0.39.0" - -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" - -[[package]] -name = "js-sys" -version = "0.3.72" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "jsonrpc" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34efde8d2422fb79ed56db1d3aea8fa5b583351d15a26770cdee2f88813dd702" -dependencies = [ - "base64 0.13.1", - "minreq", - "serde", - "serde_json", -] - -[[package]] -name = "k256" -version = "0.11.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "sha2", -] - -[[package]] -name = "keccak" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" -dependencies = [ - "cpufeatures", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" - -[[package]] -name = "libaes" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82903360c009b816f5ab72a9b68158c27c301ee2c3f20655b55c5e589e7d3bb7" - -[[package]] -name = "libc" -version = "0.2.164" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" - -[[package]] -name = "log" -version = "0.4.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" - -[[package]] -name = "memchr" -version = "2.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" - -[[package]] -name = "miniz_oxide" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" -dependencies = [ - "adler2", -] - -[[package]] -name = "minreq" -version = "2.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "763d142cdff44aaadd9268bebddb156ef6c65a0e13486bb81673cf2d8739f9b0" -dependencies = [ - "log", - "serde", - "serde_json", -] - -[[package]] -name = "noir_grumpkin" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e7d49a4b14b13c0dc730b05780b385828ab88f4148daaad7db080ecdce07350" -dependencies = [ - "ark-bn254", - "ark-ec", - "ark-ff", - "ark-std", -] - -[[package]] -name = "noirc_arena" -version = "0.39.0" - -[[package]] -name = "noirc_errors" -version = "0.39.0" -dependencies = [ - "acvm", - "base64 0.21.7", - "codespan", - "codespan-reporting", - "flate2", - "fm", - "noirc_printable_type", - "serde", - "serde_json", - "serde_with", - "tracing", -] - -[[package]] -name = "noirc_evaluator" -version = "0.39.0" -dependencies = [ - "acvm", - "bn254_blackbox_solver", - "cfg-if", - "chrono", - "fxhash", - "im", - "iter-extended", - "noirc_errors", - "noirc_frontend", - "num-bigint", - "rayon", - "serde", - "serde_json", - "serde_with", - "thiserror", - "tracing", -] - -[[package]] -name = "noirc_frontend" -version = "0.39.0" -dependencies = [ - "acvm", - "bn254_blackbox_solver", - "cfg-if", - "fm", - "im", - "iter-extended", - "noirc_arena", - "noirc_errors", - "noirc_printable_type", - "num-bigint", - "num-traits", - "petgraph", - "rangemap", - "regex", - "rustc-hash", - "serde", - "serde_json", - "small-ord-set", - "smol_str", - "strum", - "strum_macros", - "thiserror", - "tracing", -] - -[[package]] -name = "noirc_printable_type" -version = "0.39.0" -dependencies = [ - "acvm", - "iter-extended", - "jsonrpc", - "regex", - "serde", - "serde_json", - "thiserror", -] - -[[package]] -name = "num-bigint" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-conv" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - -[[package]] -name = "once_cell" -version = "1.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" - -[[package]] -name = "p256" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" -dependencies = [ - "ecdsa", - "elliptic-curve", - "sha2", -] - -[[package]] -name = "paste" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" - -[[package]] -name = "petgraph" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" -dependencies = [ - "fixedbitset", - "indexmap 2.6.0", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" - -[[package]] -name = "pkcs8" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" -dependencies = [ - "der", - "spki", -] - -[[package]] -name = "powerfmt" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" - -[[package]] -name = "ppv-lite86" -version = "0.2.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" -dependencies = [ - "zerocopy", -] - -[[package]] -name = "proc-macro2" -version = "1.0.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rand_xoshiro" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa" -dependencies = [ - "rand_core", -] - -[[package]] -name = "rangemap" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f60fcc7d6849342eff22c4350c8b9a989ee8ceabc4b481253e8946b9fe83d684" - -[[package]] -name = "rayon" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" -dependencies = [ - "crossbeam-deque", - "crossbeam-utils", -] - -[[package]] -name = "regex" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" - -[[package]] -name = "rfc6979" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" -dependencies = [ - "crypto-bigint", - "hmac", - "zeroize", -] - -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - -[[package]] -name = "rustc_version" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" -dependencies = [ - "semver", -] - -[[package]] -name = "rustversion" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" - -[[package]] -name = "ryu" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" - -[[package]] -name = "sec1" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - -[[package]] -name = "semver" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" - -[[package]] -name = "serde" -version = "1.0.215" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde-big-array" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11fc7cc2c76d73e0f27ee52abbd64eec84d46f370c88371120433196934e4b7f" -dependencies = [ - "serde", -] - -[[package]] -name = "serde_derive" -version = "1.0.215" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "serde_json" -version = "1.0.133" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" -dependencies = [ - "itoa", - "memchr", - "ryu", - "serde", -] - -[[package]] -name = "serde_with" -version = "3.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e28bdad6db2b8340e449f7108f020b3b092e8583a9e3fb82713e1d4e71fe817" -dependencies = [ - "base64 0.22.1", - "chrono", - "hex", - "indexmap 1.9.3", - "indexmap 2.6.0", - "serde", - "serde_derive", - "serde_json", - "serde_with_macros", - "time", -] - -[[package]] -name = "serde_with_macros" -version = "3.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "sha2" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - -[[package]] -name = "shlex" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - -[[package]] -name = "signature" -version = "1.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "sized-chunks" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16d69225bde7a69b235da73377861095455d298f2b970996eec25ddbb42b3d1e" -dependencies = [ - "bitmaps", - "typenum", -] - -[[package]] -name = "small-ord-set" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf7035a2b2268a5be8c1395738565b06beda836097e12021cdefc06b127a0e7e" -dependencies = [ - "smallvec", -] - -[[package]] -name = "smallvec" -version = "1.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" - -[[package]] -name = "smol_str" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad6c857cbab2627dcf01ec85a623ca4e7dcb5691cbaa3d7fb7653671f0d09c9" -dependencies = [ - "serde", -] - -[[package]] -name = "spki" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "ssa_test" -version = "0.1.0" -dependencies = [ - "clap", - "flate2", - "noirc_evaluator", - "serde", - "serde_json", -] - -[[package]] -name = "strsim" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" - -[[package]] -name = "strum" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" - -[[package]] -name = "strum_macros" -version = "0.24.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" -dependencies = [ - "heck 0.4.1", - "proc-macro2", - "quote", - "rustversion", - "syn 1.0.109", -] - -[[package]] -name = "subtle" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "thiserror" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "time" -version = "0.3.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" -dependencies = [ - "deranged", - "itoa", - "num-conv", - "powerfmt", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" - -[[package]] -name = "time-macros" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" -dependencies = [ - "num-conv", - "time-core", -] - -[[package]] -name = "tracing" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" -dependencies = [ - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "tracing-core" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -dependencies = [ - "once_cell", -] - -[[package]] -name = "typenum" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" - -[[package]] -name = "unicode-ident" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" - -[[package]] -name = "unicode-width" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" - -[[package]] -name = "utf8parse" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "wasm-bindgen" -version = "0.2.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" -dependencies = [ - "cfg-if", - "once_cell", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn 2.0.87", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" - -[[package]] -name = "winapi-util" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "windows-core" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-sys" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "byteorder", - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "zeroize" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml deleted file mode 100644 index 497f1baeab2..00000000000 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "ssa_test" -version = "0.1.0" -edition = "2021" - -[dependencies] -noirc_evaluator = {path = "../"} -serde = "1.0.214" -serde_json = "1.0.120" -flate2 = "1.0.35" -clap = { version = "4.4.11", features = ["derive"] } -[workspace] diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md deleted file mode 100644 index a2e3b47af72..00000000000 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# SSA Test Generator - -This tool generates test artifacts for formally verifying SSA instructions and their conversion to ACIR. - -## Purpose - -The test generator creates test cases for: - -- Bitvector operations (up to 127 bits): add, sub, mul, mod, xor, and, div, eq, lt, not, etc. -- Shift operations (tested with smaller bit sizes 32 and 64): shl, shr -- Binary operations (32-bit): xor, and, or -- Field operations: add, mul, div -- Signed integer operations: div (126-bit) - -Each test case generates: -- Formatted SSA representation -- Serialized ACIR output - -## Usage - -Run the generator with the desired output directory. The directory can be specified using the `-d` or `--dir` flag: - -```bash -cargo run -- -d /path/to/output/directory/ -``` - -DON'T FORGET TO CHANGE ARTIFACTS_PATH IN barretenberg/cpp/src/barretenberg/acir_formal_proofs/acir_loader.test.cpp TO THE NEW OUTPUT DIRECTORY. \ No newline at end of file diff --git a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs b/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs deleted file mode 100644 index dc02e9b3aa6..00000000000 --- a/noir/noir-repo/compiler/noirc_evaluator/ssa_test/src/main.rs +++ /dev/null @@ -1,111 +0,0 @@ -use std::fs::File; -use std::io::Write; -use std::io::Read; -use std::path::Path; -use flate2::read::GzDecoder; -use::noirc_evaluator::acir_instruction_builder::{ - InstructionArtifacts, VariableType, Variable -}; -use clap::Parser; - -#[derive(Parser)] -#[command(author, version, about, long_about = None)] -struct Args { - #[arg(short, long, default_value = "../../../../../barretenberg/cpp/src/barretenberg/acir_formal_proofs/artifacts/")] - dir: String, -} - -/// Decompresses gzipped data into a byte vector -fn ungzip(compressed_data: Vec) -> Vec { - let mut decompressed_data: Vec = Vec::new(); - let mut decoder = GzDecoder::new(&compressed_data[..]); - decoder.read_to_end(&mut decompressed_data).unwrap(); - return decompressed_data; -} - -/// Saves byte data to a file at the specified path -fn save_to_file(data: &[u8], filename: &str) -> Result<(), std::io::Error> { - let path = Path::new(filename); - let mut file = File::create(path)?; - file.write_all(data)?; - Ok(()) -} - -/// Saves instruction artifacts to files in the artifacts directory -/// Prints the formatted SSA for each artifact and saves the decompressed ACIR -fn save_artifacts(all_artifacts: Vec, dir: &str) { - for artifacts in all_artifacts.iter() { - println!("{}", artifacts.formatted_ssa); - let filename = format!("{}{}{}", dir, artifacts.instruction_name, ".acir"); - let acir = &artifacts.serialized_acir; - match save_to_file(&ungzip(acir.clone()), &filename) { - Ok(_) => (), - Err(error) => println!("Error saving data: {}", error), - } - } -} - -/// Main function that generates test artifacts for SSA instructions -/// Creates test cases for various operations with different variable types and bit sizes -fn main() { - let args = Args::parse(); - - let mut all_artifacts: Vec = Vec::new(); - - // Define test variables with different types and sizes - let field_var = Variable{ variable_type: VariableType::Field, variable_size: 0}; - // max bit size for signed and unsigned - let u127_var = Variable{ variable_type: VariableType::Unsigned, variable_size: 127}; - let i127_var = Variable{ variable_type: VariableType::Signed, variable_size: 127}; - // max bit size allowed by mod and div - let u126_var = Variable{ variable_type: VariableType::Unsigned, variable_size: 126}; - let i126_var = Variable{ variable_type: VariableType::Signed, variable_size: 126}; - // 64 bit unsigned - let u64_var = Variable{ variable_type: VariableType::Unsigned, variable_size: 64}; - // 32 bit unsigned - let u32_var = Variable{ variable_type: VariableType::Unsigned, variable_size: 32}; - // 8 bit unsigned - let u8_var = Variable{ variable_type: VariableType::Unsigned, variable_size: 8}; - - // Test bitvector operations with max bit size (127 bits) - all_artifacts.push(InstructionArtifacts::new_add(&u127_var, &u127_var)); - all_artifacts.push(InstructionArtifacts::new_sub(&u127_var, &u127_var)); - all_artifacts.push(InstructionArtifacts::new_mul(&u127_var, &u127_var)); - all_artifacts.push(InstructionArtifacts::new_mod(&u126_var, &u126_var)); - all_artifacts.push(InstructionArtifacts::new_xor(&u127_var, &u127_var)); - all_artifacts.push(InstructionArtifacts::new_and(&u127_var, &u127_var)); - all_artifacts.push(InstructionArtifacts::new_div(&u126_var, &u126_var)); - all_artifacts.push(InstructionArtifacts::new_eq(&u127_var, &u127_var)); - all_artifacts.push(InstructionArtifacts::new_lt(&u127_var, &u127_var)); - all_artifacts.push(InstructionArtifacts::new_xor(&u127_var, &u127_var)); - all_artifacts.push(InstructionArtifacts::new_or(&u127_var, &u127_var)); - all_artifacts.push(InstructionArtifacts::new_not(&u127_var)); - all_artifacts.push(InstructionArtifacts::new_constrain(&u127_var)); - all_artifacts.push(InstructionArtifacts::new_truncate(&u127_var)); - all_artifacts.push(InstructionArtifacts::new_range_check(&u127_var)); - - // Test shift operations with smaller bit sizes - // shl truncates variable, so test different sizes - // Too heavy to test 127 bits, but it just multiplies or divides by 2^rhs - // Should work the same if div and mul are verified - all_artifacts.push(InstructionArtifacts::new_shl(&u64_var, &u8_var)); - all_artifacts.push(InstructionArtifacts::new_shr(&u64_var, &u8_var)); - all_artifacts.push(InstructionArtifacts::new_shl(&u32_var, &u8_var)); - - // Test binary operations with 32 bits - all_artifacts.push(InstructionArtifacts::new_xor(&u32_var, &u32_var)); - all_artifacts.push(InstructionArtifacts::new_and(&u32_var, &u32_var)); - all_artifacts.push(InstructionArtifacts::new_or(&u32_var, &u32_var)); - - // Test field operations - all_artifacts.push(InstructionArtifacts::new_add(&field_var, &field_var)); - all_artifacts.push(InstructionArtifacts::new_mul(&field_var, &field_var)); - all_artifacts.push(InstructionArtifacts::new_div(&field_var, &field_var)); - all_artifacts.push(InstructionArtifacts::new_eq(&field_var, &field_var)); - - // Test signed division (only operation that differs for signed integers) - all_artifacts.push(InstructionArtifacts::new_div(&i126_var, &i126_var)); - all_artifacts.push(InstructionArtifacts::new_lt(&i127_var, &i127_var)); - - save_artifacts(all_artifacts, &args.dir); -} From 29ed0809b17fb2880ae6434c186774f6fb762896 Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Mon, 6 Jan 2025 14:23:12 +0000 Subject: [PATCH 30/32] broken table --- barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md index 2ef9bdff692..feaccc14e75 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md @@ -19,7 +19,7 @@ The verifier uses SMT (Satisfiability Modulo Theories) solving to formally verif ### Results | Opcode | Lhs type/size | Rhs type/size | Time/seconds | Memory/GB | Success | SMT Term Type | Reason | -| ----------- | ------------- | ------------- | ------------ | --------- | ------- | ---------------- | -------------------------- | --- | +| ----------- | ------------- | ------------- | ------------ | --------- | ------- | ---------------- | -------------------------- | | Binary::Add | Field | Field | 0.024 | - | ✓ | TermType::FFTerm | | | Binary::Add | Unsigned_127 | Unsigned_127 | 2.8 | - | ✓ | TermType::BVTerm | | | Binary::And | Unsigned_32 | Unsigned_32 | 6.7 | - | ✓ | TermType::BVTerm | | From f32a27eb029ab1705e39d42c26985b80dc96b5b3 Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Mon, 6 Jan 2025 14:27:39 +0000 Subject: [PATCH 31/32] last readme fix --- .../barretenberg/acir_formal_proofs/README.md | 33 +------------------ 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md index feaccc14e75..5dd3a5a2918 100644 --- a/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md +++ b/barretenberg/cpp/src/barretenberg/acir_formal_proofs/README.md @@ -43,36 +43,5 @@ The verifier uses SMT (Satisfiability Modulo Theories) solving to formally verif | Binary::Xor | Unsigned_127 | Unsigned_127 | 7.5 | - | ✗ | TermType::BVTerm | Probably bug in smt solver | | Not | Unsigned_127 | - | 0.2 | - | ✓ | TermType::BVTerm | | -The test suite verifies correctness of ACIR operations through SMT solving: -### Arithmetic Tests - -- `uint_terms_add`: Tests 127-bit unsigned addition. Execution time: ~2.8s -- `uint_terms_sub`: Tests 127-bit unsigned subtraction. Execution time: ~2.6s -- `uint_terms_mul`: Tests 127-bit unsigned multiplication. Execution time: ~10.0s -- `uint_terms_div`: Tests 126-bit unsigned division -- `integer_terms_div`: Tests 126-bit signed division. Execution time: >10 days -- `field_terms_div`: Tests field division. Execution time: ~0.22s -- `uint_terms_mod`: Tests 126-bit unsigned modulo. Execution time: ???. Unknown time due to bug found during reviewing. - -### Bitwise Tests - -- `uint_terms_and`: Tests 127-bit unsigned bitwise AND DOESNT WORK\* -- `uint_terms_or`: Tests 127-bit unsigned bitwise OR DOESNT WORK\* -- `uint_terms_xor`: Tests 127-bit unsigned bitwise XOR DOESNT WORK\* -- `uint_terms_not`: Tests 127-bit unsigned bitwise NOT - -### Shift Tests - -- `uint_terms_shl32`: Tests 32-bit left shift. Execution time: ~4574s, Memory: ~30GB -- `uint_terms_shl64`: Tests 64-bit left shift. Execution time: ~4588s, Memory: ~30GB -- `uint_terms_shr`: Tests right shift. Execution time: ~3927.88s, Memory: ~10GB - -### Comparison Tests - -- `uint_terms_eq`: Tests 127-bit unsigned equality comparison. Verifies both equal and unequal cases. Execution time: ~22.8s -- `uint_terms_lt`: Tests 127-bit unsigned less than comparison. Verifies both a < b and a >= b cases. Execution time: ~56.7s - -Each test attempts to find counterexamples that violate the expected behavior. A passing test indicates the operation is correctly implemented, while a failing test reveals potential issues. - -\*Note: The bitwise tests are not working yet. (probably because of bug in the SMT solver). It works only for variables with 32 bits. +Each test attempts to find counterexamples that violate the expected behavior. A passing test indicates the operation is correctly implemented, while a failing test reveals potential issues. \ No newline at end of file From 9dd47099c027b5a6d3415b539a8a5a51a95181cf Mon Sep 17 00:00:00 2001 From: jewelofchaos9 Date: Tue, 7 Jan 2025 12:23:49 +0000 Subject: [PATCH 32/32] ACIR_FORMAL_PROOFS flag for cmake --- barretenberg/cpp/src/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/CMakeLists.txt b/barretenberg/cpp/src/CMakeLists.txt index 34b4a9fd509..fd992566082 100644 --- a/barretenberg/cpp/src/CMakeLists.txt +++ b/barretenberg/cpp/src/CMakeLists.txt @@ -97,12 +97,15 @@ add_subdirectory(barretenberg/ultra_honk) add_subdirectory(barretenberg/vm) add_subdirectory(barretenberg/wasi) add_subdirectory(barretenberg/world_state) -add_subdirectory(barretenberg/acir_formal_proofs) if(SMT) add_subdirectory(barretenberg/smt_verification) endif() +if(SMT AND ACIR_FORMAL_PROOFS) + add_subdirectory(barretenberg/acir_formal_proofs) +endif() + add_subdirectory(barretenberg/benchmark) include(GNUInstallDirs)