p2panda Framework

repository·main·Indexed 19 days ago

https://github.com/p2panda/p2panda

A modular framework for building secure, privacy-respecting, local-first applications across diverse communication mediums, including standard internet protocols, LoRa, and BLE. The ecosystem includes p2panda-core for secure distributed data types, p2panda-auth for decentralized group management with DAG-based concurrency resolution, p2panda-encryption for data and message encryption using 2SM and HPKE, p2panda-discovery for confidential topic-based peer discovery via PET/PSI, and p2panda-blobs for content-addressed networked blob storage.

Tokens
89.7K
Snippets
269
Records
364
Agent score
67%

What's inside p2panda

  1. Overview of p2panda-stream

    main

    p2panda-stream provides interfaces for implementing and composing event processors on top of p2p data streams. It includes out-of-the-box implementations that wrap existing p2panda crates to provide features like:

    • Causal message ordering
    • Log validation
    • Access control
    • Group encryption CRDTs

    These capabilities are designed to assist in building various peer-to-peer applications.

    ⚠️ Note on Stability: This library is under active development. APIs are not yet considered stable for production use, and breaking changes to core data types and user-facing APIs may occur before the v1.0.0 release.

  2. Overview of p2panda-store

    main

    The p2panda-store crate provides generic trait definitions for storage and query behavior designed for peer-to-peer systems. It is used to manage various data types such as node address books, append-only logs, and operation dependencies.

    Key capabilities include:

    • Generic Traits: Flexible definitions for implementing different types of p2p stores.
    • SQLite Implementations: Concrete implementations for common p2panda stores, including:
      • Address book: Managing node transport information.
      • Cursors: Tracking positions in logs.
      • Groups: Maintaining authentication group state.
      • Logs: Efficient comparison of log-based data types.
      • Operations: Storing entries in append-only logs.
      • Orderer: Tracking dependencies in partially-ordered data sets.
    • Transaction Provider: Enables grouping related queries to ensure atomicity and consistency.
    • Database Migrations: Supports migrations during store creation or at runtime.

    ⚠️ Note: This library is under active development. APIs are not yet stable for production use and may undergo breaking changes before v1.0.0.

  3. Overview of p2panda-discovery

    main

    The p2panda-discovery library is a confidential topic and node discovery protocol. It allows nodes to find other peers that share a common interest in a specific 'topic' without leaking that topic to unintended actors.

    Key Concepts

    • Topics: A topic is a secret, randomly-generated hash that acts as a shared symmetric key. It serves as an identifier or namespace for data (e.g., a chat group or document). Warning: Topics must never be leaked to anyone outside the intended group.
    • Privacy via PET/PSI: To prevent topic leakage, the protocol uses Private Equality Testing (PET) or Private Set Intersection (PSI). This cryptographic technique ensures that nodes only exchange transport information and establish peer-to-peer connections after both parties have proven knowledge of the same topic without revealing the topic itself to unauthorized parties.
    • Transport Exchange: During the discovery process, nodes exchange transport information to facilitate the establishment of direct peer-to-peer connections.

    🚧 Note: This library is under active development. APIs and core data types are not yet stable and may undergo breaking changes before the v1.0.0 release.

  4. Overview of p2panda

    main

    p2panda is a modular framework designed for building modern, privacy-respecting, and secure local-first applications. It is built to support offline-first guarantees and is compatible with a wide range of communication infrastructures, from the internet to post-internet technologies like Bluetooth Low Energy (BLE), LoRa, packet radio, and USB sticks.

    Key characteristics:

    • Modular Design: Developers can pick and choose specific crates to avoid framework lock-in.
    • Data Agnostic: Many Rust crates operate over raw bytes, making them compatible with custom data types and any CRDT.
    • Resilient: Designed for collaboration, encryption, and access control even over unstable or ephemeral connections.
    • Broadcast-only Core: The architecture is optimized for data that can be propagated via broadcast-style communication.
  5. Overview of p2panda-blobs

    main

    The p2panda-blobs crate provides a networked blob store designed for streaming content-addressed blobs between peers. It enables users to import, export, and download blobs across a network.

    Key features include:

    • Content-addressed storage: Blobs are identified by their content.
    • Streaming: Supports streaming content between peers.
    • Persistence options: Provides both in-memory and filesystem-based persistence mechanisms.

    ⚠️ Note: This library is under active development. APIs are not yet stable for production use, and breaking changes to core data types and user-facing APIs may occur before the v1.0.0 release.

  6. Overview of p2panda-spaces

    main

    p2panda-spaces provides an API for establishing and managing encryption contexts within dynamic groups of actors. It is designed to support data encryption for groups and multiple devices.

    Key capabilities include:

    • Decentralized group key agreement with forward secrecy.
    • Encrypted messaging with post-compromise security.
    • Decentralized group management with conflict resolution.
    • Private space identifiers.
    • Support for nested groups (useful for modeling multi-device profiles).
    • Ability to reuse groups across different encryption boundaries.
    • Genericity over message types.

    Note: This library is under active development. APIs are not yet stable, and breaking changes may occur before the v1.0.0 release.

  7. Overview of p2panda-core features

    main

    p2panda-core provides extensible, secure, and distributed data types designed for efficient data exchange across various networking scenarios (from the internet to LoRa or BLE).

    Key capabilities include:

    • Security: Cryptographic signatures for authorship verification and tamper-proof messages.
    • Data Structure: An append-only implementation supporting history deletion, multi-writer ordering, fork-tolerance, and efficient partial sync.
    • Flexibility: Compatible with any application data, CRDTs, and various ordering algorithms.
    • Extensibility: Supports custom features like prefix-deletion or ephemeral 'self-destructing' messages via extensions.
    • Network Agnostic: Works in broadcast-only environments (e.g., packet radio).
  8. Overview of p2panda-sync

    main

    p2panda-sync provides data-type agnostic interfaces for implementing sync protocols and managers. It is designed for building local-first synchronization systems, either as standalone components or integrated into the p2panda-net stack.

    Key capabilities include:

    • Implementing two-party sync protocols over Sink / Stream pairs using the Protocol trait.
    • Orchestrating concurrent sync sessions using the Manager trait.
    • Using concrete implementations for syncing over p2panda append-only logs (available in the manager and protocols modules).

    Note: This library is under active development. APIs are not yet stable for production use and may undergo breaking changes before v1.0.0.

  9. Core Features of p2panda-net

    main

    p2panda-net provides a suite of modules for peer-to-peer networking and local-first application requirements. Key capabilities include:

    • Gossip Protocol: Publish & Subscribe for ephemeral messages.
    • Sync Protocol: Publish & Subscribe for messages with Eventual Consistency guarantees.
    • Private Set Intersection: Confidentially discover nodes interested in the same topic.
    • Direct Connections: Establish and manage connections over the Internet using iroh.
    • Supervision Trees: Erlang-inspired monitoring to restart modules on critical failure.
    • Modular API: Allows users to choose or replace specific layers of the networking stack.
  10. How to implement sync protocols and managers in p2panda-sync

    main

    To build custom synchronization logic, you can leverage two primary abstractions:

    1. Protocol trait: Use this to implement two-party sync protocols. The protocol operates over a Sink and Stream pair.
    2. Manager trait: Use this to instantiate and orchestrate multiple concurrent sync sessions.

    If you are looking for a high-level entry point for local-first development, it is recommended to use p2panda-net instead. p2panda-sync is intended for developers who need to integrate their own base convergent data-types and custom sync protocols into the p2panda stack.

  11. Understand p2panda-auth access levels and permissions

    main

    The p2panda-auth crate provides decentralized, offline-first group management. It uses a hierarchy of access levels to define member permissions. Each access level is a superset of the levels below it and can be associated with specific conditions (e.g., restricting access to a specific path in a dataset).

    Access Levels:

    • Pull: Lowest level access.
    • Read: Includes Pull capabilities. Can be restricted via conditions.
    • Write: Includes Read capabilities.
    • Manage: Highest level. Only members with Manage access can modify the group state (adding, removing, promoting, or demoting members).

    These levels can be used to control data replication in custom sync protocols, determining who can sync with whom and over which subsets of data.

  12. How key agreement works in p2panda-encryption

    main

    To encrypt data for a group, members must first agree on a secret key using a key agreement protocol. p2panda-encryption uses the Two-Party Secure Messaging (2SM) protocol.

    Key Components:

    • Key Bundles: Peers publish bundles containing identity keys and pre-keys to the network. These are used by others to invite them into encrypted groups.
    • Initial Round (X3DH): The initial key agreement uses X3DH. For strong security, it is recommended to use one-time pre-keys. Using long-term pre-keys is possible but relies on the application to define their lifetime for forward secrecy.
    • Subsequent Rounds (HPKE): Every subsequent 2SM round uses HPKE, where exactly one secret key is used and then immediately dropped and replaced by a new key-pair. This provides strong forward secrecy for each round independently of the initial pre-keys.
    • Efficiency: The 2SM protocol is optimized for decentralized systems, allowing a group to learn a new secret (e.g., after a member removal) in O(n) steps, where n is the number of members.