Skip to content

POC Porter implementation for /get_treasure_map, /publish_treasure_map, and /get_ursulas (unaffected by TMapConKFrags work)#2717

Merged
derekpierre merged 14 commits intonucypher:porterfrom
derekpierre:porter-impl
Jun 21, 2021
Merged

POC Porter implementation for /get_treasure_map, /publish_treasure_map, and /get_ursulas (unaffected by TMapConKFrags work)#2717
derekpierre merged 14 commits intonucypher:porterfrom
derekpierre:porter-impl

Conversation

@derekpierre
Copy link
Copy Markdown
Member

@derekpierre derekpierre commented Jun 2, 2021

Type of PR:

  • Bugfix
  • Feature
  • Documentation
  • Other

Required reviews:

  • 1
  • 2
  • 3

Issues fixed/closed:
Related to #2703, #2704.

Why it's needed:
Simple POC implementation for Porter functions /get_treasure_map (Bob), /publish_treasure_map (Alice), and /get_ursulas (Alice) that are unaffected by the work to be completed for TMapConKFrags.

Outstanding questions for reviewers:

  1. What do we do about timeouts (default timeouts) for the Porter Learner functionality? Used existing default values in original code.
  2. Is this the best way of doing connectivity checks with sampled Ursulas - https://github.com/derekpierre/nucypher/blob/porter-impl/nucypher/utilities/porter/porter.py#L142
  3. How come NotStaking wasn't caught before when trying to get a treasure map from nodes? I added it to the refactored common code here - https://github.com/derekpierre/nucypher/blob/porter-impl/nucypher/characters/utils.py#L56
  4. TreasureMapID validation only checks length; 32 bytes for federated, 16 for decentralized - is this correct/sufficient? https://github.com/derekpierre/nucypher/blob/porter-impl/nucypher/utilities/porter/control/specifications/fields/treasuremapid.py#L28
  5. TreasureMap specification validation now uses TreasureMap.splitter() and SignedTreasureMap.splitter() - it can't tell whether the treasure map bytes provided are federated or not, so the validation uses both splitters to check and if both fail, combines the two exceptions into one. Is there a way to define one splitter that encompasses both types of expected treasure map bytes? See https://github.com/derekpierre/nucypher/blob/porter-impl/nucypher/characters/control/specifications/fields/treasuremap.py#L37. Porter is really meant for decentralized mode but having it handle federated mode is great for testing.

@derekpierre derekpierre added this to the Porter v1 (MVP) milestone Jun 2, 2021
@derekpierre
Copy link
Copy Markdown
Member Author

derekpierre commented Jun 2, 2021

For /publish_treasure_map and /get_treasure_map. Federated example here, the acceptance tests use blockchain.

NOTE: the list of Ursulas returned will vary every time the following is run so other values need to be modified eg. include/exclude lists.

Federated Example

  1. Run $ python examples/run_demo_ursula_fleet.py
  2. Run Porter $ nucypher porter run --federated-only --teacher localhost:11500
  3. Run the following in ipython shell
In [1]: import requests

In [2]: payload = {"bob_encrypting_key": "026d1f4ce5b2474e0dae499d6737a8d987ed3c9ab1a55e00f57ad2d8e81fe9e9ac", "treasure_map_id": "f6ec73c93084ce91d5542a4ba6070071f5565112fe19b26ae9c960f9d658903a"}

In [3]: r = requests.get("http://localhost:9155/get_treasure_map", json=payload)

# no treasure map available since not published as yet
In [5]: r.text
Out[5]: 'Asked 12 nodes, but none had map f6ec73c93084ce91d5542a4ba6070071f5565112fe19b26ae9c960f9d658903a'

In [6]: r
Out[6]: <Response [500]>

# publish treasure map

In [7]: payload_publish = {"bob_encrypting_key": "026d1f4ce5b2474e0dae499d6737a8d987ed3c9ab1a55e00f57ad2d8e81fe9e9ac", "treasure_map": "Qld7S8sbKFCv2B8KxfJo4oxiTOjZ4VPyqTK5K1xK6DND6TbLg2hvlGaMV69aiiC5QfadB82w/5q1Sw+SNFHN2esWgAbs38QuUVUGCzDoWzQAAAGIAuhw12ZiPMNV8LaeWV8uUN+au2HGOjWilqtKsaP9fmnLAzFiTUAu9/VCxOLOQE88BPoWk1H7OxRLDEhnBVYyflpifKbOYItwLLTtWYVFRY90LtNSAzS8d3vNH4c3SHSZwYsCKY+5LvJ68GD0CqhydSxCcGckh0unttHrYGSOQsURUI4AAAEBsSMlukjA1WyYA+FouqkuRtk8bVHcYLqRUkK2n6dShEUGMuY1SzcAbBINvJYmQp+hhzK5m47AzCl463emXepYZQC/evytktG7yXxd3k8Ak+Qr7T4+G2VgJl4YrafTpIT6wowd+8u/SMSrrf/M41OhtLeBC4uDKjO3rYBQfVLTpEAgiX/9jxB80RtNMeCwgcieviAR5tlw2IlxVTEhxXbFeopcOZmfEuhVWqgBUfIakqsNCXkkubV0XS2l5G1vtTM8oNML0rP8PyKd4+0M5N6P/EQqFkHH93LCDD0IQBq9usm3MoJp0eT8N3m5gprI05drDh2xe/W6qnQfw3YXnjdvf2A="}

In [8]: r_pub = requests.post("http://localhost:9155/publish_treasure_map", json=payload_publish)

In [9]: r_pub
Out[9]: <Response [200]>

In [10]: r_pub.json()
Out[10]: {'result': {}, 'version': '5.2.0'}

# now that it is published try getting it again

In [11]: r = requests.get("http://localhost:9155/get_treasure_map", json=payload)

In [12]: r
Out[12]: <Response [200]>

In [13]: r.json()
Out[13]:
{'result': {'treasure_map': 'Qld7S8sbKFCv2B8KxfJo4oxiTOjZ4VPyqTK5K1xK6DND6TbLg2hvlGaMV69aiiC5QfadB82w/5q1Sw+SNFHN2esWgAbs38QuUVUGCzDoWzQAAAGIAuhw12ZiPMNV8LaeWV8uUN+au2HGOjWilqtKsaP9fmnLAzFiTUAu9/VCxOLOQE88BPoWk1H7OxRLDEhnBVYyflpifKbOYItwLLTtWYVFRY90LtNSAzS8d3vNH4c3SHSZwYsCKY+5LvJ68GD0CqhydSxCcGckh0unttHrYGSOQsURUI4AAAEBsSMlukjA1WyYA+FouqkuRtk8bVHcYLqRUkK2n6dShEUGMuY1SzcAbBINvJYmQp+hhzK5m47AzCl463emXepYZQC/evytktG7yXxd3k8Ak+Qr7T4+G2VgJl4YrafTpIT6wowd+8u/SMSrrf/M41OhtLeBC4uDKjO3rYBQfVLTpEAgiX/9jxB80RtNMeCwgcieviAR5tlw2IlxVTEhxXbFeopcOZmfEuhVWqgBUfIakqsNCXkkubV0XS2l5G1vtTM8oNML0rP8PyKd4+0M5N6P/EQqFkHH93LCDD0IQBq9usm3MoJp0eT8N3m5gprI05drDh2xe/W6qnQfw3YXnjdvf2A='},
 'version': '5.2.0'}

@derekpierre derekpierre changed the title [WIP] Simple POC Porter implementation for /get_treasure_map and /publish_treasure_map [WIP] Simple POC Porter implementation for /get_treasure_map, /publish_treasure_map, and /get_ursulas Jun 4, 2021
@derekpierre derekpierre changed the title [WIP] Simple POC Porter implementation for /get_treasure_map, /publish_treasure_map, and /get_ursulas [WIP] POC Porter implementation for /get_treasure_map, /publish_treasure_map, and /get_ursulas Jun 4, 2021
@derekpierre
Copy link
Copy Markdown
Member Author

For /get_ursulas:

NOTE: the list of Ursulas returned will vary every time the following is run so other values need to be modified eg. include/exclude lists.

Federated Example

  1. Run $ python examples/run_demo_ursula_fleet.py
  2. Run Porter $ nucypher porter run --federated-only --teacher localhost:11500
  3. Run the following in python shell:
In [1]: import requests

In [2]: payload = {"quantity": 5, "duration_periods": 4}

In [3]: r = requests.get("http://localhost:9155/get_ursulas", json=payload)

In [4]: r
Out[4]: <Response [200]>

In [5]: r.content
Out[5]: b'{"result": {"ursulas": [{"encrypting_key": "03440a4c53bd8a215334694ff9e262bff2bdd015afb9b00e3bb60341b220166198", "checksum_address": "0xee94Bdb476510F447D2697A821E159CbcC7Db3d9", "ip_address": "https://127.0.0.1:11507"}, {"encrypting_key": "0341b821ad2e7fc814ccecc770d66ac67fc116f8ca01f0a077010498e408b485db", "checksum_address": "0x39Dbe2270780aaB9d20a8E58f62d441851AB96cD", "ip_address": "https://127.0.0.1:11511"}, {"encrypting_key": "026d9a993e37370d135867bd8c8108e7533def19e70ff26b7127cf2ad8bf3c5674", "checksum_address": "0x519A5EF6c5f66527d6888caf1221f52d64eD7C34", "ip_address": "https://127.0.0.1:11504"}, {"encrypting_key": "026ddd7ed9f8b7e649ad2f0a994894332688421cd64bb7eabdc506ec1ead48aa71", "checksum_address": "0x226f652aE5BD2A07097085729b7109EF62D16388", "ip_address": "https://127.0.0.1:11509"}, {"encrypting_key": "03add66a40607f44525aeed31e9c8979601704e3aba23d1e6378d89dffc5262eca", "checksum_address": "0x2b49d8a024CEc7e5E4D1fB953624ADEa9308ca9F", "ip_address": "https://127.0.0.1:11500"}]}, "version": "5.2.0"}'

In [6]: include_ursulas = ["0x7b5D8E3ADf81F53c815B731295E4677D28137935", "0x519A5EF6c5f66527d6888caf1221f52d64eD7C34"]

In [7]: payload["include_ursulas"] = include_ursulas

In [8]: r = requests.get("http://localhost:9155/get_ursulas", json=payload)

In [9]: r
Out[9]: <Response [200]>

In [10]: r.content
Out[10]: b'{"result": {"ursulas": [{"encrypting_key": "02f1999d954d88745ce9f4f9b8e7348e0a8ccda05711d14e5dc206bd272bdf0493", "checksum_address": "0x64FaCbb9AD35f1E5f6aAd2Dc5f626f3A38E2247f", "ip_address": "https://127.0.0.1:11501"}, {"encrypting_key": "021bad03835961be222e7d6b9ea161a2ba902545e8a796528308dad19f073dbf45", "checksum_address": "0x41f5f375521259E8377775DEEE045E5F6eA3fC35", "ip_address": "https://127.0.0.1:11510"}, {"encrypting_key": "026d9a993e37370d135867bd8c8108e7533def19e70ff26b7127cf2ad8bf3c5674", "checksum_address": "0x519A5EF6c5f66527d6888caf1221f52d64eD7C34", "ip_address": "https://127.0.0.1:11504"}, {"encrypting_key": "030fa280e84ff8c2e10b63bc32d1f4bb487beb98a8e8949a756f254c97f2052982", "checksum_address": "0x7b5D8E3ADf81F53c815B731295E4677D28137935", "ip_address": "https://127.0.0.1:11506"}, {"encrypting_key": "03ee7b66057b75f97f8b7ea51d0c2bfb5ab3838ef66a3c1c4dfe4014a0dd9d59a0", "checksum_address": "0x1f31F8F2988f1313c4B36CE211E708c946c66fee", "ip_address": "https://127.0.0.1:11505"}]}, "version": "5.2.0"}'

In [11]: exclude_ursulas = ["0x1f31F8F2988f1313c4B36CE211E708c946c66fee", "0x64FaCbb9AD35f1E5f6aAd2Dc5f626f3A38E2247f", "0x8fEE90e395a47cfB3f4e8ce96306337B701A6ca8", "0x39Dbe2270780aaB9d20a8E58f62d441851AB96cD"]

In [12]: payload["exclude_ursulas"] = exclude_ursulas

In [13]: r = requests.get("http://localhost:9155/get_ursulas", json=payload)

In [14]: r
Out[14]: <Response [200]>

In [15]: r.content
Out[15]: b'{"result": {"ursulas": [{"encrypting_key": "026d9a993e37370d135867bd8c8108e7533def19e70ff26b7127cf2ad8bf3c5674", "checksum_address": "0x519A5EF6c5f66527d6888caf1221f52d64eD7C34", "ip_address": "https://127.0.0.1:11504"}, {"encrypting_key": "0350d0ec52ffa63691d4a71748b0e5a6fe7c8aa751bedb8873c52ad43684b51fa0", "checksum_address": "0x538D64a582C8a3A6A2b8480c5e4c231b85B747f9", "ip_address": "https://127.0.0.1:11508"}, {"encrypting_key": "030fa280e84ff8c2e10b63bc32d1f4bb487beb98a8e8949a756f254c97f2052982", "checksum_address": "0x7b5D8E3ADf81F53c815B731295E4677D28137935", "ip_address": "https://127.0.0.1:11506"}, {"encrypting_key": "020faf809b76ef4ee45ced7929f0d7697aed958e39327d31ceb7275dbe9307e751", "checksum_address": "0x14c1c069216e2b1Fd7aB41f7e21a6d9dc9D631Bc", "ip_address": "https://127.0.0.1:11503"}, {"encrypting_key": "026ddd7ed9f8b7e649ad2f0a994894332688421cd64bb7eabdc506ec1ead48aa71", "checksum_address": "0x226f652aE5BD2A07097085729b7109EF62D16388", "ip_address": "https://127.0.0.1:11509"}]}, "version": "5.2.0"}'

In [16]: r = requests.get("http://localhost:9155/get_ursulas", json=payload)

In [17]: r
Out[17]: <Response [200]>

In [18]: r.content
Out[18]: b'{"result": {"ursulas": [{"encrypting_key": "0350d0ec52ffa63691d4a71748b0e5a6fe7c8aa751bedb8873c52ad43684b51fa0", "checksum_address": "0x538D64a582C8a3A6A2b8480c5e4c231b85B747f9", "ip_address": "https://127.0.0.1:11508"}, {"encrypting_key": "026ddd7ed9f8b7e649ad2f0a994894332688421cd64bb7eabdc506ec1ead48aa71", "checksum_address": "0x226f652aE5BD2A07097085729b7109EF62D16388", "ip_address": "https://127.0.0.1:11509"}, {"encrypting_key": "030fa280e84ff8c2e10b63bc32d1f4bb487beb98a8e8949a756f254c97f2052982", "checksum_address": "0x7b5D8E3ADf81F53c815B731295E4677D28137935", "ip_address": "https://127.0.0.1:11506"}, {"encrypting_key": "026d9a993e37370d135867bd8c8108e7533def19e70ff26b7127cf2ad8bf3c5674", "checksum_address": "0x519A5EF6c5f66527d6888caf1221f52d64eD7C34", "ip_address": "https://127.0.0.1:11504"}, {"encrypting_key": "020faf809b76ef4ee45ced7929f0d7697aed958e39327d31ceb7275dbe9307e751", "checksum_address": "0x14c1c069216e2b1Fd7aB41f7e21a6d9dc9D631Bc", "ip_address": "https://127.0.0.1:11503"}]}, "version": "5.2.0"}'

Decentralized Example

  1. Run Porter $ nucypher porter run --provider https://mainnet.infura.io/v3/<APP_ID> --network mainnet
In [1]: import requests

In [2]: payload = {"quantity": 5, "duration_periods": 4}

In [3]: r = requests.get("http://localhost:9155/get_ursulas", json=payload)

In [4]: r
Out[4]: <Response [200]>

In [5]: r.content
Out[5]: b'{"result": {"ursulas": [{"encrypting_key": "025a335eca37edce8191d43c156e7bc6b451b21e5258759966bbfe0e6ce44543cb", "checksum_address": "0x5cF1703A1c99A4b42Eb056535840e93118177232", "ip_address": "https://3.236.144.36:9151"}, {"encrypting_key": "02b0a0099ee180b531b4937bd7446972296447b2479ca6259cb6357ed98b90da3a", "checksum_address": "0x7fff551249D223f723557a96a0e1a469C79cC934", "ip_address": "https://54.218.83.166:9151"}, {"encrypting_key": "02761c765e2f101df39a5f680f3943d0d993ef9576de8a3e0e5fbc040d6f8c15a5", "checksum_address": "0x9C7C824239D3159327024459Ad69bB215859Bd25", "ip_address": "https://92.53.84.156:9151"}, {"encrypting_key": "0258b7c79fe73f3499de91dd5a5341387184035d0555b10e6ac762d211a39684c0", "checksum_address": "0x9919C9f5CbBAA42CB3bEA153E14E16F85fEA5b5D", "ip_address": "https://3.36.66.164:9151"}, {"encrypting_key": "02e43a623c24db4f62565f82b6081044c1968277edfdca494a81c8fd0826e0adf6", "checksum_address": "0xfBeb3368735B3F0A65d1F1E02bf1d188bb5F5BE6", "ip_address": "https://128.199.124.254:9151"}]}, "version": "5.2.0"}'

In [6]: include_ursulas = ["0x5cF1703A1c99A4b42Eb056535840e93118177232", "0x7fff551249D223f723557a96a0e1a469C79cC934"]

In [7]: payload["include_ursulas"] = include_ursulas

In [8]: r = requests.get("http://localhost:9155/get_ursulas", json=payload)

In [9]: r
Out[9]: <Response [200]>

In [10]: r.content
Out[10]: b'{"result": {"ursulas": [{"encrypting_key": "030b29c5bbcba278a962e76cbb0f404b74ef8c50892dd33664a24c8b079369fa41", "checksum_address": "0xCef1B4Bf8F05F623A2A688b56d9dA679D302EBa7", "ip_address": "https://54.39.181.135:9151"}, {"encrypting_key": "039397a359f537a34e72859c55563ea224433ecfb02bf030da46485197868e66fc", "checksum_address": "0x02D4Fe8f98129F578fb2e160404033B8e4627A36", "ip_address": "https://54.39.190.30:9151"}, {"encrypting_key": "025a335eca37edce8191d43c156e7bc6b451b21e5258759966bbfe0e6ce44543cb", "checksum_address": "0x5cF1703A1c99A4b42Eb056535840e93118177232", "ip_address": "https://3.236.144.36:9151"}, {"encrypting_key": "02b0a0099ee180b531b4937bd7446972296447b2479ca6259cb6357ed98b90da3a", "checksum_address": "0x7fff551249D223f723557a96a0e1a469C79cC934", "ip_address": "https://54.218.83.166:9151"}, {"encrypting_key": "0389b7552f5724bd831cb7dc3d2e8ba8389575b52d544d2b091a8a65dbeffa287e", "checksum_address": "0xB04FcDF9327f65AB0107Ea95b78BB200C07FA752", "ip_address": "https://18.210.24.63:9151"}]}, "version": "5.2.0"}'

In [11]: exclude_ursulas = ["0xB04FcDF9327f65AB0107Ea95b78BB200C07FA752", "0xCef1B4Bf8F05F623A2A688b56d9dA679D302EBa7", "0x02D4Fe8f98129F578fb2e160404033B8e4627A36", "0x9C7C824239D3159327024459Ad69bB215859Bd25", "0x9919C9f5CbBAA42CB3bEA153E14E16F85fEA5b5D", "0xfBeb3368735B3F0A65d1F1E02bf1d188bb5F5BE6"]

In [12]: payload['exclude_ursulas'] = exclude_ursulas

In [13]: r = requests.get("http://localhost:9155/get_ursulas", json=payload)

In [14]: r
Out[14]: <Response [200]>

In [15]: r.content
Out[15]: b'{"result": {"ursulas": [{"encrypting_key": "025a335eca37edce8191d43c156e7bc6b451b21e5258759966bbfe0e6ce44543cb", "checksum_address": "0x5cF1703A1c99A4b42Eb056535840e93118177232", "ip_address": "https://3.236.144.36:9151"}, {"encrypting_key": "02b0a0099ee180b531b4937bd7446972296447b2479ca6259cb6357ed98b90da3a", "checksum_address": "0x7fff551249D223f723557a96a0e1a469C79cC934", "ip_address": "https://54.218.83.166:9151"}, {"encrypting_key": "030b41e643823db37ca98f69362e8665dc2b7dbfa3aa412993665795afcecc2d9b", "checksum_address": "0xbdA6Ba3Ad624582495C55451A1840e563fc16389", "ip_address": "https://34.209.206.31:9151"}, {"encrypting_key": "029efc301b857e184da14fcb29b55d8a38bf28d906763c811cc641b4c916fd423b", "checksum_address": "0x93EC08943257DC1abeFb46875C7AAF92aeE0ecC6", "ip_address": "https://44.235.74.191:9151"}, {"encrypting_key": "02921281b5b0ca222a9bf5e5c6d6525381677b7ed429e2deab79eb245b6461a472", "checksum_address": "0x42D2875a71Cb25DDcF05Dbed55490cB905498Bac", "ip_address": "https://13.212.162.22:9151"}]}, "version": "5.2.0"}'

In [16]: r = requests.get("http://localhost:9155/get_ursulas", json=payload)

In [17]: r
Out[17]: <Response [200]>

In [18]: r.content
Out[18]: b'{"result": {"ursulas": [{"encrypting_key": "025a335eca37edce8191d43c156e7bc6b451b21e5258759966bbfe0e6ce44543cb", "checksum_address": "0x5cF1703A1c99A4b42Eb056535840e93118177232", "ip_address": "https://3.236.144.36:9151"}, {"encrypting_key": "02f80e41b8269c4a57a8b8dfb3787746fcea620883e5a0a09b2c8c89cae4488bc1", "checksum_address": "0xFb626333099A91Ab677BCd5e9C71bc4Dbe0238a8", "ip_address": "https://34.209.70.116:9151"}, {"encrypting_key": "02b0a0099ee180b531b4937bd7446972296447b2479ca6259cb6357ed98b90da3a", "checksum_address": "0x7fff551249D223f723557a96a0e1a469C79cC934", "ip_address": "https://54.218.83.166:9151"}, {"encrypting_key": "029efc301b857e184da14fcb29b55d8a38bf28d906763c811cc641b4c916fd423b", "checksum_address": "0x93EC08943257DC1abeFb46875C7AAF92aeE0ecC6", "ip_address": "https://44.235.74.191:9151"}, {"encrypting_key": "027bb2220dfd1f9d02c0ccf973678b9d811806daf0e6e4439c253854746c393c77", "checksum_address": "0xb011b6794F271B1d8D2328eDf332535343CB4D44", "ip_address": "https://138.197.186.215:9151"}]}, "version": "5.2.0"}'

@derekpierre derekpierre self-assigned this Jun 4, 2021
@derekpierre derekpierre added the Web Webpages label Jun 4, 2021
@derekpierre derekpierre changed the title [WIP] POC Porter implementation for /get_treasure_map, /publish_treasure_map, and /get_ursulas POC Porter implementation for /get_treasure_map, /publish_treasure_map, and /get_ursulas Jun 8, 2021
@derekpierre derekpierre marked this pull request as ready for review June 8, 2021 18:59
@derekpierre derekpierre changed the title POC Porter implementation for /get_treasure_map, /publish_treasure_map, and /get_ursulas POC Porter implementation for /get_treasure_map, /publish_treasure_map, and /get_ursulas (unaffected by TMapConKFrags work) Jun 8, 2021
…publish_treasure_map for Porter.

Added federated functionality to Porter.
Remove unused 'publish_treasure_map' parameter from _enact() function.
Loosen validation on treasure map id which can be 32 bytes (federated) or 16 bytes (non-federated). Probably only care about non-federated but for ease of testing, federated really helps.
…or federated mode (not changed for rest api).
Added rpc and web control tests for porter.
… map id length.

Co-authored-by: David Núñez <david@nucypher.com>
Copy link
Copy Markdown
Member

@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 is the meant and potatoes of Porter, nice work. There's also some excellent code reorg in here that introduces a higher degree of testability. Still looking it over, but left a few comments and questions while I get my head around this somewhat large changeset.

return map_id

def get_treasure_map_from_known_ursulas(self, network_middleware, map_identifier, timeout=3):
def get_treasure_map_from_known_ursulas(self, map_identifier, timeout=3):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This method is intentionally name shadowing the one on the treasure map? Also, let's get some type annotations in here.

Copy link
Copy Markdown
Member Author

@derekpierre derekpierre Jun 18, 2021

Choose a reason for hiding this comment

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

I wanted to keep the calls into this original function in Bob the same and then pass through the call to the common function in treasuremap.py. It felt ok, since the function is on Bob, and Bob's encrypting key is needed anyway. Who better to pass it than Bob himself, and original callers don't have to worry about getting the encryption key themselves.

The function in treasuremap.py has the same name but can be changed if desired.

bob_enc_key = UmbralPublicKey.from_bytes(bob_encrypting_key)
treasure_map = self.implementer.get_treasure_map(map_identifier=treasure_map_id,
bob_encrypting_key=bob_enc_key)
response_data = {'treasure_map': treasure_map}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Might be good to include a dummy versioning field local to the map here in anticipation of map versioning introduced in PR #2687.

Copy link
Copy Markdown
Member Author

@derekpierre derekpierre Jun 18, 2021

Choose a reason for hiding this comment

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

Perhaps I'll wait for that to be fleshed out and address it in a different PR. Without fully understanding what's in there now, presumably the version is in the treasuremap itself, and the version may not matter with respect to obtaining it via Porter.

You should have received a copy of the GNU Affero General Public License
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
"""
from constant_sorrow.constants import NO_CONTROL_PROTOCOL
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Porter living inside a utilities module is short-selling it's greatness, and a case in favor of moving to a separate repo IMO (while I still do greatly appreciate the benefits of a unified CI).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@derekpierre and I talked about this a while ago and we agreed that a separate repo is indeed a potential outcome. We also discussed the difficulties that we've seen with nucypher-monitor living in a separate repo in terms of synchronization. I'd personally lean towards keeping it inside the same repo, potentially relocated to a more prominent namespace.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Definitely pros and cons that are up for debate, but something we can address in a separate PR.

… treasure maps provided as bytes in the `/publish_treasure_map` endpoint.

The context information is provided either at construction time of the TreasureMap field, or via the parent Schema context.
Copy link
Copy Markdown
Member

@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.

Looking good!

@derekpierre derekpierre merged commit 7f2ae2e into nucypher:porter Jun 21, 2021
@derekpierre derekpierre added Alice 👩 Effects the "Alice" development area API Bob 👨‍💼 Effects the "Bob" development area labels Jun 25, 2021
derekpierre added a commit to derekpierre/nucypher that referenced this pull request Jul 7, 2021
derekpierre added a commit to derekpierre/nucypher that referenced this pull request Jul 7, 2021
derekpierre added a commit to derekpierre/nucypher that referenced this pull request Jul 7, 2021
derekpierre added a commit to derekpierre/nucypher that referenced this pull request Jul 12, 2021
derekpierre added a commit to derekpierre/nucypher that referenced this pull request Jul 12, 2021
derekpierre added a commit to derekpierre/nucypher that referenced this pull request Jul 12, 2021
derekpierre added a commit that referenced this pull request Jul 12, 2021
derekpierre added a commit that referenced this pull request Jul 12, 2021
derekpierre added a commit that referenced this pull request Jul 12, 2021
derekpierre added a commit that referenced this pull request Jul 26, 2021
derekpierre added a commit that referenced this pull request Jul 26, 2021
derekpierre added a commit that referenced this pull request Jul 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Alice 👩 Effects the "Alice" development area Bob 👨‍💼 Effects the "Bob" development area Web Webpages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants