mershtrust 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mershtrust/__init__.py +127 -0
- mershtrust/adapters/__init__.py +4 -0
- mershtrust/adapters/agent_adapter.py +578 -0
- mershtrust/adapters/dicom_loader.py +266 -0
- mershtrust/adapters/llm_adapter.py +357 -0
- mershtrust/adapters/medgemma_adapter.py +313 -0
- mershtrust/adapters/model_adapter.py +260 -0
- mershtrust/adapters/onnx_utils.py +42 -0
- mershtrust/adapters/pt_adapter.py +64 -0
- mershtrust/adapters/rfdetr_adapter.py +290 -0
- mershtrust/adapters/tf_adapter.py +49 -0
- mershtrust/adapters/vlm_adapter.py +492 -0
- mershtrust/adapters/yolo_adapter.py +233 -0
- mershtrust/api/__init__.py +4 -0
- mershtrust/api/server.py +128 -0
- mershtrust/api/trust_engine.py +328 -0
- mershtrust/cli.py +179 -0
- mershtrust/cloud/__init__.py +5 -0
- mershtrust/cloud/client.py +510 -0
- mershtrust/cloud/sdk.py +892 -0
- mershtrust/contracts/AuditLog_abi.json +99 -0
- mershtrust/contracts/__init__.py +1 -0
- mershtrust/core/__init__.py +7 -0
- mershtrust/core/_keccak_pure.py +120 -0
- mershtrust/core/agent_audit.py +955 -0
- mershtrust/core/agent_profile.py +135 -0
- mershtrust/core/blockchain.py +542 -0
- mershtrust/core/blockchain_base.py +258 -0
- mershtrust/core/blockchain_helpers.py +86 -0
- mershtrust/core/canonical.py +166 -0
- mershtrust/core/capsule_format.py +26 -0
- mershtrust/core/ctx_trace.py +125 -0
- mershtrust/core/dp_utils.py +46 -0
- mershtrust/core/fl_defense_strategy.py +159 -0
- mershtrust/core/fl_engine.py +54 -0
- mershtrust/core/fl_pt_client.py +216 -0
- mershtrust/core/fl_tf_client.py +119 -0
- mershtrust/core/hashing.py +174 -0
- mershtrust/core/hi_trace.py +202 -0
- mershtrust/core/identity.py +68 -0
- mershtrust/core/knowledge_trace.py +209 -0
- mershtrust/core/layer_contract.py +235 -0
- mershtrust/core/losses.py +225 -0
- mershtrust/core/patch_occlusion.py +134 -0
- mershtrust/core/receipt.py +306 -0
- mershtrust/core/signing.py +257 -0
- mershtrust/core/stream_hash.py +122 -0
- mershtrust/core/transparency.py +451 -0
- mershtrust/core/verifier.py +644 -0
- mershtrust/core/verticals.py +33 -0
- mershtrust/core/vision_attestation.py +438 -0
- mershtrust/core/xai_agnostic.py +204 -0
- mershtrust/core/xai_dispatch.py +126 -0
- mershtrust/core/xai_pt.py +265 -0
- mershtrust/core/xai_tf.py +84 -0
- mershtrust/core/zk_engine.py +417 -0
- mershtrust/core/zk_feature_extractors.py +271 -0
- mershtrust/core/zk_proxy.py +264 -0
- mershtrust/integrations/__init__.py +1 -0
- mershtrust/integrations/claude_code.py +441 -0
- mershtrust/py.typed +0 -0
- mershtrust/security/__init__.py +1 -0
- mershtrust/security/auth.py +136 -0
- mershtrust/security/machine_id.py +128 -0
- mershtrust/storage/__init__.py +1 -0
- mershtrust/storage/arweave.py +104 -0
- mershtrust-0.1.0.dist-info/METADATA +493 -0
- mershtrust-0.1.0.dist-info/RECORD +71 -0
- mershtrust-0.1.0.dist-info/WHEEL +4 -0
- mershtrust-0.1.0.dist-info/entry_points.txt +3 -0
- mershtrust-0.1.0.dist-info/licenses/LICENSE +34 -0
mershtrust/__init__.py
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"""MershTrust — trusted inference for any ML model.
|
|
2
|
+
|
|
3
|
+
Wrap a TensorFlow, PyTorch, or ONNX model and get, in one call:
|
|
4
|
+
explainable AI, per-inference zero-knowledge proofs, federated learning,
|
|
5
|
+
and a tamper-evident on-chain audit trail.
|
|
6
|
+
|
|
7
|
+
from mershtrust import TrustEngine
|
|
8
|
+
|
|
9
|
+
engine = TrustEngine(model_type="cnn")
|
|
10
|
+
engine.wrap(model)
|
|
11
|
+
result = engine.run(x) # prediction + XAI + audit trail
|
|
12
|
+
|
|
13
|
+
Heavy backends (torch, tensorflow, ezkl, flwr, web3, shap, ...) are optional
|
|
14
|
+
extras and are imported lazily, so importing this package never requires them.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
__version__ = "0.1.0"
|
|
20
|
+
|
|
21
|
+
# TrustEngine only needs numpy at import time; the framework/XAI/ZK/blockchain
|
|
22
|
+
# backends load on demand inside its methods.
|
|
23
|
+
from mershtrust.api.trust_engine import TrustEngine
|
|
24
|
+
|
|
25
|
+
# Agent audit trail — dependency-free (stdlib only); framework backends are lazy.
|
|
26
|
+
from mershtrust.adapters.agent_adapter import AgentAuditor
|
|
27
|
+
from mershtrust.core.agent_audit import AgentAuditTrail, verify_agent_capsule
|
|
28
|
+
|
|
29
|
+
# Capsule verification. The agent verifier was reachable from the top level and
|
|
30
|
+
# these two were not, so verifying the product's primary artifact meant knowing an
|
|
31
|
+
# internal module path. Stdlib-only at import time; the hash backends load on
|
|
32
|
+
# demand inside the calls.
|
|
33
|
+
from mershtrust.core.verifier import (
|
|
34
|
+
VerificationCheck,
|
|
35
|
+
VerificationResult,
|
|
36
|
+
verify_capsule,
|
|
37
|
+
verify_vlm_capsule,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
# Signing. Stdlib only at import time, since the Ed25519 backends are detected
|
|
41
|
+
# lazily inside the calls, so this costs base64 and nothing else.
|
|
42
|
+
#
|
|
43
|
+
# write_private_key and read_private_key are here for the same reason they exist:
|
|
44
|
+
# a caller who cannot find them writes the key themselves, and the mode is the
|
|
45
|
+
# part people get wrong. A safe default that has to be discovered through an
|
|
46
|
+
# internal module path is not a safe default.
|
|
47
|
+
from mershtrust.core.signing import (
|
|
48
|
+
ed25519_available,
|
|
49
|
+
generate_keypair,
|
|
50
|
+
public_key,
|
|
51
|
+
read_private_key,
|
|
52
|
+
sign_envelope,
|
|
53
|
+
verify_envelope,
|
|
54
|
+
write_private_key,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
# Cross-run transparency log — proves the set of runs is complete, which a
|
|
58
|
+
# per-run capsule cannot. Also stdlib-only.
|
|
59
|
+
from mershtrust.core.stream_hash import StreamHasher
|
|
60
|
+
from mershtrust.core.transparency import (
|
|
61
|
+
TransparencyLog,
|
|
62
|
+
sign_checkpoint,
|
|
63
|
+
verify_checkpoint,
|
|
64
|
+
verify_consistency,
|
|
65
|
+
verify_inclusion,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
# W&B-style drop-in auditability SDK (stdlib-only; never imports FastAPI/uvicorn).
|
|
69
|
+
from mershtrust.cloud.sdk import (
|
|
70
|
+
AuditRun,
|
|
71
|
+
active_run,
|
|
72
|
+
finish,
|
|
73
|
+
init,
|
|
74
|
+
log,
|
|
75
|
+
log_artifact,
|
|
76
|
+
log_decision,
|
|
77
|
+
log_round,
|
|
78
|
+
log_vision,
|
|
79
|
+
login,
|
|
80
|
+
register_model,
|
|
81
|
+
use_artifact,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
# One event provable on its own, for when a single decision is questioned.
|
|
85
|
+
from mershtrust.core.receipt import build_receipt, verify_receipt
|
|
86
|
+
from mershtrust.core.agent_profile import agent_profile, run_tier
|
|
87
|
+
|
|
88
|
+
__all__ = [
|
|
89
|
+
"TrustEngine",
|
|
90
|
+
"AgentAuditor",
|
|
91
|
+
"AgentAuditTrail",
|
|
92
|
+
"verify_agent_capsule",
|
|
93
|
+
"verify_capsule",
|
|
94
|
+
"verify_vlm_capsule",
|
|
95
|
+
"VerificationResult",
|
|
96
|
+
"VerificationCheck",
|
|
97
|
+
"generate_keypair",
|
|
98
|
+
"public_key",
|
|
99
|
+
"write_private_key",
|
|
100
|
+
"read_private_key",
|
|
101
|
+
"sign_envelope",
|
|
102
|
+
"verify_envelope",
|
|
103
|
+
"ed25519_available",
|
|
104
|
+
"StreamHasher",
|
|
105
|
+
"TransparencyLog",
|
|
106
|
+
"verify_inclusion",
|
|
107
|
+
"sign_checkpoint",
|
|
108
|
+
"verify_checkpoint",
|
|
109
|
+
"agent_profile",
|
|
110
|
+
"run_tier",
|
|
111
|
+
"verify_consistency",
|
|
112
|
+
"AuditRun",
|
|
113
|
+
"init",
|
|
114
|
+
"login",
|
|
115
|
+
"log",
|
|
116
|
+
"log_artifact",
|
|
117
|
+
"log_vision",
|
|
118
|
+
"log_decision",
|
|
119
|
+
"log_round",
|
|
120
|
+
"register_model",
|
|
121
|
+
"use_artifact",
|
|
122
|
+
"finish",
|
|
123
|
+
"active_run",
|
|
124
|
+
"build_receipt",
|
|
125
|
+
"verify_receipt",
|
|
126
|
+
"__version__",
|
|
127
|
+
]
|