RFCs for PR #2780 pt. II

pull/2780/head
Kieran R. Prasch 2021-08-24 11:42:21 -07:00
parent 18c9f849b7
commit a3f8df66fc
5 changed files with 4 additions and 153 deletions

View File

@ -466,116 +466,6 @@ Example Response
}
POST /publish_treasure_map
^^^^^^^^^^^^^^^^^^^^^^^^^^
Publish a treasure map to the network as part of Alice's ``grant`` workflow. The treasure map associated
with the policy is stored by the network.
Parameters
++++++++++
+----------------------------------+---------------+----------------------------------------+
| **Parameter** | **Type** | **Description** |
+==================================+===============+========================================+
| ``treasure_map`` | String | Treasure map bytes encoded as base64. |
+----------------------------------+---------------+----------------------------------------+
| ``bob_encrypting_key`` | String | Bob's encrypting key encoded as hex. |
+----------------------------------+---------------+----------------------------------------+
Returns
+++++++
Confirmation that the treasure map was published:
* ``published`` - Value of ``true``.
If publishing the treasure map fails, an error status code is returned.
Example Request
+++++++++++++++
.. code:: bash
curl -X POST <PORTER URI>/publish_treasure_map \
-H "Content-Type: application/json" \
-d '{"treasure_map": "Qld7S8sbKFCv2B8KxfJo4oxiTOjZ4VPyqTK5K1xK6DND6TbLg2hvlGaMV69aiiC5QfadB82w/5q1Sw+SNFHN2e ...",
"bob_encrypting_key": "026d1f4ce5b2474e0dae499d6737a8d987ed3c9ab1a55e00f57ad2d8e81fe9e9ac"}'
OR
.. code:: bash
curl -X POST "<PORTER URI>/publish_treasure_map?treasure_map=Qld7S8sbKFCv2B8KxfJo4oxiTOjZ4VPyqTK5K1xK6DND6TbLg2hvlGaMV69aiiC5QfadB82w%2F5q1Sw%2BSNFHN2e ...&bob_encrypting_key=026d1f4ce5b2474e0dae499d6737a8d987ed3c9ab1a55e00f57ad2d8e81fe9e9ac"
Example Response
++++++++++++++++
.. code::
Status: 200 OK
.. code:: json
{
"result": {
"published": true
},
"version": "6.0.0"
}
GET /get_treasure_map
^^^^^^^^^^^^^^^^^^^^^
Retrieve a treasure map from the network as part of Bob's ``retrieve`` workflow. Bob needs to obtain the treasure map
associated with a policy, to learn which Ursulas were assigned to service the policy.
Parameters
++++++++++
+----------------------------------+---------------+----------------------------------------+
| **Parameter** | **Type** | **Description** |
+==================================+===============+========================================+
| ``hrac`` | String | Policy HRAC. |
+----------------------------------+---------------+----------------------------------------+
| ``bob_encrypting_key`` | String | Bob's encrypting key encoded as hex. |
+----------------------------------+---------------+----------------------------------------+
Returns
+++++++
The requested treasure map:
* ``treasure_map`` - Treasure map bytes encoded as base64
Example Request
+++++++++++++++
.. code:: bash
curl -X GET <PORTER URI>/get_treasure_map \
-H "Content-Type: application/json" \
-d '{"hrac": "f6ec73c93084ce91d5542a4ba6070071",
"bob_encrypting_key": "026d1f4ce5b2474e0dae499d6737a8d987ed3c9ab1a55e00f57ad2d8e81fe9e9ac"}'
OR
.. code:: bash
curl -X GET "<PORTER URI>/get_treasure_map?hrac=f6ec73c93084ce91d5542a4ba6070071&bob_encrypting_key=026d1f4ce5b2474e0dae499d6737a8d987ed3c9ab1a55e00f57ad2d8e81fe9e9ac"
Example Response
++++++++++++++++
.. code::
Status: 200 OK
.. code:: json
{
"result": {
"treasure_map": "Qld7S8sbKFCv2B8KxfJo4oxiTOjZ4VPyqTK5K1xK6DND6TbLg2hvlGaMV69aiiC5QfadB82w/5q1Sw+SNFHN2esWgAbs38QuUVUGCzDoWzQAAAGIAuhw12ZiPMNV8LaeWV8uUN+au2HGOjWilqtKsaP9fmnLAzFiTUAu9/VCxOLOQE88BPoWk1H7OxRLDEhnBVYyflpifKbOYItwLLTtWYVFRY90LtNSAzS8d3vNH4c3SHSZwYsCKY+5LvJ68GD0CqhydSxCcGckh0unttHrYGSOQsURUI4AAAEBsSMlukjA1WyYA+FouqkuRtk8bVHcYLqRUkK2n6dShEUGMuY1SzcAbBINvJYmQp+hhzK5m47AzCl463emXepYZQC/evytktG7yXxd3k8Ak+Qr7T4+G2VgJl4YrafTpIT6wowd+8u/SMSrrf/M41OhtLeBC4uDKjO3rYBQfVLTpEAgiX/9jxB80RtNMeCwgcieviAR5tlw2IlxVTEhxXbFeopcOZmfEuhVWqgBUfIakqsNCXkkubV0XS2l5G1vtTM8oNML0rP8PyKd4+0M5N6P/EQqFkHH93LCDD0IQBq9usm3MoJp0eT8N3m5gprI05drDh2xe/W6qnQfw3YXnjdvf2A="
},
"version": "6.0.0"
}
POST /exec_work_order
^^^^^^^^^^^^^^^^^^^^^
Use a work order to execute a re-encrypt operation on the network network as part of Bob's ``retrieve`` workflow.

View File

@ -893,7 +893,7 @@ class Bob(Character):
def _handle_treasure_map(self,
publisher_verifying_key: PublicKey,
label: bytes,
encrypted_treasure_map: Optional['EncryptedTreasureMap']
encrypted_treasure_map: Optional['EncryptedTreasureMap'] = None
) -> Tuple['TreasureMap', int]:
"""Decrypt and cache the treasure map by Bob."""
if encrypted_treasure_map:

View File

@ -14,6 +14,8 @@
You should have received a copy of the GNU Affero General Public License
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
"""
import click
from marshmallow import validates_schema
from marshmallow import fields as marshmallow_fields
@ -113,25 +115,6 @@ class AliceGetUrsulas(BaseSchema):
f"common entries {common_ursulas}")
class AlicePublishTreasureMap(BaseSchema):
treasure_map = character_fields.EncryptedTreasureMap(
required=True,
load_only=True,
click=click.option(
'--treasure-map',
'-t',
help="Treasure Map to publish",
type=click.STRING,
required=True))
bob_encrypting_key = character_fields.Key(
required=True,
load_only=True,
click=option_bob_encrypting_key())
# output
published = marshmallow_fields.Bool(dump_only=True)
class AliceRevoke(BaseSchema):
pass # TODO need to understand revoke process better
@ -139,25 +122,6 @@ class AliceRevoke(BaseSchema):
#
# Bob Endpoints
#
class BobGetTreasureMap(BaseSchema):
hrac = fields.HRAC(
required=True,
load_only=True,
click=click.option(
'--hrac',
'-h',
help="Policy HRAC as hex",
type=click.STRING,
required=True))
bob_encrypting_key = character_fields.Key(
required=True,
load_only=True,
click=option_bob_encrypting_key())
# output
# treasure map only used for serialization so no need to provide federated/non-federated context
treasure_map = character_fields.EncryptedTreasureMap(dump_only=True)
class BobExecWorkOrder(BaseSchema):
ursula = fields.UrsulaChecksumAddress(

View File

@ -91,7 +91,7 @@ def test_exec_work_order(blockchain_porter_rpc_controller,
# Setup
network_middleware = MockRestMiddleware()
# enact new random policy since idle_blockchain_policy/enacted_blockchain_policy already modified in previous tests
enacted_policy = random_blockchain_policy.enact(network_middleware=network_middleware) # enact but don't publish
enacted_policy = random_blockchain_policy.enact(network_middleware=network_middleware)
ursula_address, work_order = work_order_setup(enacted_policy,
blockchain_ursulas,
blockchain_bob,

View File

@ -20,15 +20,12 @@ from base64 import b64encode
import pytest
from nucypher.control.specifications.exceptions import InvalidArgumentCombo, InvalidInputData
from nucypher.crypto.powers import DecryptingPower
from nucypher.crypto.umbral_adapter import SecretKey
from nucypher.policy.maps import AuthorizedKeyFrag
from nucypher.policy.orders import WorkOrder as WorkOrderClass
from nucypher.utilities.porter.control.specifications.fields import UrsulaInfoSchema
from nucypher.utilities.porter.control.specifications.porter_schema import (
AliceGetUrsulas,
AlicePublishTreasureMap,
BobGetTreasureMap,
BobExecWorkOrder
)
from nucypher.utilities.porter.porter import Porter