Use umbral adapter everywhere. Fixes straggler uses of umbral 0.1.x

pull/2687/head
Kieran Prasch 2021-06-25 14:11:49 -07:00 committed by Kieran R. Prasch
parent 81ca745bfa
commit c915a1b1d3
10 changed files with 41 additions and 30 deletions

View File

@ -57,7 +57,6 @@ from twisted.internet import reactor, stdio, threads
from twisted.internet.defer import Deferred
from twisted.internet.task import LoopingCall
from twisted.logger import Logger
from umbral.key_frag import KeyFrag, VerifiedKeyFrag
from web3.types import TxReceipt
import nucypher
@ -89,8 +88,13 @@ from nucypher.crypto.powers import (
)
from nucypher.crypto.signing import InvalidSignature
from nucypher.crypto.splitters import key_splitter, signature_splitter
from nucypher.crypto.umbral_adapter import Capsule, PublicKey, VerificationError, reencrypt
from nucypher.crypto.umbral_adapter import (
Capsule,
PublicKey,
VerificationError,
reencrypt,
KeyFrag,
VerifiedKeyFrag,
Signature
)
from nucypher.crypto.utils import keccak_digest, encrypt_and_sign

View File

@ -40,6 +40,7 @@ from nucypher.crypto.umbral_adapter import (
decrypt_original,
decrypt_reencrypted
)
from nucypher.network.resources import get_static_resources
class Keypair(object):

View File

@ -17,10 +17,9 @@ along with nucypher. If not, see <https://www.gnu.org/licenses/>.
from bytestring_splitter import BytestringSplitter
from umbral.key_frag import KeyFrag
from nucypher.crypto.constants import HRAC_LENGTH
from nucypher.crypto.umbral_adapter import CapsuleFrag, PublicKey, Capsule, Signature
from nucypher.crypto.umbral_adapter import CapsuleFrag, PublicKey, Capsule, Signature, KeyFrag
key_splitter = BytestringSplitter((PublicKey, PublicKey.serialized_size()))
signature_splitter = BytestringSplitter((Signature, Signature.serialized_size()))

View File

@ -28,9 +28,6 @@ from bytestring_splitter import (
)
from constant_sorrow.constants import NO_DECRYPTION_PERFORMED, NOT_SIGNED
from eth_utils.address import to_checksum_address, to_canonical_address
from umbral.key_frag import KeyFrag
from umbral.keys import PublicKey
from umbral.signing import Signature
from nucypher.blockchain.eth.constants import ETH_ADDRESS_BYTE_LENGTH
from nucypher.characters.base import Character
@ -40,6 +37,7 @@ from nucypher.crypto.kits import UmbralMessageKit
from nucypher.crypto.powers import DecryptingPower, SigningPower
from nucypher.crypto.signing import SignatureStamp
from nucypher.crypto.splitters import signature_splitter
from nucypher.crypto.umbral_adapter import KeyFrag, PublicKey, Signature
from nucypher.network.middleware import RestMiddleware

View File

@ -23,17 +23,29 @@ import maya
from bytestring_splitter import BytestringSplitter, VariableLengthBytestring
from constant_sorrow.constants import CFRAG_NOT_RETAINED
from eth_typing.evm import ChecksumAddress
from eth_utils.address import to_checksum_address, to_canonical_address
from umbral.capsule_frag import CapsuleFrag
from umbral.keys import PublicKey
from umbral.pre import Capsule
from umbral.signing import Signature
from eth_utils.address import to_canonical_address, to_checksum_address
from nucypher.crypto.constants import WRIT_CHECKSUM_SIZE, SIGNED_WRIT_SIZE, ENCRYPTED_KFRAG_PAYLOAD_LENGTH
from nucypher.crypto.constants import (
WRIT_CHECKSUM_SIZE,
SIGNED_WRIT_SIZE,
ENCRYPTED_KFRAG_PAYLOAD_LENGTH
)
from nucypher.crypto.kits import PolicyMessageKit
from nucypher.crypto.signing import SignatureStamp, InvalidSignature
from nucypher.crypto.splitters import key_splitter, capsule_splitter, cfrag_splitter, signature_splitter, hrac_splitter, \
from nucypher.crypto.splitters import (
key_splitter,
capsule_splitter,
cfrag_splitter,
signature_splitter,
hrac_splitter,
kfrag_splitter
)
from nucypher.crypto.umbral_adapter import (
Capsule,
CapsuleFrag,
PublicKey,
Signature
)
class WorkOrder:

View File

@ -25,7 +25,6 @@ from bytestring_splitter import BytestringSplitter, VariableLengthBytestring
from eth_typing.evm import ChecksumAddress
from nucypher.crypto.api import keccak_digest
from twisted.internet import reactor
from umbral.signing import Signature
from nucypher.blockchain.eth.agents import StakersReservoir, StakingEscrowAgent
from nucypher.blockchain.eth.constants import POLICY_ID_LENGTH
@ -33,8 +32,9 @@ from nucypher.characters.lawful import Alice, Ursula
from nucypher.crypto.constants import HRAC_LENGTH
from nucypher.crypto.kits import RevocationKit
from nucypher.crypto.powers import TransactingPower
from nucypher.crypto.umbral_adapter import PublicKey, KeyFrag
from nucypher.crypto.utils import keccak_digest, construct_policy_id
from nucypher.crypto.utils import keccak_digest
from nucypher.crypto.umbral_adapter import PublicKey, KeyFrag, Signature
from nucypher.crypto.utils import construct_policy_id
from nucypher.network.middleware import RestMiddleware
from nucypher.utilities.concurrency import WorkerPool, AllAtOnceFactory
from nucypher.utilities.logging import Logger

View File

@ -26,13 +26,12 @@ from nucypher.blockchain.eth.token import NU
from nucypher.config.constants import TEMPORARY_DOMAIN
from nucypher.crypto.powers import TransactingPower
from nucypher.crypto.signing import SignatureStamp
from umbral.keys import UmbralPrivateKey
from umbral.signing import Signer
from nucypher.crypto.umbral_adapter import SecretKeyFactory, Signer
def mock_ursula(testerchain, account, mocker):
ursula_privkey = UmbralPrivateKey.gen_key()
ursula_stamp = SignatureStamp(verifying_key=ursula_privkey.pubkey,
ursula_privkey = SecretKeyFactory.random()
ursula_stamp = SignatureStamp(verifying_key=ursula_privkey.public_key(),
signer=Signer(ursula_privkey))
signed_stamp = testerchain.client.sign_message(account=account,

View File

@ -31,13 +31,12 @@ from nucypher.blockchain.eth.token import NU
from nucypher.config.constants import TEMPORARY_DOMAIN
from nucypher.crypto.powers import TransactingPower
from nucypher.crypto.signing import SignatureStamp
from umbral.keys import UmbralPrivateKey
from umbral.signing import Signer
from nucypher.crypto.umbral_adapter import SecretKeyFactory, Signer
def mock_ursula(testerchain, account, mocker):
ursula_privkey = UmbralPrivateKey.gen_key()
ursula_stamp = SignatureStamp(verifying_key=ursula_privkey.pubkey,
ursula_privkey = SecretKeyFactory.random()
ursula_stamp = SignatureStamp(verifying_key=ursula_privkey.public_key(),
signer=Signer(ursula_privkey))
signed_stamp = testerchain.client.sign_message(account=account,

View File

@ -18,14 +18,13 @@ along with nucypher. If not, see <https://www.gnu.org/licenses/>.
import pytest
import pytest_twisted
from twisted.internet import threads
from umbral import pre
from umbral.capsule_frag import CapsuleFrag
from nucypher.characters.lawful import Alice
from nucypher.config.constants import TEMPORARY_DOMAIN
from nucypher.crypto.keypairs import DecryptingKeypair
from nucypher.crypto.kits import PolicyMessageKit
from nucypher.crypto.powers import DecryptingPower
from nucypher.crypto.umbral_adapter import reencrypt
from nucypher.datastore.models import Workorder
from tests.utils.middleware import MockRestMiddleware, NodeIsDownMiddleware
@ -214,7 +213,7 @@ def test_bob_can_issue_a_work_order_to_a_specific_ursula(enacted_federated_polic
_signed_writ, the_kfrag = work_order.kfrag_payload_splitter(plaintext_kfrag_payload)
verified_kfrag = the_kfrag.verify(enacted_federated_policy.alice_verifying_key.as_umbral_pubkey())
the_correct_cfrag = pre.reencrypt(capsule=message_kit.capsule, kfrag=verified_kfrag)
reencrypt(capsule=message_kit.capsule, kfrag=verified_kfrag)
# Now we'll show that Ursula saved the correct WorkOrder.
with ursula.datastore.query_by(Workorder, filter_field='bob_verifying_key',

View File

@ -18,11 +18,11 @@
import os
from umbral.key_frag import KeyFrag
import pytest
from nucypher.crypto.powers import DecryptingPower, SigningPower
from nucypher.crypto.umbral_adapter import KeyFrag
from nucypher.policy.maps import TreasureMap
import pytest
def test_complete_treasure_map_journey(federated_alice, federated_bob, federated_ursulas, mocker):