Skip to content

Commit

Permalink
Merge branch 'master' into is/translatooooooooooooooooooor
Browse files Browse the repository at this point in the history
  • Loading branch information
Rumata888 committed Jul 27, 2023
2 parents 499cffa + d6271b9 commit 42dc3c0
Show file tree
Hide file tree
Showing 12 changed files with 530 additions and 326 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{".":"0.3.3","ts":"0.3.3"}
{".":"0.3.4","ts":"0.3.4"}
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## [0.3.4](https://github.com/AztecProtocol/barretenberg/compare/barretenberg-v0.3.3...barretenberg-v0.3.4) (2023-07-25)


### Features

* Add Goblin Ultra Circuit builder ([#587](https://github.com/AztecProtocol/barretenberg/issues/587)) ([2d38c25](https://github.com/AztecProtocol/barretenberg/commit/2d38c252de8b867955da661181e51f1a5f28cbc6))
* Modify bb.js to be compatible with next.js ([#544](https://github.com/AztecProtocol/barretenberg/issues/544)) ([d384089](https://github.com/AztecProtocol/barretenberg/commit/d384089f60d1a6d5baeb0d3459556a310b790366))
* Support public inputs in Ultra Honk ([#581](https://github.com/AztecProtocol/barretenberg/issues/581)) ([9cd0a06](https://github.com/AztecProtocol/barretenberg/commit/9cd0a064b8258bf4f72dd9e1c5e8f85b074d1bbc))

## [0.3.3](https://github.com/AztecProtocol/barretenberg/compare/barretenberg-v0.3.2...barretenberg-v0.3.3) (2023-07-17)


Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Barretenberg, an optimized elliptic curve library for the bn128 curve, and PLONK SNARK prover

Barretenberg aims to be a stand-alone and well-specified library, but please see https://github.com/AztecProtocol/aztec-packages/edit/master/circuits/cpp/barretenberg for the authoritative source of this code.
The separate repository https://github.com/AztecProtocol/barretenberg is available if working on barretenberg independently of Aztec, however it is encouraged to develop in the context of Aztec to see if it will cause issues for Aztec end-to-end tests.
As the spec solidifies, this should be less of an issue. Aztec and Barretenberg are currently under heavy development.

**This code is highly experimental, use at your own risk!**

### Dependencies
Expand Down Expand Up @@ -201,8 +205,12 @@ Alternatively you can build separate test binaries, e.g. honk_tests or numeric_t

A default configuration for VS Code is provided by the file [`barretenberg.code-workspace`](barretenberg.code-workspace). These settings can be overridden by placing configuration files in `.vscode/`.

### Integration tests with Aztec Circuits
### Integration tests with Aztec in Monorepo

CI will automatically run integration tests against Aztec. The tests in `circuits/cpp` folder use the embedded barretenberg, and can be used to integration test it.

### Integration tests with Aztec in Barretenberg Standalone Repo

CI will automatically run integration tests against Aztec's circuits which live [here](https://github.com/AztecProtocol/aztec-packages/tree/master/circuits). To change which Aztec branch or commit for CI to test against, modify [`.aztec-packages-commit`](./cpp/.aztec-packages-commit).

When working on a PR, you may want to point this file to a adifferent Aztec branch or commit, but then it should probably be pointed back to master before merging.
When working on a PR, you may want to point this file to a different Aztec branch or commit, but then it should probably be pointed back to master before merging.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.3.3 x-release-please-version
v0.3.4 x-release-please-version
4 changes: 2 additions & 2 deletions acir_tests/run_acir_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ if [ ! -d acir_tests ]; then
git clone -b $BRANCH --filter=blob:none --no-checkout https://github.com/noir-lang/noir.git
cd noir
git sparse-checkout init --cone
git sparse-checkout set crates/nargo_cli/tests/test_data
git sparse-checkout set crates/nargo_cli/tests/test_data_ssa_refactor
git checkout
cd ..
mv noir/crates/nargo_cli/tests/test_data acir_tests
mv noir/crates/nargo_cli/tests/test_data_ssa_refactor acir_tests
rm -rf noir
fi
fi
Expand Down
2 changes: 1 addition & 1 deletion barretenberg-wasm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ in
stdenv.mkDerivation
{
pname = "barretenberg.wasm";
version = "0.3.3"; # x-release-please-version
version = "0.3.4"; # x-release-please-version

src = ./cpp;

Expand Down
2 changes: 1 addition & 1 deletion barretenberg.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ in
buildEnv.mkDerivation
{
pname = "libbarretenberg";
version = "0.3.3"; # x-release-please-version
version = "0.3.4"; # x-release-please-version

src = ./cpp;

Expand Down
2 changes: 1 addition & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.24)
project(
Barretenberg
DESCRIPTION "BN254 elliptic curve library, and PLONK SNARK prover"
VERSION 0.3.3 # x-release-please-version
VERSION 0.3.4 # x-release-please-version
LANGUAGES CXX C
)

Expand Down
56 changes: 55 additions & 1 deletion cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include "acir_format.hpp"
#include "barretenberg/common/container.hpp"
#include "barretenberg/common/throw_or_abort.hpp"
#include "barretenberg/dsl/acir_format/blake2s_constraint.hpp"
#include "barretenberg/dsl/acir_format/block_constraint.hpp"
#include "barretenberg/dsl/acir_format/ecdsa_secp256k1.hpp"
Expand Down Expand Up @@ -233,6 +234,44 @@ void handle_memory(Circuit::MemoryBlock const& mem_block, bool is_ram, acir_form
af.block_constraints.push_back(BlockConstraint{ .init = init, .trace = trace, .type = (BlockType)is_ram });
}

BlockConstraint handle_memory_init(Circuit::Opcode::MemoryInit const& mem_init)
{
BlockConstraint block{ .init = {}, .trace = {}, .type = BlockType::ROM };
std::vector<poly_triple> init;
std::vector<MemOp> trace;

auto len = mem_init.init.size();
for (size_t i = 0; i < len; ++i) {
block.init.push_back(poly_triple{
.a = mem_init.init[i].value,
.b = 0,
.c = 0,
.q_m = 0,
.q_l = 1,
.q_r = 0,
.q_o = 0,
.q_c = 0,
});
}
return block;
}

void handle_memory_op(Circuit::Opcode::MemoryOp const& mem_op, BlockConstraint& block)
{
uint8_t access_type = 1;
if (mem_op.op.is_rom()) {
access_type = 0;
}
if (block.type == BlockType::ROM && access_type == 1) {
block.type = BlockType::RAM;
}

MemOp acir_mem_op = MemOp{ .access_type = access_type,
.index = serialize_arithmetic_gate(mem_op.op.index),
.value = serialize_arithmetic_gate(mem_op.op.value) };
block.trace.push_back(acir_mem_op);
}

acir_format circuit_buf_to_acir_format(std::vector<uint8_t> const& buf)
{
auto circuit = Circuit::Circuit::bincodeDeserialize(buf);
Expand All @@ -241,7 +280,7 @@ acir_format circuit_buf_to_acir_format(std::vector<uint8_t> const& buf)
af.varnum = circuit.current_witness_index + 1;
af.public_inputs = join({ map(circuit.public_parameters.value, [](auto e) { return e.value; }),
map(circuit.return_values.value, [](auto e) { return e.value; }) });

std::map<uint32_t, BlockConstraint> block_id_to_block_constraint;
for (auto gate : circuit.opcodes) {
std::visit(
[&](auto&& arg) {
Expand All @@ -254,10 +293,25 @@ acir_format circuit_buf_to_acir_format(std::vector<uint8_t> const& buf)
handle_memory(arg.value, true, af);
} else if constexpr (std::is_same_v<T, Circuit::Opcode::ROM>) {
handle_memory(arg.value, false, af);
} else if constexpr (std::is_same_v<T, Circuit::Opcode::MemoryInit>) {
auto block = handle_memory_init(arg);
uint32_t block_id = arg.block_id.value;
block_id_to_block_constraint[block_id] = block;
} else if constexpr (std::is_same_v<T, Circuit::Opcode::MemoryOp>) {
auto block = block_id_to_block_constraint.find(arg.block_id.value);
if (block == block_id_to_block_constraint.end()) {
throw_or_abort("unitialized MemoryOp");
}
handle_memory_op(arg, block->second);
}
},
gate.value);
}
for (const auto& [block_id, block] : block_id_to_block_constraint) {
if (!block.trace.empty()) {
af.block_constraints.push_back(block);
}
}
return af;
}

Expand Down
Loading

0 comments on commit 42dc3c0

Please sign in to comment.