earthstar-project / willow-js

A Willow Data Model, Sideloading, and General Purpose Sync protocol implementation in TypeScript.
https://willowprotocol.org
GNU Lesser General Public License v3.0
45 stars 3 forks source link

Private area intersection #13

Closed sgwilym closed 6 months ago

sgwilym commented 6 months ago

This PR makes the WgpsMessenger class capable of private area intersection.

Added a new PaiFinder class. When this class is given a read authorisation (e.g. a read capability or read capability + subspace capability), it is able to transform these into fragments and submit these for private set intersection. This class is also able to request and reply with subspace capabilities when the need arises.

Added a new HandleStore class. This class is able to bind data to handles, and provides the necessary primitives to safely free those handles (using reference counting) when needed.

Added a new GuaranteedQueue class. This can have bytes pushed onto it which are only emitted when the queue is given an amount of guarantees (in bytes) that the data can actually be accepted. It is also able to hear the pleas of foolish servers who guaranteed too many bytes, and always absolves them.

Added streaming decoding for all control and intersection messages, powered by a new GrowingBytes class (in willow-utils).

WgpsMessenger has been updated to coordinate the new intersection channel, intersection handle store, PaiFinder, initial read authorisations, and incoming messages.

Last but not least, test schemes have been unified so that all tests share the same (interoperable) parameters.