Skip to content

Commit 76c0028

Browse files
committed
fix black box func call inputs comments
1 parent c61968b commit 76c0028

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,14 @@ pub enum Opcode<F: AcirField> {
6868
/// Often used for exposing more efficient implementations of
6969
/// SNARK-unfriendly computations.
7070
///
71-
/// All black box functions take as input a tuple `(witness, num_bits)`,
72-
/// where `num_bits` is a constant representing the bit size of the input
73-
/// witness, and they have one or several witnesses as output.
71+
/// All black box functions input is specified as [FunctionInput],
72+
/// and they have one or several witnesses as output.
7473
///
7574
/// Some more advanced computations assume that the proving system has an
7675
/// 'embedded curve'. It is a curve that cycles with the main curve of the
7776
/// proving system, i.e the scalar field of the embedded curve is the base
7877
/// field of the main one, and vice-versa.
79-
///
80-
/// Aztec's Barretenberg uses BN254 as the main curve and Grumpkin as the
78+
/// e.g. Aztec's Barretenberg uses BN254 as the main curve and Grumpkin as the
8179
/// embedded curve.
8280
BlackBoxFuncCall(BlackBoxFuncCall<F>),
8381

acvm-repo/acir/src/circuit/opcodes/black_box_function_call.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,25 @@ use crate::{AcirField, BlackBoxFunc};
66
use serde::{Deserialize, Deserializer, Serialize, Serializer};
77
use thiserror::Error;
88

9-
// Note: Some functions will not use all of the witness
10-
// So we need to supply how many bits of the witness is needed
11-
9+
/// Enumeration for black box function inputs
1210
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)]
1311
#[cfg_attr(feature = "arb", derive(proptest_derive::Arbitrary))]
1412
pub enum ConstantOrWitnessEnum<F> {
13+
/// A constant field element
1514
Constant(F),
15+
/// A witness element, representing dynamic inputs
1616
Witness(Witness),
1717
}
1818

19+
/// Input to a black box call
1920
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)]
2021
#[cfg_attr(feature = "arb", derive(proptest_derive::Arbitrary))]
2122
pub struct FunctionInput<F> {
23+
/// The actual input value
2224
input: ConstantOrWitnessEnum<F>,
25+
/// A constant representing the bit size of the input value
26+
/// Some functions will not use all of the witness
27+
/// So we need to supply how many bits of the witness is needed
2328
num_bits: u32,
2429
}
2530

@@ -81,6 +86,11 @@ impl<F: std::fmt::Display> std::fmt::Display for FunctionInput<F> {
8186
}
8287
}
8388

89+
/// These opcodes represent a specialized computation.
90+
/// Even if any computation can be done using only assert-zero opcodes,
91+
/// it is not always efficient.
92+
/// Some proving systems, can implement several computations more efficiently using
93+
/// techniques such as custom gates and lookup tables.
8494
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Hash)]
8595
pub enum BlackBoxFuncCall<F> {
8696
/// Ciphers (encrypts) the provided plaintext using AES128 in CBC mode,

0 commit comments

Comments
 (0)