mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
renamed crypto.core to crypto.asymmetric
This commit is contained in:
parent
9dc767318e
commit
4255c1780b
@ -4,7 +4,7 @@ import bigchaindb
|
|||||||
from bigchaindb import config_utils
|
from bigchaindb import config_utils
|
||||||
from bigchaindb import exceptions
|
from bigchaindb import exceptions
|
||||||
from bigchaindb import util
|
from bigchaindb import util
|
||||||
from bigchaindb.crypto import core
|
from bigchaindb.crypto import asymmetric
|
||||||
|
|
||||||
|
|
||||||
class Client:
|
class Client:
|
||||||
@ -92,6 +92,6 @@ def temp_client():
|
|||||||
A client initialized with a keypair generated on the fly.
|
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')
|
return Client(private_key=private_key, public_key=public_key, api_endpoint='http://localhost:5000/api/v1')
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import bigchaindb
|
|||||||
import bigchaindb.config_utils
|
import bigchaindb.config_utils
|
||||||
from bigchaindb import db
|
from bigchaindb import db
|
||||||
from bigchaindb.commands.utils import base_parser, start
|
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.exceptions import DatabaseAlreadyExists
|
||||||
from bigchaindb.processes import Processes
|
from bigchaindb.processes import Processes
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ def run_configure(args, skip_if_exists=False):
|
|||||||
conf = copy.deepcopy(bigchaindb._config)
|
conf = copy.deepcopy(bigchaindb._config)
|
||||||
|
|
||||||
print('Generating keypair')
|
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:
|
if not args.yes:
|
||||||
for key in ('host', 'port', 'name'):
|
for key in ('host', 'port', 'name'):
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import bigchaindb
|
|||||||
from bigchaindb import config_utils
|
from bigchaindb import config_utils
|
||||||
from bigchaindb import exceptions
|
from bigchaindb import exceptions
|
||||||
from bigchaindb import util
|
from bigchaindb import util
|
||||||
from bigchaindb.crypto import core
|
from bigchaindb.crypto import asymmetric
|
||||||
from bigchaindb.monitor import Monitor
|
from bigchaindb.monitor import Monitor
|
||||||
|
|
||||||
monitor = Monitor()
|
monitor = Monitor()
|
||||||
@ -96,7 +96,7 @@ class Bigchain(object):
|
|||||||
|
|
||||||
signature = data.pop('signature')
|
signature = data.pop('signature')
|
||||||
public_key_base58 = signed_transaction['transaction']['current_owner']
|
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)
|
return public_key.verify(util.serialize(data), signature)
|
||||||
|
|
||||||
@monitor.timer('write_transaction', rate=bigchaindb.config['statsd']['rate'])
|
@monitor.timer('write_transaction', rate=bigchaindb.config['statsd']['rate'])
|
||||||
@ -329,8 +329,8 @@ class Bigchain(object):
|
|||||||
|
|
||||||
# Calculate the hash of the new block
|
# Calculate the hash of the new block
|
||||||
block_data = util.serialize(block)
|
block_data = util.serialize(block)
|
||||||
block_hash = core.hash_data(block_data)
|
block_hash = asymmetric.hash_data(block_data)
|
||||||
block_signature = core.PrivateKey(self.me_private).sign(block_data)
|
block_signature = asymmetric.PrivateKey(self.me_private).sign(block_data)
|
||||||
|
|
||||||
block = {
|
block = {
|
||||||
'id': block_hash,
|
'id': block_hash,
|
||||||
@ -355,7 +355,7 @@ class Bigchain(object):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# 1. Check if current hash is correct
|
# 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']:
|
if calculated_hash != block['id']:
|
||||||
raise exceptions.InvalidHash()
|
raise exceptions.InvalidHash()
|
||||||
|
|
||||||
@ -450,7 +450,7 @@ class Bigchain(object):
|
|||||||
}
|
}
|
||||||
|
|
||||||
vote_data = util.serialize(vote)
|
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 = {
|
vote_signed = {
|
||||||
'node_pubkey': self.me,
|
'node_pubkey': self.me,
|
||||||
|
|||||||
@ -9,7 +9,7 @@ from cryptography.hazmat.backends import default_backend
|
|||||||
from cryptography.hazmat.primitives import hashes
|
from cryptography.hazmat.primitives import hashes
|
||||||
from cryptography.hazmat.primitives.asymmetric import ec
|
from cryptography.hazmat.primitives.asymmetric import ec
|
||||||
|
|
||||||
from bigchaindb.crypto.core import PrivateKey, PublicKey
|
from bigchaindb.crypto.asymmetric import PrivateKey, PublicKey
|
||||||
|
|
||||||
|
|
||||||
class ECDSAPrivateKey(PrivateKey):
|
class ECDSAPrivateKey(PrivateKey):
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import base64
|
|||||||
import base58
|
import base58
|
||||||
import ed25519
|
import ed25519
|
||||||
|
|
||||||
from bigchaindb.crypto.core import PrivateKey, PublicKey
|
from bigchaindb.crypto.asymmetric import PrivateKey, PublicKey
|
||||||
|
|
||||||
|
|
||||||
class ED25519PrivateKey(PrivateKey):
|
class ED25519PrivateKey(PrivateKey):
|
||||||
|
|||||||
@ -5,7 +5,7 @@ from datetime import datetime
|
|||||||
|
|
||||||
import bigchaindb
|
import bigchaindb
|
||||||
from bigchaindb import exceptions
|
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):
|
class ProcessGroup(object):
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import bigchaindb
|
|||||||
from bigchaindb import exceptions
|
from bigchaindb import exceptions
|
||||||
from bigchaindb import util
|
from bigchaindb import util
|
||||||
from bigchaindb.block import Block
|
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
|
from bigchaindb.voter import Voter
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import pytest
|
|||||||
import rethinkdb as r
|
import rethinkdb as r
|
||||||
|
|
||||||
from bigchaindb import util
|
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
|
from bigchaindb.voter import Voter, BlockStream
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import json
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from bigchaindb import util
|
from bigchaindb import util
|
||||||
from bigchaindb.crypto import core
|
from bigchaindb.crypto import asymmetric
|
||||||
|
|
||||||
|
|
||||||
TX_ENDPOINT = '/api/v1/transactions/'
|
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):
|
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')
|
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):
|
def test_post_transfer_transaction_endpoint(b, client):
|
||||||
from_keypair = core.generate_key_pair()
|
from_keypair = asymmetric.generate_key_pair()
|
||||||
to_keypair = core.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')
|
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))
|
res = client.post(TX_ENDPOINT, data=json.dumps(tx))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user