Skip to content

Commit 2a5b3ae

Browse files
committed
Progress developer docs
1 parent b80a343 commit 2a5b3ae

20 files changed

Lines changed: 48 additions & 43 deletions

TODO

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,6 @@ TODO: Avoid usage: __main__.py in --help output for client / hub
7373
TODO: Add site map to Google Search Console
7474

7575
TODO: Consistently use httpx for client side (not requests for synchronous calls)
76+
77+
TODO: Do we really need the allocated / consumed distinction? Can't we simply return the fragment
78+
to the block if an error occurs?

docs/developer-guide.md

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ The code technology stack includes:
2626
* [FastAPI](https://www.python.org/) for server-side HTTP APIs.
2727
* [HTTPX](https://www.python-httpx.org/) for client-side HTTP APIs.
2828
* [Uvicorn](https://uvicorn.dev/)as the ASGI (synchronous Server Gateway Interface) web server.
29-
* [Git](https://git-scm.com/) and [Github](https://github.com/brunorijsman/dske-python) for version control.
3029

3130
The development toolchain includes:
31+
* [Git](https://git-scm.com/) and [Github](https://github.com/brunorijsman/dske-python) for version control.
3232
* [Github actions](https://github.com/features/actions) for continuous integration.
3333
* [Pylint](https://pypi.org/project/pylint/) for linting.
3434
* [Black](https://black.readthedocs.io/) for code formatting.
@@ -37,15 +37,6 @@ The development toolchain includes:
3737
* [Venv](https://docs.python.org/3/library/venv.html) for virtual environments.
3838
* [Markdown](https://en.wikipedia.org/wiki/Markdown) for documentation.
3939

40-
## DSKE protocol
41-
42-
The Distributed Symmetric Key Establishment (DSKE) implementation in this repository is based on
43-
IETF draft
44-
[draft-mwag-dske-02](https://datatracker.ietf.org/doc/draft-mwag-dske/02/).
45-
It has been developed completely independently of the authors of the draft, based only on the public
46-
information in the draft.
47-
See [the DSKE protocol page](dske-protocol.md) for more details.
48-
4940
## Proof of concept
5041

5142
The code is intended to be a proof-of-concept to study the DSKE protocol; it is not
@@ -103,28 +94,27 @@ Here we provide a summary of the API endpoints and their purpose.
10394

10495
The API endpoints belong to one of the following groups:
10596

106-
| Endpoint path | Purpose |
97+
| API endpoint URL | Purpose |
10798
|-|-|
10899
| `.../dske/...` | DSKE protocol. |
109100
| `.../dske/oob/...` | The out-of-band (OOB) portion of the DSKE protocol. |
110101
| `.../dske/api/...` | The in-band portion of the DSKE protocol. |
111-
| `../mgmt/...` | Used for management. Since this code is not intended for production deployment, these endpoints are also not authenticated. |
102+
| `../mgmt/...` | Used to manage the nodes. |
112103

113104
All API endpoints include the node type and the node name at the start of the URL path.
114105
For example:
115106

116-
| Node type | URL prefix |
107+
| Node type | API endpoint URL |
117108
|-|-|
118-
| PUT | `/hub/HUB_NAME/...` |
119-
| GET | `/client/CLIENT_NAME/...` |
120-
121-
Currently, this is not really necessary for anything, since each node runs in its own process
122-
on a different HTTP port.
123-
But we anticipate that we (or someone else) may run this code as a cloud-based service at some
124-
point in the future (similar to what we did with
125-
[QuKayDee](https://qukaydee.com) for QKD).
126-
In that case, the cloud-based service would expose only a single HTTP port, and some proxy
127-
(e.g [Nginx](https://nginx.org/)) would use URL-based routing to dispatch each request to the
109+
| Hub | `/hub/HUB_NAME/...` |
110+
| Client | `/client/CLIENT_NAME/...` |
111+
112+
Including the node name in the URL is currently not really necessary since each node runs in its
113+
own process on a different HTTP port.
114+
But if this code is run as a cloud-based service (similar to
115+
[QuKayDee](https://qukaydee.com)
116+
for QKD) sitting behind a proxy
117+
(e.g [Nginx](https://nginx.org/)) we can use URL-based routing to dispatch each request to the
128118
correct node process.
129119

130120
All API endpoints are versioned (currently `v1`).
@@ -164,8 +154,8 @@ using the authentication mechanism described in the
164154
[protocol guide](protocol-guide.md)
165155

166156
The out-of-band DSKE protocol API endpoints (`.../dske/oob/...`) are not authenticated.
167-
They only exist to simulate actions that would be some secure out-of-band physical distribution
168-
mechanism in real life for the purpose of automated testing.
157+
They only exist for the purpose of automated testing, simulating actions that would be some
158+
secure out-of-band physical distribution mechanism in real life.
169159

170160
The management API endpoints (`../mgmt/...`) are also not authenticated because this implementation
171161
is not intended for production deployment.
@@ -175,26 +165,30 @@ we only implement a simplified subset of the
175165
[ETSI QKD 014](https://www.etsi.org/deliver/etsi_gs/QKD/001_099/014/01.01.01_60/gs_qkd014v010101p.pdf)
176166
key delivery interface.
177167

178-
TODO Continue from here
179-
180168
## Pre-Shared Random Data (PSRD) management
181169

182170
Pre-Shared Random Data (PSRD) is a central concept in DSKE.
183171
This section summarizes how PSRD is implemented in the code.
184172

173+
PSRD management is implemented using the classes `Block`, `Pool`, `Fragment`, and `Allocation`.
174+
We describe each of these classes below.
175+
The relationship between these classes are shown in the following figure:
176+
177+
![PSRD Management Classes](figures/psrd-management-classes.png)
178+
185179
### Class `Block`
186180

187-
The class `Block` represents a block PSRD bytes that the hub sends to the client.
188-
The hub sends the block to the client using some secure out-of-band mechanism;
189-
in our code this mechanism is represented by the `.../dske/oob/v1/psrd` REST interface endpoint.
181+
The class `Block` represents a block of PSRD bytes that the hub sends to the client.
182+
183+
A client requests one block of PSRD from the hub sending a GET request to the
184+
`/hub/HUB_NAME/dske/oob/v1/psrd` API endpoint.
190185

191186
The `Block` class has the following attributes:
192187

193188
| Attribute | Type | Purpose |
194189
|-|-|-|
195190
| block_uuid | UUID | Uniquely identifies the block. |
196191
| size | int | Size of the block in bytes. |
197-
| owned | bool | True is the block is owned: it is possible to both allocate and consume fragments from this block. False if the block is not owned: it is not possible to locally allocate fragments; it is only possible to consume fragments that have been allocated by the peer node. The concept of ownership is described in more detail below. |
198192
| data | bytes | The bytes in the block. |
199193
| allocated | bitarray | A bit for each byte in the block to indicate whether the byte is allocated. |
200194
| consumed | bitarray | A bit for each byte in the block to indicate whether the byte is consumed. |
@@ -205,18 +199,28 @@ The state of each byte in the block is described by the following Finite State M
205199

206200
When the block is created, each byte is unallocated.
207201

208-
The code can locally allocate bytes from the block.
209-
A contiguous sequence of bytes allocated from a block is called a fragment.
202+
A node can have multiple blocks, organized into pools.
203+
A pool is represented by the `Pool` class.
204+
205+
A node may need to allocate some bytes from a pool for the purpose of allocating an encryption
206+
key to encrypt an outgoing message to a signing key to sign an outgoing message.
207+
Such an allocation of bytes is represented by the `Allocation` class.
208+
209+
When allocation is created, one or more blocks are selected to allocate the bytes from.
210+
A contiguous sequence of bytes within a block that is assigned to an allocation is called
211+
a fragment and represented by the `Fragment` class.
212+
An allocation may span multiple blocks and hence consist of multiple fragments.
210213

211-
Bytes that have been allocated can be consumed. The byte value used to encrypt or authenticate
212-
a key share. The byte in the block is zeroed out.
214+
Allocating bytes from a block is a two step process.
213215

214-
It is also possible to consume bytes that have not been _locally_ allocated from a block.
215-
This happens when the bytes have been _remotely_ allocated by the peer node, and the allocated
216-
fragment is communicated through the DSKE protocol.
216+
First the bytes are _allocated_ which means that they are assigned to an allocation.
217217

218-
Under circumstances the code can return an allocated byte to the block without consuming it.
219-
This is called deallocating the byte. Once a byte has been consumed, it can no longer be deallocated.
218+
Then the allocated bytes are _consumed_ which means that the allocated bytes are taken out of
219+
the block and erased in the block.
220+
221+
A byte which has been allocated but not yet consumed can be deallocated.
222+
223+
TODO: CONTINUE FROM HERE
220224

221225
### Class `Fragment`
222226

@@ -235,8 +239,6 @@ The `Fragment` class has the following attributes:
235239

236240
The relationship between a block and its fragments in shown in the following figure:
237241

238-
![Relation between block and fragments](figures/block-and-fragments.png)
239-
240242
### The concept of block ownership
241243

242244
When a hub and a client share a block of Pre-Shared Random Data (PSRD) there is a `Block` object
-63 KB
Binary file not shown.

docs/figures/block-fsm.png

0 Bytes
Loading
0 Bytes
Loading

docs/figures/convert-powerpoint-to-png

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ mv figures-8.png message-signing.png
2929
mv figures-9.png ladder-diagram-startup.png
3030
mv figures-10.png ladder-diagram-get-key.png
3131
mv figures-11.png block-fsm.png
32-
mv figures-12.png block-and-fragments.png
32+
mv figures-12.png psrd-management-classes.png

docs/figures/figures-13.png

61.2 KB
Loading

docs/figures/figures.pdf

27.3 KB
Binary file not shown.

docs/figures/figures.pptx

13.8 KB
Binary file not shown.
0 Bytes
Loading

0 commit comments

Comments
 (0)