Skip to main content

Crate web4_core

Crate web4_core 

Source
Expand description

§Web4 Core Library

Trust-native distributed intelligence infrastructure implemented in Rust.

This crate provides the foundational primitives for Web4:

  • LCT (Linked Context Token): Non-transferable presence tokens
  • T3 (Trust Tensor): 3 root dimensions (Talent/Training/Temperament), fractally extensible via RDF sub-dimensions
  • V3 (Value Tensor): 3 root dimensions (Valuation/Veracity/Validity), same fractal RDF pattern as T3
  • Coherence: Identity coherence scoring (C * S * Phi * R)
  • Crypto: Ed25519 cryptographic operations

§Quick Start

use web4_core::{Lct, EntityType, T3, TrustDimension};

// Create an LCT for a human user
let (lct, keypair) = Lct::new(EntityType::Human, None);

// Sign a message
let message = b"Hello, Web4!";
let signature = keypair.sign(message);

// Verify the signature
assert!(lct.verify_signature(message, &signature).is_ok());

// Create a trust tensor and record observations
let mut trust = T3::new();
trust.observe(TrustDimension::Talent, 0.9).unwrap();
trust.observe(TrustDimension::Training, 0.85).unwrap();

// Get aggregate trust score
let score = trust.aggregate();

§Design Philosophy

Web4 implements trust as a first-class primitive, not an afterthought. Every identity is cryptographically bound, every interaction is witnessed, and trust accumulates through demonstrated behavior over time.

Key principles:

  • Non-transferable identity: LCTs cannot be sold, stolen, or faked
  • Fractal trust: 3 root dimensions extensible via web4:subDimensionOf
  • Coherence requirements: Entities must maintain identity coherence
  • Hardware binding: Production deployments bind keys to secure hardware

Re-exports§

pub use act::Act;
pub use act::ActAddress;
pub use act::ActOutcome;
pub use act::ConsequenceClass;
pub use act::MrhDirection;
pub use act::SubstanceMedium;
pub use act::SubstanceRef;
pub use atp::ATPAccount;
pub use atp::TransferResult;
pub use coherence::check_coherence;
pub use coherence::coherence_threshold_for_entity;
pub use coherence::Coherence;
pub use coherence::CoherenceCalculator;
pub use coherence::CoherenceEvent;
pub use coherence::CoherenceParams;
pub use crypto::sha256;
pub use crypto::sha256_hex;
pub use crypto::KeyPair;
pub use crypto::PublicKey;
pub use crypto::SignatureBytes;
pub use error::Result;
pub use error::Web4Error;
pub use lct::EntityType;
pub use lct::HardwareBinding;
pub use lct::Lct;
pub use lct::LctBuilder;
pub use lct::LctStatus;
pub use ledger::InMemoryLedger;
pub use ledger::Ledger;
pub use ledger::LedgerEntry;
pub use ledger::LedgerEvent;
pub use ledger::LedgerProof;
pub use ledger::LocalLedger;
pub use ledger::MintReceipt;
pub use r6::ActionResult;
pub use r6::ActionRole;
pub use r6::ActionStatus;
pub use r6::R7Action;
pub use r6::ReputationDelta;
pub use r6::Request;
pub use r6::ResourceRequirements;
pub use r6::Rules;
pub use delegation::DelegatedAuthority;
pub use delegation::DelegationScope;
pub use did::DidDocument;
pub use did::DidDocumentMetadata;
pub use did::ServiceEndpoints;
pub use did::did_web4;
pub use did::parse_did_web4;
pub use role::RoleAssignment;
pub use role::RoleEvent;
pub use role::RoleEventKind;
pub use role::SocietyRole;
pub use role_extension::Affordance;
pub use role_extension::AtpBudget;
pub use role_extension::DriftMark;
pub use role_extension::ExtensionVerdict;
pub use role_extension::LintVerdict;
pub use role_extension::Responsibility;
pub use role_extension::RoleEntity;
pub use role_extension::RoleExtension;
pub use role_extension::RoleRegistry;
pub use role_extension::Scope;
pub use sd_jwt_vc::SdJwtVc;
pub use sd_jwt_vc::UnsignedSdJwtVc;
pub use sd_jwt_vc::VerifiedCredential;
pub use sd_jwt_vc::verify_issuer;
pub use sd_jwt_vc::verify_presentation;
pub use sd_jwt_vc::present;
pub use sd_jwt_vc::web4_presence_credential;
pub use society::MetabolicState;
pub use society::Society;
pub use vault::Vault;
pub use vault::VaultContents;
pub use vault::Document;
pub use vault::ItemRef;
pub use vault::Protection;
pub use t3::TrustDimension;
pub use t3::TrustObservation;
pub use t3::TrustRelation;
pub use t3::T3;
pub use t3::T3_DIMENSIONS;
pub use time::Criticality;
pub use time::Deadline;
pub use time::DeadlineOutcome;
pub use time::TemporalImpact;
pub use time::Timing;
pub use time::WitnessAvailability;
pub use v3::TrustValueScore;
pub use v3::ValueDimension;
pub use v3::ValueObservation;
pub use v3::V3;
pub use v3::V3_DIMENSIONS;

Modules§

act
Acts: the unifying primitive for memory, forum posts, and handoffs
atp
ATP/ADP — Allocation Transfer / Discharge Packets
coherence
Identity Coherence Implementation
crypto
Cryptographic primitives for Web4
delegation
Delegated Authority — binding a delegator to an agent with scoped permissions.
did
did:web4 — the W3C DID interop face of an LCT.
error
Error types for web4-core
event
Events: R6/R7 as a wait-on-event-with-timeout
lct
Linked Context Token (LCT) Implementation
ledger
Ledger
oid4vc
OpenID4VCI / OpenID4VP protocol types + reference flows (EUDI Phase 2).
pair_channel
PAIRED-CHANNELS Sprint E: end-to-end encryption for LCT pair messages.
prelude
Prelude module for convenient imports
r6
R6/R7 Action Framework
role
Society Roles — the 7 base-mandatory roles per society-roles.md.
role_extension
Role-extension entities — the Rust representation of the canonical web4-standard/ontology/role-extension.ttl schema (Phase-0 concord, #486), plus role-LCT issuance and a registry. This is the web4-core/schema half of the Hestia role-orchestration PRD: it turns an orchestration role from a bare string into a first-class EntityType::Role LCT entity carrying its law extension (affordances / responsibilities / scope), so a role born from a migrated launcher and a role defined via the hub UI are the same entity.
sd_jwt_vc
SD-JWT-VC issuance — Web4 attestations as selectively-disclosable Verifiable Credentials (EUDI / IETF interop, Phase 1).
society
Society — a self-sovereign Web4 entity with roles, citizens, and ATP.
t3
Trust Tensor (T3) Implementation
time
Time as a first-class web4 axis (the temporal twin of ATP)
v3
Value Tensor (V3) Implementation
vault
Recursive in-memory vault

Constants§

VERSION
Library version