Skip to content

Conversation

sandreae
Copy link
Member

@sandreae sandreae commented Jul 28, 2025

🔬 PR is an experimental integration and not meant to be merged.

This is an "proof of concept" integration of the new, in-progress p2panda-spaces crate, which brings access control and group encryption into Reflection.

Documents are "spaces" now, allowing "managers" to add and remove other members into the space, assigning read, write and manage permissions. Every delta or snapshot operation is encrypted towards the shared secrets inside that space and sent to every other peer. When they're part of the space they're able to decrypt the payload and apply it to the Loro CRDT.

Things will likely change a bit until we're integrating this for real, this serve as a playground to explore the API and identify potential refactorings.

How to use this

Since we're not having any UI yet to handle user identities (address book etc.) and to add them to a document (give read / write / admin access) we're hard-coding private keys and the regarding key bundles (for encryption) in this POC.

There are two existing identities: "alice" and "bob". Set the SPACES_PEER_ID env var in org.p2panda.reflection.json to either of them for two Reflection instances to try out sending encrypted messages inside of an "space" to each other.

Known Issues

We've identified a couple of shortcomings with the current spaces API which will be reflected in future work (see TODOs in code), otherwise there's a bunch of strange database constraint errors happening, likely because of us messing with the storage layer a bit. They don't seem to affect the encryption and collaborative editing of documents, so we've decided to ignore these errors for now.

@adzialocha adzialocha force-pushed the basic-spaces-integration branch from aa2b3eb to 4b14d5a Compare July 29, 2025 11:57
@adzialocha adzialocha changed the title Basic p2panda-spaces integration Experimental p2panda-spaces integration (not to be merged) Jul 29, 2025
Users of the `p2panda-spaces` API should not need to pull in more
dependencies than necessary.
@adzialocha adzialocha force-pushed the basic-spaces-integration branch from 4ed5c95 to 43f341f Compare July 29, 2025 13:20
* Store operations outside of the forge, for this i've introduced an
  `insert_operation` method
* We didn't persist the "create message" yet (for sync), this is fixed now
* Write everything into one log as we don't have an orderer yet (which
  would help with getting a partial ordering on top of multiple logs)
To run the demo users need to set the SPACES_PEER_ID to "alice" on one,
and to "bob" on the other peer.
Space ids are actor ids which again are public keys. We use the gossip
overlay to learn about changes around a topic, which can be both a space
id or the network-wide gossip overlay. The latter is not a public key,
this is why the conversion fails (due to an invalid edwards point).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants