Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion circuits/cpp/barretenberg
Submodule barretenberg updated 37 files
+2 −2 README.md
+1 −1 cpp/.aztec-packages-commit
+1 −1 cpp/dockerfiles/Dockerfile.circuits-wasm-linux-clang-builder-runner
+1 −1 cpp/dockerfiles/Dockerfile.wasm-linux-clang
+1 −0 cpp/src/barretenberg/benchmark/honk_bench/compare_honk_branch_vs_baseline.sh
+23 −5 cpp/src/barretenberg/crypto/ecdsa/ecdsa_impl.hpp
+109 −77 cpp/src/barretenberg/crypto/generators/generator_data.cpp
+2 −3 cpp/src/barretenberg/crypto/generators/generator_data.hpp
+5 −1 cpp/src/barretenberg/honk/flavor/standard.hpp
+5 −1 cpp/src/barretenberg/honk/flavor/standard_grumpkin.hpp
+5 −1 cpp/src/barretenberg/honk/flavor/ultra.hpp
+5 −1 cpp/src/barretenberg/honk/flavor/ultra_grumpkin.hpp
+2 −1 cpp/src/barretenberg/honk/proof_system/composer_lib.hpp
+5 −4 cpp/src/barretenberg/honk/sumcheck/relations/arithmetic_relation.hpp
+5 −4 cpp/src/barretenberg/honk/sumcheck/relations/auxiliary_relation.hpp
+6 −5 cpp/src/barretenberg/honk/sumcheck/relations/elliptic_relation.hpp
+5 −4 cpp/src/barretenberg/honk/sumcheck/relations/gen_perm_sort_relation.hpp
+6 −5 cpp/src/barretenberg/honk/sumcheck/relations/lookup_relation.hpp
+12 −10 cpp/src/barretenberg/honk/sumcheck/relations/permutation_relation.hpp
+39 −29 cpp/src/barretenberg/honk/sumcheck/relations/relation_types.hpp
+6 −5 cpp/src/barretenberg/honk/sumcheck/relations/ultra_arithmetic_relation.hpp
+4 −3 cpp/src/barretenberg/honk/sumcheck/sumcheck.hpp
+153 −50 cpp/src/barretenberg/honk/sumcheck/sumcheck_round.hpp
+39 −3 cpp/src/barretenberg/honk/sumcheck/sumcheck_round.test.cpp
+1 −1 cpp/src/barretenberg/honk/transcript/transcript.test.cpp
+1 −1 cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.test.cpp
+1 −1 cpp/src/barretenberg/proof_system/circuit_builder/turbo_circuit_builder.hpp
+3 −3 cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen.bench.cpp
+7 −7 cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen.test.cpp
+8 −0 cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa_impl.hpp
+1 −0 cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.hpp
+51 −0 cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.test.cpp
+94 −27 cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield_impl.hpp
+14 −14 cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.test.cpp
+1 −1 cpp/src/barretenberg/stdlib/primitives/field/field.test.cpp
+0 −1 cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.hpp
+1 −1 ts/src/barretenberg_api/pedersen.test.ts
3 changes: 2 additions & 1 deletion circuits/cpp/src/aztec3/circuits/abis/c_bind.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <gtest/gtest.h>

#include <cstdint>
#include <vector>

namespace {
Expand Down Expand Up @@ -160,7 +161,7 @@ TEST(abi_tests, hash_vk)
{
// Initialize some random VK data
NT::VKData vk_data;
vk_data.circuit_type = engine.get_random_uint32();
vk_data.circuit_type = static_cast<uint32_t>(proof_system::CircuitType::ULTRA);
vk_data.circuit_size = static_cast<uint32_t>(1) << (engine.get_random_uint8() >> 3); // must be a power of two
vk_data.num_public_inputs = engine.get_random_uint32();
vk_data.commitments["test1"] = g1::element::random_element();
Expand Down
89 changes: 55 additions & 34 deletions circuits/cpp/src/aztec3/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,41 +60,62 @@ constexpr size_t FUNCTION_SELECTOR_NUM_BYTES = 4; // must be <= 31
// sha256 hash is stored in two fields to accommodate all 256-bits of the hash
constexpr size_t NUM_FIELDS_PER_SHA256 = 2;

// Enumerate the hash_indices which are used for pedersen hashing
// Start from 1 to avoid the default generators.
/**
* Enumerate the hash_indices which are used for pedersen hashing.
* We start from 1 to avoid the default generators. The generator indices are listed
* based on the number of elements each index hashes. The following conditions must be met:
*
* +-----------+-------------------------------+----------------------+
* | Hash size | Number of elements hashed (n) | Condition to use |
* |-----------+-------------------------------+----------------------|
* | LOW | n ≤ 8 | 0 < hash_index ≤ 32 |
* | MID | 8 < n ≤ 16 | 32 < hash_index ≤ 40 |
* | HIGH | 16 < n ≤ 44 | 40 < hash_index ≤ 44 |
* +-----------+-------------------------------+----------------------+
*
*/
enum GeneratorIndex {
COMMITMENT = 1,
COMMITMENT_PLACEHOLDER, // for omitting some elements of the commitment when partially committing.
OUTER_COMMITMENT,
NULLIFIER_HASHED_PRIVATE_KEY,
NULLIFIER,
INITIALISATION_NULLIFIER,
OUTER_NULLIFIER,
PUBLIC_DATA_READ,
PUBLIC_DATA_UPDATE_REQUEST,
VK,
FUNCTION_DATA,
FUNCTION_LEAF,
CONTRACT_DEPLOYMENT_DATA,
CONSTRUCTOR,
CONSTRUCTOR_ARGS,
CONTRACT_ADDRESS,
CONTRACT_LEAF,
CALL_CONTEXT,
CALL_STACK_ITEM,
CALL_STACK_ITEM_2, // see function where it's used for explanation
L2_TO_L1_MSG,
PRIVATE_CIRCUIT_PUBLIC_INPUTS,
PUBLIC_CIRCUIT_PUBLIC_INPUTS,
TX_CONTEXT,
TX_REQUEST,
PUBLIC_LEAF_INDEX,
PUBLIC_DATA_LEAF,
SIGNED_TX_REQUEST,
L1_TO_L2_MESSAGE_SECRET,
FUNCTION_ARGS,
GLOBAL_VARIABLES,
PARTIAL_CONTRACT_ADDRESS,
/**
* Indices with size ≤ 8
*/
COMMITMENT = 1, // Size = 7 (unused)
COMMITMENT_PLACEHOLDER, // Size = 1 (unused), for omitting some elements of commitment when partially comm
OUTER_COMMITMENT, // Size = 2
NULLIFIER_HASHED_PRIVATE_KEY, // Size = 1 (unused)
NULLIFIER, // Size = 4 (unused)
INITIALISATION_NULLIFIER, // Size = 2 (unused)
OUTER_NULLIFIER, // Size = 2
PUBLIC_DATA_READ, // Size = 2
PUBLIC_DATA_UPDATE_REQUEST, // Size = 3
FUNCTION_DATA, // Size = 3
FUNCTION_LEAF, // Size = 4
CONTRACT_DEPLOYMENT_DATA, // Size = 4
CONSTRUCTOR, // Size = 3
CONSTRUCTOR_ARGS, // Size = 8
CONTRACT_ADDRESS, // Size = 4
CONTRACT_LEAF, // Size = 3
CALL_CONTEXT, // Size = 6
CALL_STACK_ITEM, // Size = 3
CALL_STACK_ITEM_2, // Size = ? (unused), // TODO see function where it's used for explanation
L1_TO_L2_MESSAGE_SECRET, // Size = 1 (wrongly used)
L2_TO_L1_MSG, // Size = 2 (unused)
TX_CONTEXT, // Size = 4
PUBLIC_LEAF_INDEX, // Size = 2 (unused)
PUBLIC_DATA_LEAF, // Size = ? (unused) // TODO what's the expected size? Assuming ≤ 8
SIGNED_TX_REQUEST, // Size = 7
GLOBAL_VARIABLES, // Size = 4
PARTIAL_CONTRACT_ADDRESS, // Size = 7
Comment thread
suyash67 marked this conversation as resolved.
/**
* Indices with size ≤ 16
*/
TX_REQUEST = 33, // Size = 14
/**
* Indices with size ≤ 44
*/
VK = 41, // Size = 35
PRIVATE_CIRCUIT_PUBLIC_INPUTS, // Size = 39
PUBLIC_CIRCUIT_PUBLIC_INPUTS, // Size = 32 (unused)
FUNCTION_ARGS, // Size ≤ 40
};

enum StorageSlotGeneratorIndex {
Expand Down
3 changes: 2 additions & 1 deletion circuits/cpp/src/aztec3/utils/types/convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,14 @@ template <typename Builder> typename NT::ecdsa_signature to_nt(typename CT<Build
{
std::vector<uint8_t> r_bytes = e.r.get_value();
std::vector<uint8_t> s_bytes = e.s.get_value();
const uint8_t v_byte = e.v.get_value();

std::array<uint8_t, 32> r_array;
std::array<uint8_t, 32> s_array;
std::copy(r_bytes.begin(), r_bytes.end(), r_array.begin());
std::copy(s_bytes.begin(), s_bytes.end(), s_array.begin());

return NT::ecdsa_signature{ r_array, s_array, e.v };
return NT::ecdsa_signature{ r_array, s_array, v_byte };
};

template <typename Builder>
Expand Down
164 changes: 62 additions & 102 deletions yarn-project/circuits.js/src/abis/__snapshots__/abis.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,38 @@ exports[`abis wasm bindings computes a contract address 1`] = `
AztecAddress {
"buffer": {
"data": [
16,
254,
252,
39,
166,
189,
149,
143,
172,
43,
91,
5,
169,
98,
157,
197,
151,
152,
84,
209,
170,
71,
61,
58,
131,
234,
131,
176,
163,
212,
247,
210,
181,
243,
184,
106,
198,
189,
57,
9,
223,
214,
106,
194,
189,
60,
7,
40,
152,
129,
5,
46,
153,
67,
89,
52,
99,
15,
236,
226,
244,
],
"type": "Buffer",
},
Expand All @@ -44,7 +44,7 @@ AztecAddress {

exports[`abis wasm bindings computes a function leaf 1`] = `
Fr {
"value": 587703305517770651443581700965463419402329990676290745771558099600379869110n,
"value": 10724872372058747971865607189197215883616299259274114995580068674650484136837n,
}
`;

Expand All @@ -68,93 +68,53 @@ Fr {

exports[`abis wasm bindings computes function tree root 1`] = `
Fr {
"value": 14183899854343735726273072423861389595545367822703803926156437266914765787587n,
}
`;

exports[`abis wasm bindings hashes VK 1`] = `
Object {
"data": Array [
3,
215,
112,
230,
112,
168,
8,
190,
95,
206,
52,
172,
46,
85,
55,
190,
134,
187,
169,
57,
109,
253,
250,
109,
224,
150,
49,
156,
32,
17,
205,
37,
],
"type": "Buffer",
"value": 12906610331695443491500387150847739068531523218659917858520872318692742082976n,
}
`;

exports[`abis wasm bindings hashes a tx request 1`] = `
{
"data": [
46,
34,
203,
156,
120,
223,
99,
48,
53,
15,
204,
1,
228,
99,
23,
184,
176,
133,
230,
58,
209,
220,
44,
229,
185,
120,
139,
48,
34,
89,
210,
214,
204,
179,
84,
22,
155,
178,
238,
165,
191,
93,
247,
184,
223,
45,
107,
137,
24,
36,
144,
135,
180,
126,
227,
233,
41,
239,
80,
144,
],
"type": "Buffer",
}
`;

exports[`abis wasm bindings hashes constructor info 1`] = `
Fr {
"value": 7216897321497646146262929975092090377195732654088850742428710375667397735848n,
"value": 74771810193401619436460949258064408227201554785021679654928411451496318664n,
}
`;

Expand All @@ -166,12 +126,12 @@ Fr {

exports[`abis wasm bindings hashes function args 1`] = `
Fr {
"value": 12125610727223956800302813404878728417440563546649886466255076581695454329514n,
"value": 15720617086745159386029213699351568409853600750676188473180204896020576500517n,
}
`;

exports[`abis wasm bindings hashes many function args 1`] = `
Fr {
"value": 8955236039943388976259759391839453100491522182218493180262383122788045296302n,
"value": 8821391622027037199809426224131086995026830636507153731707255950359820668907n,
}
`;
21 changes: 15 additions & 6 deletions yarn-project/circuits.js/src/structs/generators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
* @see circuits/cpp/src/aztec3/constants.hpp
*/
export enum GeneratorIndex {
/**
* Indices with size ≤ 8
*/
COMMITMENT = 1,
COMMITMENT_PLACEHOLDER,
OUTER_COMMITMENT,
Expand All @@ -12,7 +15,6 @@ export enum GeneratorIndex {
OUTER_NULLIFIER,
PUBLIC_DATA_READ,
PUBLIC_DATA_UPDATE_REQUEST,
VK,
FUNCTION_DATA,
FUNCTION_LEAF,
CONTRACT_DEPLOYMENT_DATA,
Expand All @@ -23,16 +25,23 @@ export enum GeneratorIndex {
CALL_CONTEXT,
CALL_STACK_ITEM,
CALL_STACK_ITEM_2,
L1_TO_L2_MESSAGE_SECRET,
L2_TO_L1_MSG,
PRIVATE_CIRCUIT_PUBLIC_INPUTS,
PUBLIC_CIRCUIT_PUBLIC_INPUTS,
TX_CONTEXT,
TX_REQUEST,
PUBLIC_LEAF_INDEX,
PUBLIC_DATA_LEAF,
SIGNED_TX_REQUEST,
L1_TO_L2_MESSAGE_SECRET,
FUNCTION_ARGS,
GLOBAL_VARIABLES,
PARTIAL_CONTRACT_ADDRESS,
Comment thread
suyash67 marked this conversation as resolved.
/**
* Indices with size ≤ 16
*/
TX_REQUEST = 33, // Size = 14
/**
* Indices with size ≤ 44
*/
VK = 41, // Size = 35
PRIVATE_CIRCUIT_PUBLIC_INPUTS, // Size = 39
PUBLIC_CIRCUIT_PUBLIC_INPUTS, // Size = 32 (unused)
FUNCTION_ARGS, // Size ≤ 40
}
Loading