Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
univariate.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
8
9#include <array>
10#include <span>
11#include <vector>
12
17
18namespace bb {
19
27template <class Fr, size_t view_domain_end> class UnivariateView;
28
32template <class Fr, size_t domain_end> class Univariate {
33 public:
34 static constexpr size_t LENGTH = domain_end;
36 static constexpr size_t MONOMIAL_LENGTH = LENGTH > 1 ? 2 : 1;
38
39 using value_type = Fr; // used to get the type of the elements consistently with std::array
40
41 // TODO(https://github.com/AztecProtocol/barretenberg/issues/714) Try out std::valarray?
43
44 Univariate() = default;
45
49 ~Univariate() = default;
50 Univariate(const Univariate& other) = default;
51 Univariate(Univariate&& other) noexcept = default;
52 Univariate& operator=(const Univariate& other) = default;
53 Univariate& operator=(Univariate&& other) noexcept = default;
54
56 requires(LENGTH > 1)
57 {
58 static_assert(domain_end >= 2);
59
61 result.coefficients[0] = evaluations[0];
62 result.coefficients[1] = evaluations[1] - evaluations[0];
63 result.coefficients[2] = evaluations[1];
64 return result;
65 }
66
67 // Compute Lagrange coefficients of a given linear polynomial represented in monomial basis.
68 template <bool has_a0_plus_a1> Univariate(const UnivariateCoefficientBasis<Fr, 2, has_a0_plus_a1>& monomial)
69 {
70 Fr to_add = monomial.coefficients[1];
71 evaluations[0] = monomial.coefficients[0];
72 auto prev = evaluations[0];
73
74 for (size_t i = 1; i < domain_end; ++i) {
75 prev = prev + to_add;
76 evaluations[i] = prev;
77 }
78 }
79
80 // Compute Lagrange coefficients of a given quadratic polynomial represented in monomial basis.
81 template <bool has_a0_plus_a1> Univariate(const UnivariateCoefficientBasis<Fr, 3, has_a0_plus_a1>& monomial)
82 {
83 Fr to_add = monomial.coefficients[1]; // a1 + a2
84 Fr derivative = monomial.coefficients[2] + monomial.coefficients[2]; // 2a2
85 evaluations[0] = monomial.coefficients[0];
86 auto prev = evaluations[0];
87
88 for (size_t i = 1; i < domain_end - 1; ++i) {
89 prev += to_add;
90 evaluations[i] = prev;
91 to_add += derivative;
92 }
93 prev += to_add;
94 evaluations[domain_end - 1] = prev;
95 }
96
97 // Construct constant Univariate from scalar which represents the value that all the points in the domain
98 // evaluate to
99 explicit Univariate(const Fr& value)
100 {
101 for (size_t i = 0; i < LENGTH; ++i) {
102 evaluations[i] = value;
103 }
104 }
105 // Construct Univariate from UnivariateView.
106 // Lengths will match since we use `domain_end` both in the Univariate and the UnivariateView.
108 {
110 for (size_t i = 0; i < LENGTH; ++i) {
111 evaluations[i] = in.evaluations[i];
112 }
113 }
114
115 Fr& value_at(size_t i) { return evaluations[i]; }
116 const Fr& value_at(size_t i) const { return evaluations[i]; }
117 size_t size() { return evaluations.size(); };
118
119 // Check if the univariate is identically zero
120 bool is_zero() const
121 {
122 for (size_t i = 0; i < LENGTH; ++i) {
123 if (!evaluations[i].is_zero()) {
124 return false;
125 }
126 }
127 return true;
128 }
129
130 // Write the Univariate evaluations to a buffer
131 [[nodiscard]] std::vector<uint8_t> to_buffer() const { return ::to_buffer(evaluations); }
132
133 // Static method for creating a Univariate from a buffer
134 // IMPROVEMENT: Could be made to identically match equivalent methods in e.g. field.hpp. Currently bypasses
135 // unnecessary ::from_buffer call
137 {
138 Univariate result;
140 return result;
141 }
142
144 {
145 auto output = Univariate<Fr, domain_end>();
146 for (size_t i = 0; i != LENGTH; ++i) {
147 output.value_at(i) = Fr::random_element();
148 }
149 return output;
150 };
151
153
154 // Operations between Univariate and other Univariate
155 bool operator==(const Univariate& other) const = default;
156
158 {
159 for (size_t i = 0; i < LENGTH; ++i) {
160 evaluations[i] += other.evaluations[i];
161 }
162 return *this;
163 }
165 {
166 for (size_t i = 0; i < LENGTH; ++i) {
167 evaluations[i] -= other.evaluations[i];
168 }
169 return *this;
170 }
172 {
173 for (size_t i = 0; i < LENGTH; ++i) {
174 evaluations[i] *= other.evaluations[i];
175 }
176 return *this;
177 }
179 {
180 for (size_t i = 0; i < LENGTH; ++i) {
182 }
183 return *this;
184 }
185 Univariate operator+(const Univariate& other) const
186 {
187 Univariate res(*this);
188 res += other;
189 return res;
190 }
191
192 Univariate operator-(const Univariate& other) const
193 {
194 Univariate res(*this);
195 res -= other;
196 return res;
197 }
199 {
200 Univariate res(*this);
201 for (auto& eval : res.evaluations) {
202 eval = -eval;
203 }
204 return res;
205 }
206
207 Univariate operator*(const Univariate& other) const
208 {
209 Univariate res(*this);
210 res *= other;
211 return res;
212 }
213
215 {
216 Univariate res(*this);
217 res.self_sqr();
218 return res;
219 }
220
221 // Operations between Univariate and scalar
222 Univariate& operator+=(const Fr& scalar)
223 {
224 for (auto& eval : evaluations) {
225 eval += scalar;
226 }
227 return *this;
228 }
229
230 Univariate& operator-=(const Fr& scalar)
231 {
232 for (auto& eval : evaluations) {
233 eval -= scalar;
234 }
235 return *this;
236 }
237 Univariate& operator*=(const Fr& scalar)
238 {
239 for (auto& eval : evaluations) {
240 eval *= scalar;
241 }
242 return *this;
243 }
244
245 Univariate operator+(const Fr& scalar) const
246 {
247 Univariate res(*this);
248 res += scalar;
249 return res;
250 }
251
252 Univariate operator-(const Fr& scalar) const
253 {
254 Univariate res(*this);
255 res -= scalar;
256 return res;
257 }
258
259 Univariate operator*(const Fr& scalar) const
260 {
261 Univariate res(*this);
262 res *= scalar;
263 return res;
264 }
265
266 // Operations between Univariate and UnivariateView
268 {
269 for (size_t i = 0; i < LENGTH; ++i) {
270 evaluations[i] += view.evaluations[i];
271 }
272 return *this;
273 }
274
276 {
277 for (size_t i = 0; i < LENGTH; ++i) {
278 evaluations[i] -= view.evaluations[i];
279 }
280 return *this;
281 }
282
284 {
285 for (size_t i = 0; i < LENGTH; ++i) {
286 evaluations[i] *= view.evaluations[i];
287 }
288 return *this;
289 }
290
292 {
293 Univariate res(*this);
294 res += view;
295 return res;
296 }
297
299 {
300 Univariate res(*this);
301 res -= view;
302 return res;
303 }
304
306 {
307 Univariate res(*this);
308 res *= view;
309 return res;
310 }
311
312 // Output is immediately parsable as a list of integers by Python.
313 friend std::ostream& operator<<(std::ostream& os, const Univariate& u)
314 {
315 os << "[";
316 os << u.evaluations[0] << "," << std::endl;
317 for (size_t i = 1; i < u.evaluations.size(); i++) {
318 os << " " << u.evaluations[i];
319 if (i + 1 < u.evaluations.size()) {
320 os << "," << std::endl;
321 } else {
322 os << "]";
323 };
324 }
325 return os;
326 }
327
328 template <size_t EXTENDED_DOMAIN_END>
330 requires(domain_end == 2)
331 {
332 return extend_to<EXTENDED_DOMAIN_END>();
333 }
334
352 template <size_t EXTENDED_DOMAIN_END> Univariate<Fr, EXTENDED_DOMAIN_END> extend_to() const
353 {
354 static constexpr size_t EXTENDED_LENGTH = EXTENDED_DOMAIN_END;
356 static_assert(EXTENDED_LENGTH >= LENGTH);
357
359
360 std::copy(evaluations.begin(), evaluations.end(), result.evaluations.begin());
361
362 static constexpr Fr inverse_two = Fr(2).invert();
363 if constexpr (LENGTH == 2) {
364 // f = b x + c
365 // f(0) = c
366 // f(1) = b + c
367 // Hence, b = f(1) - f(0)
368 // f(i + 1) = f(i) + b
369 Fr delta = value_at(1) - value_at(0);
370 static_assert(EXTENDED_LENGTH != 0);
371 for (size_t idx = domain_end - 1; idx < EXTENDED_DOMAIN_END - 1; idx++) {
372 result.value_at(idx + 1) = result.value_at(idx) + delta;
373 }
374 } else if constexpr (LENGTH == 3) {
375 // Based off https://hackmd.io/@aztec-network/SyR45cmOq?type=view
376 // The technique used here is the same as the length == 3 case below.
377 // f = a x^2 + b x + c
378 // f(0) = c
379 // f(1) = a + b + c
380 // f(2) = 4a + 2b + c
381 // f(2) + f(0) - 2f(1) = 2a
382 // Hence, a = (f(2) + f(0) - 2f(1)) / 2
383 // b = f(1) - a - f(0)
384 // f(i+1) = f(i) + 2a * i + b + a
385 Fr a = (value_at(2) + value_at(0)) * inverse_two - value_at(1);
386 Fr b = value_at(1) - a - value_at(0);
387 Fr a2 = a + a;
388 Fr a_mul = a2;
389 // compute 2a * domain_end - 2
390 for (size_t i = 0; i < domain_end - 2; i++) {
391 a_mul += a2;
392 }
393 Fr extra = a_mul + a + b;
394 for (size_t idx = domain_end - 1; idx < EXTENDED_DOMAIN_END - 1; idx++) {
395 result.value_at(idx + 1) = result.value_at(idx) + extra;
396 extra += a2;
397 }
398 } else if constexpr (LENGTH == 4) {
399 static constexpr Fr inverse_six = Fr(6).invert(); // computed at compile time for efficiency
400
401 // To compute a barycentric extension, we can compute the coefficients of the univariate.
402 // We have the evaluation of the polynomial at the domain (which is assumed to be 0, 1, 2, 3).
403 // Therefore, we have the 4 linear equations from plugging into f(x) = ax^3 + bx^2 + cx + d:
404 // a*0 + b*0 + c*0 + d = f(0)
405 // a*1 + b*1 + c*1 + d = f(1)
406 // a*2^3 + b*2^2 + c*2 + d = f(2)
407 // a*3^3 + b*3^2 + c*3 + d = f(3)
408 // These equations can be rewritten as a matrix equation M * [a, b, c, d] = [f(0), f(1), f(2),
409 // f(3)], where M is:
410 // 0, 0, 0, 1
411 // 1, 1, 1, 1
412 // 2^3, 2^2, 2, 1
413 // 3^3, 3^2, 3, 1
414 // We can invert this matrix in order to compute a, b, c, d:
415 // -1/6, 1/2, -1/2, 1/6
416 // 1, -5/2, 2, -1/2
417 // -11/6, 3, -3/2, 1/3
418 // 1, 0, 0, 0
419 // To compute these values, we can multiply everything by 6 and multiply by inverse_six at the
420 // end for each coefficient The resulting computation here does 18 field adds, 6 subtracts, 3
421 // muls to compute a, b, c, and d.
422 Fr zero_times_3 = value_at(0) + value_at(0) + value_at(0);
423 Fr zero_times_6 = zero_times_3 + zero_times_3;
424 Fr zero_times_12 = zero_times_6 + zero_times_6;
425 Fr one_times_3 = value_at(1) + value_at(1) + value_at(1);
426 Fr one_times_6 = one_times_3 + one_times_3;
427 Fr two_times_3 = value_at(2) + value_at(2) + value_at(2);
428 Fr three_times_2 = value_at(3) + value_at(3);
429 Fr three_times_3 = three_times_2 + value_at(3);
430
431 Fr one_minus_two_times_3 = one_times_3 - two_times_3;
432 Fr one_minus_two_times_6 = one_minus_two_times_3 + one_minus_two_times_3;
433 Fr one_minus_two_times_12 = one_minus_two_times_6 + one_minus_two_times_6;
434 Fr a = (one_minus_two_times_3 + value_at(3) - value_at(0)) * inverse_six; // compute a in 1 muls and 4 adds
435 Fr b = (zero_times_6 - one_minus_two_times_12 - one_times_3 - three_times_3) * inverse_six;
436 Fr c = (value_at(0) - zero_times_12 + one_minus_two_times_12 + one_times_6 + two_times_3 + three_times_2) *
437 inverse_six;
438
439 // Then, outside of the a, b, c, d computation, we need to do some extra precomputation
440 // This work is 3 field muls, 8 adds
441 Fr a_plus_b = a + b;
442 Fr a_plus_b_times_2 = a_plus_b + a_plus_b;
443 size_t start_idx_sqr = (domain_end - 1) * (domain_end - 1);
444 size_t idx_sqr_three = start_idx_sqr + start_idx_sqr + start_idx_sqr;
445 Fr idx_sqr_three_times_a = Fr(idx_sqr_three) * a;
446 Fr x_a_term = Fr(6 * (domain_end - 1)) * a;
447 Fr three_a = a + a + a;
448 Fr six_a = three_a + three_a;
449
450 Fr three_a_plus_two_b = a_plus_b_times_2 + a;
451 Fr linear_term = Fr(domain_end - 1) * three_a_plus_two_b + (a_plus_b + c);
452 // For each new evaluation, we do only 6 field additions and 0 muls.
453 for (size_t idx = domain_end - 1; idx < EXTENDED_DOMAIN_END - 1; idx++) {
454 result.value_at(idx + 1) = result.value_at(idx) + idx_sqr_three_times_a + linear_term;
455
456 idx_sqr_three_times_a += x_a_term + three_a;
457 x_a_term += six_a;
458
459 linear_term += three_a_plus_two_b;
460 }
461 } else {
462 for (size_t k = domain_end; k != EXTENDED_DOMAIN_END; ++k) {
463 result.value_at(k) = 0;
464 // compute each term v_j / (d_j*(x-x_j)) of the sum
465 for (size_t j = 0; j != domain_end; ++j) {
466 Fr term = value_at(j);
467 term *= Data::precomputed_denominator_inverses[LENGTH * k + j];
468 result.value_at(k) += term;
469 }
470 // scale the sum by the value of of B(x)
471 result.value_at(k) *= Data::full_numerator_values[k];
472 }
473 }
474 return result;
475 }
476
483 template <size_t INITIAL_LENGTH> void self_extend_from()
484 {
485 if constexpr (INITIAL_LENGTH == 2) {
486 const Fr delta = value_at(1) - value_at(0);
487 Fr next = value_at(1);
488 for (size_t idx = 2; idx < LENGTH; idx++) {
489 next += delta;
490 value_at(idx) = next;
491 }
492 } else {
493 throw_or_abort("self_extend_from called with INITIAL_LENGTH different from 2.");
494 }
495 }
496
503 Fr evaluate(const Fr& u) const
504 {
506 Fr full_numerator_value = 1;
507 for (size_t i = 0; i != domain_end; ++i) {
508 full_numerator_value *= u - i;
509 }
510
511 // build set of domain size-many denominator inverses 1/(d_i*(x_k - x_j)). will multiply against
512 // each of these (rather than to divide by something) for each barycentric evaluation
513 std::array<Fr, LENGTH> denominator_inverses;
514 for (size_t i = 0; i != LENGTH; ++i) {
515 Fr inv = Data::lagrange_denominators[i];
516 inv *= u - Data::big_domain[i]; // warning: need to avoid zero here
517 inv = Fr(1) / inv;
518 denominator_inverses[i] = inv;
519 }
520
521 Fr result = 0;
522 // compute each term v_j / (d_j*(x-x_j)) of the sum
523 for (size_t i = 0; i != domain_end; ++i) {
524 Fr term = value_at(i);
525 term *= denominator_inverses[i];
526 result += term;
527 }
528 // scale the sum by the value of of B(x)
529 result *= full_numerator_value;
530 return result;
531 };
532
533 // Begin iterators
534 auto begin() { return evaluations.begin(); }
535 auto begin() const { return evaluations.begin(); }
536 // End iterators
537 auto end() { return evaluations.end(); }
538 auto end() const { return evaluations.end(); }
539};
540
541template <typename B, class Fr, size_t domain_end> inline void read(B& it, Univariate<Fr, domain_end>& univariate)
542{
543 using serialize::read;
544 read(it, univariate.evaluations);
545}
546
547template <typename B, class Fr, size_t domain_end>
548inline void write(B& it, Univariate<Fr, domain_end> const& univariate)
549{
550 using serialize::write;
551 write(it, univariate.evaluations);
552}
553
554template <class Fr, size_t domain_end>
556{
557 return uv + ff;
558}
559
560template <class Fr, size_t domain_end>
562{
563 return -uv + ff;
564}
565
566template <class Fr, size_t domain_end>
568{
569 return uv * ff;
570}
571
572template <class Fr, size_t domain_end> class UnivariateView {
573 public:
574 static constexpr size_t LENGTH = domain_end;
576 static constexpr size_t MONOMIAL_LENGTH = LENGTH > 1 ? 2 : 1;
578
579 UnivariateView() = default;
580
581 bool operator==(const UnivariateView& other) const
582 {
583 for (size_t i = 0; i < LENGTH; ++i) {
584 if (evaluations[i] != other.evaluations[i]) {
585 return false;
586 }
587 }
588 return true;
589 };
590
591 const Fr& value_at(size_t i) const { return evaluations[i]; };
592
593 template <size_t full_domain_end>
594 explicit UnivariateView(const Univariate<Fr, full_domain_end>& univariate_in)
595 : evaluations(std::span<const Fr>(univariate_in.evaluations.data(), LENGTH)){};
596
598 requires(LENGTH > 1)
599 {
600 static_assert(domain_end >= 2);
601
603
604 result.coefficients[0] = evaluations[0];
605 result.coefficients[1] = evaluations[1] - evaluations[0];
606 result.coefficients[2] = evaluations[1];
607 return result;
608 }
609
611 {
613 res += other;
614 return res;
615 }
616
618 {
620 res -= other;
621 return res;
622 }
623
625 {
627 for (auto& eval : res.evaluations) {
628 eval = -eval;
629 }
630 return res;
631 }
632
634 {
636 res *= other;
637 return res;
638 }
640 {
642 res = res.sqr();
643 return res;
644 }
645
647 {
649 res *= other;
650 return res;
651 }
652
654 {
656 res += other;
657 return res;
658 }
659
661 {
663 res += other;
664 return res;
665 }
666
668 {
670 res -= other;
671 return res;
672 }
673
675 {
677 res *= other;
678 return res;
679 }
680
682 {
684 res -= other;
685 return res;
686 }
687
688 // Output is immediately parsable as a list of integers by Python.
689 friend std::ostream& operator<<(std::ostream& os, const UnivariateView& u)
690 {
691 os << "[";
692 os << u.evaluations[0] << "," << std::endl;
693 for (size_t i = 1; i < u.evaluations.size(); i++) {
694 os << " " << u.evaluations[i];
695 if (i + 1 < u.evaluations.size()) {
696 os << "," << std::endl;
697 } else {
698 os << "]";
699 };
700 }
701 return os;
702 }
703};
704
705template <class Fr, size_t domain_end>
707{
708 return uv + ff;
709}
710
711template <class Fr, size_t domain_end>
713{
714 return -uv + ff;
715}
716
717template <class Fr, size_t domain_end>
719{
720 return uv * ff;
721}
722
736template <typename T, typename U, std::size_t N, std::size_t... Is>
737std::array<T, sizeof...(Is)> array_to_array_aux(const std::array<U, N>& elements, std::index_sequence<Is...>)
738{
739 return { { T{ elements[Is] }... } };
740};
741
759template <typename T, typename U, std::size_t N> std::array<T, N> array_to_array(const std::array<U, N>& elements)
760{
761 // Calls the aux method that uses the index sequence to unpack all values in `elements`
762 return array_to_array_aux<T, U, N>(elements, std::make_index_sequence<N>());
763};
764
765} // namespace bb
766
767namespace std {
768
769template <typename T, size_t N> struct tuple_size<bb::Univariate<T, N>> : std::integral_constant<std::size_t, N> {};
770
771} // namespace std
A view of a univariate, also used to truncate univariates.
std::array< Fr, 3 > coefficients
coefficients is a length-3 array with the following representation:
A univariate polynomial represented by its values on {0, 1,..., domain_end - 1}.
const Fr & value_at(size_t i) const
Univariate()=default
static constexpr size_t LENGTH
Univariate & operator+=(const Univariate &other)
Univariate & operator-=(const Univariate &other)
bool is_zero() const
bool operator==(const Univariate &other) const =default
Univariate & operator+=(const Fr &scalar)
Univariate operator*(const UnivariateView< Fr, domain_end > &view) const
Univariate(const std::array< Fr, LENGTH > &evaluations)
Fr & value_at(size_t i)
Univariate(const UnivariateCoefficientBasis< Fr, 3, has_a0_plus_a1 > &monomial)
static Univariate zero()
Univariate & self_sqr()
friend std::ostream & operator<<(std::ostream &os, const Univariate &u)
auto end() const
void self_extend_from()
Compute the evaluations of the polynomial from the INITIAL_LENGTH up to the total LENGTH....
Univariate & operator=(Univariate &&other) noexcept=default
Univariate operator*(const Fr &scalar) const
~Univariate()=default
Univariate & operator*=(const Fr &scalar)
Univariate operator+(const UnivariateView< Fr, domain_end > &view) const
std::array< Fr, LENGTH > evaluations
Univariate operator-(const Fr &scalar) const
static Univariate serialize_from_buffer(uint8_t const *buffer)
Univariate operator-(const UnivariateView< Fr, domain_end > &view) const
Univariate & operator=(const Univariate &other)=default
static Univariate get_random()
Univariate(Univariate &&other) noexcept=default
Univariate & operator*=(const UnivariateView< Fr, domain_end > &view)
Univariate operator-(const Univariate &other) const
auto begin() const
std::vector< uint8_t > to_buffer() const
Univariate & operator*=(const Univariate &other)
Univariate operator+(const Fr &scalar) const
static constexpr size_t MONOMIAL_LENGTH
Univariate & operator-=(const UnivariateView< Fr, domain_end > &view)
Univariate sqr() const
Univariate & operator+=(const UnivariateView< Fr, domain_end > &view)
Univariate operator*(const Univariate &other) const
Fr evaluate(const Fr &u) const
Evaluate a univariate at a point u not known at compile time and assumed not to be in the domain (els...
Univariate(const Univariate &other)=default
Univariate operator-() const
Univariate(const UnivariateCoefficientBasis< Fr, 2, has_a0_plus_a1 > &monomial)
Univariate(const UnivariateView< Fr, domain_end > &in)
Univariate operator+(const Univariate &other) const
Univariate(const Fr &value)
Univariate< Fr, EXTENDED_DOMAIN_END > extend_to() const
Given a univariate f represented by {f(0), ..., f(domain_end - 1)}, compute the evaluations {f(domain...
Univariate & operator-=(const Fr &scalar)
A view of a univariate, also used to truncate univariates.
Univariate< Fr, domain_end > sqr() const
bool operator==(const UnivariateView &other) const
friend std::ostream & operator<<(std::ostream &os, const UnivariateView &u)
Univariate< Fr, domain_end > operator-() const
std::span< const Fr, LENGTH > evaluations
static constexpr size_t LENGTH
Univariate< Fr, domain_end > operator-(const Fr &other) const
Univariate< Fr, domain_end > operator*(const UnivariateView &other) const
Univariate< Fr, domain_end > operator-(const UnivariateView &other) const
Univariate< Fr, domain_end > operator*(const Univariate< Fr, domain_end > &other) const
Univariate< Fr, domain_end > operator+(const Univariate< Fr, domain_end > &other) const
const Fr & value_at(size_t i) const
UnivariateView(const Univariate< Fr, full_domain_end > &univariate_in)
Univariate< Fr, domain_end > operator+(const UnivariateView &other) const
UnivariateView()=default
Univariate< Fr, domain_end > operator*(const Fr &other) const
Univariate< Fr, domain_end > operator+(const Fr &other) const
static constexpr size_t MONOMIAL_LENGTH
Univariate< Fr, domain_end > operator-(const Univariate< Fr, domain_end > &other) const
const std::vector< MemoryValue > data
FF a
FF b
uint8_t buffer[RANDOM_BUFFER_SIZE]
Definition engine.cpp:34
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
Univariate< Fr, domain_end > operator+(const Fr &ff, const Univariate< Fr, domain_end > &uv)
void write(std::vector< uint8_t > &buf, Chonk::VerificationKey const &vk)
Definition chonk.hpp:366
void read(uint8_t const *&it, Chonk::VerificationKey &vk)
Definition chonk.hpp:350
Univariate< Fr, domain_end > operator-(const Fr &ff, const Univariate< Fr, domain_end > &uv)
Univariate< Fr, domain_end > operator*(const Fr &ff, const Univariate< Fr, domain_end > &uv)
std::array< T, N > array_to_array(const std::array< U, N > &elements)
Given an std::array<U,N>, returns an std::array<T,N>, by calling the (explicit) constructor T(U).
std::array< T, sizeof...(Is)> array_to_array_aux(const std::array< U, N > &elements, std::index_sequence< Is... >)
Create a sub-array of elements at the indices given in the template pack Is, converting them to the n...
std::conditional_t< is_field_type_v< Fr >, BarycentricDataCompileTime< Fr, domain_end, num_evals >, BarycentricDataRunTime< Fr, domain_end, num_evals > > BarycentricData
Exposes BarycentricData with compile time arrays if the type is bberg::field and runtime arrays other...
void read(auto &it, msgpack_concepts::HasMsgPack auto &obj)
Automatically derived read for any object that defines .msgpack() (implicitly defined by MSGPACK_FIEL...
void write(auto &buf, const msgpack_concepts::HasMsgPack auto &obj)
Automatically derived write for any object that defines .msgpack() (implicitly defined by MSGPACK_FIE...
STL namespace.
void read(auto &buf, std::integral auto &value)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
Curve::ScalarField Fr
constexpr field invert() const noexcept
static field random_element(numeric::RNG *engine=nullptr) noexcept
static constexpr field zero()
void throw_or_abort(std::string const &err)