Skip to main content

Crate noethers_turnstile_core

Crate noethers_turnstile_core 

Source
Expand description

§turnstile-core

Pure Rust implementation of the admissibility compiler.

The judgment form is:

Γ ⊢ z : p until ε

The compiler is parameterized over a PermissionChain — a validated total order of named levels with role anchors (Bottom, ExpiryFloor, Refused, Unsatisfied, BlockerThreshold, Top). The default chain (the historical 12-level OOC < EXP < REF < UNS < ETA < ESC < ROL < DIA < REV < AEX < ALR < AAA) is available via PermissionChain::default_chain.

See docs/specs/permission_chain_refactor_spec.md for the full design.

§Quick start (default chain)

use noethers_turnstile_core::{
    context::{Membership, ProofContext, Scope},
    compiler::compile,
    expiry::Expiry,
    default_levels,
};

let ctx = ProofContext {
    claim_id: "my-claim".into(),
    candidate_id: "z-001".into(),
    context_id: "ctx-001".into(),
    context_fingerprint: "fp-001".into(),
    allowed_use: "diagnostics".into(),
    disallowed_uses: vec![],
    scope: Scope::default(),
    gaps: vec![],
    profiles: vec![],
    tokens: vec![],
    expiry: Expiry::never(),
    authority_ceiling: None,
    permission_ceiling: None,
    expected_chain_hash: None,
    membership: Membership::InClass,
};

let judgment = compile(ctx).unwrap();
// No profiles registered → OOC.
assert_eq!(judgment.permission, default_levels::OOC());

Re-exports§

pub use compiler::compile;
pub use compiler::compile_at;
pub use compiler::compile_at_with_chain;
pub use compiler::compile_with_chain;
pub use compiler::Judgment;
pub use composition::compose;
pub use composition::compose_judgments;
pub use composition::compose_n;
pub use composition::compose_n_with_chain;
pub use composition::compose_with_chain;
pub use context::ProofContext;
pub use expiry::Expiry;
pub use expiry::LiveJudgment;
pub use expiry::RuntimeContext;
pub use permission::AuditError;
pub use permission::ChainError;
pub use permission::ChainHash;
pub use permission::ChainRegistry;
pub use permission::ChainRole;
pub use permission::InMemoryChainRegistry;
pub use permission::NameRejectionReason;
pub use permission::Permission;
pub use permission::PermissionChain;
pub use permission::MAX_LEVELS;
pub use permission::MAX_NAME_LEN;
pub use token::NegativeControlStatus;

Modules§

audit
certifier
compiler
The admissibility compiler: Γ ⊢ z : p until ε.
composition
Composition operator on ProofContext.
context
ProofContext (Γ): the full proof context for a compilation.
default_levels
Default-chain level constants — for TESTS, EXAMPLES, and the Python binding only.
error
TurnstileError hierarchy.
expiry
Expiry types and the LiveJudgment wrapper.
gap
permission
Permission levels, chains, and chain identity.
registry
token

Functions§

verify_published
Verify that a judgment’s chain_hash resolves in the given registry, and that the resolved chain re-hashes to the same value.