barretenberg
Loading...
Searching...
No Matches
eccvm_builder_types.hpp
1#pragma once
2
3#include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp"
4
5namespace proof_system_eccvm {
6
7static constexpr size_t NUM_SCALAR_BITS = 128;
8static constexpr size_t WNAF_SLICE_BITS = 4;
9static constexpr size_t NUM_WNAF_SLICES = (NUM_SCALAR_BITS + WNAF_SLICE_BITS - 1) / WNAF_SLICE_BITS;
10static constexpr uint64_t WNAF_MASK = static_cast<uint64_t>((1ULL << WNAF_SLICE_BITS) - 1ULL);
11static constexpr size_t POINT_TABLE_SIZE = 1ULL << (WNAF_SLICE_BITS);
12static constexpr size_t WNAF_SLICES_PER_ROW = 4;
13static constexpr size_t ADDITIONS_PER_ROW = 4;
14
15template <typename CycleGroup> struct VMOperation {
16 bool add = false;
17 bool mul = false;
18 bool eq = false;
19 bool reset = false;
20 typename CycleGroup::affine_element base_point = typename CycleGroup::affine_element{ 0, 0 };
21 uint256_t z1 = 0;
22 uint256_t z2 = 0;
23 typename CycleGroup::subgroup_field mul_scalar_full = 0;
24 [[nodiscard]] uint32_t get_opcode_value() const
25 {
26 auto res = static_cast<uint32_t>(add);
27 res += res;
28 res += static_cast<uint32_t>(mul);
29 res += res;
30 res += static_cast<uint32_t>(eq);
31 res += res;
32 res += static_cast<uint32_t>(reset);
33 return res;
34 }
35};
36template <typename CycleGroup> struct ScalarMul {
37 uint32_t pc;
38 uint256_t scalar;
39 typename CycleGroup::affine_element base_point;
40 std::array<int, NUM_WNAF_SLICES> wnaf_slices;
41 bool wnaf_skew;
42 std::array<typename CycleGroup::affine_element, POINT_TABLE_SIZE> precomputed_table;
43};
44
45template <typename CycleGroup> using MSM = std::vector<ScalarMul<CycleGroup>>;
46
47} // namespace proof_system_eccvm
Definition: uint256.hpp:25
Definition: eccvm_builder_types.hpp:36
Definition: eccvm_builder_types.hpp:15