Example #1
0
 def test_decrypt_private_key(self):
     """Test that we can decrypt an AES key using a keypair"""
     encrypted, aes_key, user_key, next_id = self.test_encrypt_private_key()
     decrypted = decrypt_private_key(aes_key=aes_key,
                                     next_id=next_id,
                                     encrypted_private_key=encrypted)
     self.assertEqual(user_key.private_key, decrypted.decode("ascii"))
 def test_decrypt_private_key(self):
     self.assertTrue(callable(decrypt_private_key))
     encrypted, aes_key, user_key, user_id = self.test_encrypt_private_key()
     decrypted = decrypt_private_key(aes_key=aes_key,
                                     user_id=user_id,
                                     encrypted_private_key=encrypted)
     self.assertEqual(user_key.private_key, decrypted.decode("ascii"))
Example #3
0
async def get_transactor_key(request):
    id_dict = deserialize_api_key(request.app.config.SECRET_KEY, request.token)
    user_id = id_dict.get("id")

    auth_data = await auth_query.fetch_info_by_user_id(
        request.app.config.DB_CONN, user_id)
    encrypted_private_key = auth_data.get("encrypted_private_key")
    private_key = decrypt_private_key(request.app.config.AES_KEY, user_id,
                                      encrypted_private_key)
    hex_private_key = binascii.hexlify(private_key)
    return Key(hex_private_key)
Example #4
0
async def get_transactor_key(request):
    """Get transactor key out of request."""
    id_dict = deserialize_api_key(request.app.config.SECRET_KEY,
                                  extract_request_token(request))
    next_id = id_dict.get("id")

    auth_data = await get_auth_by_next_id(next_id)
    encrypted_private_key = auth_data.get("encrypted_private_key")
    private_key = decrypt_private_key(request.app.config.AES_KEY, next_id,
                                      encrypted_private_key)
    hex_private_key = binascii.hexlify(private_key)
    return Key(hex_private_key), next_id