pub struct Lct {
pub id: Uuid,
pub entity_type: EntityType,
pub status: LctStatus,
pub public_key: PublicKey,
pub created_at: DateTime<Utc>,
pub created_by: Option<Uuid>,
pub hardware_binding: HardwareBinding,
pub parent_id: Option<Uuid>,
pub lineage_depth: u32,
}Expand description
Linked Context Token - the fundamental identity primitive
Fields§
§id: UuidUnique identifier
entity_type: EntityTypeEntity type
status: LctStatusCurrent status
public_key: PublicKeyPublic key for this LCT
created_at: DateTime<Utc>Creation timestamp
created_by: Option<Uuid>Creator’s LCT ID (None for root entities)
hardware_binding: HardwareBindingHardware binding information
parent_id: Option<Uuid>Parent LCT ID for hierarchical relationships
lineage_depth: u32Lineage depth (distance from root)
Implementations§
Source§impl Lct
impl Lct
Sourcepub fn new(entity_type: EntityType, created_by: Option<Uuid>) -> (Self, KeyPair)
pub fn new(entity_type: EntityType, created_by: Option<Uuid>) -> (Self, KeyPair)
Create a new LCT
Returns both the LCT and the keypair (which should be securely stored)
Sourcepub fn create_child(&self, entity_type: EntityType) -> (Self, KeyPair)
pub fn create_child(&self, entity_type: EntityType) -> (Self, KeyPair)
Create a child LCT under this parent
Sourcepub fn trust_ceiling(&self) -> f64
pub fn trust_ceiling(&self) -> f64
Get trust ceiling based on hardware binding
Sourcepub fn verify_signature(
&self,
message: &[u8],
signature: &SignatureBytes,
) -> Result<()>
pub fn verify_signature( &self, message: &[u8], signature: &SignatureBytes, ) -> Result<()>
Verify a signature from this LCT
Sourcepub fn fingerprint(&self) -> String
pub fn fingerprint(&self) -> String
Get the LCT fingerprint (short identifier for display)
Examples found in repository?
71fn main() -> ExitCode {
72 let (ledger_path, sidecar_path) = parse_args();
73
74 println!("[rust] Reading sidecar at {}", sidecar_path.display());
75 let sidecar_text = match fs::read_to_string(&sidecar_path) {
76 Ok(s) => s,
77 Err(e) => {
78 eprintln!("[rust] Could not read sidecar {}: {}", sidecar_path.display(), e);
79 eprintln!("[rust] Did you run `python mint.py` first?");
80 return ExitCode::from(2);
81 }
82 };
83 let sidecar: LctSidecar = match serde_json::from_str(&sidecar_text) {
84 Ok(s) => s,
85 Err(e) => {
86 eprintln!("[rust] Sidecar parse error: {}", e);
87 return ExitCode::from(2);
88 }
89 };
90 println!("[rust] lct_id = {}", sidecar.lct_id);
91 println!("[rust] fingerprint = {}", sidecar.fingerprint);
92
93 println!(
94 "[rust] Opening LocalLedger at {} (this replays + verifies the chain)",
95 ledger_path.display()
96 );
97 let ledger = match LocalLedger::open(&ledger_path) {
98 Ok(l) => l,
99 Err(e) => {
100 eprintln!("[rust] Ledger open failed: {}", e);
101 eprintln!("[rust] If this is a chain-integrity failure, the ledger was tampered.");
102 return ExitCode::from(3);
103 }
104 };
105 println!("[rust] Chain intact. {} entries replayed.", ledger.len());
106
107 let lct_uuid = match uuid::Uuid::parse_str(&sidecar.lct_id) {
108 Ok(u) => u,
109 Err(e) => {
110 eprintln!("[rust] Sidecar lct_id is not a UUID: {}", e);
111 return ExitCode::from(2);
112 }
113 };
114
115 let lookup = match ledger.lookup(lct_uuid) {
116 Ok(l) => l,
117 Err(e) => {
118 eprintln!("[rust] Ledger lookup failed: {}", e);
119 return ExitCode::from(3);
120 }
121 };
122 let lct = match lookup {
123 Some(lct) => lct,
124 None => {
125 eprintln!("[rust] LCT {} not present in ledger.", sidecar.lct_id);
126 return ExitCode::from(3);
127 }
128 };
129 println!("[rust] LCT present in ledger.");
130
131 if lct.fingerprint() != sidecar.fingerprint {
132 eprintln!(
133 "[rust] FINGERPRINT MISMATCH:\n sidecar: {}\n on-chain: {}",
134 sidecar.fingerprint,
135 lct.fingerprint()
136 );
137 return ExitCode::from(3);
138 }
139 println!("[rust] Fingerprint matches sidecar.");
140
141 let proof = match ledger.anchor(lct.id) {
142 Ok(p) => p,
143 Err(e) => {
144 eprintln!("[rust] anchor() failed: {}", e);
145 return ExitCode::from(3);
146 }
147 };
148 let verified = match ledger.verify_proof(&proof) {
149 Ok(v) => v,
150 Err(e) => {
151 eprintln!("[rust] verify_proof error: {}", e);
152 return ExitCode::from(3);
153 }
154 };
155 if !verified {
156 eprintln!("[rust] Anchor proof DID NOT verify under the Rust implementation.");
157 return ExitCode::from(3);
158 }
159 println!("[rust] Anchor proof verifies under the Rust implementation. ✓");
160 println!();
161 println!("[rust] Cross-language verification succeeded.");
162 println!(
163 "[rust] Python wrote a hash-chained ledger; Rust read the same file, replayed the chain, \
164 looked up the LCT by id, matched its fingerprint, and verified the inclusion proof — \
165 with zero shared runtime. The on-disk format is the contract."
166 );
167 ExitCode::SUCCESS
168}Sourcepub fn mint(&self, ledger: &mut dyn Ledger) -> Result<MintReceipt>
pub fn mint(&self, ledger: &mut dyn Ledger) -> Result<MintReceipt>
Anchor this LCT to a Ledger, recording the mint as a ledger entry.
Returns a MintReceipt with the entry hash and index. This
is the canonical creation path for production use — Lct::new() alone leaves
the LCT unanchored, which is fine for tests and prototyping but not for any
deployment where presence needs to be verifiable.
§Example
use web4_core::{Lct, EntityType, InMemoryLedger, Ledger};
let (lct, _kp) = Lct::new(EntityType::Human, None);
let mut ledger = InMemoryLedger::new();
let receipt = lct.mint(&mut ledger).unwrap();
assert_eq!(receipt.lct_id, lct.id);Sourcepub fn coherence_threshold(&self) -> f64
pub fn coherence_threshold(&self) -> f64
Check coherence requirements based on entity type
Returns the minimum coherence threshold for trust accumulation