def _test_with_vector(self, PUB, REPR, PRIV, VALID): Repr = ref_ed.decodeint("".join(map(chr, REPR))) X = ref_ed.decodeint("".join(map(chr, PUB))) Priv = ref_ed.decodeint("".join(map(chr, PRIV))) Pub = curvemod.mul(Priv, self.curve25519.base_point, self.curve25519.curve) # Check valid valid = True try: P1, P2 = self.curve25519.curve.get_y(X) except: valid = False self.assertEquals(valid, VALID) # Check mappings back and forth if valid: """ print print 'P1', P1 print 'P2', P2 print 'XXX', self.ell2.map_random_to_point(Repr) print self.assertEquals(Repr, self.ell2.map_point_to_random(P1)) self.assertEquals(Repr, self.ell2.map_point_to_random(P2)) """ self.assertEquals(Repr, self.ell2.map_point_to_random(Pub)) self.assertEquals(X, self.ell2.map_random_to_point(Repr)[0])
def _test_with_vector(self, PUB, REPR, PRIV, VALID): Repr = ref_ed.decodeint(''.join(map(chr, REPR))) X = ref_ed.decodeint(''.join(map(chr, PUB))) Priv = ref_ed.decodeint(''.join(map(chr, PRIV))) Pub = curvemod.mul(Priv, self.curve25519.base_point, self.curve25519.curve) # Check valid valid = True try: P1, P2 = self.curve25519.curve.get_y(X) except: valid = False self.assertEquals(valid, VALID) # Check mappings back and forth if valid: """ print print 'P1', P1 print 'P2', P2 print 'XXX', self.ell2.map_random_to_point(Repr) print self.assertEquals(Repr, self.ell2.map_point_to_random(P1)) self.assertEquals(Repr, self.ell2.map_point_to_random(P2)) """ self.assertEquals(Repr, self.ell2.map_point_to_random(Pub)) self.assertEquals(X, self.ell2.map_random_to_point(Repr)[0])
def _test_with_vector(self, PUB, REPR, PRIV, VALID): Repr = ref_ed.decodeint(''.join(map(chr, REPR))) X = ref_ed.decodeint(''.join(map(chr, PUB))) Priv = ref_ed.decodeint(''.join(map(chr, PRIV))) Pub = curvemod.mul(Priv, self.curve25519.base_point, self.curve25519.curve) self.assertEquals(arr2str(PRIV), self.curve25519.canonical_binary_form_private(Priv)) self.assertEquals(arr2str(PUB), self.curve25519.canonical_binary_form_public(Pub)) self.assertEquals(Priv, self.curve25519.binary_to_private(arr2str(PRIV)))