@@ -192,11 +192,16 @@ The `Block` class has the following attributes:
192192| data | bytes | The bytes in the block. |
193193| used | bitarray | A bit for each byte in the block to indicate whether the byte is used (allocated). |
194194
195+ Once data is used (allocated), it is copied to a ` Fragment ` object;
196+ the original data is zeroed out in the ` Block ` .
197+ In some rare circumstances (having to do with error handling) a ` Fragment ` object
198+ can be put back into a ` Block ` in which case the data is copied back.
199+
200+
195201### Class ` Pool ` ###
196202
197203The class ` Pool ` represents a pool of Pre-Shared Random Data (PSRD) from which the DSKE code
198204make do allocations (see class ` Allocation ` below).
199- Once data is allocated, it is zeroed out in the ` Pool ` .
200205Each pool has an owner (local or remote); the concept of pool ownership is explained below.
201206The pools implemented as a sequence of PSRD blocks (` Block ` objects).
202207
@@ -208,7 +213,6 @@ The `Pool` class has the following attributes:
208213| blocks | List[ Block] | A list of blocks in the pool. |
209214| owner | local or remote | The owner of the pool (explained below). |
210215
211-
212216### Class ` Fragment `
213217
214218The class ` Fragment ` represents a contiguous sequence of bytes within a block that have been
@@ -238,20 +242,38 @@ the `Allocation` class has the following attributes:
238242| -| -| -|
239243| fragments | List[ Fragment] | The list of fragments that the allocation is composed of. |
240244
241-
242245### The concept of block ownership
243246
244247When a hub and a client share a block of Pre-Shared Random Data (PSRD) there is a ` Block ` object
245248on the hub side and a ` Block ` object with the same random data on the client side.
246249The hub and the client use their blocks to allocate secrets that are shared with their peer.
247250These shared secrets are used for encryption and authentication of DSKE protocol messages.
248251
249- In the code, allocating a shared secret means creating an ` Allocation ` object.
250- This marks some bytes in some blocks as being allocated and consumed.
251- Sharing a secret means sending the some information about the ` Allocation ` object to the peer:
252- which bytes in which blocks have been allocated, but not the byte values themselves.
253- The peer then uses this information to create a corresponding ` Allocation ` object with
254- identical byte values.
252+ Both the client-side and the hub-side do allocate ` Allocation ` objects from ` Pool ` objects for
253+ the purpose of authenticating messages (HTTP requests and responses) and for encrypting key share
254+ data.
255+
256+ When one party sends a message to another party, the sender makes an allocation from it's local
257+ pool of PSRD.
258+ The sender uses the allocation to sign and possibly encrypt part of the message.
259+ The sender also sends the meta-data of the allocation to the receiver.
260+ does the allocation and sends
261+ When the receiver receives the meta-data, it allocates the exact same bytes from the
262+ receiver's copy of the PSRD.
263+ The receiver then uses the allocation to verify the signature and potentially decrypt part of
264+ the message.
265+
266+ In certain scenarios, there can be a race condition where the client and the hub both try to
267+ send a message at roughly the same time.
268+ Typically, the client sends a new HTTP request when the hub is still sending a response for
269+ the previous HTTP request.
270+ In such a race condition there is a risk of the client and the hub trying to allocate the exact
271+ same byte in the PSRD for two different purposes.
272+
273+ We introduced the concent of pool ownership to solve this problem.
274+ Each node has _ two_ pools: a locally owned pool and a pool owned by the peer.
275+ Each node always makes allocations from the locally owned pool for sent messages.
276+ And each node always makes allocations from the pool owned by the peer for received messages.
255277
256278## Message authentication
257279
@@ -260,9 +282,9 @@ it uses its own authentication and encryption mechanisms instead of relying on T
260282
261283In-band DSKE protocol messages are signed using PSRD data for authentication.
262284
263- The client signs outgoing HTTP request messages and the hub verifies the signature on incoming
285+ The _ client _ signs outgoing HTTP request messages and the hub verifies the signature on incoming
264286HTTP request messages.
265- The hub signs outgoing HTTP response message and the client verifies the signature on incoming
287+ The _ hub _ signs outgoing HTTP response message and the client verifies the signature on incoming
266288HTTP response messages.
267289
268290The sender of an HTTP message signs outgoing HTTP messages as follows:
0 commit comments