Skip to content

Porter implementation of /exec_work_order (associated with TMapConKFrags for /reencrypt endpoint)#2729

Merged
derekpierre merged 7 commits intonucypher:porterfrom
derekpierre:exec-work-order
Jul 14, 2021
Merged

Porter implementation of /exec_work_order (associated with TMapConKFrags for /reencrypt endpoint)#2729
derekpierre merged 7 commits intonucypher:porterfrom
derekpierre:exec-work-order

Conversation

@derekpierre
Copy link
Copy Markdown
Member

@derekpierre derekpierre commented Jun 25, 2021

Type of PR:

  • Bugfix
  • Feature
  • Documentation
  • Other

Required reviews:

  • 1
  • 2
  • 3

What this does:
POC implementation of /exec_work_order for Bob. The actual mechanics of the reencrypt operation is modified by TMapConKFrags since kFrags would not be stored by Ursula.

Slight modification to original design of function - #2667 (comment) ('work_order' -> 'work_order_payload')

Request

{
    "ursula": <checksum_address>,
    "work_order_payload": <bytes encoded as base64>
}

Response

{
    "result": {
        "work_order_result": <bytes encoded as base64>
    }
}

Issues fixed/closed:
Related to #2704
Closes #2667

Notes for reviewers:
Based over #2733 .

RestMiddleware.send_work_order_payload_to_ursula() will be changed by TMapConKfrags to not require an associated arrangement id, so there is currently a stub for that function until TMapConKFrags gets merged. Therefore, actually trying to use the endpoint at the moment will not work properly.

@derekpierre derekpierre added Web Webpages Bob 👨‍💼 Effects the "Bob" development area labels Jun 25, 2021
@derekpierre derekpierre added this to the Porter v1 (MVP) milestone Jun 25, 2021
@derekpierre derekpierre requested a review from KPrasch June 25, 2021 14:34
@derekpierre derekpierre self-assigned this Jun 25, 2021
@derekpierre derekpierre force-pushed the exec-work-order branch 2 times, most recently from d4f3a82 to 220bbba Compare June 25, 2021 17:05
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.

General high-level question: What made you decide to go with exec_work_order instead of retrieve?

@derekpierre
Copy link
Copy Markdown
Member Author

derekpierre commented Jun 28, 2021

General high-level question: What made you decide to go with exec_work_order instead of retrieve?

Traditionally "retrieve" was defined by Bob.retrieve (at least in the Python API/CLI) and it involved a series of steps including:

  1. Getting the treasure map (probably no more with TMapConKFrags)
  2. Processing the treasure map to obtain ursulas, and construct work orders
  3. Sending work orders to ursula(s) to obtain cfrags
  4. Attaching the returned cfrags to the capsule
  5. Decrypting the data to obtain the cleartext

I viewed this as a single step in that process and did not want to confuse it with being the entire "retrieve" process.

One additional thought I had with this endpoint was the ability for exec_work_order to possibly generalize to any functionality, although I'm uncertain of the feasibility since these may/may not be different characters:

This can potentially be extended for additional functionality under the guise of a generalized WorkOrder (perhaps?). It could be more of an Ursula do something you know how to do (DKG, TSS, etc.) with the relevant WorkOrder sub-type provided.

(See #2667 (comment))

wdyt?

@derekpierre derekpierre force-pushed the exec-work-order branch 2 times, most recently from 0f1206e to f24b3e1 Compare July 2, 2021 18:26
@derekpierre derekpierre force-pushed the exec-work-order branch 3 times, most recently from c09355f to 087c800 Compare July 12, 2021 18:34
@derekpierre derekpierre changed the title [WIP] Porter implementation of /exec_work_order (affected by TMapConKFrags) Porter implementation of /exec_work_order (affected by TMapConKFrags) Jul 12, 2021
@derekpierre derekpierre marked this pull request as ready for review July 12, 2021 18:56
@derekpierre
Copy link
Copy Markdown
Member Author

derekpierre commented Jul 12, 2021

Unsure why test_policy_simple_sinpa is failing - perhaps someone can point me in the right direction - perhaps I missed something with the original TMapConKFrag rebase. Same issue in porter branch - https://app.circleci.com/pipelines/github/nucypher/nucypher/8150/workflows/8130953c-39e3-4906-bca5-39d5ee05c720/jobs/138062.

@derekpierre derekpierre changed the title Porter implementation of /exec_work_order (affected by TMapConKFrags) Porter implementation of /exec_work_order (associated with TMapConKFrags for /reencrypt endpoint) Jul 12, 2021
@derekpierre derekpierre changed the title Porter implementation of /exec_work_order (associated with TMapConKFrags for /reencrypt endpoint) Porter implementation of /exec_work_order (associated with TMapConKFrags for /reencrypt endpoint) Jul 12, 2021
Copy link
Copy Markdown
Contributor

@piotr-roslaniec piotr-roslaniec left a comment

Choose a reason for hiding this comment

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

LGTM 👍



class WorkOrder(BaseField, fields.Field):
class WorkOrder(Base64BytesRepresentation):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I love this

… about url encoding in docs.

Add unit test for Base64BytesRepresentation field.
Cleanup imports.
If URL parameters are used for the ``/publish_treasure_map`` endpoint instead of JSON data, the request will fail because the URL becomes too long.
.. code:: bash

curl -X POST "<PORTER URI>/publish_treasure_map?treasure_map=Qld7S8sbKFCv2B8KxfJo4oxiTOjZ4VPyqTK5K1xK6DND6TbLg2hvlGaMV69aiiC5QfadB82w%2F5q1Sw%2BSNFHN2e ...&bob_encrypting_key=026d1f4ce5b2474e0dae499d6737a8d987ed3c9ab1a55e00f57ad2d8e81fe9e9ac"
Copy link
Copy Markdown
Member Author

@derekpierre derekpierre Jul 14, 2021

Choose a reason for hiding this comment

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

@piotr-roslaniec / @vepkenez - it turns out that I am able to execute /publish_treasure_map with URL parameters using the python requests library even though the URL is long (~3000 characters) - the problem was the treasure_map value not being URL encoded 🤦 . Made a note about URL encoding in the docs, and that it is tool dependent.

@derekpierre derekpierre merged commit e68eefe into nucypher:porter Jul 14, 2021
derekpierre added a commit that referenced this pull request Jul 26, 2021
Porter implementation of `/exec_work_order` (associated with TMapConKFrags for `/reencrypt` endpoint)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants