def test_sign_operation(self): op = Operation(OperationRev(), 'http://example.com/', [PublicKey.from_signing_key(SigningKey.generate())]) user = User.new_keys() with self.assertRaisesRegex(Operation.VerifyError, "object is not signed"): op.verify() user.sign_object(op) self.assertTrue(op.verify()) self.assertEqual(op.public_key, user._public_key)
def test_new_keys(self): user = User.new_keys(curve=NIST256p) self.assertIsInstance(user, User) self.assertIsInstance(user._private_key, SigningKey) self.assertIsInstance(user._public_key.verifying_key, VerifyingKey) self.assertEqual(user._private_key.to_der(), SigningKey.from_string(user._private_key.to_string(), NIST256p).to_der()) self.assertEqual(len(user._private_key.to_der()), len(SigningKey.generate(curve=NIST256p).to_der())) self.assertNotEqual(len(user._private_key.to_der()), len(SigningKey.generate().to_der()))