Skip to content

Commit b36603c

Browse files
committed
Merge branch 'master' into tf/pull-out-get-all-contracts
* master: chore: add timeouts to CI (#7725) chore: Resolve various rustdoc warnings (#7724) chore: encapsulate `Index` within `LocalModuleId` (#7719) fix: doc comments on functions warn unexpectedly (#7721) chore: update docusaurus config to correct trailing slash issue (#7720) feat: allow `fn` returning `()` without having to write `-> ()` (#7717) fix: allow omitting ';' after last block statement if it's an assignment (#7718) chore: fix rustdoc issues (#7712) chore: check test program execution success output (#7713) chore: remove ultraplonk tests (#7680) chore(docs): Document BlackBoxFuncCall enum (#7702)
2 parents 3cd44ba + d587fcc commit b36603c

File tree

154 files changed

+817
-631
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+817
-631
lines changed

.github/workflows/reports.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ jobs:
1010
benchmark-projects-list:
1111
name: Load benchmark projects list
1212
runs-on: ubuntu-22.04
13+
timeout-minutes: 5
1314
outputs:
1415
projects: ${{ steps.get_bench_projects.outputs.projects }}
1516

@@ -26,6 +27,7 @@ jobs:
2627
2728
build-nargo:
2829
runs-on: ubuntu-22.04
30+
timeout-minutes: 15
2931

3032
steps:
3133
- name: Checkout Noir repo
@@ -61,6 +63,7 @@ jobs:
6163
name: Circuit sizes
6264
needs: [build-nargo]
6365
runs-on: ubuntu-24.04
66+
timeout-minutes: 20
6467
permissions:
6568
pull-requests: write
6669

@@ -101,6 +104,7 @@ jobs:
101104
name: Brillig bytecode sizes
102105
needs: [build-nargo]
103106
runs-on: ubuntu-22.04
107+
timeout-minutes: 20
104108
permissions:
105109
pull-requests: write
106110

@@ -150,6 +154,7 @@ jobs:
150154
name: Brillig execution trace sizes
151155
needs: [build-nargo]
152156
runs-on: ubuntu-22.04
157+
timeout-minutes: 20
153158
permissions:
154159
pull-requests: write
155160

@@ -199,6 +204,7 @@ jobs:
199204
name: Peak memory usage
200205
needs: [build-nargo]
201206
runs-on: ubuntu-22.04
207+
timeout-minutes: 20
202208
permissions:
203209
pull-requests: write
204210

@@ -240,6 +246,7 @@ jobs:
240246
name: Compilation and execution time
241247
needs: [build-nargo]
242248
runs-on: ubuntu-22.04
249+
timeout-minutes: 20
243250
permissions:
244251
pull-requests: write
245252

@@ -507,6 +514,7 @@ jobs:
507514
upload_compilation_report:
508515
name: Upload compilation report
509516
needs: [generate_compilation_and_execution_report, external_repo_compilation_and_execution_report]
517+
timeout-minutes: 5
510518
# We want this job to run even if one variation of the matrix in `external_repo_compilation_and_execution_report` fails
511519
if: always()
512520
runs-on: ubuntu-22.04
@@ -558,6 +566,7 @@ jobs:
558566
upload_compilation_memory_report:
559567
name: Upload compilation memory report
560568
needs: [generate_memory_report, external_repo_memory_report]
569+
timeout-minutes: 5
561570
# We want this job to run even if one variation of the matrix in `external_repo_memory_report` fails
562571
if: always()
563572
runs-on: ubuntu-22.04
@@ -608,6 +617,7 @@ jobs:
608617
upload_execution_memory_report:
609618
name: Upload execution memory report
610619
needs: [generate_memory_report, external_repo_memory_report]
620+
timeout-minutes: 5
611621
# We want this job to run even if one variation of the matrix in `external_repo_memory_report` fails
612622
if: always()
613623
runs-on: ubuntu-22.04
@@ -655,10 +665,10 @@ jobs:
655665
alert-comment-cc-users: "@TomAFrench"
656666
max-items-in-chart: 50
657667

658-
659668
upload_execution_report:
660669
name: Upload execution report
661670
needs: [generate_compilation_and_execution_report, external_repo_compilation_and_execution_report]
671+
timeout-minutes: 5
662672
# We want this job to run even if one variation of the matrix in `external_repo_compilation_and_execution_report` fails
663673
if: always()
664674
runs-on: ubuntu-22.04
@@ -711,6 +721,7 @@ jobs:
711721
reports-end:
712722
name: End
713723
runs-on: ubuntu-22.04
724+
timeout-minutes: 5
714725
# We want this job to always run (even if the dependant jobs fail) as we want this job to fail rather than skipping.
715726
if: ${{ always() }}
716727
needs:

acvm-repo/acir/README.md

+18-16
Original file line numberDiff line numberDiff line change
@@ -211,27 +211,29 @@ The black box functions supported by ACIR are:
211211
**Sha256Compression**: SHA256 compression function
212212

213213
**RecursiveAggregation**: verify a proof inside the circuit.
214-
**Warning: this opcode is subject to change.**
215214

216-
This black box function does not fully verify a proof, what it does is verify
217-
that the provided `key_hash` is indeed a hash of `verification_key`, allowing
218-
the user to use the verification key as private inputs and only have the
219-
`key_hash` as public input, which is more performant.
215+
Computes a recursive aggregation object internally when verifying a proof inside
216+
another circuit.
217+
The outputted aggregation object will then be either checked in a
218+
top-level verifier or aggregated upon again.
219+
The aggregation object should be maintained by the backend implementer.
220220

221-
Another thing that it does is preparing the verification of the proof. In order
222-
to fully verify a proof, some operations may still be required to be done by the
223-
final verifier. This is why this black box function does not say if verification
224-
is passing or not.
221+
This opcode prepares the verification of the final proof.
222+
In order to fully verify a recursive proof, some operations may still be required
223+
to be done by the final verifier (e.g. a pairing check).
224+
This is why this black box function does not say if verification is passing or not.
225+
It delays the expensive part of verification out of the SNARK
226+
and leaves it to the final verifier outside of the SNARK circuit.
225227

226-
If you have several proofs to verify in one ACIR program, you would call
227-
`RecursiveAggregation()` multiple times while passing the
228-
`output_aggregation_object` as `input_aggregation_object` to the next
229-
`RecursiveAggregation()` call, except for the first call where you do not have
230-
any `input_aggregation_object`.
228+
This opcode also verifies that the key_hash is indeed a hash of verification_key,
229+
allowing the user to use the verification key as private inputs and only
230+
have the key_hash as public input, which is more performant.
231231

232-
If one of the proof you verify with the black box function does not verify, then
233-
the verification of the proof of the main ACIR program will ultimately fail.
232+
**Warning: the key hash logic does not need to be part of the black box and subject to be removed.**
234233

234+
If one of the recursive proofs you verify with the black box function fails to
235+
verify, then the verification of the final proof of the main ACIR program will
236+
ultimately fail.
235237

236238
### Brillig
237239

acvm-repo/acir/src/circuit/black_box_functions.rs

+23-127
Original file line numberDiff line numberDiff line change
@@ -6,155 +6,51 @@
66
use serde::{Deserialize, Serialize};
77
use strum_macros::EnumIter;
88

9+
/// Representation of available black box function names.
10+
/// This enum should be used to represent a black box before we have set up the
11+
/// appropriate inputs and outputs. At which point it should be converted to a [crate::circuit::opcodes::BlackBoxFuncCall]
912
#[allow(clippy::upper_case_acronyms)]
1013
#[derive(Clone, Debug, Hash, Copy, PartialEq, Eq, Serialize, Deserialize, EnumIter)]
1114
pub enum BlackBoxFunc {
12-
/// Ciphers (encrypts) the provided plaintext using AES128 in CBC mode,
13-
/// padding the input using PKCS#7.
14-
/// - inputs: byte array `[u8; N]`
15-
/// - iv: initialization vector `[u8; 16]`
16-
/// - key: user key `[u8; 16]`
17-
/// - outputs: byte vector `[u8]` of length `input.len() + (16 - input.len() % 16)`
15+
/// More details can be found at [crate::circuit::opcodes::BlackBoxFuncCall::AES128Encrypt]
1816
AES128Encrypt,
19-
20-
/// Performs the bitwise AND of `lhs` and `rhs`. `bit_size` must be the same for
21-
/// both inputs.
22-
/// - lhs: (witness, bit_size)
23-
/// - rhs: (witness, bit_size)
24-
/// - output: a witness whose value is constrained to be lhs AND rhs, as
25-
/// bit_size bit integers
17+
/// More details can be found at [crate::circuit::opcodes::BlackBoxFuncCall::AND]
2618
AND,
27-
28-
/// Performs the bitwise XOR of `lhs` and `rhs`. `bit_size` must be the same for
29-
/// both inputs.
30-
/// - lhs: (witness, bit_size)
31-
/// - rhs: (witness, bit_size)
32-
/// - output: a witness whose value is constrained to be lhs XOR rhs, as
33-
/// bit_size bit integers
19+
/// More details can be found at [crate::circuit::opcodes::BlackBoxFuncCall::XOR]
3420
XOR,
35-
36-
/// Range constraint to ensure that a witness
37-
/// can be represented in the specified number of bits.
38-
/// - input: (witness, bit_size)
21+
/// More details can be found at [crate::circuit::opcodes::BlackBoxFuncCall::RANGE]
3922
RANGE,
40-
41-
/// Computes the Blake2s hash of the inputs, as specified in
42-
/// https://tools.ietf.org/html/rfc7693
43-
/// - inputs are a byte array, i.e a vector of (witness, 8)
44-
/// - output is a byte array of length 32, i.e. an array of 32
45-
/// (witness, 8), constrained to be the blake2s of the inputs.
23+
/// More details can be found at [crate::circuit::opcodes::BlackBoxFuncCall::Blake2s]
4624
Blake2s,
47-
48-
/// Computes the Blake3 hash of the inputs
49-
/// - inputs are a byte array, i.e a vector of (witness, 8)
50-
/// - output is a byte array of length 32, i.e an array of 32
51-
/// (witness, 8), constrained to be the blake3 of the inputs.
25+
/// More details can be found at [crate::circuit::opcodes::BlackBoxFuncCall::Blake3]
5226
Blake3,
53-
54-
/// Verifies a ECDSA signature over the secp256k1 curve.
55-
/// - inputs:
56-
/// - x coordinate of public key as 32 bytes
57-
/// - y coordinate of public key as 32 bytes
58-
/// - the signature, as a 64 bytes array
59-
/// - the hash of the message, as a vector of bytes
60-
/// - output: 0 for failure and 1 for success
27+
/// More details can be found at [crate::circuit::opcodes::BlackBoxFuncCall::EcdsaSecp256k1]
6128
EcdsaSecp256k1,
62-
63-
/// Verifies a ECDSA signature over the secp256r1 curve.
64-
///
65-
/// Same as EcdsaSecp256k1, but done over another curve.
29+
/// More details can be found at [crate::circuit::opcodes::BlackBoxFuncCall::EcdsaSecp256r1]
6630
EcdsaSecp256r1,
67-
68-
/// Multiple scalar multiplication (MSM) with a variable base/input point
69-
/// (P) of the embedded curve. An MSM multiplies the points and scalars and
70-
/// sums the results.
71-
/// - input:
72-
/// points (witness, N) a vector of x and y coordinates of input
73-
/// points `[x1, y1, x2, y2,...]`.
74-
/// scalars (witness, N) a vector of low and high limbs of input
75-
/// scalars `[s1_low, s1_high, s2_low, s2_high, ...]`. (witness, N)
76-
/// For Barretenberg, they must both be less than 128 bits.
77-
/// - output:
78-
/// a tuple of `x` and `y` coordinates of output.
79-
/// Points computed as `s_low*P+s_high*2^{128}*P`
80-
///
81-
/// Because the Grumpkin scalar field is bigger than the ACIR field, we
82-
/// provide 2 ACIR fields representing the low and high parts of the Grumpkin
83-
/// scalar $a$: `a=low+high*2^{128}`, with `low, high < 2^{128}`
31+
/// More details can be found at [crate::circuit::opcodes::BlackBoxFuncCall::MultiScalarMul]
8432
MultiScalarMul,
85-
86-
/// Keccak Permutation function of width 1600
87-
/// - inputs: An array of 25 64-bit Keccak lanes that represent a keccak sponge of 1600 bits
88-
/// - outputs: The result of a keccak f1600 permutation on the input state. Also an array of 25 Keccak lanes.
33+
/// More details can be found at [crate::circuit::opcodes::BlackBoxFuncCall::Keccakf1600]
8934
Keccakf1600,
90-
91-
/// Compute a recursive aggregation object when verifying a proof inside
92-
/// another circuit.
93-
/// This outputted aggregation object will then be either checked in a
94-
/// top-level verifier or aggregated upon again.
95-
///
96-
/// **Warning: this opcode is subject to change.**
97-
/// Note that the `254` in `(witness, 254)` refers to the upper bound of
98-
/// the `witness`.
99-
/// - verification_key: Vector of (witness, 254) representing the
100-
/// verification key of the circuit being verified
101-
/// - public_inputs: Vector of (witness, 254) representing the public
102-
/// inputs corresponding to the proof being verified
103-
/// - key_hash: one (witness, 254). It should be the hash of the
104-
/// verification key. Barretenberg expects the Pedersen hash of the
105-
/// verification key
106-
///
107-
/// Another thing that it does is preparing the verification of the proof.
108-
/// In order to fully verify a proof, some operations may still be required
109-
/// to be done by the final verifier. This is why this black box function
110-
/// does not say if verification is passing or not.
111-
///
112-
/// This black box function does not fully verify a proof, what it does is
113-
/// verifying that the key_hash is indeed a hash of verification_key,
114-
/// allowing the user to use the verification key as private inputs and only
115-
/// have the key_hash as public input, which is more performant.
116-
///
117-
/// If one of the recursive proofs you verify with the black box function does not
118-
/// verify, then the verification of the proof of the main ACIR program will
119-
/// ultimately fail.
35+
/// More details can be found at [crate::circuit::opcodes::BlackBoxFuncCall::RecursiveAggregation]
12036
RecursiveAggregation,
121-
122-
/// Addition over the embedded curve on which the witness is defined
123-
/// The opcode makes the following assumptions but does not enforce them because
124-
/// it is more efficient to do it only when required. For instance, adding two
125-
/// points that are on the curve it guarantee to give a point on the curve.
126-
///
127-
/// It assumes that the points are on the curve.
128-
/// If the inputs are the same witnesses index, it will perform a doubling,
129-
/// If not, it assumes that the points' x-coordinates are not equal.
130-
/// It also assumes neither point is the infinity point.
37+
/// More details can be found at [crate::circuit::opcodes::BlackBoxFuncCall::EmbeddedCurveAdd]
13138
EmbeddedCurveAdd,
132-
133-
/// BigInt addition
39+
/// More details can be found at [crate::circuit::opcodes::BlackBoxFuncCall::BigIntAdd]
13440
BigIntAdd,
135-
136-
/// BigInt subtraction
41+
/// More details can be found at [crate::circuit::opcodes::BlackBoxFuncCall::BigIntSub]
13742
BigIntSub,
138-
139-
/// BigInt multiplication
43+
/// More details can be found at [crate::circuit::opcodes::BlackBoxFuncCall::BigIntMul]
14044
BigIntMul,
141-
142-
/// BigInt division
45+
/// More details can be found at [crate::circuit::opcodes::BlackBoxFuncCall::BigIntDiv]
14346
BigIntDiv,
144-
145-
/// BigInt from le bytes
47+
/// More details can be found at [crate::circuit::opcodes::BlackBoxFuncCall::BigIntFromLeBytes]
14648
BigIntFromLeBytes,
147-
148-
/// BigInt to le bytes
49+
/// More details can be found at [crate::circuit::opcodes::BlackBoxFuncCall::BigIntToLeBytes]
14950
BigIntToLeBytes,
150-
151-
/// Permutation function of Poseidon2
51+
/// More details can be found at [crate::circuit::opcodes::BlackBoxFuncCall::Poseidon2Permutation]
15252
Poseidon2Permutation,
153-
154-
/// SHA256 compression function
155-
/// - input: [(witness, 32); 16]
156-
/// - state: [(witness, 32); 8]
157-
/// - output: [(witness, 32); 8]
53+
/// More details can be found at [crate::circuit::opcodes::BlackBoxFuncCall::Sha256Compression]
15854
Sha256Compression,
15955
}
16056

acvm-repo/acir/src/circuit/brillig.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub enum BrilligOutputs {
2424

2525
/// This is purely a wrapper struct around a list of Brillig opcode's which represents
2626
/// a full Brillig function to be executed by the Brillig VM.
27-
/// This is stored separately on a program and accessed through a [BrilligPointer].
27+
/// This is stored separately on a program and accessed through a [BrilligFunctionId].
2828
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Default, Debug, Hash)]
2929
#[cfg_attr(feature = "arb", derive(proptest_derive::Arbitrary))]
3030
pub struct BrilligBytecode<F> {

0 commit comments

Comments
 (0)