Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
secp256r1_fixed_base_params.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: not started, auditors: [], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
7#pragma once
8
9#include <cstddef>
10
11namespace bb::plookup {
12
23 // 7-bit-dominant window layout with short tails per half.
24 // Lo half (20 windows = 19 × 7 + 1 × 3 = 136 bits) covers the bigfield's lo half (= 2·NUM_LIMB_BITS).
25 // Hi half (18 windows = 17 × 7 + 1 × 1 = 120 bits) covers the bigfield's hi half
26 // (= NUM_LIMB_BITS + NUM_LAST_LIMB_BITS).
27 //
28 // The "big" windows are all 7-bit (128 entries); each half ends in a short tail window so the
29 // per-half bit count matches the bigfield's invariant exactly. Inter-window steps are uniformly
30 // 128 across both halves (every transition is at a 7-bit boundary), so the MultiTable column-1
31 // coefficient is uniformly 128 — the tail's smaller `slice_size` is what distinguishes it.
32 static constexpr size_t NUM_WINDOWS_LO = 20;
33 static constexpr size_t NUM_WINDOWS_HI = 18;
34 static constexpr size_t NUM_WINDOWS = NUM_WINDOWS_LO + NUM_WINDOWS_HI;
35 static constexpr size_t WINDOW_BITS = 7;
36 static constexpr size_t WINDOW_BITS_LO_TAIL = 3;
37 static constexpr size_t WINDOW_BITS_HI_TAIL = 1;
38 static constexpr size_t TABLE_SIZE_BIG = 1ULL << WINDOW_BITS; // 128
39 static constexpr size_t TABLE_SIZE_LO_TAIL = 1ULL << WINDOW_BITS_LO_TAIL; // 8
40 static constexpr size_t TABLE_SIZE_HI_TAIL = 1ULL << WINDOW_BITS_HI_TAIL; // 2
41 static constexpr size_t NUM_AXES = 4;
42
43 // Named indices of the two tail windows within the global [0, NUM_WINDOWS) range.
44 static constexpr size_t LO_TAIL_WINDOW = NUM_WINDOWS_LO - 1; // 19
45 static constexpr size_t HI_TAIL_WINDOW = NUM_WINDOWS - 1; // 37
46
47 static_assert((NUM_WINDOWS_LO - 1) * WINDOW_BITS + WINDOW_BITS_LO_TAIL == 136,
48 "lo half must cover 2·NUM_LIMB_BITS = 136 bits");
49 static_assert((NUM_WINDOWS_HI - 1) * WINDOW_BITS + WINDOW_BITS_HI_TAIL == 120,
50 "hi half must cover NUM_LIMB_BITS + NUM_LAST_LIMB_BITS = 120 bits");
51
52 // Per-window helpers: window position w ∈ [0, NUM_WINDOWS) → (bit-width, table-size).
53 static constexpr size_t window_bits(size_t w)
54 {
55 if (w == LO_TAIL_WINDOW) {
57 }
58 if (w == HI_TAIL_WINDOW) {
60 }
61 return WINDOW_BITS;
62 }
63 static constexpr size_t table_size(size_t w)
64 {
65 if (w == LO_TAIL_WINDOW) {
66 return TABLE_SIZE_LO_TAIL;
67 }
68 if (w == HI_TAIL_WINDOW) {
69 return TABLE_SIZE_HI_TAIL;
70 }
71 return TABLE_SIZE_BIG;
72 }
73};
74
75} // namespace bb::plookup
Layout parameters for the secp256r1 fixed-base plookup decomposition.
static constexpr size_t window_bits(size_t w)