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: Complete, auditors: [Khashayar], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
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
42
43 Univariate() = default;
44
48 ~Univariate() = default;
49 Univariate(const Univariate& other) = default;
50 Univariate(Univariate&& other) noexcept = default;
51 Univariate& operator=(const Univariate& other) = default;
52 Univariate& operator=(Univariate&& other) noexcept = default;
53
55 requires(LENGTH > 1)
56 {
57 static_assert(domain_end >= 2);
58
60 result.coefficients[0] = evaluations[0];
61 result.coefficients[1] = evaluations[1] - evaluations[0];
62 result.coefficients[2] = evaluations[1];
63 return result;
64 }
65
66 // Compute Lagrange coefficients of a given linear polynomial represented in monomial basis.
67 template <bool has_a0_plus_a1> Univariate(const UnivariateCoefficientBasis<Fr, 2, has_a0_plus_a1>& monomial)
68 {
69 Fr to_add = monomial.coefficients[1];
70 evaluations[0] = monomial.coefficients[0];
71 auto prev = evaluations[0];
72
73 for (size_t i = 1; i < domain_end; ++i) {
74 prev = prev + to_add;
75 evaluations[i] = prev;
76 }
77 }
78
79 // Compute Lagrange coefficients of a given quadratic polynomial represented in monomial basis.
80 template <bool has_a0_plus_a1> Univariate(const UnivariateCoefficientBasis<Fr, 3, has_a0_plus_a1>& monomial)
81 {
82 Fr to_add = monomial.coefficients[1]; // a1 + a2
83 Fr derivative = monomial.coefficients[2] + monomial.coefficients[2]; // 2a2
84 evaluations[0] = monomial.coefficients[0];
85 auto prev = evaluations[0];
86
87 for (size_t i = 1; i < domain_end - 1; ++i) {
88 prev += to_add;
89 evaluations[i] = prev;
90 to_add += derivative;
91 }
92 prev += to_add;
93 evaluations[domain_end - 1] = prev;
94 }
95
96 // Construct constant Univariate from scalar which represents the value that all the points in the domain
97 // evaluate to
98 explicit Univariate(const Fr& value)
99 {
100 for (size_t i = 0; i < LENGTH; ++i) {
101 evaluations[i] = value;
102 }
103 }
104 // Construct Univariate from UnivariateView.
105 // Lengths will match since we use `domain_end` both in the Univariate and the UnivariateView.
107 {
109 for (size_t i = 0; i < LENGTH; ++i) {
110 evaluations[i] = in.evaluations[i];
111 }
112 }
113
114 Fr& value_at(size_t i) { return evaluations[i]; }
115 const Fr& value_at(size_t i) const { return evaluations[i]; }
116 size_t size() { return evaluations.size(); };
117
118 // Check if the univariate is identically zero
119 bool is_zero() const
120 {
121 for (size_t i = 0; i < LENGTH; ++i) {
122 if (!evaluations[i].is_zero()) {
123 return false;
124 }
125 }
126 return true;
127 }
128
129 // Write the Univariate evaluations to a buffer
130 [[nodiscard]] std::vector<uint8_t> to_buffer() const { return ::to_buffer(evaluations); }
131
132 // Static method for creating a Univariate from a buffer
133 // IMPROVEMENT: Could be made to identically match equivalent methods in e.g. field.hpp. Currently bypasses
134 // unnecessary ::from_buffer call
136 {
137 Univariate result;
139 return result;
140 }
141
143 {
144 auto output = Univariate<Fr, domain_end>();
145 for (size_t i = 0; i != LENGTH; ++i) {
146 output.value_at(i) = Fr::random_element();
147 }
148 return output;
149 };
150
152
153 // Operations between Univariate and other Univariate
154 bool operator==(const Univariate& other) const = default;
155
157 {
158 for (size_t i = 0; i < LENGTH; ++i) {
159 evaluations[i] += other.evaluations[i];
160 }
161 return *this;
162 }
164 {
165 for (size_t i = 0; i < LENGTH; ++i) {
166 evaluations[i] -= other.evaluations[i];
167 }
168 return *this;
169 }
171 {
172 for (size_t i = 0; i < LENGTH; ++i) {
173 evaluations[i] *= other.evaluations[i];
174 }
175 return *this;
176 }
178 {
179 for (size_t i = 0; i < LENGTH; ++i) {
181 }
182 return *this;
183 }
184 Univariate operator+(const Univariate& other) const
185 {
186 Univariate res(*this);
187 res += other;
188 return res;
189 }
190
191 Univariate operator-(const Univariate& other) const
192 {
193 Univariate res(*this);
194 res -= other;
195 return res;
196 }
198 {
199 Univariate res(*this);
200 for (auto& eval : res.evaluations) {
201 eval = -eval;
202 }
203 return res;
204 }
205
206 Univariate operator*(const Univariate& other) const
207 {
208 Univariate res(*this);
209 res *= other;
210 return res;
211 }
212
214 {
215 Univariate res(*this);
216 res.self_sqr();
217 return res;
218 }
219
220 // Operations between Univariate and scalar
221 Univariate& operator+=(const Fr& scalar)
222 {
223 for (auto& eval : evaluations) {
224 eval += scalar;
225 }
226 return *this;
227 }
228
229 Univariate& operator-=(const Fr& scalar)
230 {
231 for (auto& eval : evaluations) {
232 eval -= scalar;
233 }
234 return *this;
235 }
236 Univariate& operator*=(const Fr& scalar)
237 {
238 for (auto& eval : evaluations) {
239 eval *= scalar;
240 }
241 return *this;
242 }
243
244 Univariate operator+(const Fr& scalar) const
245 {
246 Univariate res(*this);
247 res += scalar;
248 return res;
249 }
250
251 Univariate operator-(const Fr& scalar) const
252 {
253 Univariate res(*this);
254 res -= scalar;
255 return res;
256 }
257
258 Univariate operator*(const Fr& scalar) const
259 {
260 Univariate res(*this);
261 res *= scalar;
262 return res;
263 }
264
265 // Operations between Univariate and UnivariateView
267 {
268 for (size_t i = 0; i < LENGTH; ++i) {
269 evaluations[i] += view.evaluations[i];
270 }
271 return *this;
272 }
273
275 {
276 for (size_t i = 0; i < LENGTH; ++i) {
277 evaluations[i] -= view.evaluations[i];
278 }
279 return *this;
280 }
281
283 {
284 for (size_t i = 0; i < LENGTH; ++i) {
285 evaluations[i] *= view.evaluations[i];
286 }
287 return *this;
288 }
289
291 {
292 Univariate res(*this);
293 res += view;
294 return res;
295 }
296
298 {
299 Univariate res(*this);
300 res -= view;
301 return res;
302 }
303
305 {
306 Univariate res(*this);
307 res *= view;
308 return res;
309 }
310
311 // Output is immediately parsable as a list of integers by Python.
312 friend std::ostream& operator<<(std::ostream& os, const Univariate& u)
313 {
314 os << "[";
315 os << u.evaluations[0] << "," << std::endl;
316 for (size_t i = 1; i < u.evaluations.size(); i++) {
317 os << " " << u.evaluations[i];
318 if (i + 1 < u.evaluations.size()) {
319 os << "," << std::endl;
320 } else {
321 os << "]";
322 };
323 }
324 return os;
325 }
326
327 template <size_t EXTENDED_DOMAIN_END>
329 requires(domain_end == 2)
330 {
331 return extend_to<EXTENDED_DOMAIN_END>();
332 }
333
351 template <size_t EXTENDED_DOMAIN_END> Univariate<Fr, EXTENDED_DOMAIN_END> extend_to() const
352 {
353 static constexpr size_t EXTENDED_LENGTH = EXTENDED_DOMAIN_END;
355 static_assert(EXTENDED_LENGTH >= LENGTH);
356
358
359 std::copy(evaluations.begin(), evaluations.end(), result.evaluations.begin());
360
361 if constexpr (LENGTH == 2) {
362 // f = b x + c
363 // f(0) = c
364 // f(1) = b + c
365 // Hence, b = f(1) - f(0)
366 // f(i + 1) = f(i) + b
367 Fr delta = value_at(1) - value_at(0);
368 static_assert(EXTENDED_LENGTH != 0);
369 for (size_t idx = domain_end - 1; idx < EXTENDED_DOMAIN_END - 1; idx++) {
370 result.value_at(idx + 1) = result.value_at(idx) + delta;
371 }
372 } else if constexpr (LENGTH == 3) {
373 static constexpr Fr inverse_two = Fr(2).invert();
374 // f = a x^2 + b x + c
375 // f(0) = c
376 // f(1) = a + b + c
377 // f(2) = 4a + 2b + c
378 // f(2) + f(0) - 2f(1) = 2a
379 // Hence, a = (f(2) + f(0) - 2f(1)) / 2
380 // b = f(1) - a - f(0)
381 // f(i+1) = f(i) + 2a * i + b + a
382 // Cost note: after computing a,b, extending several points costs a few adds per point (no
383 // inversions), vs the generic barycentric path.
384 Fr a = (value_at(2) + value_at(0)) * inverse_two - value_at(1);
385 Fr b = value_at(1) - a - value_at(0);
386 Fr a2 = a + a;
387 Fr a_mul = a2;
388 // compute 2a * domain_end - 2
389 for (size_t i = 0; i < domain_end - 2; i++) {
390 a_mul += a2;
391 }
392 Fr extra = a_mul + a + b;
393 for (size_t idx = domain_end - 1; idx < EXTENDED_DOMAIN_END - 1; idx++) {
394 result.value_at(idx + 1) = result.value_at(idx) + extra;
395 extra += a2;
396 }
397 } else if constexpr (LENGTH == 4) {
398 static constexpr Fr inverse_six = Fr(6).invert(); // computed at compile time for efficiency
399
400 // To compute a barycentric extension, we can compute the coefficients of the univariate.
401 // We have the evaluation of the polynomial at the domain (which is assumed to be 0, 1, 2, 3).
402 // Therefore, we have the 4 linear equations from plugging into f(x) = ax^3 + bx^2 + cx + d:
403 // a*0 + b*0 + c*0 + d = f(0)
404 // a*1 + b*1 + c*1 + d = f(1)
405 // a*2^3 + b*2^2 + c*2 + d = f(2)
406 // a*3^3 + b*3^2 + c*3 + d = f(3)
407 // These equations can be rewritten as a matrix equation M * [a, b, c, d] = [f(0), f(1), f(2),
408 // f(3)], where M is:
409 // 0, 0, 0, 1
410 // 1, 1, 1, 1
411 // 2^3, 2^2, 2, 1
412 // 3^3, 3^2, 3, 1
413 // We can invert this matrix in order to compute a, b, c, d:
414 // -1/6, 1/2, -1/2, 1/6
415 // 1, -5/2, 2, -1/2
416 // -11/6, 3, -3/2, 1/3
417 // 1, 0, 0, 0
418 // To compute these values, we can multiply everything by 6 and multiply by inverse_six at the
419 // end for each coefficient The resulting computation here does 18 field adds, 6 subtracts, 3
420 // muls to compute a, b, c, and d.
421 Fr zero_times_3 = value_at(0) + value_at(0) + value_at(0);
422 Fr zero_times_6 = zero_times_3 + zero_times_3;
423 Fr zero_times_12 = zero_times_6 + zero_times_6;
424 Fr one_times_3 = value_at(1) + value_at(1) + value_at(1);
425 Fr one_times_6 = one_times_3 + one_times_3;
426 Fr two_times_3 = value_at(2) + value_at(2) + value_at(2);
427 Fr three_times_2 = value_at(3) + value_at(3);
428 Fr three_times_3 = three_times_2 + value_at(3);
429
430 Fr one_minus_two_times_3 = one_times_3 - two_times_3;
431 Fr one_minus_two_times_6 = one_minus_two_times_3 + one_minus_two_times_3;
432 Fr one_minus_two_times_12 = one_minus_two_times_6 + one_minus_two_times_6;
433 Fr a = (one_minus_two_times_3 + value_at(3) - value_at(0)) * inverse_six; // compute a in 1 muls and 4 adds
434 Fr b = (zero_times_6 - one_minus_two_times_12 - one_times_3 - three_times_3) * inverse_six;
435 Fr c = (value_at(0) - zero_times_12 + one_minus_two_times_12 + one_times_6 + two_times_3 + three_times_2) *
436 inverse_six;
437
438 // Then, outside of the a, b, c, d computation, we need to do some extra precomputation
439 // This work is 3 field muls, 8 adds
440 Fr a_plus_b = a + b;
441 Fr a_plus_b_times_2 = a_plus_b + a_plus_b;
442 size_t start_idx_sqr = (domain_end - 1) * (domain_end - 1);
443 size_t idx_sqr_three = start_idx_sqr + start_idx_sqr + start_idx_sqr;
444 Fr idx_sqr_three_times_a = Fr(idx_sqr_three) * a;
445 Fr x_a_term = Fr(6 * (domain_end - 1)) * a;
446 Fr three_a = a + a + a;
447 Fr six_a = three_a + three_a;
448
449 Fr three_a_plus_two_b = a_plus_b_times_2 + a;
450 Fr linear_term = Fr(domain_end - 1) * three_a_plus_two_b + (a_plus_b + c);
451 // For each new evaluation, we do only 6 field additions and 0 muls.
452 for (size_t idx = domain_end - 1; idx < EXTENDED_DOMAIN_END - 1; idx++) {
453 result.value_at(idx + 1) = result.value_at(idx) + idx_sqr_three_times_a + linear_term;
454
455 idx_sqr_three_times_a += x_a_term + three_a;
456 x_a_term += six_a;
457
458 linear_term += three_a_plus_two_b;
459 }
460 } else {
461 for (size_t k = domain_end; k != EXTENDED_DOMAIN_END; ++k) {
462 result.value_at(k) = 0;
463 // compute each term v_j / (d_j*(x-x_j)) of the sum
464 for (size_t j = 0; j != domain_end; ++j) {
465 Fr term = value_at(j);
466 term *= Data::precomputed_denominator_inverses[LENGTH * k + j];
467 result.value_at(k) += term;
468 }
469 // scale the sum by the value of of B(x)
470 result.value_at(k) *= Data::full_numerator_values[k];
471 }
472 }
473 return result;
474 }
475
482 template <size_t INITIAL_LENGTH> void self_extend_from()
483 {
484 if constexpr (INITIAL_LENGTH == 2) {
485 const Fr delta = value_at(1) - value_at(0);
486 Fr next = value_at(1);
487 for (size_t idx = 2; idx < LENGTH; idx++) {
488 next += delta;
489 value_at(idx) = next;
490 }
491 } else {
492 throw_or_abort("self_extend_from called with INITIAL_LENGTH different from 2.");
493 }
494 }
495
502 Fr evaluate(const Fr& u) const
503 {
505 Fr full_numerator_value = 1;
506 for (size_t i = 0; i != domain_end; ++i) {
507 full_numerator_value *= u - i;
508 }
509
510 // build set of domain size-many denominator inverses 1/(d_i*(x_k - x_j)). will multiply against
511 // each of these (rather than to divide by something) for each barycentric evaluation
512 std::array<Fr, LENGTH> denominator_inverses;
513 for (size_t i = 0; i != LENGTH; ++i) {
514 Fr inv = Data::lagrange_denominators[i];
515 inv *= u - Data::big_domain[i]; // warning: need to avoid zero here
516 inv = Fr(1) / inv;
517 denominator_inverses[i] = inv;
518 }
519
520 Fr result = 0;
521 // compute each term v_j / (d_j*(x-x_j)) of the sum
522 for (size_t i = 0; i != domain_end; ++i) {
523 Fr term = value_at(i);
524 term *= denominator_inverses[i];
525 result += term;
526 }
527 // scale the sum by the value of of B(x)
528 result *= full_numerator_value;
529 return result;
530 };
531
532 // Begin iterators
533 auto begin() { return evaluations.begin(); }
534 auto begin() const { return evaluations.begin(); }
535 // End iterators
536 auto end() { return evaluations.end(); }
537 auto end() const { return evaluations.end(); }
538};
539
540template <typename B, class Fr, size_t domain_end> inline void read(B& it, Univariate<Fr, domain_end>& univariate)
541{
542 using serialize::read;
543 read(it, univariate.evaluations);
544}
545
546template <typename B, class Fr, size_t domain_end>
547inline void write(B& it, Univariate<Fr, domain_end> const& univariate)
548{
549 using serialize::write;
550 write(it, univariate.evaluations);
551}
552
553template <class Fr, size_t domain_end>
555{
556 return uv + ff;
557}
558
559template <class Fr, size_t domain_end>
561{
562 return -uv + ff;
563}
564
565template <class Fr, size_t domain_end>
567{
568 return uv * ff;
569}
570
571template <class Fr, size_t domain_end> class UnivariateView {
572 public:
573 static constexpr size_t LENGTH = domain_end;
575 static constexpr size_t MONOMIAL_LENGTH = LENGTH > 1 ? 2 : 1;
577
578 UnivariateView() = default;
579
580 bool operator==(const UnivariateView& other) const
581 {
582 for (size_t i = 0; i < LENGTH; ++i) {
583 if (evaluations[i] != other.evaluations[i]) {
584 return false;
585 }
586 }
587 return true;
588 };
589
590 const Fr& value_at(size_t i) const { return evaluations[i]; };
591
592 template <size_t full_domain_end>
593 explicit UnivariateView(const Univariate<Fr, full_domain_end>& univariate_in)
594 : evaluations(std::span<const Fr>(univariate_in.evaluations.data(), LENGTH)){};
595
597 requires(LENGTH > 1)
598 {
599 static_assert(domain_end >= 2);
600
602
603 result.coefficients[0] = evaluations[0];
604 result.coefficients[1] = evaluations[1] - evaluations[0];
605 result.coefficients[2] = evaluations[1];
606 return result;
607 }
608
610 {
612 res += other;
613 return res;
614 }
615
617 {
619 res -= other;
620 return res;
621 }
622
624 {
626 for (auto& eval : res.evaluations) {
627 eval = -eval;
628 }
629 return res;
630 }
631
633 {
635 res *= other;
636 return res;
637 }
639 {
641 res = res.sqr();
642 return res;
643 }
644
646 {
648 res *= other;
649 return res;
650 }
651
653 {
655 res += other;
656 return res;
657 }
658
660 {
662 res += other;
663 return res;
664 }
665
667 {
669 res -= other;
670 return res;
671 }
672
674 {
676 res *= other;
677 return res;
678 }
679
681 {
683 res -= other;
684 return res;
685 }
686
687 // Output is immediately parsable as a list of integers by Python.
688 friend std::ostream& operator<<(std::ostream& os, const UnivariateView& u)
689 {
690 os << "[";
691 os << u.evaluations[0] << "," << std::endl;
692 for (size_t i = 1; i < u.evaluations.size(); i++) {
693 os << " " << u.evaluations[i];
694 if (i + 1 < u.evaluations.size()) {
695 os << "," << std::endl;
696 } else {
697 os << "]";
698 };
699 }
700 return os;
701 }
702};
703
704template <class Fr, size_t domain_end>
706{
707 return uv + ff;
708}
709
710template <class Fr, size_t domain_end>
712{
713 return -uv + ff;
714}
715
716template <class Fr, size_t domain_end>
718{
719 return uv * ff;
720}
721
735template <typename T, typename U, std::size_t N, std::size_t... Is>
736std::array<T, sizeof...(Is)> array_to_array_aux(const std::array<U, N>& elements, std::index_sequence<Is...>)
737{
738 return { { T{ elements[Is] }... } };
739};
740
758template <typename T, typename U, std::size_t N> std::array<T, N> array_to_array(const std::array<U, N>& elements)
759{
760 // Calls the aux method that uses the index sequence to unpack all values in `elements`
761 return array_to_array_aux<T, U, N>(elements, std::make_index_sequence<N>());
762};
763
764} // namespace bb
765
766namespace std {
767
768template <typename T, size_t N> struct tuple_size<bb::Univariate<T, N>> : std::integral_constant<std::size_t, N> {};
769
770} // 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
std::unique_ptr< uint8_t[]> buffer
Definition engine.cpp:50
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
void read(B &it, field2< base_field, Params > &value)
Univariate< Fr, domain_end > operator+(const Fr &ff, const Univariate< Fr, domain_end > &uv)
void write(B &buf, field2< base_field, Params > const &value)
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)