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: Planned, auditors: [], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
7#pragma once
12
13namespace bb {
14
21template <typename Transcript> class TranslationData {
22 public:
24 using FF = typename Flavor::FF;
25 using BF = typename Flavor::BF;
29 static constexpr size_t SUBGROUP_SIZE = Flavor::Curve::SUBGROUP_SIZE;
30
31 // WITNESS_MASKING_TERM_LENGTH (shared, from constants.hpp) is the degree-1 masking term added to G to hide [G]
32 // and G(r); it must match the length the SmallSubgroupIPAProver consumes.
33 static constexpr size_t MASKED_CONCATENATED_WITNESS_LENGTH = SUBGROUP_SIZE + WITNESS_MASKING_TERM_LENGTH;
34
35 // M(X) whose Lagrange coefficients are given by (m_0||m_1|| ... || m_{NUM_TRANSLATION_EVALUATIONS-1} || 0 ||...||0)
37
38 // M(X) + Z_H(X) * R(X), where R(X) is a random polynomial of length = WITNESS_MASKING_TERM_LENGTH
41
42 // Interpolation domain {1, g, \ldots, g^{SUBGROUP_SIZE - 1}} required for Lagrange interpolation
43 std::array<FF, SUBGROUP_SIZE> interpolation_domain;
44
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.srs_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.
82 transcript->send_to_verifier("Translation:concatenated_masking_term_commitment",
84 }
91 void compute_concatenated_polynomials(const RefVector<Polynomial>& transcript_polynomials)
92 {
93 std::array<FF, SUBGROUP_SIZE> coeffs_lagrange_subgroup;
94
95 for (size_t idx = 0; idx < SUBGROUP_SIZE; idx++) {
96 coeffs_lagrange_subgroup[idx] = FF{ 0 };
97 }
98
99 // Extract the masking terms from the head of the transcript polynomials (top-of-trace masking)
100 // Positions 0..TRACE_OFFSET-1 contain: zero row (pos 0), masking values (pos 1,2,3)
101 constexpr size_t coeffs_per_poly = Flavor::TRACE_OFFSET;
102 for (size_t poly_idx = 0; poly_idx < NUM_TRANSLATION_EVALUATIONS; poly_idx++) {
103 for (size_t idx = 0; idx < coeffs_per_poly; idx++) {
104 size_t idx_to_populate = poly_idx * coeffs_per_poly + idx;
105 coeffs_lagrange_subgroup[idx_to_populate] = transcript_polynomials[poly_idx][idx];
106 }
107 }
108 concatenated_polynomial_lagrange = Polynomial(coeffs_lagrange_subgroup);
109
110 // Generate the masking term
112
113 // Compute monomial coefficients of the concatenated polynomial
114 Polynomial concatenated_monomial_form_unmasked(interpolation_domain, coeffs_lagrange_subgroup, SUBGROUP_SIZE);
115
116 for (size_t idx = 0; idx < SUBGROUP_SIZE; idx++) {
117 masked_concatenated_polynomial.at(idx) = concatenated_monomial_form_unmasked.at(idx);
118 }
119
120 // Mask the polynomial in monomial form.
121 for (size_t idx = 0; idx < masking_scalars.size(); idx++) {
122 masked_concatenated_polynomial.at(idx) -= masking_scalars.value_at(idx);
123 masked_concatenated_polynomial.at(SUBGROUP_SIZE + idx) += masking_scalars.value_at(idx);
124 }
125 }
126};
127} // namespace bb
typename Curve::ScalarField FF
typename G1::affine_element Commitment
typename Curve::BaseField BF
bb::Polynomial< FF > Polynomial
bb::CommitmentKey< Curve > CommitmentKey
static constexpr size_t TRACE_OFFSET
A template class for a reference vector. Behaves as if std::vector<T&> was possible.
A class designed to accept the ECCVM Transcript Polynomials, concatenate their masking terms in Lagra...
void compute_concatenated_polynomials(const RefVector< Polynomial > &transcript_polynomials)
Extract the first coefficients from each of the transcript polynomials, concatenate them as ,...
static constexpr size_t MASKED_CONCATENATED_WITNESS_LENGTH
TranslationData(const RefVector< Polynomial > &transcript_polynomials, const std::shared_ptr< Transcript > &transcript, CommitmentKey &commitment_key)
Let and . Given masked transcript polynomials for , we extract their first coefficients (the maski...
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 Univariate get_random()
Entry point for Barretenberg command-line interface.
Definition api.hpp:5