Exemplo n.º 1
0
    def test_add(self):
        e = []
        for i in range(100):
            seed = str(i).encode("ascii")
            s = password_to_scalar(seed)
            e.append(Base.scalarmult(s))
        for i in range(100):
            x = random.choice(e)
            y = random.choice(e)

            sum1 = element_from_affine(
                slow_add_affine(xform_extended_to_affine(x.XYTZ),
                                xform_extended_to_affine(y.XYTZ)))
            sum2 = x.add(y)
            self.assertElementsEqual(sum1, sum2)
            if x != y:
                sum3 = Element(_add_elements_nonunfied(x.XYTZ, y.XYTZ))
                self.assertElementsEqual(sum1, sum3)
Exemplo n.º 2
0
    def test_add(self):
        e = []
        for i in range(100):
            seed = str(i).encode("ascii")
            s = password_to_scalar(seed)
            e.append(Base.scalarmult(s))
        for i in range(100):
            x = random.choice(e)
            y = random.choice(e)

            sum1 = element_from_affine(
                slow_add_affine(xform_extended_to_affine(x.XYTZ),
                                xform_extended_to_affine(y.XYTZ)))
            sum2 = x.add(y)
            self.assertElementsEqual(sum1, sum2)
            if x != y:
                sum3 = Element(_add_elements_nonunfied(x.XYTZ, y.XYTZ))
                self.assertElementsEqual(sum1, sum3)
Exemplo n.º 3
0
 def test_password_to_scalar(self):
     for i in range(20):
         seed = str(i).encode("ascii")
         s = password_to_scalar(seed)
         s2 = password_to_scalar(seed)
         self.assertEqual(s, s2)
Exemplo n.º 4
0
def _start(pw, entropy_f, blinding):
    a = random_scalar(entropy_f)
    pw_scalar = password_to_scalar(pw)
    X = Base.scalarmult(a).add(blinding.scalarmult(pw_scalar))
    X_s = X.to_bytes()
    return (a, pw_scalar), X_s
Exemplo n.º 5
0
 def test_password_to_scalar(self):
     for i in range(20):
         seed = str(i).encode("ascii")
         s = password_to_scalar(seed)
         s2 = password_to_scalar(seed)
         self.assertEqual(s, s2)
Exemplo n.º 6
0
def _start(pw, entropy_f, blinding):
    a = random_scalar(entropy_f)
    pw_scalar = password_to_scalar(pw)
    X = Base.scalarmult(a).add(blinding.scalarmult(pw_scalar))
    X_s = X.to_bytes()
    return (a, pw_scalar), X_s