async def _prog(context):
        shared_points = [SharedPoint.from_point(context, p) for p in TEST_POINTS]
        actual_negated = [SharedPoint.from_point(context, -p) for p in TEST_POINTS]

        shared_negated = [s.neg() for s in shared_points]

        zipped = zip(actual_negated, shared_negated)
        assert all(
            await asyncio.gather(*[shared_point_equals(a, r) for a, r in zipped])
        )
    async def _prog(context):
        shared_points = [SharedPoint.from_point(context, p) for p in TEST_POINTS]
        actual_doubled = [
            SharedPoint.from_point(context, p.double()) for p in TEST_POINTS
        ]

        results = [p.double() for p in shared_points]
        assert all(
            await asyncio.gather(
                *[shared_point_equals(a, r) for a, r in zip(actual_doubled, results)]
            )
        )
    async def _prog(context):
        shared_points = [SharedPoint.from_point(context, p) for p in TEST_POINTS]
        actual_negated = [SharedPoint.from_point(context, -p) for p in TEST_POINTS]

        # We're going to be testing that given point p, p - p == p + (-p)
        actual = [p.sub(p) for p in shared_points]
        result = [p1.add(p2) for p1, p2 in zip(shared_points, actual_negated)]

        assert all(
            await asyncio.gather(
                *[shared_point_equals(a, r) for a, r in zip(actual, result)]
            )
        )
    async def _prog(context):
        p1 = SharedPoint.from_point(context, TEST_POINTS[1])
        p1_double = p1.double()
        p1_quad = p1_double.double()

        assert await shared_point_equals(p1_quad, p1.montgomery_mul(4))

        assert await shared_point_equals(p1_quad.add(p1), p1.montgomery_mul(5))
    async def _prog(context):
        p1 = SharedPoint.from_point(context, TEST_POINTS[1])
        p1_double = p1.double()
        p1_quad = p1_double.double()
        p4 = p1.mul(4)
        p5 = p1.add(p4)
        p1_quint = p1_quad.add(p1)

        assert await shared_point_equals(p1_quad, p4)
        assert await shared_point_equals(p1_quint, p5)
    async def _prog(context):
        p1 = SharedPoint.from_point(context, TEST_POINTS[0])
        p2 = SharedPoint.from_point(context, TEST_POINTS[1])

        # Different curve
        t3 = copy(TEST_POINTS[0])
        t3.curve = Jubjub(Jubjub.Field(-2))
        p3 = SharedPoint.from_point(context, t3)

        p4 = SharedIdeal(TEST_CURVE)

        eqs = await asyncio.gather(
            *[
                shared_point_equals(p1, p1),
                shared_point_equals(p1, p2),
                shared_point_equals(p1, p3),
                shared_point_equals(p1, p4),
            ]
        )

        assert [True, False, False, False] == eqs
    async def _prog(context):
        ideal = SharedIdeal(TEST_CURVE)

        p1, p2, p3, p4 = [
            SharedPoint.from_point(context, point) for point in TEST_POINTS
        ]

        r1, r2, r3 = p2.add(ideal), p1.add(p2), p2.add(p3)

        assert all(
            await asyncio.gather(
                shared_point_equals(r1, p2),
                shared_point_equals(r2, p2),
                shared_point_equals(r3, p4),
            )
        )
Exemple #8
0
 async def _prog(context):
     base = SharedPoint.from_point(context, TEST_POINT)
     result = base.montgomery_mul(multiplier)
     await result.open()
Exemple #9
0
 async def _prog(context):
     result = SharedPoint.from_point(context, TEST_POINT)
     result = result.double()
     await result.open()
 async def _prog(context):
     p1 = Point(0, 1)
     p1s = SharedPoint.from_point(context, p1)
     assert await p1s.open() == p1