Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
eccvm_translation_data.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: not started, auditors: [], date: YYYY-MM-DD }
3// external_1: { status: not started, auditors: [], date: YYYY-MM-DD }
4// external_2: { status: not started, auditors: [], date: YYYY-MM-DD }
5// =====================
6
7#pragma once
11
12namespace bb {
13
20template <typename Transcript> class TranslationData {
21 public:
23 using FF = typename Flavor::FF;
24 using BF = typename Flavor::BF;
28 static constexpr size_t SUBGROUP_SIZE = Flavor::Curve::SUBGROUP_SIZE;
29
30 // A masking term of length 2 (degree 1) is required to mask [G] and G(r).
31 static constexpr size_t WITNESS_MASKING_TERM_LENGTH = 2;
33
34 // M(X) whose Lagrange coefficients are given by (m_0||m_1|| ... || m_{NUM_TRANSLATION_EVALUATIONS-1} || 0 ||...||0)
36
37 // M(X) + Z_H(X) * R(X), where R(X) is a random polynomial of length = WITNESS_MASKING_TERM_LENGTH
39
40 // Interpolation domain {1, g, \ldots, g^{SUBGROUP_SIZE - 1}} required for Lagrange interpolation
41 std::array<FF, SUBGROUP_SIZE> interpolation_domain;
42
60 TranslationData(const RefVector<Polynomial>& transcript_polynomials,
61 const std::shared_ptr<Transcript>& transcript,
62 CommitmentKey& commitment_key)
65 {
66 // Reallocate the commitment key if necessary. This is an edge case with SmallSubgroupIPA since it has
67 // polynomials that may exceed the circuit size.
68 if (commitment_key.dyadic_size < MASKED_CONCATENATED_WITNESS_LENGTH) {
70 }
71 // Create interpolation domain required for Lagrange interpolation
72 interpolation_domain[0] = FF{ 1 };
73
74 for (size_t idx = 1; idx < SUBGROUP_SIZE; idx++) {
75 interpolation_domain[idx] = interpolation_domain[idx - 1] * Flavor::Curve::subgroup_generator;
76 }
77 // Concatenate the last entries of the `transcript_polynomials`.
78 compute_concatenated_polynomials(transcript_polynomials);
79
80 // Commit to M(X) + Z_H(X)*R(X), where R is a random polynomial of WITNESS_MASKING_TERM_LENGTH.
81 transcript->send_to_verifier("Translation:concatenated_masking_term_commitment",
82 commitment_key.commit(masked_concatenated_polynomial));
83 }
91 void compute_concatenated_polynomials(const RefVector<Polynomial>& transcript_polynomials)
92 {
93 const size_t circuit_size = transcript_polynomials[0].size();
94
95 std::array<FF, SUBGROUP_SIZE> coeffs_lagrange_subgroup;
96
97 for (size_t idx = 0; idx < SUBGROUP_SIZE; idx++) {
98 coeffs_lagrange_subgroup[idx] = FF{ 0 };
99 }
100
101 // Extract the Lagrange coefficients of the concatenated masking term from the transcript polynomials
102 for (size_t poly_idx = 0; poly_idx < NUM_TRANSLATION_EVALUATIONS; poly_idx++) {
103 for (size_t idx = 0; idx < NUM_DISABLED_ROWS_IN_SUMCHECK; idx++) {
104 size_t idx_to_populate = poly_idx * NUM_DISABLED_ROWS_IN_SUMCHECK + idx;
105 coeffs_lagrange_subgroup[idx_to_populate] =
106 transcript_polynomials[poly_idx].at(circuit_size - NUM_DISABLED_ROWS_IN_SUMCHECK + idx);
107 }
108 }
109 concatenated_polynomial_lagrange = Polynomial(coeffs_lagrange_subgroup);
110
111 // Generate the masking term
113
114 // Compute monomial coefficients of the concatenated polynomial
115 Polynomial concatenated_monomial_form_unmasked(interpolation_domain, coeffs_lagrange_subgroup, SUBGROUP_SIZE);
116
117 for (size_t idx = 0; idx < SUBGROUP_SIZE; idx++) {
118 masked_concatenated_polynomial.at(idx) = concatenated_monomial_form_unmasked.at(idx);
119 }
120
121 // Mask the polynomial in monomial form.
122 for (size_t idx = 0; idx < masking_scalars.size(); idx++) {
123 masked_concatenated_polynomial.at(idx) -= masking_scalars.value_at(idx);
124 masked_concatenated_polynomial.at(SUBGROUP_SIZE + idx) += masking_scalars.value_at(idx);
125 }
126 }
127};
128} // namespace bb
typename Curve::ScalarField FF
typename G1::affine_element Commitment
typename Curve::BaseField BF
bb::Polynomial< FF > Polynomial
bb::CommitmentKey< Curve > CommitmentKey
A template class for a reference vector. Behaves as if std::vector<T&> was possible.
std::size_t size() const
A class designed to accept the ECCVM Transcript Polynomials, concatenate their masking terms in Lagra...
void compute_concatenated_polynomials(const RefVector< Polynomial > &transcript_polynomials)
Let and let be the vectors of last coeffs in each transcript poly , we compute the concatenation ...
static constexpr size_t MASKED_CONCATENATED_WITNESS_LENGTH
TranslationData(const RefVector< Polynomial > &transcript_polynomials, const std::shared_ptr< Transcript > &transcript, CommitmentKey &commitment_key)
Given masked transcript_polynomials , for , we extract and concatenate their masking terms ....
typename Flavor::CommitmentKey CommitmentKey
typename Flavor::Polynomial Polynomial
static constexpr size_t SUBGROUP_SIZE
typename Flavor::Commitment Commitment
std::array< FF, SUBGROUP_SIZE > interpolation_domain
static constexpr size_t WITNESS_MASKING_TERM_LENGTH
static Univariate get_random()
Entry point for Barretenberg command-line interface.