Removing references to 'KMS'

pull/268/head
jMyles 2018-05-08 12:35:34 -07:00
parent 2d68b9bf70
commit 41805d5d06
113 changed files with 228 additions and 1316 deletions

View File

@ -10,5 +10,5 @@ before_script:
- wget https://github.com/ethereum/solidity/releases/download/v0.4.23/solc-static-linux -O "${VIRTUAL_ENV}/bin/solc"
- chmod +x "${VIRTUAL_ENV}/bin/solc"
script:
- pipenv run -- pytest --runslow --cov=nkms -v tests
- pipenv run -- pytest --runslow --cov=nucypher -v tests
- codecov

View File

@ -10,8 +10,8 @@ cryptography35_linux = { file="https://github.com/nucypher/pyUmbral/blob/master/
cryptography36_linux = { file="https://github.com/nucypher/pyUmbral/blob/master/wheelhouse/cryptography-2.3.dev1-cp36-cp36m-linux_x86_64.whl?raw=true", markers="python_version >= '3.6' and python_version < '3.7' and platform_system == 'Linux'"}
rpcudp = {git = "https://github.com/nucypher/rpcudp", ref = "kms-dependency"}
kademlia = {git = "https://github.com/nucypher/kademlia", ref = "kms-dependency"}
rpcudp = {git = "https://github.com/nucypher/rpcudp", ref = "nucypher-depend"}
kademlia = {git = "https://github.com/nucypher/kademlia", ref = "nucypher-depend"}
PyNaCl = "*"
"pysha3" = "*"
bidict = "*"
@ -24,8 +24,8 @@ maya = "*"
pyumbral = {git = "https://github.com/nucypher/pyumbral.git"}
requests = "*"
hendrix = {git = "https://github.com/hendrix/hendrix", ref = "tags/3.0.0rc1"}
constantSorrow = {git = "https://github.com/nucypher/constantSorrow.git", ref = "kms-depend"}
bytestringSplitter = {git = "https://github.com/nucypher/byteStringSplitter.git", ref = "kms-depend"}
constantSorrow = {git = "https://github.com/nucypher/constantSorrow.git", ref = "nucypher-depend"}
bytestringSplitter = {git = "https://github.com/nucypher/byteStringSplitter.git", ref = "nucypher-depend"}
appdirs = "*"
[dev-packages]

1084
Pipfile.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
NuCypher decentralized KMS
============================
NuCypher
========
Depencencies / technologies
=============================
@ -55,7 +55,7 @@ this information on blockchain.
When a node start, a key which will be used to decrypt the persisted
data can be generated, read from a file (not very safe!), made from
passphrase (safe if the passphrase is long enough and generated),
or stored + delegated access using our KMS itself.
or stored + delegated access using NuCypher itself.
This kademlia-based protocol is *not* intended to be anonymous, we hope for
split-key reencryption properties (e.g. that < m random nodes will be corrupt).
@ -158,7 +158,7 @@ key is created for a path shared::
where key[i] is calculated in-place from the path, and rk might mean also all re-encryption shares
rather than just one rekey.
After the calculation, the rk is stored with the KMS network. It will be stored in the following
After the calculation, the rk is stored with the NuCypher network. It will be stored in the following
persistent mapping::
hmac(pk_o + pk_b, '/'.join(path[:i])) -> (rk, policy, algorithm, sign(hash + rk + policy + algorithm, pk_o))

View File

@ -1,6 +1,6 @@
# NuCypher KMS Ethereum
# NuCypher Ethereum
Ethereum (solidity) code for nucypher-kms, consists contracts and python classes for miners and clients.
Ethereum (solidity) code for NuCypher, consists contracts and python classes for miners and clients.
Part of contracts was copied from [OpenZeppelin](https://github.com/OpenZeppelin/zeppelin-solidity) repo.
The basis is built on the [Populus](https://github.com/ethereum/populus) framework.
@ -13,9 +13,9 @@ Period is calculating using block.timestamp in getCurrentPeriod() function (`Min
# Main contracts
* Token contract
`NuCypherKMSToken` contract is ERC20 token with additional function - burn own tokens (only for owners)
`NuCypherToken` contract is ERC20 token with additional function - burn own tokens (only for owners)
* Miner contract
`MinersEscrow` contract holds stake from miners, store information about miners activity and assigns a reward for participating in NuCypher KMS network
`MinersEscrow` contract holds stake from miners, store information about miners activity and assigns a reward for participating in NuCypher network
* Client contract
`PolicyManager` contract holds policies fee and distributes fee by periods
* User escrow contract
@ -24,4 +24,4 @@ Period is calculating using block.timestamp in getCurrentPeriod() function (`Min
# Solidity libraries
* `LinkedList` library is structure of linked list for address data type
* `Dispatcher` contract is proxy which used for updating versions of any contract. See [README.MD](nkms.blockchain.eth/project/contracts/proxy/README.MD)
* `Dispatcher` contract is proxy which used for updating versions of any contract. See [README.MD](nucypher.blockchain.eth/project/contracts/proxy/README.MD)

View File

@ -7,9 +7,9 @@ import datetime
import sys
from examples.sandbox_resources import SandboxNetworkyStuff
from nkms.characters import Alice, Bob, Ursula
from nkms.data_sources import DataSource
from nkms.network.node import NetworkyStuff
from nucypher.characters import Alice, Bob, Ursula
from nucypher.data_sources import DataSource
from nucypher.network.node import NetworkyStuff
import maya
# This is already running in another process.

View File

@ -11,11 +11,11 @@ from cryptography.hazmat.primitives.asymmetric import ec
from hendrix.deploy.tls import HendrixDeployTLS
from hendrix.facilities.services import ExistingKeyTLSContextFactory
from nkms.characters import Ursula
from nucypher.characters import Ursula
from OpenSSL.crypto import X509
from OpenSSL.SSL import TLSv1_2_METHOD
from nkms.crypto.api import generate_self_signed_certificate
from nucypher.crypto.api import generate_self_signed_certificate
DB_NAME = "non-mining-proxy-node"

View File

@ -1,7 +1,7 @@
import requests
from nkms.characters import Ursula
from nkms.network.node import NetworkyStuff
from nkms.crypto.powers import SigningPower, EncryptingPower
from nucypher.characters import Ursula
from nucypher.network.node import NetworkyStuff
from nucypher.crypto.powers import SigningPower, EncryptingPower
class SandboxNetworkyStuff(NetworkyStuff):

View File

@ -1,3 +0,0 @@
from nkms.config.utils import check_config_runtime
check_config_runtime()

View File

@ -3,7 +3,7 @@ from collections import OrderedDict
from datetime import datetime
from typing import Tuple, List, Union
from nkms.blockchain.eth.agents import NuCypherKMSTokenAgent
from nucypher.blockchain.eth.agents import NucypherTokenAgent
class TokenActor(ABC):
@ -11,7 +11,7 @@ class TokenActor(ABC):
class ActorError(Exception):
pass
def __init__(self, token_agent: NuCypherKMSTokenAgent, address: Union[bytes, str]):
def __init__(self, token_agent: NucypherTokenAgent, address: Union[bytes, str]):
self.token_agent = token_agent
if isinstance(address, bytes):

View File

@ -5,7 +5,7 @@ from typing import Set, Generator, List
from functools import partial
from nkms.blockchain.eth.deployers import MinerEscrowDeployer, NuCypherKMSTokenDeployer, PolicyManagerDeployer, \
from nucypher.blockchain.eth.deployers import MinerEscrowDeployer, NucypherTokenDeployer, PolicyManagerDeployer, \
ContractDeployer
@ -70,10 +70,10 @@ class EthereumContractAgent(ABC):
return self.read().balanceOf(address)
class NuCypherKMSTokenAgent(EthereumContractAgent):
class NucypherTokenAgent(EthereumContractAgent):
_deployer = NuCypherKMSTokenDeployer
_principal_contract_name = NuCypherKMSTokenDeployer._contract_name
_deployer = NucypherTokenDeployer
_principal_contract_name = NucypherTokenDeployer._contract_name
class MinerAgent(EthereumContractAgent):
@ -98,7 +98,7 @@ class MinerAgent(EthereumContractAgent):
CONFIRMED_PERIOD_1 = 3
CONFIRMED_PERIOD_2 = 4
def __init__(self, token_agent: NuCypherKMSTokenAgent):
def __init__(self, token_agent: NucypherTokenAgent):
super().__init__(blockchain=token_agent.blockchain) # TODO: public
self.token_agent = token_agent
self.miners = list() # Tracks per client

View File

@ -2,7 +2,7 @@ import random
from abc import ABC
from typing import List
from nkms.blockchain.eth.interfaces import ContractProvider
from nucypher.blockchain.eth.interfaces import ContractProvider
class TheBlockchain(ABC):
@ -103,7 +103,7 @@ class TesterBlockchain(TheBlockchain):
Deposit and lock a random amount of tokens in the miner escrow
from each address, "spawning" new Miners.
"""
from nkms.blockchain.eth.actors import Miner
from nucypher.blockchain.eth.actors import Miner
miners = list()
for address in addresses:

View File

@ -2,7 +2,7 @@ from typing import Tuple, Dict
from web3.contract import Contract
from nkms.blockchain.eth.constants import NuCypherMinerConfig, NuCypherTokenConfig
from nucypher.blockchain.eth.constants import NuCypherMinerConfig, NuCypherTokenConfig
from .chains import TheBlockchain
@ -150,9 +150,9 @@ class ContractDeployer:
raise NotImplementedError
class NuCypherKMSTokenDeployer(ContractDeployer, NuCypherTokenConfig):
class NucypherTokenDeployer(ContractDeployer, NuCypherTokenConfig):
_contract_name = 'NuCypherKMSToken'
_contract_name = 'NuCypherToken'
def __init__(self, blockchain):
super().__init__(blockchain=blockchain)
@ -160,7 +160,7 @@ class NuCypherKMSTokenDeployer(ContractDeployer, NuCypherTokenConfig):
def deploy(self) -> str:
"""
Deploy and publish the NuCypherKMS Token contract
Deploy and publish the NuCypher Token contract
to the blockchain network specified in self.blockchain.network.
The contract must be armed before it can be deployed.
@ -212,7 +212,7 @@ class MinerEscrowDeployer(ContractDeployer, NuCypherMinerConfig):
def deploy(self) -> Dict[str, str]:
"""
Deploy and publish the NuCypherKMS Token contract
Deploy and publish the NuCypher Token contract
to the blockchain network specified in self.blockchain.network.
The contract must be armed before it can be deployed.

View File

@ -6,7 +6,7 @@ from typing import Tuple, List
from web3 import Web3
from web3.contract import Contract
from nkms.blockchain.eth.sol.compile import SolidityCompiler
from nucypher.blockchain.eth.sol.compile import SolidityCompiler
_DEFAULT_CONFIGURATION_DIR = os.path.join(str(Path.home()), '.nucypher')
@ -16,7 +16,7 @@ class Registrar:
Records known contracts on the disk for future access and utility. This
lazily writes to the filesystem during contract enrollment.
WARNING: Unless you are developing the KMS/work at NuCypher, you most
WARNING: Unless you are developing NuCypher, you most
likely won't ever need to use this.
"""
__DEFAULT_REGISTRAR_FILEPATH = os.path.join(_DEFAULT_CONFIGURATION_DIR, 'registrar.json')
@ -86,7 +86,7 @@ class Registrar:
to the filesystem as JSON. This can also be used to update the info
under the specified `contract_name`.
Note: Unless you are developing the KMS, you most likely won't ever need to use this.
Note: Unless you are developing NuCypher, you most likely won't ever need to use this.
"""
contract_data = {
contract_addr: {

View File

@ -1,4 +1,4 @@
from nkms.blockchain.eth.actors import Miner
from nucypher.blockchain.eth.actors import Miner
class BlockchainArrangement:

View File

@ -6,7 +6,7 @@ A simple Python script to deploy contracts and then estimate gas for different m
"""
from nkms.blockchain.eth.agents import NuCypherKMSTokenAgent, MinerAgent
from nucypher.blockchain.eth.agents import NucypherTokenAgent, MinerAgent
import os
from tests.utilities import TesterBlockchain
@ -21,7 +21,7 @@ def main():
# TODO: Updatae to agents and deployers
# Create an ERC20 token
token = NuCypherKMSToken(blockchain=chain)
token = NucypherToken(blockchain=chain)
token.arm()
token.deploy()

View File

@ -21,5 +21,3 @@ chmod +x "${VENV}/bin/solc"
pipenv run pip3 install -e .
pipenv install --dev
#Populus
echo "export PYTEST_POPULUS_PROJECT=\"$PWD/nkms_eth/project/\"" >> "${VENV}/bin/activate"

View File

@ -5,7 +5,7 @@
A simple Python script to deploy contracts and then estimate gas for different methods.
"""
import random
from nkms.blockchain.eth.blockchain import project
from nucypher.blockchain.eth.blockchain import project
TIMEOUT = 10
MINING_COEFF = [10 ** 5, 10 ** 7]
@ -29,7 +29,7 @@ def main():
# Create an ERC20 token
token, tx = chain.provider.get_or_deploy_contract(
'HumanStandardToken', deploy_args=[
int(1e9) * M, int(1e10) * M, 'NuCypher KMS', 6, 'KMS'],
int(1e9) * M, int(1e10) * M, 'NuCypher', 6, 'NU'],
deploy_transaction={
'from': creator})
chain.wait.for_receipt(tx, timeout=TIMEOUT)

View File

@ -1,7 +1,7 @@
pragma solidity ^0.4.23;
import "contracts/NuCypherKMSToken.sol";
import "contracts/NuCypherToken.sol";
import "zeppelin/math/SafeMath.sol";
import "zeppelin/math/Math.sol";
import "proxy/Upgradeable.sol";
@ -16,7 +16,7 @@ contract Issuer is Upgradeable {
/// Issuer is initialized with a reserved reward
event Initialized(uint256 reservedReward);
NuCypherKMSToken public token;
NuCypherToken public token;
uint256 public miningCoefficient;
uint256 public secondsPerPeriod;
uint256 public lockedPeriodsCoefficient;
@ -46,7 +46,7 @@ contract Issuer is Upgradeable {
* @param _awardedPeriods Max periods that will be additionally awarded
**/
constructor(
NuCypherKMSToken _token,
NuCypherToken _token,
uint256 _hoursPerPeriod,
uint256 _miningCoefficient,
uint256 _lockedPeriodsCoefficient,

View File

@ -19,7 +19,7 @@ contract PolicyManagerInterface {
Each node that lock its tokens will receive some compensation
**/
contract MinersEscrow is Issuer {
using SafeERC20 for NuCypherKMSToken;
using SafeERC20 for NuCypherToken;
using AdditionalMath for uint256;
event Deposited(address indexed owner, uint256 value, uint256 periods);
@ -96,7 +96,7 @@ contract MinersEscrow is Issuer {
* @param _maxAllowableLockedTokens Max amount of tokens that can be locked
**/
constructor(
NuCypherKMSToken _token,
NuCypherToken _token,
uint256 _hoursPerPeriod,
uint256 _miningCoefficient,
uint256 _lockedPeriodsCoefficient,

View File

@ -7,11 +7,11 @@ import "zeppelin/token/ERC20/DetailedERC20.sol";
/**
* @title NuCypher KMS token
* @title NuCypher token
* @notice ERC20 token which can be burned by their owners
* @dev Optional approveAndCall() functionality to notify a contract if an approve() has occurred.
**/
contract NuCypherKMSToken is StandardToken, DetailedERC20('NuCypher KMS', 'KMS', 18), BurnableToken {
contract NuCypherToken is StandardToken, DetailedERC20('NuCypher', 'NU', 18), BurnableToken {
/**
* @notice Set amount of tokens

View File

@ -6,7 +6,7 @@ import "zeppelin/math/SafeMath.sol";
import "zeppelin/math/Math.sol";
import "./lib/AdditionalMath.sol";
import "contracts/MinersEscrow.sol";
import "contracts/NuCypherKMSToken.sol";
import "contracts/NuCypherToken.sol";
import "proxy/Upgradeable.sol";
@ -14,7 +14,7 @@ import "proxy/Upgradeable.sol";
* @notice Contract holds policy data and locks fees
**/
contract PolicyManager is Upgradeable {
using SafeERC20 for NuCypherKMSToken;
using SafeERC20 for NuCypherToken;
using SafeMath for uint256;
using AdditionalMath for uint256;
using AdditionalMath for int256;

View File

@ -3,7 +3,7 @@ pragma solidity ^0.4.23;
import "zeppelin/token/ERC20/SafeERC20.sol";
import "zeppelin/ownership/Ownable.sol";
import "zeppelin/math/SafeMath.sol";
import "contracts/NuCypherKMSToken.sol";
import "contracts/NuCypherToken.sol";
import "contracts/MinersEscrow.sol";
import "contracts/PolicyManager.sol";
@ -14,7 +14,7 @@ import "contracts/PolicyManager.sol";
* Also tokens can be send to the miners escrow
**/
contract UserEscrow is Ownable {
using SafeERC20 for NuCypherKMSToken;
using SafeERC20 for NuCypherToken;
using SafeMath for uint256;
event Deposited(address indexed sender, uint256 value, uint256 duration);
@ -34,7 +34,7 @@ contract UserEscrow is Ownable {
event RewardWithdrawnAsMiner(address indexed owner, uint256 value);
event RewardWithdrawn(address indexed owner, uint256 value);
NuCypherKMSToken public token;
NuCypherToken public token;
MinersEscrow public escrow;
PolicyManager public policyManager;
uint256 public lockedValue;
@ -48,7 +48,7 @@ contract UserEscrow is Ownable {
* @param _policyManager PolicyManager contract
**/
constructor(
NuCypherKMSToken _token,
NuCypherToken _token,
MinersEscrow _escrow,
PolicyManager _policyManager
)

View File

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -9,20 +9,20 @@ from typing import Dict, ClassVar
from typing import Union, List
from bytestring_splitter import BytestringSplitter
from nkms.network.node import NetworkyStuff
from nucypher.network.node import NetworkyStuff
from umbral.keys import UmbralPublicKey
from constant_sorrow import constants, default_constant_splitter
from nkms.blockchain.eth.actors import PolicyAuthor
from nkms.config.configs import KMSConfig
from nkms.crypto.api import secure_random, keccak_digest, encrypt_and_sign
from nkms.crypto.constants import PUBLIC_KEY_LENGTH
from nkms.crypto.kits import UmbralMessageKit
from nkms.crypto.powers import CryptoPower, SigningPower, EncryptingPower, DelegatingPower, NoSigningPower
from nkms.crypto.signature import Signature, signature_splitter, SignatureStamp, StrangerStamp
from nkms.network import blockchain_client
from nkms.network.protocols import dht_value_splitter, dht_with_hrac_splitter
from nkms.network.server import NuCypherDHTServer, NuCypherSeedOnlyDHTServer, ProxyRESTServer
from nucypher.blockchain.eth.actors import PolicyAuthor
from nucypher.config.configs import NucypherConfig
from nucypher.crypto.api import secure_random, keccak_digest, encrypt_and_sign
from nucypher.crypto.constants import PUBLIC_KEY_LENGTH
from nucypher.crypto.kits import UmbralMessageKit
from nucypher.crypto.powers import CryptoPower, SigningPower, EncryptingPower, DelegatingPower, NoSigningPower
from nucypher.crypto.signature import Signature, signature_splitter, SignatureStamp, StrangerStamp
from nucypher.network import blockchain_client
from nucypher.network.protocols import dht_value_splitter, dht_with_hrac_splitter
from nucypher.network.server import NuCypherDHTServer, NuCypherSeedOnlyDHTServer, ProxyRESTServer
class Character(object):
@ -38,7 +38,7 @@ class Character(object):
def __init__(self, attach_server=True, crypto_power: CryptoPower=None,
crypto_power_ups=None, is_me=True, network_middleware=None,
config: "KMSConfig"=None) -> None:
config: "NucypherConfig"=None) -> None:
"""
:param attach_server: Whether to attach a Server when this Character is
born.
@ -60,7 +60,7 @@ class Character(object):
Character, but there are scenarios in which its imaginable to be
represented by zero Characters or by more than one Character.
"""
# self.config = config if config is not None else KMSConfig.get_config()
# self.config = config if config is not None else NucypherConfig.get_config()
self.known_nodes = {}
self.log = getLogger("characters")
@ -343,7 +343,7 @@ class Alice(Character, PolicyAuthor):
Generates KFrags and attaches them.
"""
public_key, kfrags = self.generate_kfrags(bob, label, m, n)
from nkms.policy.models import Policy
from nucypher.policy.models import Policy
policy = Policy.from_alice(
alice=self,
label=label,
@ -396,7 +396,7 @@ class Bob(Character):
super().__init__(*args, **kwargs)
self.treasure_maps = {}
from nkms.policy.models import WorkOrderHistory # Need a bigger strategy to avoid circulars.
from nucypher.policy.models import WorkOrderHistory # Need a bigger strategy to avoid circulars.
self._saved_work_orders = WorkOrderHistory()
def follow_treasure_map(self, hrac, using_dht=False):
@ -481,7 +481,7 @@ class Bob(Character):
if not verified:
return constants.NOT_FROM_ALICE
else:
from nkms.policy.models import TreasureMap
from nucypher.policy.models import TreasureMap
node_list = msgpack.loads(packed_node_list)
m = node_list.pop()
treasure_map = TreasureMap(m=m, ursula_interface_ids=node_list)
@ -494,7 +494,7 @@ class Bob(Character):
Return the first one who has it.
TODO: What if a node gives a bunk TreasureMap?
"""
from nkms.network.protocols import dht_value_splitter
from nucypher.network.protocols import dht_value_splitter
for node in self.known_nodes.values():
response = networky_stuff.get_treasure_map_from_node(node, map_id)
@ -508,7 +508,7 @@ class Bob(Character):
assert False
def generate_work_orders(self, kfrag_hrac, *capsules, num_ursulas=None):
from nkms.policy.models import WorkOrder # Prevent circular import
from nucypher.policy.models import WorkOrder # Prevent circular import
try:
treasure_map_to_use = self.treasure_maps[kfrag_hrac]

View File

@ -0,0 +1,3 @@
from nucypher.config.utils import check_config_runtime
check_config_runtime()

View File

@ -7,7 +7,7 @@ import maya
_DEFAULT_CONFIGURATION_DIR = os.path.join(str(Path.home()), '.nucypher')
class KMSConfigurationError(RuntimeError):
class NucypherConfigurationError(RuntimeError):
pass
@ -32,7 +32,7 @@ class StakeConfig:
for rule, failure_message in rules:
if rule is False:
raise KMSConfigurationError(failure_message)
raise NucypherConfigurationError(failure_message)
else:
return True
@ -49,7 +49,7 @@ class PolicyConfig:
class NetworkConfig:
__default_db_name = 'kms_datastore.db' # TODO
__default_db_name = 'nucypher_datastore.db' # TODO
__default_db_path = os.path.join(_DEFAULT_CONFIGURATION_DIR , __default_db_name)
__default_port = 5867
@ -64,7 +64,7 @@ class NetworkConfig:
return self.__db_path
class KMSConfig:
class NucypherConfig:
__default_configuration_root = _DEFAULT_CONFIGURATION_DIR
__default_json_config_filepath = os.path.join(__default_configuration_root, 'conf.json')
@ -88,7 +88,7 @@ class KMSConfig:
@classmethod
def from_json_config(cls, path: str=None):
"""TODO: Reads the config file and creates a KMSConfig instance"""
"""TODO: Reads the config file and creates a NucypherConfig instance"""
with open(cls.__default_json_config_filepath, 'r') as config_file:
data = json.loads(config_file.read())

View File

@ -2,10 +2,10 @@
Public facing client interface
"""
from nkms.config.keys import KMSKeyring
from nucypher.config.keys import NucypherKeyring
def _bootstrap_config():
"""Do not actually use this."""
passphrase = input("Enter passphrase >> ")
return KMSKeyring.generate(passphrase=passphrase)
return NucypherKeyring.generate(passphrase=passphrase)

View File

@ -14,10 +14,10 @@ from nacl.secret import SecretBox
from umbral.keys import UmbralPrivateKey
from web3.auto import w3
from nkms.config import utils
from nkms.config.configs import _DEFAULT_CONFIGURATION_DIR
from nkms.config.utils import _parse_keyfile, _save_private_keyfile, validate_passphrase, _save_public_keyfile
from nkms.crypto.powers import SigningPower, EncryptingPower, CryptoPower
from nucypher.config import utils
from nucypher.config.configs import _DEFAULT_CONFIGURATION_DIR
from nucypher.config.utils import _parse_keyfile, _save_private_keyfile, validate_passphrase, _save_public_keyfile
from nucypher.crypto.powers import SigningPower, EncryptingPower, CryptoPower
w3.eth.enable_unaudited_features()
@ -51,7 +51,7 @@ def _derive_wrapping_key_from_key_material(salt: bytes, key_material: bytes) ->
algorithm=hashes.BLAKE2b(64),
length=64,
salt=salt,
info=b'NuCypher-KMS-KeyWrap',
info=b'NuCypher-KeyWrap',
backend=default_backend()
).derive(key_material)
@ -113,7 +113,7 @@ def _generate_transacting_keys(passphrase: str) -> dict:
return encrypted_wallet_data
class KMSKeyring:
class NucypherKeyring:
"""
Warning: This class handles private keys!
@ -154,7 +154,7 @@ class KMSKeyring:
pub_signing_key_path: str=None,
transacting_key_path: str=None):
"""
Generates a KMSKeyring instance with the provided key paths,
Generates a NucypherKeyring instance with the provided key paths,
falling back to default keyring paths.
"""
@ -233,7 +233,7 @@ class KMSKeyring:
return new_cryptopower
@classmethod
def generate(cls, passphrase: str, encryption: bool=True, transacting: bool=True, output_path: str=None) -> 'KMSKeyring':
def generate(cls, passphrase: str, encryption: bool=True, transacting: bool=True, output_path: str=None) -> 'NucypherKeyring':
"""
Generates new encryption, signing, and transacting keys encrypted with the passphrase,
respectively saving keyfiles on the local filesystem from *default* paths,

View File

@ -2,7 +2,7 @@ import json
import os
import stat
from .configs import _DEFAULT_CONFIGURATION_DIR, KMSConfigurationError
from .configs import _DEFAULT_CONFIGURATION_DIR, NucypherConfigurationError
def _save_private_keyfile(keypath: str, key_data: dict) -> str:
@ -87,7 +87,7 @@ def _parse_keyfile(keypath: str):
try:
key_metadata = json.loads(keyfile)
except json.JSONDecodeError:
raise KMSConfigurationError("Invalid data in keyfile {}".format(keypath))
raise NucypherConfigurationError("Invalid data in keyfile {}".format(keypath))
else:
return key_metadata
@ -112,14 +112,14 @@ def validate_passphrase(passphrase) -> bool:
for rule, failure_message in rules:
if not rule:
raise KMSConfigurationError(failure_message)
raise NucypherConfigurationError(failure_message)
return True
def check_config_tree(configuration_dir: str=None) -> bool:
path = configuration_dir if configuration_dir else _DEFAULT_CONFIGURATION_DIR
if not os.path.exists(path):
raise FileNotFoundError('No KMS configuration directory found at {}.'.format(configuration_dir))
raise FileNotFoundError('No NuCypher configuration directory found at {}.'.format(configuration_dir))
return True

View File

@ -6,8 +6,8 @@ from constant_sorrow import constants
from cryptography.exceptions import InvalidSignature
from cryptography.hazmat.primitives.asymmetric import ec
from nkms.crypto.constants import BLAKE2B
from nkms.crypto.kits import UmbralMessageKit
from nucypher.crypto.constants import BLAKE2B
from nucypher.crypto.kits import UmbralMessageKit
from umbral.keys import UmbralPrivateKey, UmbralPublicKey
from umbral import pre
from cryptography import x509

View File

@ -1,4 +1,4 @@
from nkms.crypto.splitters import key_splitter, capsule_splitter
from nucypher.crypto.splitters import key_splitter, capsule_splitter
from constant_sorrow import constants

View File

@ -1,8 +1,8 @@
import inspect
from typing import List, Union
from nkms.keystore import keypairs
from nkms.keystore.keypairs import SigningKeypair, EncryptingKeypair
from nucypher.keystore import keypairs
from nucypher.keystore.keypairs import SigningKeypair, EncryptingKeypair
from umbral.keys import UmbralPublicKey, UmbralPrivateKey, UmbralKeyingMaterial
from umbral import pre

View File

@ -1,7 +1,7 @@
from nkms.crypto import api as API
from nucypher.crypto import api as API
from umbral.keys import UmbralPublicKey
from cryptography.hazmat.primitives.asymmetric.utils import decode_dss_signature, encode_dss_signature
from nkms.crypto.api import keccak_digest
from nucypher.crypto.api import keccak_digest
from bytestring_splitter import BytestringSplitter

View File

@ -1,4 +1,4 @@
from nkms.crypto.constants import PUBLIC_KEY_LENGTH, CAPSULE_LENGTH
from nucypher.crypto.constants import PUBLIC_KEY_LENGTH, CAPSULE_LENGTH
from bytestring_splitter import BytestringSplitter
from umbral.keys import UmbralPublicKey
from umbral.pre import Capsule

View File

@ -1,5 +1,5 @@
from typing import Any
from nkms.crypto.api import keccak_digest
from nucypher.crypto.api import keccak_digest
def fingerprint_from_key(public_key: Any):

View File

@ -1,6 +1,6 @@
from nkms.crypto.api import encrypt_and_sign
from nkms.crypto.signature import SignatureStamp
from nkms.keystore.keypairs import SigningKeypair
from nucypher.crypto.api import encrypt_and_sign
from nucypher.crypto.signature import SignatureStamp
from nucypher.keystore.keypairs import SigningKeypair
from constant_sorrow.constants import NO_SIGNING_POWER
from umbral.keys import UmbralPublicKey

View File

@ -2,8 +2,8 @@ import sha3
from datetime import datetime
from nkms.crypto.utils import fingerprint_from_key
from nkms.keystore.db import Base
from nucypher.crypto.utils import fingerprint_from_key
from nucypher.keystore.db import Base
from sqlalchemy.orm import relationship
from sqlalchemy import (

View File

@ -1,13 +1,13 @@
import sha3
from typing import Union
from nkms.crypto import api as API
from nkms.crypto.api import generate_self_signed_certificate
from nucypher.crypto import api as API
from nucypher.crypto.api import generate_self_signed_certificate
from umbral.keys import UmbralPrivateKey, UmbralPublicKey
from umbral import pre
from umbral.config import default_curve
from nkms.crypto.kits import MessageKit
from nkms.crypto.signature import Signature
from nucypher.crypto.kits import MessageKit
from nucypher.crypto.signature import Signature
class Keypair(object):
@ -68,8 +68,6 @@ class EncryptingKeypair(Keypair):
"""
Decrypt data encrypted with Umbral.
:param message_kit: A KMS MessageKit.
:return: bytes
"""
cleartext = pre.decrypt(ciphertext=message_kit.ciphertext,

View File

@ -1,13 +1,13 @@
from typing import Union
from nkms.crypto.constants import KFRAG_LENGTH
from nkms.crypto.signature import Signature
from nucypher.crypto.constants import KFRAG_LENGTH
from nucypher.crypto.signature import Signature
from bytestring_splitter import BytestringSplitter
from nkms.keystore.db.models import Key, PolicyArrangement, Workorder
from nucypher.keystore.db.models import Key, PolicyArrangement, Workorder
from umbral.fragments import KFrag
from umbral.keys import UmbralPublicKey
from . import keypairs
from nkms.crypto.utils import fingerprint_from_key
from nucypher.crypto.utils import fingerprint_from_key
from sqlalchemy.orm import sessionmaker

View File

@ -2,7 +2,7 @@ import requests
from kademlia.node import Node
from bytestring_splitter import BytestringSplitter, VariableLengthBytestring
from nkms.network.capabilities import ServerCapability
from nucypher.network.capabilities import ServerCapability
from umbral.fragments import CapsuleFrag

View File

@ -3,12 +3,12 @@ from kademlia.protocol import KademliaProtocol
from kademlia.utils import digest
from constant_sorrow import default_constant_splitter, constants
from nkms.crypto.api import keccak_digest
from nkms.crypto.constants import PUBLIC_KEY_LENGTH, KECCAK_DIGEST_LENGTH
from nkms.crypto.signature import Signature
from nucypher.crypto.api import keccak_digest
from nucypher.crypto.constants import PUBLIC_KEY_LENGTH, KECCAK_DIGEST_LENGTH
from nucypher.crypto.signature import Signature
from bytestring_splitter import BytestringSplitter
from nkms.network.node import NuCypherNode
from nkms.network.routing import NuCypherRoutingTable
from nucypher.network.node import NuCypherNode
from nucypher.network.routing import NuCypherRoutingTable
from umbral.keys import UmbralPublicKey
dht_value_splitter = default_constant_splitter + BytestringSplitter(Signature, (UmbralPublicKey, PUBLIC_KEY_LENGTH))

View File

@ -13,14 +13,14 @@ from bytestring_splitter import VariableLengthBytestring
from umbral import pre
from umbral.fragments import KFrag
from nkms.crypto.kits import UmbralMessageKit
from nkms.crypto.powers import EncryptingPower, SigningPower
from nkms.keystore.threading import ThreadedSession
from nkms.network.capabilities import SeedOnly, ServerCapability
from nkms.network.node import NuCypherNode
from nkms.network.protocols import NuCypherSeedOnlyProtocol, NuCypherHashProtocol, \
from nucypher.crypto.kits import UmbralMessageKit
from nucypher.crypto.powers import EncryptingPower, SigningPower
from nucypher.keystore.threading import ThreadedSession
from nucypher.network.capabilities import SeedOnly, ServerCapability
from nucypher.network.node import NuCypherNode
from nucypher.network.protocols import NuCypherSeedOnlyProtocol, NuCypherHashProtocol, \
dht_value_splitter, dht_with_hrac_splitter
from nkms.network.storage import SeedOnlyStorage
from nucypher.network.storage import SeedOnlyStorage
class NuCypherDHTServer(Server):
@ -137,8 +137,8 @@ class ProxyRESTServer(object):
if not db_name:
raise TypeError("In order to start a datastore, you need to supply a db_name.")
from nkms.keystore import keystore
from nkms.keystore.db import Base
from nucypher.keystore import keystore
from nucypher.keystore.db import Base
from sqlalchemy.engine import create_engine
engine = create_engine('sqlite:///{}'.format(db_name))
@ -174,7 +174,7 @@ class ProxyRESTServer(object):
return Response(bytes(signature) + ursulas_as_bytes, headers=headers)
def consider_arrangement(self, request: http.Request):
from nkms.policy.models import Arrangement
from nucypher.policy.models import Arrangement
arrangement = Arrangement.from_bytes(request.body)
with ThreadedSession(self.db_engine) as session:
@ -231,7 +231,7 @@ class ProxyRESTServer(object):
return # TODO: Return A 200, with whatever policy metadata.
def reencrypt_via_rest(self, hrac_as_hex, request: http.Request):
from nkms.policy.models import WorkOrder # Avoid circular import
from nucypher.policy.models import WorkOrder # Avoid circular import
hrac = binascii.unhexlify(hrac_as_hex)
work_order = WorkOrder.from_rest_payload(hrac, request.body)
with ThreadedSession(self.db_engine) as session:

View File

@ -7,15 +7,15 @@ from datetime import datetime
import maya
import msgpack
from nkms.characters import Alice
from nkms.characters import Bob, Ursula
from nkms.crypto.api import keccak_digest
from nkms.crypto.constants import KECCAK_DIGEST_LENGTH
from nkms.crypto.powers import SigningPower, DelegatingPower
from nkms.crypto.signature import Signature
from nkms.crypto.splitters import key_splitter
from nucypher.characters import Alice
from nucypher.characters import Bob, Ursula
from nucypher.crypto.api import keccak_digest
from nucypher.crypto.constants import KECCAK_DIGEST_LENGTH
from nucypher.crypto.powers import SigningPower, DelegatingPower
from nucypher.crypto.signature import Signature
from nucypher.crypto.splitters import key_splitter
from bytestring_splitter import BytestringSplitter
from nkms.blockchain.eth.policies import BlockchainArrangement
from nucypher.blockchain.eth.policies import BlockchainArrangement
from umbral.pre import Capsule
from constant_sorrow import constants

View File

@ -22,18 +22,18 @@ TESTS_REQUIRE = [
# should add --process-dependency-links to pip
LINKS = [
'https://github.com/nucypher/kademlia/archive/kms-dependency.tar.gz#egg=kademlia-1.0',
'https://github.com/nucypher/kademlia/archive/nucypher-depend.tar.gz#egg=kademlia-1.0',
'https://github.com/bmuller/rpcudp/archive/python3.5.tar.gz#egg=rpcudp-3.0.0',
]
setup(name='nkms',
setup(name='nucypher',
version=VERSION,
description='NuCypher decentralized KMS',
description='A proxy re-encryption network to empower privacy in decentralized systems.',
install_requires=INSTALL_REQUIRES,
dependency_links=LINKS,
extras_require={'testing': TESTS_REQUIRE},
packages=find_packages(),
package_data={'nkms': [
package_data={'nucypher': [
'blockchain/eth/*', 'project/contracts/*',
'blockchain/eth/sol_source/contracts/lib/*',
'blockchain/eth/sol_source/contracts/zepellin/math/*',

View File

@ -2,7 +2,7 @@ pragma solidity ^0.4.23;
import "contracts/Issuer.sol";
import "contracts/NuCypherKMSToken.sol";
import "contracts/NuCypherToken.sol";
/**
@ -11,7 +11,7 @@ import "contracts/NuCypherKMSToken.sol";
contract IssuerMock is Issuer {
constructor(
NuCypherKMSToken _token,
NuCypherToken _token,
uint256 _hoursPerPeriod,
uint256 _miningCoefficient,
uint256 _lockedPeriodsCoefficient,

View File

@ -2,7 +2,7 @@ pragma solidity ^0.4.23;
import "contracts/Issuer.sol";
import "contracts/NuCypherKMSToken.sol";
import "contracts/NuCypherToken.sol";
/**
@ -13,7 +13,7 @@ contract IssuerV2Mock is Issuer {
uint256 public valueToCheck;
constructor(
NuCypherKMSToken _token,
NuCypherToken _token,
uint256 _hoursPerPeriod,
uint256 _miningCoefficient,
uint256 _lockedPeriodsCoefficient,

View File

@ -2,7 +2,7 @@ pragma solidity ^0.4.23;
import "contracts/MinersEscrow.sol";
import "contracts/NuCypherKMSToken.sol";
import "contracts/NuCypherToken.sol";
/**
@ -11,7 +11,7 @@ import "contracts/NuCypherKMSToken.sol";
contract MinersEscrowBad is MinersEscrow {
constructor(
NuCypherKMSToken _token,
NuCypherToken _token,
uint256 _hoursPerPeriod,
uint256 _miningCoefficient,
uint256 _lockedPeriodsCoefficient,

View File

@ -1,7 +1,7 @@
pragma solidity ^0.4.23;
import "contracts/NuCypherKMSToken.sol";
import "contracts/NuCypherToken.sol";
/**
@ -9,14 +9,14 @@ import "contracts/NuCypherKMSToken.sol";
**/
contract MinersEscrowForUserEscrowMock {
NuCypherKMSToken token;
NuCypherToken token;
address public node;
uint256 public value;
uint256 public lockedValue;
uint256 public periods;
uint256 public confirmedPeriod;
constructor(NuCypherKMSToken _token) public {
constructor(NuCypherToken _token) public {
token = _token;
}

View File

@ -2,7 +2,7 @@ pragma solidity ^0.4.23;
import "contracts/MinersEscrow.sol";
import "contracts/NuCypherKMSToken.sol";
import "contracts/NuCypherToken.sol";
/**
@ -13,7 +13,7 @@ contract MinersEscrowV2Mock is MinersEscrow {
uint256 public valueToCheck;
constructor(
NuCypherKMSToken _token,
NuCypherToken _token,
uint256 _hoursPerPeriod,
uint256 _miningCoefficient,
uint256 _lockedPeriodsCoefficient,

View File

@ -26,7 +26,7 @@ LAST_MINED_PERIOD_FIELD = 2
@pytest.fixture()
def token(chain):
# Create an ERC20 token
contract, _ = chain.provider.deploy_contract('NuCypherKMSToken', 2 * 10 ** 9)
contract, _ = chain.provider.deploy_contract('NuCypherToken', 2 * 10 ** 9)
return contract

View File

@ -7,7 +7,7 @@ from eth_tester.exceptions import TransactionFailed
def token(web3, chain):
creator = web3.eth.accounts[0]
# Create an ERC20 token
token, _ = chain.provider.deploy_contract('NuCypherKMSToken', 2 * 10 ** 40)
token, _ = chain.provider.deploy_contract('NuCypherToken', 2 * 10 ** 40)
return token
@pytest.mark.slow

View File

@ -14,7 +14,7 @@ LAST_ACTIVE_PERIOD_FIELD = 4
@pytest.fixture()
def token(chain):
# Create an ERC20 token
token, _ = chain.provider.deploy_contract('NuCypherKMSToken', 2 * 10 ** 9)
token, _ = chain.provider.deploy_contract('NuCypherToken', 2 * 10 ** 9)
return token

View File

@ -14,7 +14,7 @@ def test_create_token(web3, chain):
account2 = web3.eth.accounts[2]
# Create an ERC20 token
token, txhash = chain.provider.deploy_contract('NuCypherKMSToken', 10 ** 9)
token, txhash = chain.provider.deploy_contract('NuCypherToken', 10 ** 9)
assert txhash is not None
# Account balances
@ -22,9 +22,9 @@ def test_create_token(web3, chain):
assert token.functions.balanceOf(account1).call() == 0
# Basic properties
assert token.functions.name().call() == 'NuCypher KMS'
assert token.functions.name().call() == 'NuCypher'
assert token.functions.decimals().call() == 18
assert token.functions.symbol().call() == 'KMS'
assert token.functions.symbol().call() == 'NU'
# Cannot send ethers to the contract
with pytest.raises((TransactionFailed, ValueError)):

View File

@ -6,7 +6,7 @@ from eth_tester.exceptions import TransactionFailed
def token(web3, chain):
creator = web3.eth.accounts[0]
# Create an ERC20 token
token, _ = chain.provider.deploy_contract('NuCypherKMSToken', int(2e9))
token, _ = chain.provider.deploy_contract('NuCypherToken', int(2e9))
return token

View File

@ -1,8 +1,8 @@
import os
import pytest
from nkms.blockchain.eth.actors import Miner
from nkms.blockchain.eth.agents import MinerAgent
from nucypher.blockchain.eth.actors import Miner
from nucypher.blockchain.eth.agents import MinerAgent
@pytest.mark.skip("Last 5 stubborn blockchain tests.")

View File

@ -1,19 +1,19 @@
import pytest
from nkms.blockchain.eth.agents import NuCypherKMSTokenAgent, MinerAgent
from nkms.blockchain.eth.deployers import NuCypherKMSTokenDeployer, MinerEscrowDeployer, PolicyManagerDeployer
from nucypher.blockchain.eth.agents import NucypherTokenAgent, MinerAgent
from nucypher.blockchain.eth.deployers import NucypherTokenDeployer, MinerEscrowDeployer, PolicyManagerDeployer
def test_token_deployer_and_agent(chain):
# Trying to get token from blockchain before it's been published fails
# with raises(NoKnownAddress):
# NuCypherKMSTokenAgent(blockchain=chain)
# NucypherTokenAgent(blockchain=chain)
# The big day...
deployer = NuCypherKMSTokenDeployer(blockchain=chain)
deployer = NucypherTokenDeployer(blockchain=chain)
with pytest.raises(NuCypherKMSTokenDeployer.ContractDeploymentError):
with pytest.raises(NucypherTokenDeployer.ContractDeploymentError):
deployer.deploy()
# Token must be armed before deploying to the blockchain
@ -21,11 +21,11 @@ def test_token_deployer_and_agent(chain):
deployer.deploy()
# Create a token instance
token_agent = NuCypherKMSTokenAgent(blockchain=chain)
token_agent = NucypherTokenAgent(blockchain=chain)
# Make sure we got the name right
deployer_contract_identifier = NuCypherKMSTokenDeployer._contract_name
assert'NuCypherKMSToken' == deployer_contract_identifier
deployer_contract_identifier = NucypherTokenDeployer._contract_name
assert'NuCypherToken' == deployer_contract_identifier
# Ensure the contract is deployed and has a valid blockchain address
assert len(token_agent.contract_address) == 42
@ -35,7 +35,7 @@ def test_token_deployer_and_agent(chain):
# assert token().totalSupply() == int(1e9) * _M # TODO
# Retrieve the token from the blockchain
same_token_agent = NuCypherKMSTokenAgent(blockchain=chain)
same_token_agent = NucypherTokenAgent(blockchain=chain)
# Compare the contract address for equality
assert token_agent.contract_address == same_token_agent.contract_address
@ -46,18 +46,18 @@ def test_token_deployer_and_agent(chain):
def test_deploy_ethereum_contracts(chain):
"""
Launch all ethereum contracts:
- NuCypherKMSToken
- NuCypherToken
- PolicyManager
- MinersEscrow
- UserEscrow
- Issuer
"""
token_deployer = NuCypherKMSTokenDeployer(blockchain=chain)
token_deployer = NucypherTokenDeployer(blockchain=chain)
token_deployer.arm()
token_deployer.deploy()
token_agent = NuCypherKMSTokenAgent(blockchain=chain)
token_agent = NucypherTokenAgent(blockchain=chain)
miner_escrow_deployer = MinerEscrowDeployer(token_agent=token_agent)
miner_escrow_deployer.arm()

View File

@ -1,6 +1,6 @@
import pytest
from nkms.blockchain.eth.interfaces import Registrar
from nucypher.blockchain.eth.interfaces import Registrar
#def test_registrar_read_write(tempfile_path):

View File

@ -1,4 +1,4 @@
from nkms.blockchain.eth.deployers import NuCypherKMSTokenDeployer
from nucypher.blockchain.eth.deployers import NucypherTokenDeployer
def test_chain_creation(chain):
@ -13,5 +13,5 @@ def test_nucypher_contract_compiled(chain):
# Check that populus paths are set...
# Ensure that solidity smart contacts are available, post-compile.
token_contract_identifier = NuCypherKMSTokenDeployer(blockchain=chain)._contract_name
token_contract_identifier = NucypherTokenDeployer(blockchain=chain)._contract_name
assert token_contract_identifier in chain.provider._ContractProvider__raw_contract_cache

View File

@ -6,9 +6,9 @@ from eth_tester.backends import is_pyevm_available
from eth_tester.backends.pyevm.main import get_default_genesis_params, get_default_account_keys, generate_genesis_state
from web3 import Web3
from nkms.blockchain.eth.agents import MinerAgent
from nkms.blockchain.eth.constants import NuCypherMinerConfig
from nkms.blockchain.eth.deployers import MinerEscrowDeployer
from nucypher.blockchain.eth.agents import MinerAgent
from nucypher.blockchain.eth.constants import NuCypherMinerConfig
from nucypher.blockchain.eth.deployers import MinerEscrowDeployer
class MockNuCypherMinerConfig(NuCypherMinerConfig):

Some files were not shown because too many files have changed in this diff Show More