15TEST(ECCVMCircuitBuilderTests, BaseCase)
28 op_queue->add_accumulate(
a);
29 op_queue->mul_accumulate(
a, x);
30 op_queue->mul_accumulate(
b, x);
31 op_queue->mul_accumulate(
b, y);
32 op_queue->add_accumulate(
a);
33 op_queue->mul_accumulate(
b, x);
34 op_queue->add_accumulate(
b);
35 op_queue->eq_and_reset();
36 op_queue->add_accumulate(c);
37 op_queue->mul_accumulate(
a, x);
38 op_queue->mul_accumulate(point_at_infinity, x);
39 op_queue->mul_accumulate(
b, x);
40 op_queue->eq_and_reset();
41 op_queue->mul_accumulate(
a, x);
42 op_queue->mul_accumulate(
b, x);
43 op_queue->mul_accumulate(point_at_infinity, zero_scalar);
44 op_queue->mul_accumulate(c, x);
45 op_queue->eq_and_reset();
46 op_queue->mul_accumulate(point_at_infinity, zero_scalar);
47 op_queue->mul_accumulate(point_at_infinity, x);
48 op_queue->mul_accumulate(point_at_infinity, zero_scalar);
49 op_queue->add_accumulate(
a);
50 op_queue->eq_and_reset();
51 op_queue->add_accumulate(
a);
52 op_queue->add_accumulate(point_at_infinity);
53 op_queue->eq_and_reset();
54 op_queue->add_accumulate(point_at_infinity);
55 op_queue->eq_and_reset();
56 op_queue->mul_accumulate(point_at_infinity, x);
57 op_queue->mul_accumulate(point_at_infinity, -x);
58 op_queue->eq_and_reset();
59 op_queue->add_accumulate(
a);
60 op_queue->mul_accumulate(point_at_infinity, x);
61 op_queue->mul_accumulate(point_at_infinity, -x);
62 op_queue->add_accumulate(
a);
63 op_queue->add_accumulate(
a);
64 op_queue->eq_and_reset();
68 EXPECT_EQ(result,
true);
166TEST(ECCVMCircuitBuilderTests, MSMOverPointAtInfinity)
178 op_queue->mul_accumulate(
b, x);
179 op_queue->mul_accumulate(point_at_infinity, x);
180 op_queue->eq_and_reset();
185 EXPECT_EQ(result,
true);
189 op_queue->mul_accumulate(point_at_infinity, x);
190 op_queue->eq_and_reset();
195 EXPECT_EQ(result,
true);
199 op_queue->mul_accumulate(
b, zero_scalar);
200 op_queue->eq_and_reset();
205 EXPECT_EQ(result,
true);
209 op_queue->mul_accumulate(point_at_infinity, zero_scalar);
210 op_queue->eq_and_reset();
215 EXPECT_EQ(result,
true);
219 op_queue->mul_accumulate(point_at_infinity, x);
220 op_queue->mul_accumulate(
b, zero_scalar);
221 op_queue->eq_and_reset();
226 EXPECT_EQ(result,
true);
373TEST(ECCVMCircuitBuilderTests, MSM)
375 static constexpr size_t max_num_msms = 9;
378 const auto compute_msms = [&](
const size_t num_msms,
auto& op_queue) {
380 std::vector<Fr> scalars;
382 for (
size_t i = 0; i < num_msms; ++i) {
383 points.emplace_back(generators[i]);
385 expected += (points[i] * scalars[i]);
386 op_queue->mul_accumulate(points[i], scalars[i]);
388 op_queue->eq_and_reset();
393 for (
size_t j = 1; j < max_num_msms; ++j) {
396 compute_msms(j, op_queue);
399 EXPECT_EQ(result,
true);
404 for (
size_t j = 1; j < 9; ++j) {
405 compute_msms(j, op_queue);
409 EXPECT_EQ(result,
true);
499TEST(ECCVMCircuitBuilderTests, InfinityFailure)
504 auto P1 = G1::infinity();
509 for (
size_t i = 0; i < 1; i++) {
510 op_queue->mul_accumulate(P1,
Fr(0));
519 bool row_op_code_correct = transcript_rows[1].opcode == 4;
521 bool failure =
Fr(transcript_rows[1].base_x) ==
Fr(0);
525 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.