{"id":15888296,"url":"https://github.com/antoncoding/nucypher_demo","last_synced_at":"2025-04-02T16:44:26.779Z","repository":{"id":104219876,"uuid":"190989625","full_name":"antoncoding/nucypher_demo","owner":"antoncoding","description":"Demo of Nucypher CLI, umbral scheme etc","archived":false,"fork":false,"pushed_at":"2019-06-09T15:58:55.000Z","size":53,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-08T07:25:22.888Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antoncoding.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-09T09:51:11.000Z","updated_at":"2019-06-09T15:58:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"e9f2ee05-0f3c-4a3d-b020-6cf854cb4c2a","html_url":"https://github.com/antoncoding/nucypher_demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoncoding%2Fnucypher_demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoncoding%2Fnucypher_demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoncoding%2Fnucypher_demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoncoding%2Fnucypher_demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antoncoding","download_url":"https://codeload.github.com/antoncoding/nucypher_demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246853420,"owners_count":20844577,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-06T06:07:00.855Z","updated_at":"2025-04-02T16:44:26.747Z","avatar_url":"https://github.com/antoncoding.png","language":"Jupyter Notebook","readme":"\n# Nucypher CLI Charactor Demo\n* This is a demo code following official tutorial from https://www.youtube.com/watch?v=om0tew-Z4gE.\n* Some changes are made to fit the new version. (0.1.0-alpha2.2)\n\n## Installation\n```\npip3 install nucypher\n```\nOr follow the installation guid on https://docs.nucypher.com/en/latest/guides/installation_guide.html\n\n\n```python\nfrom base64 import b64decode, b64encode\nimport json\nimport requests\nimport maya # to build ISO format string\nimport datetime\n```\n\n## Run Ursula\n```\nnucypher ursula run --dev --federated-only\n```\n\n## Run Alice Node\n```shell\nnucypher alice run --dev --federated-only --teacher-uri localhost:10151\n```\nPaste the `Alice Verifying Key` in the following\n\n\n```python\nalice = \"http://127.0.0.1:8151\"\nalice_verifying_key = '02b7cd69017a5ce728074ac995793c0ac24b53fc22e0a552c3ed5d72b86274df3b'\n\n```\n\n###  Get Policy Encrypting Key\n\n\n```python\nlabel = 'villa'\nderivation_response = requests.post(\"{}/derive_policy_encrypting_key/{}\".format(alice, label))\nvilla_key = json.loads(derivation_response.text)['result']['policy_encrypting_key']\nprint('Policy {}\\tEncryption key:\\t{}'.format(label, villa_key))\n\n```\n\n    Policy villa\tEncryption key:\t030a04a0754265051833bdd1beaacfc153068100b5050581d70d0de979aba38daf\n\n\n## Start Enrico Node\nStart Nucypher Enrico with the Policy Encryption Key.\n```\nucypher enrico run --policy-encrypting-key 030a04a0754265051833bdd1beaacfc153068100b5050581d70d0de979aba38daf --http-port 5151\n```\n\n\n```python\nenrico = 'http://127.0.0.1:5151'\n```\n\n\n```python\nmy_message = b\"I love you! Let's Try out this Nucypher\" # It should be bytes\nencryption_request = { \"message\": b64encode(my_message).decode()}\nencryption_respone = requests.post(\"{}/encrypt_message\".format(enrico), data=json.dumps(encryption_request))\nencrypted_message = json.loads(encryption_respone.text)['result']\nencrypted_message\n```\n\n\n\n\n    {'message_kit': 'A3RCisAfCRdDQtCPVuHCi5/PzR4yYkrrAOqZdV8tLTLlAge+mtr2aIsSPqVYTz5mQUnO508Izy1i9zENB8VmOepJOhgwXN3qg45gTQkYlAXpyWKL9IeA6K9NZoa0OfQ33AID6/jWervG4G4lZlj4tx+VdzqREVRLvdsV7I87bAmtR8Mm8s081TYl+NwfD9/ayyl8menu4V3VqzKvpYezCsuxnw2Q00KQMMyBaCVeyZtqhD3IZGDpagQx7wBSdokUp3GWAgGn5BYIT5vfMUrmjoyxIxThb4KTnn5Cwv/HBJjY7E0AbExCJXolo10NoyIns4zLElxnuFTRmRrAwTma4n2d9G+S8807RDOgwQ66rVybwTHl5D4SEYnAKA==',\n     'signature': '2CxNeR9PD1B0bZvcc0ogy8vk0L09DDqrrzkKhWMCzGDT0p67AWT1AbCz4Hm0oR32/7GukG7maAKgmZaCROc+HQ=='}\n\n\n\n## Start Bob \n\n```\nnucypher bob run --dev --federated-only --teacher-uri localhost:10151 --http-port 11151\n```\n\nStart Node Bob and past `bob_verifying_key` and `bob_encrypting_key` here.\n\n\n```python\nbob = 'http://127.0.0.1:11151'\nbob_verifying_key = '024ce49fb4d7c96cbcad50e716b340054e3219a4b953f6b707736f8e405c8e6bf9'\nbob_encrypting_key = '03736e6fcc0f58c9df38c8009a7cd1bd9635ce75040f9a6860e784b8573f061da0'\n\n```\n\n### Bob: Try Retrieve the Message before Alice Grant Access\n\n\n```python\nretrieval = {}\nretrieval['label'] = label\nretrieval['policy_encrypting_key'] = villa_key\nretrieval['alice_verifying_key'] = alice_verifying_key\nretrieval['message_kit'] = encrypted_message['message_kit']\n\nretrieval_response = requests.post('{}/retrieve'.format(bob), json=retrieval)\nretrieval_response\n\n```\n\n\n\n\n    \u003cResponse [500]\u003e\n\n\n\n### Alice: Grant Access (of label Villa) to Bob\n\n\n```python\nexpiration = (maya.now() + datetime.timedelta(days=3)).iso8601()\nprint(expiration)\n# Grant Access to bob\ngrant = {}\ngrant['bob_verifying_key'] = bob_verifying_key # not on API Doc\ngrant['bob_encrypting_key'] = bob_encrypting_key\ngrant['expiration'] = expiration\ngrant['label'] = label\ngrant['m'] = 1\ngrant['n'] = 1\nres = requests.put('{}/grant'.format(alice), json=grant)\nprint('Grant Access Call:\\t{}'.format(res.status_code))\ngrant_res = json.loads(res.text)['result']\n```\n\n    2019-06-12T09:49:53.144843Z\n    Grant Access Call:\t200\n\n\n### Bob: Retrieve Data Again\n\n\n```python\nretrieval_response = requests.post('{}/retrieve'.format(bob), json=retrieval)\nprint(retrieval_response)\n```\n\n    \u003cResponse [200]\u003e\n\n\n\n```python\nencoded_text = json.loads(retrieval_response.text)['result']['cleartexts']\nprint('Decrypted Message = {}'.format(b64decode(encoded_text[0])))\n```\n\n    Decrypted Message = b\"I love you! Let's Try out this Nucypher\"\n\n\n### Yay!\nWe successfully Got the message from Bob's side!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantoncoding%2Fnucypher_demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantoncoding%2Fnucypher_demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantoncoding%2Fnucypher_demo/lists"}