Skip to main content

NTI Verified

langchain-nti

Full 5-pillar post-quantum security for LangChain agents, powered by NTI (Neutral Trust Infrastructure).

PyPI License Python 3.10+

Installation

pip install langchain-nti ube-foundation langchain-core

Quick Start — Drop-In Security Callback

from langchain_core.tools import tool
from langchain_nti import NTICallbackHandler, NTISecurityLayer

# Instantiate NTI security handler
handler = NTISecurityLayer(agent_id="finance_agent")

# Grant explicit zero-trust capability
handler.grant_capability("execute_transfer")

@tool
def execute_transfer(amount: int) -> str:
    """Executes a financial transfer."""
    return f"Transferred ${amount} successfully"

# Execute tool with NTI callback attached
response = execute_transfer.invoke({"amount": 100}, config={"callbacks": [handler]})
print(response)  # "Transferred $100 successfully"

Verifying Tool Output Signatures

# Enable tool response verification on the handler
handler = NTICallbackHandler(
    agent_id="secure_agent",
    strict=True,
    verify_tool_responses=True,
)

# Sign a response payload
signed_payload = handler.sign_output("Sensitive bank balance data")

# Verify payload signature
is_valid = handler.verify_output(signed_payload)
print("Signature valid:", is_valid)  # True

What It Enforces — All 5 Pillars of NTI

Pillar What It Does
1. Zero-Trust Capability Enforcement Agents have zero inherent permissions. Every action requires an explicit capability grant, evaluated in real-time.
2. NIST Post-Quantum Cryptography Every request is signed with CRYSTALS-Dilithium5 (NIST Level 5). Envelope encryption uses CRYSTALS-Kyber1024 + ChaCha20Poly1305.
3. BFT Multi-Agent Consensus Multi-agent decisions require threshold signature collection. Prevents single-agent prompt injection and rogue agent behavior.
4. Merkle-Chained Audit Trails Every evaluated action is hashed into a SHA-256 Merkle audit chain. Tamper-proof compliance logs.
5. P2P Agent Mesh & State Persistence Cryptographic agent identity, key rotation, and X25519 DH handshakes. Audit trails persist to disk and self-verify on reload.

BFT Consensus Example

handler.register_voter_key("voter_01", voter_public_key_bytes)
handler.register_voter_key("voter_02", voter_public_key_bytes)
# Multi-agent consensus enforced automatically on evaluation.

Why NTI

Autonomous LLM agents are prone to prompt injection, hallucinated function calls, and unconstrained action execution. NTI provides a cryptographically verifiable execution barrier in <1ms overhead, ensuring agents cannot execute unauthorized actions even if compromised at the prompt level.

License

Apache License 2.0. See LICENSE.

Architecture

graph TD
    subgraph LC["LangChain Framework"]
        Agent["Agent / AgentExecutor"]
        Tool["Tool Execution"]
    end

    subgraph NTI["NTI Security Layer"]
        OnStart["on_tool_start Interceptor"]
        OnEnd["on_tool_end Interceptor"]
        PolicyCheck["Capability & Policy Check"]
        OutputCheck["Output Signature Verifier"]
        Blocked["PermissionError<br/>(Action or Output Blocked)"]
    end

    subgraph Crypto["Crypto Engine (ube-foundation)"]
        TrustEngine["TrustEngine<br/>(Zero-Trust Policy & Merkle Audit)"]
        PqcKeyPair["PqcKeyPair<br/>(CRYSTALS-Dilithium5 & Kyber1024)"]
    end

    %% Tool invocation flow
    Agent -- "1. Invokes Tool Action" --> OnStart
    OnStart -- "2. Construct ActionRequest" --> PolicyCheck
    PolicyCheck -- "3. Evaluate Policy" --> TrustEngine

    TrustEngine -- "4a. Deny (Unauthorized)" --> Blocked
    TrustEngine -- "4b. Allow (Capability Granted)" --> Tool

    %% Tool execution & output verification flow
    Tool -- "5. Return Tool Output" --> OnEnd
    OnEnd -- "6. Verify Output (if enabled)" --> OutputCheck
    OutputCheck -- "7. Verify Signature" --> PqcKeyPair

    PqcKeyPair -- "8a. Tampered / Unsigned Response" --> Blocked
    PqcKeyPair -- "8b. Valid PQC Signature" --> Agent

Metadata

Release files for langchain-nti 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-nti 0.1.4
File Size Uploaded Provenance Actions
langchain_nti-0.1.4.tar.gz 13.1 kB With provenance Details for langchain_nti-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-nti 0.1.4
File Interpreter ABI Platform Actions
langchain_nti-0.1.4-py3-none-any.whl Python 3 none any Details for langchain_nti-0.1.4-py3-none-any.whl

Total release size: 24.4 kB

Release files / langchain_nti-0.1.4.tar.gz

Download URL langchain_nti-0.1.4.tar.gz
Size 13.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2c68ad1592edb12e73b0065458f62222067d49b6f95c08427e0cf34e23f51161
BLAKE2b-256 checksum
How to use checksums
45e117980bd3ffa6821a1f1864965cc2373f24d26ed2d7831093db407466a53a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / langchain_nti-0.1.4-py3-none-any.whl

Download URL langchain_nti-0.1.4-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0612b1723fc9bd3421943bf3a7e3a88e67d62a5ff150a2f147478d4e2ea47ebc
BLAKE2b-256 checksum
How to use checksums
3d02b1aaf4d004348092b1bb1d85b759bc08a54b173350297b3c08ea118b7f35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Security for langchain-nti 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_nti-0.1.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page