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.rsBasisStore— libs/weave-sdk/src/node.rsConnectedPeer— libs/weave-sdk/src/network_manager.rsDriveAcl— libs/weave-sdk/src/visibility.rsDriveInfo— libs/weave-sdk/src/drive_manager.rsDriveManager— libs/weave-sdk/src/drive_manager.rsForumStore— libs/weave-sdk/src/node.rsGnosisStore— libs/weave-sdk/src/node.rsLensStore— libs/weave-sdk/src/node.rsLocusStore— libs/weave-sdk/src/node.rsMessagingManager— libs/weave-sdk/src/messaging.rsNetworkConfig— 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(())
}