mirror of https://github.com/nucypher/nucypher.git
Passing params into Capsule.
parent
d0376748e0
commit
56347ee9b2
|
@ -1,9 +1,10 @@
|
||||||
from nucypher.crypto.constants import PUBLIC_KEY_LENGTH, CAPSULE_LENGTH
|
from nucypher.crypto.constants import PUBLIC_KEY_LENGTH, CAPSULE_LENGTH
|
||||||
from bytestring_splitter import BytestringSplitter
|
from bytestring_splitter import BytestringSplitter
|
||||||
|
from umbral.config import default_params
|
||||||
from umbral.keys import UmbralPublicKey
|
from umbral.keys import UmbralPublicKey
|
||||||
from umbral.pre import Capsule
|
from umbral.pre import Capsule
|
||||||
|
|
||||||
|
|
||||||
key_splitter = BytestringSplitter((UmbralPublicKey, PUBLIC_KEY_LENGTH))
|
key_splitter = BytestringSplitter((UmbralPublicKey, PUBLIC_KEY_LENGTH))
|
||||||
capsule_splitter = BytestringSplitter((Capsule, CAPSULE_LENGTH))
|
capsule_splitter = BytestringSplitter((Capsule, CAPSULE_LENGTH, {"params": default_params()}))
|
||||||
|
|
||||||
|
|
|
@ -77,8 +77,6 @@ class EncryptingKeypair(Keypair):
|
||||||
cleartext = pre.decrypt(ciphertext=message_kit.ciphertext,
|
cleartext = pre.decrypt(ciphertext=message_kit.ciphertext,
|
||||||
capsule=message_kit.capsule,
|
capsule=message_kit.capsule,
|
||||||
decrypting_key=self._privkey,
|
decrypting_key=self._privkey,
|
||||||
delegating_pubkey=message_kit.policy_pubkey,
|
|
||||||
verifying_key=verifying_key,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return cleartext
|
return cleartext
|
||||||
|
|
|
@ -2,22 +2,22 @@ import asyncio
|
||||||
import binascii
|
import binascii
|
||||||
import uuid
|
import uuid
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
import maya
|
import maya
|
||||||
import msgpack
|
import msgpack
|
||||||
|
from bytestring_splitter import BytestringSplitter
|
||||||
|
from constant_sorrow import constants
|
||||||
|
from umbral.config import default_params
|
||||||
|
from umbral.pre import Capsule
|
||||||
|
|
||||||
|
from nucypher.blockchain.eth.policies import BlockchainArrangement
|
||||||
from nucypher.characters import Alice
|
from nucypher.characters import Alice
|
||||||
from nucypher.characters import Bob, Ursula
|
from nucypher.characters import Bob, Ursula
|
||||||
from nucypher.crypto.api import keccak_digest
|
from nucypher.crypto.api import keccak_digest
|
||||||
from nucypher.crypto.constants import KECCAK_DIGEST_LENGTH
|
from nucypher.crypto.constants import KECCAK_DIGEST_LENGTH
|
||||||
from nucypher.crypto.powers import SigningPower, DelegatingPower
|
from nucypher.crypto.powers import SigningPower
|
||||||
from nucypher.crypto.signing import Signature
|
from nucypher.crypto.signing import Signature
|
||||||
from nucypher.crypto.splitters import key_splitter
|
from nucypher.crypto.splitters import key_splitter
|
||||||
from bytestring_splitter import BytestringSplitter
|
|
||||||
from nucypher.blockchain.eth.policies import BlockchainArrangement
|
|
||||||
from umbral.pre import Capsule
|
|
||||||
from constant_sorrow import constants
|
|
||||||
|
|
||||||
|
|
||||||
class Arrangement(BlockchainArrangement):
|
class Arrangement(BlockchainArrangement):
|
||||||
|
@ -327,7 +327,7 @@ class WorkOrder(object):
|
||||||
payload_splitter = BytestringSplitter(Signature) + key_splitter
|
payload_splitter = BytestringSplitter(Signature) + key_splitter
|
||||||
signature, bob_pubkey_sig, (receipt_bytes, packed_capsules) = payload_splitter(rest_payload,
|
signature, bob_pubkey_sig, (receipt_bytes, packed_capsules) = payload_splitter(rest_payload,
|
||||||
msgpack_remainder=True)
|
msgpack_remainder=True)
|
||||||
capsules = [Capsule.from_bytes(p) for p in msgpack.loads(packed_capsules)]
|
capsules = [Capsule.from_bytes(p, params=default_params()) for p in msgpack.loads(packed_capsules)]
|
||||||
verified = signature.verify(receipt_bytes, bob_pubkey_sig)
|
verified = signature.verify(receipt_bytes, bob_pubkey_sig)
|
||||||
if not verified:
|
if not verified:
|
||||||
raise ValueError("This doesn't appear to be from Bob.")
|
raise ValueError("This doesn't appear to be from Bob.")
|
||||||
|
|
Loading…
Reference in New Issue