Skip to content

You Sign Me (Geth EIP-191 "E" Support); Controller, CLI Bug Fixes#1031

Merged
KPrasch merged 23 commits intonucypher:hawksbeardfrom
KPrasch:you-sign-me
Jun 3, 2019
Merged

You Sign Me (Geth EIP-191 "E" Support); Controller, CLI Bug Fixes#1031
KPrasch merged 23 commits intonucypher:hawksbeardfrom
KPrasch:you-sign-me

Conversation

@KPrasch
Copy link
Member

@KPrasch KPrasch commented May 30, 2019

  • Implements geth client signing via w3.eth.sign in NuCypher client abstractions
  • Verify wallet signature as part of standard node verification
  • Labels are Unicode, not Base64
  • Remove keccack of hexadecimal map ID in requests
  • Handle internal geth process management in-test for signature integration
  • Remove "pubkey_sig" from the codebase
  • Use common deploy interactive input fixture

@codecov
Copy link

codecov bot commented May 31, 2019

Codecov Report

Merging #1031 into hawksbeard will increase coverage by 10.14%.
The diff coverage is 91.89%.

Impacted file tree graph

@@               Coverage Diff               @@
##           hawksbeard    #1031       +/-   ##
===============================================
+ Coverage       72.88%   83.03%   +10.14%     
===============================================
  Files              67       67               
  Lines            8642     8658       +16     
===============================================
+ Hits             6299     7189      +890     
+ Misses           2343     1469      -874
Impacted Files Coverage Δ
nucypher/cli/characters/alice.py 80% <ø> (+44.58%) ⬆️
nucypher/utilities/sandbox/ursula.py 98.07% <ø> (-0.14%) ⬇️
nucypher/characters/control/serializers.py 87.6% <ø> (+6.45%) ⬆️
nucypher/crypto/signing.py 85.71% <ø> (+2.85%) ⬆️
nucypher/cli/main.py 91.93% <0%> (+3.22%) ⬆️
nucypher/blockchain/eth/actors.py 76.83% <100%> (+8.99%) ⬆️
nucypher/crypto/kits.py 87.27% <100%> (ø) ⬆️
nucypher/blockchain/eth/interfaces.py 70.27% <100%> (+4.95%) ⬆️
nucypher/network/server.py 87.96% <100%> (+0.05%) ⬆️
nucypher/keystore/db/models.py 94.23% <100%> (+5.76%) ⬆️
... and 46 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 60ed5de...1ee37a4. Read the comment docs.

@KPrasch KPrasch changed the title You Sign Me (EIP-191 Support) You Sign Me (Geth EIP-191 Support); CLI Bug Fixes May 31, 2019
@KPrasch KPrasch changed the title You Sign Me (Geth EIP-191 Support); CLI Bug Fixes You Sign Me (Geth EIP-191 Support); Controller, CLI Bug Fixes May 31, 2019
@KPrasch KPrasch marked this pull request as ready for review June 1, 2019 10:51
client_kwargs = {
'node_technology': node_technology,
'version': client_data[1],
'backend': client_data[-1],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice logic!

raise NotImplementedError

def unlockAccount(self, address, password):
def unlock_account(self, address, password) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this convention of using underscore_methods to make them obviously distinct from w3 calls


def __repr__(self):
r = "({})⇀{}↽ ({})"
r = self._display_name_template
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


def derive_policy_encrypting_key(self, label: bytes) -> dict:
policy_encrypting_key = self.character.get_policy_pubkey_from_label(label)
policy_encrypting_key = self.character.get_policy_encrypting_key_from_label(label)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these name changes make it much clearer to me what is going on here!
💯

'bob_encrypting_key': bob_encrypting_key,
'bob_verifying_key': bob_verifying_key,
'label': b64encode(label.encode()).decode(),
'label': label,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥂 indeed

"""
return keccak_digest(bytes(self._verifying_key) + bytes(self._hrac)).hex()
_id = keccak_digest(bytes(self._verifying_key) + bytes(self._hrac)).hex()
return _id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to new standards! 🥂

Copy link
Contributor

@vepkenez vepkenez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No new features, tons of cleanup and readability improvements.
Awesome.

@cygnusv
Copy link
Member

cygnusv commented Jun 3, 2019

@KPrasch I have an ugly workaround for the finnegan's wake issue. It's in here, in case you want to cherry-pick and have this PR with tests passing.
ed65dce

Copy link
Member

@cygnusv cygnusv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, @KPrasch !

# Needed for on-chain verification
if not self.federated_only:
self.blockchain = blockchain or Blockchain.connect()
self.miner_agent = MinerAgent(blockchain=blockchain)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is somewhat weird, since all characters, even Enrico will get a miner agent. But for the moment I guess it's OK!

Perhaps a TODO?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raise InvalidSignature("Signature for message isn't valid: {}".format(signature_to_use))
else:
raise self.InvalidSignature("No signature provided -- signature presumed invalid.")
raise InvalidSignature("No signature provided -- signature presumed invalid.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we changing here the type of InvalidSignature? Previous one was our own, and now it's the one from the cryptography, even if the Signature is ours.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See related PR #1040

signature=message_kit.signature,
decrypt=True,
label=label
)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we returning here a list of cleartexts, when message_kit always corresponds to a single message?
I know that Bob.retrieve() returns a list of cleartexts, but only because it's associated to WorkOrders, which may have more than one capsule (although currently they don't).
This may not be an issue to solve here, but perhaps we should consider a better API for retrieve/decrypt methods: it doesn't make any sense to have methods that accept only a single capsule, but that output a list of cleartexts (of length 1). Either we make the input also a list, or we return the only cleartext.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true: some hackathon participants wondered about the same thing

'bob_encrypting_key': bob_encrypting_key,
'bob_verifying_key': bob_verifying_key,
'label': b64encode(label.encode()).decode(),
'label': label,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥂 indeed

# TODO 341 - what if we already have this TreasureMap?
this_node.treasure_maps[keccak_digest(binascii.unhexlify(treasure_map_id))] = treasure_map
treasure_map_index = bytes.fromhex(treasure_map_id)
this_node.treasure_maps[treasure_map_index] = treasure_map
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

checksum_public_address=testerchain.alice_account,
network_middleware=MockRestMiddleware(),
known_nodes=blockchain_ursulas,
known_nodes=blockchain_ursulas[:-1], # TODO: 1035
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[:-1] <-- nice guy!

cygnusv and others added 2 commits June 3, 2019 21:48
@KPrasch KPrasch merged commit 2e4bff7 into nucypher:hawksbeard Jun 3, 2019
@KPrasch KPrasch changed the title You Sign Me (Geth EIP-191 Support); Controller, CLI Bug Fixes You Sign Me (Geth EIP-191 "E" Support); Controller, CLI Bug Fixes Jun 9, 2019
@KPrasch KPrasch deleted the you-sign-me branch July 21, 2020 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants