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
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
58 TranslationData(const RefVector<Polynomial>& transcript_polynomials,
59 const std::shared_ptr<Transcript>& transcript,
60 CommitmentKey& commitment_key)
63 {
64 // Reallocate the commitment key if necessary. This is an edge case with SmallSubgroupIPA since it has
65 // polynomials that may exceed the circuit size.
66 if (commitment_key.srs_size < MASKED_CONCATENATED_WITNESS_LENGTH) {
68 }
69 // Create interpolation domain required for Lagrange interpolation
70 interpolation_domain[0] = FF{ 1 };
71
72 for (size_t idx = 1; idx < SUBGROUP_SIZE; idx++) {
73 interpolation_domain[idx] = interpolation_domain[idx - 1] * Flavor::Curve::subgroup_generator;
74 }
75 // Concatenate the last entries of the `transcript_polynomials`.
76 compute_concatenated_polynomials(transcript_polynomials);
77
78 // Commit to M(X) + Z_H(X)*R(X), where R is a random polynomial of WITNESS_MASKING_TERM_LENGTH.
79 transcript->send_to_verifier("Translation:concatenated_masking_term_commitment",
80 commitment_key.commit(masked_concatenated_polynomial));
81 }
88 void compute_concatenated_polynomials(const RefVector<Polynomial>& transcript_polynomials)
89 {
90 std::array<FF, SUBGROUP_SIZE> coeffs_lagrange_subgroup;
91
92 for (size_t idx = 0; idx < SUBGROUP_SIZE; idx++) {
93 coeffs_lagrange_subgroup[idx] = FF{ 0 };
94 }
95
96 // Extract the masking terms from the head of the transcript polynomials (top-of-trace masking)
97 // Positions 0..TRACE_OFFSET-1 contain: zero row (pos 0), masking values (pos 1,2,3)
98 constexpr size_t coeffs_per_poly = Flavor::TRACE_OFFSET;
99 for (size_t poly_idx = 0; poly_idx < NUM_TRANSLATION_EVALUATIONS; poly_idx++) {
100 for (size_t idx = 0; idx < coeffs_per_poly; idx++) {
101 size_t idx_to_populate = poly_idx * coeffs_per_poly + idx;
102 coeffs_lagrange_subgroup[idx_to_populate] = transcript_polynomials[poly_idx][idx];
103 }
104 }
105 concatenated_polynomial_lagrange = Polynomial(coeffs_lagrange_subgroup);
106
107 // Generate the masking term
109
110 // Compute monomial coefficients of the concatenated polynomial
111 Polynomial concatenated_monomial_form_unmasked(interpolation_domain, coeffs_lagrange_subgroup, SUBGROUP_SIZE);
112
113 for (size_t idx = 0; idx < SUBGROUP_SIZE; idx++) {
114 masked_concatenated_polynomial.at(idx) = concatenated_monomial_form_unmasked.at(idx);
115 }
116
117 // Mask the polynomial in monomial form.
118 for (size_t idx = 0; idx < masking_scalars.size(); idx++) {
119 masked_concatenated_polynomial.at(idx) -= masking_scalars.value_at(idx);
120 masked_concatenated_polynomial.at(SUBGROUP_SIZE + idx) += masking_scalars.value_at(idx);
121 }
122 }
123};
124} // 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 constexpr size_t WITNESS_MASKING_TERM_LENGTH
static Univariate get_random()
Entry point for Barretenberg command-line interface.
Definition api.hpp:5