Skip to content

cleanup and refactor encrypt.py#42

Merged
jMyles merged 6 commits intocryptograss:mainfrom
kubic71:cleanup-encrypt
Aug 13, 2023
Merged

cleanup and refactor encrypt.py#42
jMyles merged 6 commits intocryptograss:mainfrom
kubic71:cleanup-encrypt

Conversation

@kubic71
Copy link
Copy Markdown
Collaborator

@kubic71 kubic71 commented Jul 21, 2023

No description provided.

Copy link
Copy Markdown
Collaborator

@KPrasch KPrasch left a comment

Choose a reason for hiding this comment

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

This PR is looking great! It will be beneficial to use click (since it will generate help text for the commands) and also document a usage example of the new CLI.

None of my comments are meant to be blocking, and can be follow-ups. Approved 👍🏻

encrypt.py Outdated
definitely_tony = tony.read()

def encapsulate(secret):
def encapsulate(secret: bytes, clear_text: bytes) -> bytes:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

clear_text -> cleartext is conventional.

from typing import TypedDict
from nucypher.policy.conditions.lingo import ConditionLingo, Lingo

class TMK(TypedDict):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

😎

encrypt.py Outdated
Comment on lines +110 to +117
parser = argparse.ArgumentParser(description="Encrypt file using threshold encryption.")
parser.add_argument("--file_path", type=str, default="manzana.mp3", help="Path to the file to be encrypted")
parser.add_argument("--ritual_id", type=int, help="Ritual ID obtained from a side channel", default=15)
parser.add_argument("--coordinator_provider_uri", type=str, help="URI of the coordinator provider", required=True)
parser.add_argument("--coordinator_network", type=str, default="mumbai", help="Network for the coordinator", choices=["mumbai", "rinkeby", "mainnet", "goerli", "ropsten", "kovan"])
parser.add_argument("--chain", type=int, help="Ethereum chain ID", default=80001)
parser.add_argument("--eth_address", type=str, help="Ethereum address for balance check", default="0x210eeAC07542F815ebB6FD6689637D8cA2689392")
parser.add_argument("--output-file", type=str, default="tony.tmk", help="Output file for encrypted data")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's nice to see this tool formalized. With this many options and custom parsing you may want to consider using click instead! https://click.palletsprojects.com/en/8.1.x/

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@KPrasch the code is now udpated with click as cmdline arg parser.

Just wondering - what is it's benefit compared to argparse?

"chain": chain,
"method": "eth_getBalance",
"parameters": [eth_address, "latest"],
"returnValueTest": {"comparator": ">=", "value": eth_minimum_balance},
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I changed the comparator and added an eth_minimim_balance parameter, because in the final incrypt we want to set this to 10 ETH and not 0, right?

@kubic71
Copy link
Copy Markdown
Collaborator Author

kubic71 commented Jul 23, 2023

What was done from the last PR round:

  • using click instead of argparse
  • add eth-minimum-balance param
  • renamed clear_text -> cleartext
  • print the keccak hash of the symmetric key, which we need for calling the commitSecret of the Contribution contract.

@kubic71 kubic71 requested a review from KPrasch July 23, 2023 16:44
@kubic71
Copy link
Copy Markdown
Collaborator Author

kubic71 commented Jul 23, 2023

When #41 gets merged, we should add click to the dependencies.

@kubic71
Copy link
Copy Markdown
Collaborator Author

kubic71 commented Jul 23, 2023

May be superseded by #47

@jMyles jMyles merged commit 0fab1b2 into cryptograss:main Aug 13, 2023
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.

3 participants