WeaveDocs
Weave Sdk

Identity and Messaging

Identity and messaging in the Weave SDK — keypair lifecycle, signed messages, and peer-to-peer encrypted channels.

Purpose

Application SDK for identities, drives, stores, messaging, replication, and peer networking.

This page follows the real source shape for Weave Sdk and explains the workflow a developer is likely to use first.

Trust contract

Document which keys authorize the operation, what is signed, what is encrypted, what is deliberately public, and which policy hook can deny the call. Security examples should use deterministic test vectors where possible.

Primary types to know

  • AgentMessage — libs/weave-sdk/src/messaging.rs
  • BasisStore — libs/weave-sdk/src/node.rs
  • ConnectedPeer — libs/weave-sdk/src/network_manager.rs
  • DriveAcl — libs/weave-sdk/src/visibility.rs
  • DriveInfo — libs/weave-sdk/src/drive_manager.rs
  • DriveManager — libs/weave-sdk/src/drive_manager.rs
  • ForumStore — libs/weave-sdk/src/node.rs
  • GnosisStore — libs/weave-sdk/src/node.rs
  • LensStore — libs/weave-sdk/src/node.rs
  • LocusStore — libs/weave-sdk/src/node.rs
  • MessagingManager — libs/weave-sdk/src/messaging.rs
  • NetworkConfig — libs/weave-sdk/src/network_manager.rs

Example shape

use weave_sdk::messaging::AgentMessage;
use weave_sdk::prelude::*;

#[tokio::main]
async fn main() -> WeaveResult<()> {
    // Each node carries a WeaveIdentity whose Ed25519 key signs both strand
    // blocks and AgentMessages.
    let node = WeaveNode::builder()
        .namespace("l1fe")
        .identifier("messaging-demo")
        .storage_dir("/tmp/weave-messaging")
        .build()
        .await?;

    let identity = node.identity();
    let did = identity.did().to_string();

    // Sign and verify a payload through the same key that publishes strand events.
    let payload = b"audit:replay-required";
    let signature = identity.sign(payload);
    identity.verify(payload, &signature)?;

    // Construct an AgentMessage targeted at a topic; this is the wire frame the
    // messaging layer sends between nodes.
    let message = AgentMessage::new(identity, "audit", payload.to_vec());
    let _ = message.payload.len();
    println!(
        "did={} discovery_key={} message_topic={}",
        did,
        hex::encode(identity.discovery_key()),
        message.topic,
    );
    Ok(())
}