17TEST(ECCVMCircuitBuilderTests, BaseCase)
30 op_queue->add_accumulate(
a);
31 op_queue->mul_accumulate(
a, x);
32 op_queue->mul_accumulate(
b, x);
33 op_queue->mul_accumulate(
b, y);
34 op_queue->add_accumulate(
a);
35 op_queue->mul_accumulate(
b, x);
36 op_queue->add_accumulate(
b);
37 op_queue->eq_and_reset();
38 op_queue->add_accumulate(c);
39 op_queue->mul_accumulate(
a, x);
40 op_queue->mul_accumulate(point_at_infinity, x);
41 op_queue->mul_accumulate(
b, x);
42 op_queue->eq_and_reset();
43 op_queue->mul_accumulate(
a, x);
44 op_queue->mul_accumulate(
b, x);
45 op_queue->mul_accumulate(point_at_infinity, zero_scalar);
46 op_queue->mul_accumulate(c, x);
47 op_queue->eq_and_reset();
48 op_queue->mul_accumulate(point_at_infinity, zero_scalar);
49 op_queue->mul_accumulate(point_at_infinity, x);
50 op_queue->mul_accumulate(point_at_infinity, zero_scalar);
51 op_queue->add_accumulate(
a);
52 op_queue->eq_and_reset();
53 op_queue->add_accumulate(
a);
54 op_queue->add_accumulate(point_at_infinity);
55 op_queue->eq_and_reset();
56 op_queue->add_accumulate(point_at_infinity);
57 op_queue->eq_and_reset();
58 op_queue->mul_accumulate(point_at_infinity, x);
59 op_queue->mul_accumulate(point_at_infinity, -x);
60 op_queue->eq_and_reset();
61 op_queue->add_accumulate(
a);
62 op_queue->mul_accumulate(point_at_infinity, x);
63 op_queue->mul_accumulate(point_at_infinity, -x);
64 op_queue->add_accumulate(
a);
65 op_queue->add_accumulate(
a);
66 op_queue->eq_and_reset();
68 add_hiding_op_for_test(op_queue);
71 EXPECT_EQ(result,
true);
175TEST(ECCVMCircuitBuilderTests, MSMOverPointAtInfinity)
187 op_queue->mul_accumulate(
b, x);
188 op_queue->mul_accumulate(point_at_infinity, x);
189 op_queue->eq_and_reset();
191 add_hiding_op_for_test(op_queue);
195 EXPECT_EQ(result,
true);
199 op_queue->mul_accumulate(point_at_infinity, x);
200 op_queue->eq_and_reset();
205 EXPECT_EQ(result,
true);
209 op_queue->mul_accumulate(
b, zero_scalar);
210 op_queue->eq_and_reset();
215 EXPECT_EQ(result,
true);
219 op_queue->mul_accumulate(point_at_infinity, zero_scalar);
220 op_queue->eq_and_reset();
225 EXPECT_EQ(result,
true);
229 op_queue->mul_accumulate(point_at_infinity, x);
230 op_queue->mul_accumulate(
b, zero_scalar);
231 op_queue->eq_and_reset();
236 EXPECT_EQ(result,
true);
391TEST(ECCVMCircuitBuilderTests, MSM)
393 static constexpr size_t max_num_msms = 9;
396 const auto compute_msms = [&](
const size_t num_msms,
auto& op_queue) {
398 std::vector<Fr> scalars;
400 for (
size_t i = 0; i < num_msms; ++i) {
401 points.emplace_back(generators[i]);
403 expected += (points[i] * scalars[i]);
404 op_queue->mul_accumulate(points[i], scalars[i]);
406 op_queue->eq_and_reset();
411 for (
size_t j = 1; j < max_num_msms; ++j) {
414 compute_msms(j, op_queue);
415 add_hiding_op_for_test(op_queue);
418 EXPECT_EQ(result,
true);
423 for (
size_t j = 1; j < 9; ++j) {
424 compute_msms(j, op_queue);
426 add_hiding_op_for_test(op_queue);
429 EXPECT_EQ(result,
true);
523TEST(ECCVMCircuitBuilderTests, InfinityFailure)
528 auto P1 = G1::infinity();
533 for (
size_t i = 0; i < 1; i++) {
534 op_queue->mul_accumulate(P1,
Fr(0));
537 add_hiding_op_for_test(op_queue);
545 bool row_op_code_correct = transcript_rows[2].opcode == 4;
547 bool failure =
Fr(transcript_rows[2].base_x) ==
Fr(0);
551 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.