Skip to main content

Lct

Struct Lct 

Source
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: Uuid

Unique identifier

§entity_type: EntityType

Entity type

§status: LctStatus

Current status

§public_key: PublicKey

Public key for this LCT

§created_at: DateTime<Utc>

Creation timestamp

§created_by: Option<Uuid>

Creator’s LCT ID (None for root entities)

§hardware_binding: HardwareBinding

Hardware binding information

§parent_id: Option<Uuid>

Parent LCT ID for hierarchical relationships

§lineage_depth: u32

Lineage depth (distance from root)

Implementations§

Source§

impl Lct

Source

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)

Source

pub fn create_child(&self, entity_type: EntityType) -> (Self, KeyPair)

Create a child LCT under this parent

Source

pub fn is_active(&self) -> bool

Check if LCT is active

Source

pub fn void(&mut self)

Void this LCT (entity ceased to exist)

Source

pub fn slash(&mut self)

Slash this LCT (compromised or malicious)

Source

pub fn trust_ceiling(&self) -> f64

Get trust ceiling based on hardware binding

Source

pub fn verify_signature( &self, message: &[u8], signature: &SignatureBytes, ) -> Result<()>

Verify a signature from this LCT

Source

pub fn fingerprint(&self) -> String

Get the LCT fingerprint (short identifier for display)

Examples found in repository?
examples/cross_language_verify/verify.rs (line 131)
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}
Source

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);
Source

pub fn coherence_threshold(&self) -> f64

Check coherence requirements based on entity type

Returns the minimum coherence threshold for trust accumulation

Trait Implementations§

Source§

impl Clone for Lct

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Lct

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Lct

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Lct

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Lct

§

impl RefUnwindSafe for Lct

§

impl Send for Lct

§

impl Sync for Lct

§

impl Unpin for Lct

§

impl UnsafeUnpin for Lct

§

impl UnwindSafe for Lct

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V