Example #1
0
def test_half_trace():
    from crypto import half_trace

    def htr(x):
        a = 0
        for i in range((m - 1) // 2 + 1):
            a ^= x
            x = fe_sq(x)
            x = fe_sq(x)
        return a

    return all(
        htr(x) == half_trace(x) for x in (fe_rand() for i in range(100)))
Example #2
0
def test_trace():
    from crypto import trace

    def tr(x):
        a = 0
        for i in range(m):
            a ^= x
            x = fe_sq(x)
        x = 0
        for i in range(m):
            x ^= a % 2
            a >> 1
        return x

    return all(tr(x) == trace(x) for x in (fe_rand() for i in range(100)))
Example #3
0
def test_fe_sqrt():
    from crypto import fe_sqrt
    return all(fe_sq(fe_sqrt(x)) == x for x in (fe_rand() for i in range(100)))
Example #4
0
def test_fe_sq():
    from crypto import fe_mul
    return all(
        fe_sq(x) == fe_mul(x, x) for x in (fe_rand() for i in range(100)))
Example #5
0
def test_fe_inv():
    from crypto import fe_mul, fe_inv
    return all(
        fe_mul(x, fe_inv(x)) == 1 for x in (fe_rand() for i in range(100)))