diff --git a/bigchaindb/client.py b/bigchaindb/client.py index 67f73f28..156dc6b1 100644 --- a/bigchaindb/client.py +++ b/bigchaindb/client.py @@ -4,7 +4,7 @@ import bigchaindb from bigchaindb import config_utils from bigchaindb import exceptions from bigchaindb import util -from bigchaindb.crypto import core +from bigchaindb.crypto import asymmetric class Client: @@ -92,6 +92,6 @@ def temp_client(): A client initialized with a keypair generated on the fly. """ - private_key, public_key = core.generate_key_pair() + private_key, public_key = asymmetric.generate_key_pair() return Client(private_key=private_key, public_key=public_key, api_endpoint='http://localhost:5000/api/v1') diff --git a/bigchaindb/commands/bigchain.py b/bigchaindb/commands/bigchain.py index 0447fb13..b79b11b8 100644 --- a/bigchaindb/commands/bigchain.py +++ b/bigchaindb/commands/bigchain.py @@ -9,7 +9,7 @@ import bigchaindb import bigchaindb.config_utils from bigchaindb import db from bigchaindb.commands.utils import base_parser, start -from bigchaindb.crypto import core +from bigchaindb.crypto import asymmetric from bigchaindb.exceptions import DatabaseAlreadyExists from bigchaindb.processes import Processes @@ -50,7 +50,7 @@ def run_configure(args, skip_if_exists=False): conf = copy.deepcopy(bigchaindb._config) print('Generating keypair') - conf['keypair']['private'], conf['keypair']['public'] = core.generate_key_pair() + conf['keypair']['private'], conf['keypair']['public'] = asymmetric.generate_key_pair() if not args.yes: for key in ('host', 'port', 'name'): diff --git a/bigchaindb/core.py b/bigchaindb/core.py index 265a8616..be66ecf2 100644 --- a/bigchaindb/core.py +++ b/bigchaindb/core.py @@ -7,7 +7,7 @@ import bigchaindb from bigchaindb import config_utils from bigchaindb import exceptions from bigchaindb import util -from bigchaindb.crypto import core +from bigchaindb.crypto import asymmetric from bigchaindb.monitor import Monitor monitor = Monitor() @@ -96,7 +96,7 @@ class Bigchain(object): signature = data.pop('signature') public_key_base58 = signed_transaction['transaction']['current_owner'] - public_key = core.PublicKey(public_key_base58) + public_key = asymmetric.PublicKey(public_key_base58) return public_key.verify(util.serialize(data), signature) @monitor.timer('write_transaction', rate=bigchaindb.config['statsd']['rate']) @@ -329,8 +329,8 @@ class Bigchain(object): # Calculate the hash of the new block block_data = util.serialize(block) - block_hash = core.hash_data(block_data) - block_signature = core.PrivateKey(self.me_private).sign(block_data) + block_hash = asymmetric.hash_data(block_data) + block_signature = asymmetric.PrivateKey(self.me_private).sign(block_data) block = { 'id': block_hash, @@ -355,7 +355,7 @@ class Bigchain(object): """ # 1. Check if current hash is correct - calculated_hash = core.hash_data(util.serialize(block['block'])) + calculated_hash = asymmetric.hash_data(util.serialize(block['block'])) if calculated_hash != block['id']: raise exceptions.InvalidHash() @@ -450,7 +450,7 @@ class Bigchain(object): } vote_data = util.serialize(vote) - signature = core.PrivateKey(self.me_private).sign(vote_data) + signature = asymmetric.PrivateKey(self.me_private).sign(vote_data) vote_signed = { 'node_pubkey': self.me, diff --git a/bigchaindb/crypto/core.py b/bigchaindb/crypto/asymmetric.py similarity index 100% rename from bigchaindb/crypto/core.py rename to bigchaindb/crypto/asymmetric.py diff --git a/bigchaindb/crypto/ecdsa.py b/bigchaindb/crypto/ecdsa.py index 023bfbae..29bf6e45 100644 --- a/bigchaindb/crypto/ecdsa.py +++ b/bigchaindb/crypto/ecdsa.py @@ -9,7 +9,7 @@ from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.asymmetric import ec -from bigchaindb.crypto.core import PrivateKey, PublicKey +from bigchaindb.crypto.asymmetric import PrivateKey, PublicKey class ECDSAPrivateKey(PrivateKey): diff --git a/bigchaindb/crypto/ed25519.py b/bigchaindb/crypto/ed25519.py index bdd83d26..823a6643 100644 --- a/bigchaindb/crypto/ed25519.py +++ b/bigchaindb/crypto/ed25519.py @@ -5,7 +5,7 @@ import base64 import base58 import ed25519 -from bigchaindb.crypto.core import PrivateKey, PublicKey +from bigchaindb.crypto.asymmetric import PrivateKey, PublicKey class ED25519PrivateKey(PrivateKey): diff --git a/bigchaindb/util.py b/bigchaindb/util.py index 761f8c92..9e49b083 100644 --- a/bigchaindb/util.py +++ b/bigchaindb/util.py @@ -5,7 +5,7 @@ from datetime import datetime import bigchaindb from bigchaindb import exceptions -from bigchaindb.crypto.core import PrivateKey, PublicKey, hash_data +from bigchaindb.crypto.asymmetric import PrivateKey, PublicKey, hash_data class ProcessGroup(object): diff --git a/tests/db/test_bigchain_api.py b/tests/db/test_bigchain_api.py index 227ec9dd..0ed02a8b 100644 --- a/tests/db/test_bigchain_api.py +++ b/tests/db/test_bigchain_api.py @@ -9,7 +9,7 @@ import bigchaindb from bigchaindb import exceptions from bigchaindb import util from bigchaindb.block import Block -from bigchaindb.crypto.core import PrivateKey, PublicKey, generate_key_pair, hash_data +from bigchaindb.crypto.asymmetric import PrivateKey, PublicKey, generate_key_pair, hash_data from bigchaindb.voter import Voter diff --git a/tests/db/test_voter.py b/tests/db/test_voter.py index 69eae0df..e4ae8efa 100644 --- a/tests/db/test_voter.py +++ b/tests/db/test_voter.py @@ -5,7 +5,7 @@ import pytest import rethinkdb as r from bigchaindb import util -from bigchaindb.crypto.core import PublicKey, generate_key_pair +from bigchaindb.crypto.asymmetric import PublicKey, generate_key_pair from bigchaindb.voter import Voter, BlockStream diff --git a/tests/web/test_basic_views.py b/tests/web/test_basic_views.py index 88189b7b..1db8c7a9 100644 --- a/tests/web/test_basic_views.py +++ b/tests/web/test_basic_views.py @@ -3,7 +3,7 @@ import json import pytest from bigchaindb import util -from bigchaindb.crypto import core +from bigchaindb.crypto import asymmetric TX_ENDPOINT = '/api/v1/transactions/' @@ -18,7 +18,7 @@ def test_get_transaction_endpoint(b, client, user_public_key): def test_post_create_transaction_endpoint(b, client): - keypair = core.generate_key_pair() + keypair = asymmetric.generate_key_pair() tx = util.create_and_sign_tx(keypair[0], keypair[1], keypair[1], None, 'CREATE') @@ -28,8 +28,8 @@ def test_post_create_transaction_endpoint(b, client): def test_post_transfer_transaction_endpoint(b, client): - from_keypair = core.generate_key_pair() - to_keypair = core.generate_key_pair() + from_keypair = asymmetric.generate_key_pair() + to_keypair = asymmetric.generate_key_pair() tx = util.create_and_sign_tx(from_keypair[0], from_keypair[1], from_keypair[1], None, 'CREATE') res = client.post(TX_ENDPOINT, data=json.dumps(tx))