Crate p2panda_rs
source ·Expand description
p2panda-rs
This library provides all tools required to write a client for the p2panda network. It is
shipped both as a Rust crate p2panda-rs
with WebAssembly bindings and a NPM package
p2panda-js
with TypeScript definitions running in NodeJS or any modern web browser.
Example
Creates and signs data which can be sent to a p2panda node.
// Generate new Ed25519 key pair
let key_pair = KeyPair::new();
// Add field data to "create" operation
let operation = OperationBuilder::new(&profile_schema_id)
.fields(&[("username", "panda".into())])
.build()?;
// Encode operation into bytes
let encoded_operation = encode_operation(&operation)?;
// Create Bamboo entry (append-only log data type) with operation as payload
let entry = EntryBuilder::new()
.sign(&encoded_operation, &key_pair)?;
// Encode entry into bytes
let encoded_entry = encode_entry(&entry)?;
println!("{} {}", encoded_entry, encoded_operation);
Modules
- Common validation and API methods following the p2panda specification.
- High-level datatype representing data published to the p2panda network as key-value pairs.
- Create, sign, encode and decode
Bamboo
entries. - Generic structs which can be used for building a graph structure and sorting it’s nodes in a topological depth-first manner.
- Hash type of p2panda using BLAKE3 algorithm wrapped in
YASMF
“Yet-Another-Smol-Multi-Format”. - Generates and maintains Ed25519 key pairs with the secret and public (PublicKey) counterparts.
- Create, encode and decode p2panda operations.
- Schemas describe the format of data used in operation fields.
- Create and moderate large secret groups to maintain key material for secure messaging.
- Commonly used functions for serialization and deserialization of values.
- Storage provider traits needed for implementing custom p2panda storage solutions.
Traits
- Trait used by p2panda structs for human-facing functionality, like better readability.
- Trait used by p2panda structs to validate data formats.
- Trait used by p2panda structs which contain at least one id.