27TEST(ECCVMCircuitBuilderTests, BaseCase)
40 op_queue->add_accumulate(
a);
41 op_queue->mul_accumulate(
a, x);
42 op_queue->mul_accumulate(
b, x);
43 op_queue->mul_accumulate(
b, y);
44 op_queue->add_accumulate(
a);
45 op_queue->mul_accumulate(
b, x);
46 op_queue->add_accumulate(
b);
47 op_queue->eq_and_reset();
48 op_queue->add_accumulate(c);
49 op_queue->mul_accumulate(
a, x);
50 op_queue->mul_accumulate(point_at_infinity, x);
51 op_queue->mul_accumulate(
b, x);
52 op_queue->eq_and_reset();
53 op_queue->mul_accumulate(
a, x);
54 op_queue->mul_accumulate(
b, x);
55 op_queue->mul_accumulate(point_at_infinity, zero_scalar);
56 op_queue->mul_accumulate(c, x);
57 op_queue->eq_and_reset();
58 op_queue->mul_accumulate(point_at_infinity, zero_scalar);
59 op_queue->mul_accumulate(point_at_infinity, x);
60 op_queue->mul_accumulate(point_at_infinity, zero_scalar);
61 op_queue->add_accumulate(
a);
62 op_queue->eq_and_reset();
63 op_queue->add_accumulate(
a);
64 op_queue->add_accumulate(point_at_infinity);
65 op_queue->eq_and_reset();
66 op_queue->add_accumulate(point_at_infinity);
67 op_queue->eq_and_reset();
68 op_queue->mul_accumulate(point_at_infinity, x);
69 op_queue->mul_accumulate(point_at_infinity, -x);
70 op_queue->eq_and_reset();
71 op_queue->add_accumulate(
a);
72 op_queue->mul_accumulate(point_at_infinity, x);
73 op_queue->mul_accumulate(point_at_infinity, -x);
74 op_queue->add_accumulate(
a);
75 op_queue->add_accumulate(
a);
76 op_queue->eq_and_reset();
78 add_hiding_op_for_test(op_queue);
81 EXPECT_EQ(result,
true);
185TEST(ECCVMCircuitBuilderTests, MSMOverPointAtInfinity)
197 op_queue->mul_accumulate(
b, x);
198 op_queue->mul_accumulate(point_at_infinity, x);
199 op_queue->eq_and_reset();
201 add_hiding_op_for_test(op_queue);
205 EXPECT_EQ(result,
true);
209 op_queue->mul_accumulate(point_at_infinity, x);
210 op_queue->eq_and_reset();
215 EXPECT_EQ(result,
true);
219 op_queue->mul_accumulate(
b, zero_scalar);
220 op_queue->eq_and_reset();
225 EXPECT_EQ(result,
true);
229 op_queue->mul_accumulate(point_at_infinity, zero_scalar);
230 op_queue->eq_and_reset();
235 EXPECT_EQ(result,
true);
239 op_queue->mul_accumulate(point_at_infinity, x);
240 op_queue->mul_accumulate(
b, zero_scalar);
241 op_queue->eq_and_reset();
246 EXPECT_EQ(result,
true);
401TEST(ECCVMCircuitBuilderTests, MSM)
403 static constexpr size_t max_num_msms = 9;
406 const auto compute_msms = [&](
const size_t num_msms,
auto& op_queue) {
408 std::vector<Fr> scalars;
410 for (
size_t i = 0; i < num_msms; ++i) {
411 points.emplace_back(generators[i]);
413 expected += (points[i] * scalars[i]);
414 op_queue->mul_accumulate(points[i], scalars[i]);
416 op_queue->eq_and_reset();
421 for (
size_t j = 1; j < max_num_msms; ++j) {
424 compute_msms(j, op_queue);
425 add_hiding_op_for_test(op_queue);
428 EXPECT_EQ(result,
true);
433 for (
size_t j = 1; j < 9; ++j) {
434 compute_msms(j, op_queue);
436 add_hiding_op_for_test(op_queue);
439 EXPECT_EQ(result,
true);
533TEST(ECCVMCircuitBuilderTests, InfinityFailure)
538 auto P1 = G1::infinity();
543 for (
size_t i = 0; i < 1; i++) {
544 op_queue->mul_accumulate(P1,
Fr(0));
547 add_hiding_op_for_test(op_queue);
555 bool row_op_code_correct = transcript_rows[2].opcode == 4;
557 bool failure =
Fr(transcript_rows[2].base_x) ==
Fr(0);
561 EXPECT_TRUE(failure && row_op_code_correct && circuit_checked);
static std::vector< affine_element > derive_generators(const std::vector< uint8_t > &domain_separator_bytes, const size_t num_generators, const size_t starting_index=0)
Derives generator points via hash-to-curve.