Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7622668
comments in generator lookup tables.
suyash67 Aug 13, 2025
9cfd789
cleanup and avoid hard-coded num limb bits.
suyash67 Aug 13, 2025
5810139
remove unused fns.
suyash67 Aug 13, 2025
1a9afd2
minor pointers in twin rom table.
suyash67 Aug 16, 2025
cbfa9f4
remove redundant condition on zero index, put_constant_variable shoul…
suyash67 Aug 16, 2025
0cba4f4
move create_endo_pair_four_bit_table_plookup to biggroup_tables.
suyash67 Aug 18, 2025
19123ad
use NUM_LIMBS instead of hard-coded values.
suyash67 Aug 18, 2025
0c0f446
fix warnings in structs, add default destructors and move constructors.
suyash67 Aug 18, 2025
59a7ef9
fix warnings in function arg names
suyash67 Aug 18, 2025
f5ce7e2
cosmetic fixes.
suyash67 Aug 18, 2025
c298ab3
dest for element.
suyash67 Aug 18, 2025
d0c8e28
remove unused create_endo_pair_five_lookup_table
suyash67 Aug 18, 2025
93e507b
remove unused batch_lookup_table_base.
suyash67 Aug 18, 2025
e50b1ff
fix warning in batch_lookup_table_plookup constr.
suyash67 Aug 18, 2025
0dbf115
add comments and simplify batch_lookup_table_plookup constr.
suyash67 Aug 18, 2025
ab63952
minor fix
suyash67 Aug 18, 2025
f7226b0
minor fix
suyash67 Aug 18, 2025
3fcc637
draft readme for lookup tables.
suyash67 Aug 18, 2025
f80affa
add todo
suyash67 Aug 18, 2025
8f2db9b
fix format.
suyash67 Sep 9, 2025
14dba4d
remove lookup_table_base as its not used anywhere.
suyash67 Sep 9, 2025
92f60b0
avoid hard-coded values.
suyash67 Sep 9, 2025
0e50d01
comments and fix warnings.
suyash67 Sep 9, 2025
faac600
avoid hard-coded values.
suyash67 Sep 9, 2025
6a3e1ef
remove (unused) len = 7 case.
suyash67 Sep 9, 2025
fd66488
address comments.
suyash67 Sep 25, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
$\newcommand{\endogroup}{\textcolor{orange}{\lambda}}$
$\newcommand{\endofield}{\textcolor{orange}{\beta}}$
$\newcommand{\rom}[1]{\textcolor{purple}{#1}}$
$\newcommand{\windex}[1]{\textcolor{grey}{#1}}$

### Lookup Tables in Biggroup

In the biggroup class, we use lookup tables to store precomputed multiples of a fixed group element $P$. Since we use the wNAF (windowed non-adjacent form) method for scalar multiplication, we need to store odd multiples of $P$ up to a certain window size. Further, to leverage endomorphism while computing scalar multiplication, we also store the endomorphic mapping of the multiples of $P$ in the table. For instance with a wNAF window size of 3, the lookup table for $P$ is represented as follows:

| Index | Element | Endomorphism |
| ----- | ------------ | ----------------------- |
| 0 | $-7 \cdot P$ | $-7 \endogroup \cdot P$ |
| 1 | $-5 \cdot P$ | $-5 \endogroup \cdot P$ |
| 2 | $-3 \cdot P$ | $-3 \endogroup \cdot P$ |
| 3 | $-1 \cdot P$ | $-1 \endogroup \cdot P$ |
| 4 | $1 \cdot P$ | $1 \endogroup \cdot P$ |
| 5 | $3 \cdot P$ | $3 \endogroup \cdot P$ |
| 6 | $5 \cdot P$ | $5 \endogroup \cdot P$ |
| 7 | $7 \cdot P$ | $7 \endogroup \cdot P$ |

Note that our wNAF form uses only (positive and negative) odd multiples of $P$ so as to avoid handling conditional logic in the circuit for 0 values. Each group element in the above table is represented as a point on the elliptic curve: $Q = (x, y)$ such that $x, y \in \mathbb{F}_q$. In our case, $\mathbb{F}_q$ is either the base field of BN254 or secp256k1 (or secp256r1). Since the native field used in our circuits is the scalar field $\mathbb{F}_r$ of BN254, $x$ and $y$ are non-native field elements and are represented as two `bigfield` elements, i.e., each of $x$ and $y$ consists of four binary-basis limbs and one prime-basis limb:

$$
\begin{aligned}
x &\equiv (x_0, x_1, x_2, x_3, x_p) & & \in \mathbb{F}_r^5, \\
y &\equiv (y_0, y_1, y_2, y_3, y_p) & & \in \mathbb{F}_r^5.
\end{aligned}
$$

Thus, when generating lookup tables, each element $Q$ in the table is represented as a tuple of 10 native field elements. Since we only support tables with one key and two values, we need 5 tables to represent the group element $Q$:

| Table 1: xlo | | | Table 2: xhi | |
| ------------ | ------- | --- | ------------ | ------- |
| Value 1 | Value 2 | | Value 1 | Value 2 |
| $x_0$ | $x_1$ | | $x_2$ | $x_3$ |

| Table 3: ylo | | | Table 4: yhi | |
| ------------ | ------- | --- | ------------ | ------- |
| Value 1 | Value 2 | | Value 1 | Value 2 |
| $y_0$ | $y_1$ | | $y_2$ | $y_3$ |

| Table 5: prime table | |
| -------------------- | ------- |
| Value 1 | Value 2 |
| $x_p$ | $y_p$ |

Additionally, we also need tables for the endomorphism values. Suppose $x' := \endofield \cdot x$ is the x-coordinate of the endomorphism of the group element $Q$, represented as $x' = (x'_0, x'_1, x'_2, x'_3, x'_p) \in \mathbb{F}_r^5$. The endomorphism table is represented as follows:

| endo xlo table | | | | endo xhi table | |
| -------------- | ------- | --- | --- | -------------- | ------- |
| Value 1 | Value 2 | | | Value 1 | Value 2 |
| $x'_0$ | $x'_1$ | | | $x'_2$ | $x'_3$ |

| endo prime table | |
| ---------------- | ------- |
| Value 1 | Value 2 |
| $x'_p$ | $y_p$ |

Note that since the y-coordinate remains unchanged under the endomorphism, we can use the same y-coordinate tables. For the prime-basis limb of the endomorphism, we use the same value $y_p$ (which is redundant but ensures consistency of using two-column tables). Thus, overall we need 8 tables to represent the lookup table for a group element $P$ with each table size being $2^3$ (for a wNAF window size of 3).

> Note:
> In the context of biggroup, we need variable-base lookup tables and fixed-base lookup tables. The variable-base lookup tables are used when the base point $P$ is not known at circuit synthesis time and is provided as a circuit witness. In this case, we need to generate the lookup tables on-the-fly based on the input base point $P$. On the other hand, fixed-base lookup tables are used when the base point $P$ is known at circuit synthesis time and can be hardcoded into the circuit (for example group generators). Fixed-base lookup tables are more efficient as they can be precomputed and do not require additional gates to enforce the correctness of the table entries. Variable-base lookup tables are realized using ROM tables (described below) while fixed-base lookup tables are realized using standard lookup tables in the circuit.

Refer to the [ROM table documentation](../memory/README.md) for details on how ROM tables are implemented in Barretenberg.
Loading
Loading