ciris-verify 23.3.2__tar.gz → 23.4.0__tar.gz
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.
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/PKG-INFO +1 -1
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify/__init__.py +3 -23
- ciris_verify-23.4.0/ciris_verify/_accord_invocation.py +118 -0
- ciris_verify-23.4.0/ciris_verify/_operational_admit.py +139 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify/client.py +0 -45
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify.egg-info/PKG-INFO +1 -1
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify.egg-info/SOURCES.txt +0 -3
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/pyproject.toml +1 -1
- ciris_verify-23.3.2/ciris_verify/_accord_custody.py +0 -143
- ciris_verify-23.3.2/ciris_verify/_accord_invocation.py +0 -202
- ciris_verify-23.3.2/ciris_verify/_manifest_contribution.py +0 -268
- ciris_verify-23.3.2/ciris_verify/_operational_admit.py +0 -243
- ciris_verify-23.3.2/ciris_verify/_wheel_skill_import.py +0 -255
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/README.md +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify/_bin_sign.py +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify/_bin_verify.py +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify/_canonical_subject.py +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify/_epoch_key.py +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify/_evm_tx.py +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify/_federation_identity.py +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify/_jcs.py +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify/_raw_verify.py +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify/_rns_dest_hash.py +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify/_scope_privacy.py +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify/_self_enc.py +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify/_stream_dek.py +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify/_test_anchor.py +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify/_wheel_hybrid_kex.py +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify/_wheel_key_grant.py +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify/_wheel_locale_merkle.py +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify/_wheel_reconsider_dos.py +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify/exceptions.py +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify/py.typed +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify/types.py +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify.egg-info/dependency_links.txt +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify.egg-info/entry_points.txt +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify.egg-info/requires.txt +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/ciris_verify.egg-info/top_level.txt +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/setup.cfg +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/tests/test_client.py +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/tests/test_memory_baseline.py +0 -0
- {ciris_verify-23.3.2 → ciris_verify-23.4.0}/tests/test_types.py +0 -0
|
@@ -69,14 +69,7 @@ from ._self_enc import (
|
|
|
69
69
|
from ._federation_identity import create_federation_identity
|
|
70
70
|
from ._evm_tx import keccak256, checksum_address
|
|
71
71
|
from ._raw_verify import verify_ed25519, verify_p256
|
|
72
|
-
from .
|
|
73
|
-
assemble_build_attestation_bundle,
|
|
74
|
-
build_attestation_bundle_envelope,
|
|
75
|
-
verify_build_attestation_bundle,
|
|
76
|
-
verify_build_manifest_contribution,
|
|
77
|
-
)
|
|
78
|
-
from ._accord_invocation import accord_latch_apply, accord_latch_status, verify_accord_invocation
|
|
79
|
-
from ._accord_custody import verify_accord_custody_attestation
|
|
72
|
+
from ._accord_invocation import accord_latch_status
|
|
80
73
|
from ._test_anchor import test_anchor_compiled_in
|
|
81
74
|
from ._canonical_subject import (
|
|
82
75
|
CanonicalSubjectError,
|
|
@@ -84,11 +77,7 @@ from ._canonical_subject import (
|
|
|
84
77
|
canonical_subject_from_triple,
|
|
85
78
|
parse_canonical_subject,
|
|
86
79
|
)
|
|
87
|
-
from ._operational_admit import
|
|
88
|
-
resolve_role_authority,
|
|
89
|
-
verify_delegation_scope_split,
|
|
90
|
-
verify_partner_record_quorum,
|
|
91
|
-
)
|
|
80
|
+
from ._operational_admit import verify_delegation_scope_split
|
|
92
81
|
from .types import (
|
|
93
82
|
LicenseStatus,
|
|
94
83
|
LicenseTier,
|
|
@@ -178,7 +167,7 @@ def get_library_version() -> str:
|
|
|
178
167
|
return __version__
|
|
179
168
|
|
|
180
169
|
|
|
181
|
-
__version__ = "23.
|
|
170
|
+
__version__ = "23.4.0"
|
|
182
171
|
__all__ = [
|
|
183
172
|
"CIRISVerify",
|
|
184
173
|
"MockCIRISVerify",
|
|
@@ -201,21 +190,12 @@ __all__ = [
|
|
|
201
190
|
"self_enc_pubkeys",
|
|
202
191
|
"self_enc_respond",
|
|
203
192
|
"create_federation_identity",
|
|
204
|
-
"verify_build_manifest_contribution",
|
|
205
|
-
"build_attestation_bundle_envelope",
|
|
206
|
-
"assemble_build_attestation_bundle",
|
|
207
|
-
"verify_build_attestation_bundle",
|
|
208
|
-
"verify_accord_invocation",
|
|
209
|
-
"accord_latch_apply",
|
|
210
193
|
"accord_latch_status",
|
|
211
|
-
"verify_accord_custody_attestation",
|
|
212
194
|
"test_anchor_compiled_in",
|
|
213
195
|
"canonical_subject",
|
|
214
196
|
"canonical_subject_from_triple",
|
|
215
197
|
"parse_canonical_subject",
|
|
216
198
|
"CanonicalSubjectError",
|
|
217
|
-
"resolve_role_authority",
|
|
218
|
-
"verify_partner_record_quorum",
|
|
219
199
|
"verify_delegation_scope_split",
|
|
220
200
|
"DEFAULT_REGISTRY_URL",
|
|
221
201
|
"TreeVerifyRequest",
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"""HUMANITY_ACCORD halt latch status — Python binding (CIRISVerify#305).
|
|
2
|
+
|
|
3
|
+
Exposes :func:`accord_latch_status`, a thin wrapper over the FFI symbol
|
|
4
|
+
``ciris_verify_accord_latch_status``: the act gate's question, is this node
|
|
5
|
+
paused at ``now``, over a latch a node persisted from
|
|
6
|
+
``ciris_verify_core::accord_halt_latch::HaltLatch::apply_forward`` (edition-2
|
|
7
|
+
rows read by ``edition2::accord_halt``).
|
|
8
|
+
|
|
9
|
+
``verify_accord_invocation`` and ``accord_latch_apply`` read the earlier,
|
|
10
|
+
pair-signed invocation form and were removed in 23.3.3.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import ctypes
|
|
16
|
+
import json as _json
|
|
17
|
+
import platform as _platform
|
|
18
|
+
import threading as _threading
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
from typing import Any, Optional
|
|
21
|
+
|
|
22
|
+
__all__ = ["accord_latch_status"]
|
|
23
|
+
|
|
24
|
+
_lib: Optional[ctypes.CDLL] = None
|
|
25
|
+
_lib_lock = _threading.Lock()
|
|
26
|
+
_SUCCESS = 0
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _candidate_paths() -> list[str]:
|
|
30
|
+
here = Path(__file__).resolve().parent
|
|
31
|
+
system = _platform.system()
|
|
32
|
+
names = {
|
|
33
|
+
"Linux": ["libciris_verify_ffi.so", "libciris_verify.so"],
|
|
34
|
+
"Darwin": ["libciris_verify_ffi.dylib", "libciris_verify.dylib"],
|
|
35
|
+
"Windows": ["ciris_verify_ffi.dll", "ciris_verify.dll"],
|
|
36
|
+
}.get(system, ["libciris_verify_ffi.so"])
|
|
37
|
+
paths: list[str] = [str(here / n) for n in names]
|
|
38
|
+
try:
|
|
39
|
+
from .client import DEFAULT_BINARY_PATHS # type: ignore
|
|
40
|
+
|
|
41
|
+
paths.extend(DEFAULT_BINARY_PATHS.get(system, []))
|
|
42
|
+
except Exception: # pragma: no cover - defensive
|
|
43
|
+
pass
|
|
44
|
+
return paths
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _wire(fn: Any) -> None:
|
|
48
|
+
fn.argtypes = [
|
|
49
|
+
ctypes.c_char_p, # input_json (UTF-8 bytes)
|
|
50
|
+
ctypes.c_size_t, # input_len
|
|
51
|
+
ctypes.POINTER(ctypes.POINTER(ctypes.c_ubyte)), # result_out
|
|
52
|
+
ctypes.POINTER(ctypes.c_size_t), # result_len_out
|
|
53
|
+
]
|
|
54
|
+
fn.restype = ctypes.c_int
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _load_lib() -> ctypes.CDLL:
|
|
58
|
+
global _lib
|
|
59
|
+
if _lib is not None:
|
|
60
|
+
return _lib
|
|
61
|
+
with _lib_lock:
|
|
62
|
+
if _lib is not None:
|
|
63
|
+
return _lib
|
|
64
|
+
last_err: Optional[Exception] = None
|
|
65
|
+
for path in _candidate_paths():
|
|
66
|
+
if not Path(path).exists():
|
|
67
|
+
continue
|
|
68
|
+
try:
|
|
69
|
+
lib = ctypes.CDLL(path)
|
|
70
|
+
_wire(lib.ciris_verify_accord_latch_status)
|
|
71
|
+
except (OSError, AttributeError) as exc:
|
|
72
|
+
last_err = exc
|
|
73
|
+
continue
|
|
74
|
+
lib.ciris_verify_free.argtypes = [ctypes.c_void_p]
|
|
75
|
+
lib.ciris_verify_free.restype = None
|
|
76
|
+
_lib = lib
|
|
77
|
+
return _lib
|
|
78
|
+
raise RuntimeError(
|
|
79
|
+
"accord latch FFI symbol not available — could not load the "
|
|
80
|
+
f"CIRISVerify shared library (last error: {last_err}). The library "
|
|
81
|
+
"must be built with the wheel (>= v19.1.0)."
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _call(symbol: str, request: dict) -> dict:
|
|
86
|
+
lib = _load_lib()
|
|
87
|
+
fn = getattr(lib, symbol)
|
|
88
|
+
body = _json.dumps(request, ensure_ascii=False).encode("utf-8")
|
|
89
|
+
out_ptr = ctypes.POINTER(ctypes.c_ubyte)()
|
|
90
|
+
out_len = ctypes.c_size_t(0)
|
|
91
|
+
rc = fn(body, len(body), ctypes.byref(out_ptr), ctypes.byref(out_len))
|
|
92
|
+
if rc != _SUCCESS:
|
|
93
|
+
raise ValueError(
|
|
94
|
+
f"{symbol}: malformed request (FFI code {rc}) — this is a caller "
|
|
95
|
+
"error, distinct from a fail-closed negative verdict"
|
|
96
|
+
)
|
|
97
|
+
n = out_len.value
|
|
98
|
+
if n == 0:
|
|
99
|
+
return {}
|
|
100
|
+
try:
|
|
101
|
+
raw = ctypes.string_at(out_ptr, n)
|
|
102
|
+
finally:
|
|
103
|
+
lib.ciris_verify_free(ctypes.cast(out_ptr, ctypes.c_void_p))
|
|
104
|
+
return _json.loads(raw)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def accord_latch_status(latch: Optional[dict], now: str, halt_fuse_secs: Optional[int] = None) -> dict:
|
|
108
|
+
"""The act gate's question: is this node paused at ``now``?
|
|
109
|
+
|
|
110
|
+
Call it before every effectful act (CC 4.2.1.1). ``latch`` is the state
|
|
111
|
+
the node persisted (``None`` when clear); ``halt_fuse_secs`` is the bundle
|
|
112
|
+
in force's (omit for the 86400 default). Returns
|
|
113
|
+
``{"paused", "halt_id", "confirmed", "lapses_at", "latch"}``.
|
|
114
|
+
"""
|
|
115
|
+
req: dict = {"latch": latch, "now": now}
|
|
116
|
+
if halt_fuse_secs is not None:
|
|
117
|
+
req["halt_fuse_secs"] = halt_fuse_secs
|
|
118
|
+
return _call("ciris_verify_accord_latch_status", req)
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"""Delegation scope split — Python binding (CIRISVerify#77).
|
|
2
|
+
|
|
3
|
+
Exposes :func:`verify_delegation_scope_split`, a thin wrapper over the FFI
|
|
4
|
+
symbol ``ciris_verify_delegation_scope_split``, which calls
|
|
5
|
+
``ciris_verify_core::operational_admit::verify_delegation_scope_split``: a
|
|
6
|
+
``node``-only delegate carrying any ``agency:*`` scope is rejected, and an
|
|
7
|
+
unknown scope fails closed. A pure evaluator — no I/O — and **fail-closed**: a
|
|
8
|
+
negative verdict is a successful call, never an exception.
|
|
9
|
+
|
|
10
|
+
``resolve_role_authority`` and ``verify_partner_record_quorum`` checked the
|
|
11
|
+
pair-signed ``organization`` / ``org_membership`` / ``partner_record`` rows,
|
|
12
|
+
which CC 3.3.9 retired; they were removed in 23.3.3.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import ctypes
|
|
18
|
+
import json as _json
|
|
19
|
+
import platform as _platform
|
|
20
|
+
import threading as _threading
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
from typing import Any, Optional
|
|
23
|
+
|
|
24
|
+
__all__ = ["verify_delegation_scope_split"]
|
|
25
|
+
|
|
26
|
+
_lib: Optional[ctypes.CDLL] = None
|
|
27
|
+
_lib_lock = _threading.Lock()
|
|
28
|
+
_SUCCESS = 0
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _candidate_paths() -> list[str]:
|
|
32
|
+
here = Path(__file__).resolve().parent
|
|
33
|
+
system = _platform.system()
|
|
34
|
+
names = {
|
|
35
|
+
"Linux": ["libciris_verify_ffi.so", "libciris_verify.so"],
|
|
36
|
+
"Darwin": ["libciris_verify_ffi.dylib", "libciris_verify.dylib"],
|
|
37
|
+
"Windows": ["ciris_verify_ffi.dll", "ciris_verify.dll"],
|
|
38
|
+
}.get(system, ["libciris_verify_ffi.so"])
|
|
39
|
+
paths: list[str] = [str(here / n) for n in names]
|
|
40
|
+
try:
|
|
41
|
+
from .client import DEFAULT_BINARY_PATHS # type: ignore
|
|
42
|
+
|
|
43
|
+
paths.extend(DEFAULT_BINARY_PATHS.get(system, []))
|
|
44
|
+
except Exception: # pragma: no cover - defensive
|
|
45
|
+
pass
|
|
46
|
+
return paths
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _wire(fn: Any) -> None:
|
|
50
|
+
fn.argtypes = [
|
|
51
|
+
ctypes.c_char_p, # input_json (UTF-8 bytes)
|
|
52
|
+
ctypes.c_size_t, # input_len
|
|
53
|
+
ctypes.POINTER(ctypes.POINTER(ctypes.c_ubyte)), # result_out
|
|
54
|
+
ctypes.POINTER(ctypes.c_size_t), # result_len_out
|
|
55
|
+
]
|
|
56
|
+
fn.restype = ctypes.c_int
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _load_lib() -> ctypes.CDLL:
|
|
60
|
+
global _lib
|
|
61
|
+
if _lib is not None:
|
|
62
|
+
return _lib
|
|
63
|
+
with _lib_lock:
|
|
64
|
+
if _lib is not None:
|
|
65
|
+
return _lib
|
|
66
|
+
last_err: Optional[Exception] = None
|
|
67
|
+
for path in _candidate_paths():
|
|
68
|
+
if not Path(path).exists():
|
|
69
|
+
continue
|
|
70
|
+
try:
|
|
71
|
+
lib = ctypes.CDLL(path)
|
|
72
|
+
_wire(lib.ciris_verify_delegation_scope_split)
|
|
73
|
+
except (OSError, AttributeError) as exc:
|
|
74
|
+
last_err = exc
|
|
75
|
+
continue
|
|
76
|
+
lib.ciris_verify_free.argtypes = [ctypes.c_void_p]
|
|
77
|
+
lib.ciris_verify_free.restype = None
|
|
78
|
+
_lib = lib
|
|
79
|
+
return _lib
|
|
80
|
+
raise RuntimeError(
|
|
81
|
+
"operational-admit FFI symbols not available — could not load the "
|
|
82
|
+
f"CIRISVerify shared library (last error: {last_err}). The library "
|
|
83
|
+
"must be built with the wheel (>= v5.1.0)."
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def _call(symbol: str, request: dict) -> dict:
|
|
88
|
+
lib = _load_lib()
|
|
89
|
+
fn = getattr(lib, symbol)
|
|
90
|
+
body = _json.dumps(request, ensure_ascii=False).encode("utf-8")
|
|
91
|
+
out_ptr = ctypes.POINTER(ctypes.c_ubyte)()
|
|
92
|
+
out_len = ctypes.c_size_t(0)
|
|
93
|
+
rc = fn(body, len(body), ctypes.byref(out_ptr), ctypes.byref(out_len))
|
|
94
|
+
if rc != _SUCCESS:
|
|
95
|
+
raise ValueError(
|
|
96
|
+
f"{symbol}: malformed request (FFI code {rc}) — this is a caller "
|
|
97
|
+
"error, distinct from a fail-closed negative verdict"
|
|
98
|
+
)
|
|
99
|
+
n = out_len.value
|
|
100
|
+
if n == 0:
|
|
101
|
+
return {}
|
|
102
|
+
try:
|
|
103
|
+
raw = ctypes.string_at(out_ptr, n)
|
|
104
|
+
finally:
|
|
105
|
+
lib.ciris_verify_free(ctypes.cast(out_ptr, ctypes.c_void_p))
|
|
106
|
+
return _json.loads(raw)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def verify_delegation_scope_split(
|
|
110
|
+
attested_identity_type: str,
|
|
111
|
+
delegated_scope: list[str],
|
|
112
|
+
) -> dict:
|
|
113
|
+
"""Enforce the CEG §8.1.12.7.1 / §5.6.8.10 ``infra:*`` / ``agency:*``
|
|
114
|
+
delegation scope split — the wire-checkable form of §1.3 "infrastructure
|
|
115
|
+
must not have agency" (CIRISRegistry#83).
|
|
116
|
+
|
|
117
|
+
Args:
|
|
118
|
+
attested_identity_type: the caller-resolved §7.0.1 ``identity_type``
|
|
119
|
+
SET (comma-joined) of the delegation's ``attested_key_id``. The
|
|
120
|
+
delegate is a brain iff the set contains ``agent``.
|
|
121
|
+
delegated_scope: the delegation's scopes. A ``node``-only delegate may
|
|
122
|
+
carry only ``infra:*``; any ``agency:*`` (or legacy agency kind) is
|
|
123
|
+
rejected, as is any unrecognized scope (fail-closed).
|
|
124
|
+
|
|
125
|
+
Returns:
|
|
126
|
+
``{"ok": bool, "error": str?}``. Fail-closed: a violating delegation
|
|
127
|
+
is ``ok: False`` with a reason, not an exception.
|
|
128
|
+
|
|
129
|
+
Raises:
|
|
130
|
+
ValueError: the request itself is malformed.
|
|
131
|
+
RuntimeError: the shared library / FFI symbols are unavailable.
|
|
132
|
+
"""
|
|
133
|
+
return _call(
|
|
134
|
+
"ciris_verify_delegation_scope_split",
|
|
135
|
+
{
|
|
136
|
+
"attested_identity_type": attested_identity_type,
|
|
137
|
+
"delegated_scope": delegated_scope,
|
|
138
|
+
},
|
|
139
|
+
)
|
|
@@ -693,14 +693,6 @@ class CIRISVerify:
|
|
|
693
693
|
]
|
|
694
694
|
self._lib.ciris_verify_admit_attestation.restype = ctypes.c_int
|
|
695
695
|
|
|
696
|
-
self._lib.ciris_verify_invocation_canonical_bytes.argtypes = [
|
|
697
|
-
ctypes.c_char_p, # invocation_json
|
|
698
|
-
ctypes.c_size_t, # invocation_len
|
|
699
|
-
ctypes.POINTER(ctypes.POINTER(ctypes.c_uint8)), # result_out
|
|
700
|
-
ctypes.POINTER(ctypes.c_size_t), # result_len_out
|
|
701
|
-
]
|
|
702
|
-
self._lib.ciris_verify_invocation_canonical_bytes.restype = ctypes.c_int
|
|
703
|
-
|
|
704
696
|
self._lib.ciris_verify_sth_cosignature_consistency_proof.argtypes = [
|
|
705
697
|
ctypes.c_char_p, # proof_json
|
|
706
698
|
ctypes.c_size_t, # proof_len
|
|
@@ -2398,41 +2390,6 @@ class CIRISVerify:
|
|
|
2398
2390
|
except Exception:
|
|
2399
2391
|
return None
|
|
2400
2392
|
|
|
2401
|
-
def invocation_canonical_bytes(self, invocation: dict) -> Optional[bytes]:
|
|
2402
|
-
"""CEG §9.2.1 HUMANITY_ACCORD canonical-bytes producer
|
|
2403
|
-
(CIRISVerify#41, v4.2.0+).
|
|
2404
|
-
|
|
2405
|
-
Args:
|
|
2406
|
-
invocation: Invocation dict with `invocation_kind`,
|
|
2407
|
-
`invocation_id`, `nonce`, `asserted_at`, `valid_until`,
|
|
2408
|
-
`payload_sha256`. Timestamps must be §0.5 canonical RFC 3339;
|
|
2409
|
-
`payload_sha256` must be §0.6 canonical lowercase hex.
|
|
2410
|
-
|
|
2411
|
-
Returns:
|
|
2412
|
-
Canonical bytes to sign (raw `bytes`), or None on failure.
|
|
2413
|
-
The hybrid signature scheme per §5.2.1 signs Ed25519 over these
|
|
2414
|
-
bytes and ML-DSA-65 over `bytes || ed25519_sig`.
|
|
2415
|
-
"""
|
|
2416
|
-
if not self._has_v4_2_conformance_support:
|
|
2417
|
-
return None
|
|
2418
|
-
inv_bytes = json.dumps(invocation).encode("utf-8")
|
|
2419
|
-
result_ptr = ctypes.POINTER(ctypes.c_uint8)()
|
|
2420
|
-
result_len = ctypes.c_size_t()
|
|
2421
|
-
ret = self._lib.ciris_verify_invocation_canonical_bytes(
|
|
2422
|
-
inv_bytes,
|
|
2423
|
-
len(inv_bytes),
|
|
2424
|
-
ctypes.byref(result_ptr),
|
|
2425
|
-
ctypes.byref(result_len),
|
|
2426
|
-
)
|
|
2427
|
-
if ret != 0:
|
|
2428
|
-
return None
|
|
2429
|
-
try:
|
|
2430
|
-
data = ctypes.string_at(result_ptr, result_len.value)
|
|
2431
|
-
self._lib.ciris_verify_free(result_ptr)
|
|
2432
|
-
return data
|
|
2433
|
-
except Exception:
|
|
2434
|
-
return None
|
|
2435
|
-
|
|
2436
2393
|
def verify_sth_cosignature_consistency_proof(
|
|
2437
2394
|
self,
|
|
2438
2395
|
proof: dict,
|
|
@@ -4001,10 +3958,8 @@ from ._wheel_hybrid_kex import attach_to as _attach_hybrid_kex # noqa: E402
|
|
|
4001
3958
|
from ._wheel_key_grant import attach_to as _attach_key_grant # noqa: E402
|
|
4002
3959
|
from ._wheel_locale_merkle import attach_to as _attach_locale_merkle # noqa: E402
|
|
4003
3960
|
from ._wheel_reconsider_dos import attach_to as _attach_reconsider_dos # noqa: E402
|
|
4004
|
-
from ._wheel_skill_import import attach_to as _attach_skill_import # noqa: E402
|
|
4005
3961
|
|
|
4006
3962
|
_attach_hybrid_kex(CIRISVerify)
|
|
4007
3963
|
_attach_key_grant(CIRISVerify)
|
|
4008
3964
|
_attach_locale_merkle(CIRISVerify)
|
|
4009
3965
|
_attach_reconsider_dos(CIRISVerify)
|
|
4010
|
-
_attach_skill_import(CIRISVerify)
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
README.md
|
|
2
2
|
pyproject.toml
|
|
3
3
|
ciris_verify/__init__.py
|
|
4
|
-
ciris_verify/_accord_custody.py
|
|
5
4
|
ciris_verify/_accord_invocation.py
|
|
6
5
|
ciris_verify/_bin_sign.py
|
|
7
6
|
ciris_verify/_bin_verify.py
|
|
@@ -10,7 +9,6 @@ ciris_verify/_epoch_key.py
|
|
|
10
9
|
ciris_verify/_evm_tx.py
|
|
11
10
|
ciris_verify/_federation_identity.py
|
|
12
11
|
ciris_verify/_jcs.py
|
|
13
|
-
ciris_verify/_manifest_contribution.py
|
|
14
12
|
ciris_verify/_operational_admit.py
|
|
15
13
|
ciris_verify/_raw_verify.py
|
|
16
14
|
ciris_verify/_rns_dest_hash.py
|
|
@@ -22,7 +20,6 @@ ciris_verify/_wheel_hybrid_kex.py
|
|
|
22
20
|
ciris_verify/_wheel_key_grant.py
|
|
23
21
|
ciris_verify/_wheel_locale_merkle.py
|
|
24
22
|
ciris_verify/_wheel_reconsider_dos.py
|
|
25
|
-
ciris_verify/_wheel_skill_import.py
|
|
26
23
|
ciris_verify/client.py
|
|
27
24
|
ciris_verify/exceptions.py
|
|
28
25
|
ciris_verify/py.typed
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"""Accord-holder custody attestation — Python binding (CIRISVerify#91).
|
|
2
|
-
|
|
3
|
-
Exposes :func:`verify_accord_custody_attestation`, a thin wrapper over the FFI
|
|
4
|
-
symbol ``ciris_verify_accord_custody_attestation`` which calls
|
|
5
|
-
``ciris_verify_core::accord_custody_attestation`` — the hardware-unforgeable
|
|
6
|
-
YubiKey-PIV custody check the CIRISServer admission gate runs before admitting a
|
|
7
|
-
holder to the accord kill-switch roster (the CIRISServer#41 safe-mesh floor).
|
|
8
|
-
|
|
9
|
-
There is exactly one blessed implementation of the check; the wheel reaches it
|
|
10
|
-
rather than reimplement the PIV chain walk. The function is **fail-closed**: a
|
|
11
|
-
negative admission (chain invalid, floor not met, wrong attested key) is a
|
|
12
|
-
successful call returning ``admitted = False`` with a ``reason``, never an
|
|
13
|
-
exception. Only a malformed request raises :class:`ValueError`.
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
from __future__ import annotations
|
|
17
|
-
|
|
18
|
-
import ctypes
|
|
19
|
-
import json as _json
|
|
20
|
-
import platform as _platform
|
|
21
|
-
import threading as _threading
|
|
22
|
-
from pathlib import Path
|
|
23
|
-
from typing import Any, Optional
|
|
24
|
-
|
|
25
|
-
__all__ = ["verify_accord_custody_attestation"]
|
|
26
|
-
|
|
27
|
-
_lib: Optional[ctypes.CDLL] = None
|
|
28
|
-
_lib_lock = _threading.Lock()
|
|
29
|
-
_SUCCESS = 0
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def _candidate_paths() -> list[str]:
|
|
33
|
-
here = Path(__file__).resolve().parent
|
|
34
|
-
system = _platform.system()
|
|
35
|
-
names = {
|
|
36
|
-
"Linux": ["libciris_verify_ffi.so", "libciris_verify.so"],
|
|
37
|
-
"Darwin": ["libciris_verify_ffi.dylib", "libciris_verify.dylib"],
|
|
38
|
-
"Windows": ["ciris_verify_ffi.dll", "ciris_verify.dll"],
|
|
39
|
-
}.get(system, ["libciris_verify_ffi.so"])
|
|
40
|
-
paths: list[str] = [str(here / n) for n in names]
|
|
41
|
-
try:
|
|
42
|
-
from .client import DEFAULT_BINARY_PATHS # type: ignore
|
|
43
|
-
|
|
44
|
-
paths.extend(DEFAULT_BINARY_PATHS.get(system, []))
|
|
45
|
-
except Exception: # pragma: no cover - defensive
|
|
46
|
-
pass
|
|
47
|
-
return paths
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
def _wire(fn: Any) -> None:
|
|
51
|
-
fn.argtypes = [
|
|
52
|
-
ctypes.c_char_p, # input_json (UTF-8 bytes)
|
|
53
|
-
ctypes.c_size_t, # input_len
|
|
54
|
-
ctypes.POINTER(ctypes.POINTER(ctypes.c_ubyte)), # result_out
|
|
55
|
-
ctypes.POINTER(ctypes.c_size_t), # result_len_out
|
|
56
|
-
]
|
|
57
|
-
fn.restype = ctypes.c_int
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
def _load_lib() -> ctypes.CDLL:
|
|
61
|
-
global _lib
|
|
62
|
-
if _lib is not None:
|
|
63
|
-
return _lib
|
|
64
|
-
with _lib_lock:
|
|
65
|
-
if _lib is not None:
|
|
66
|
-
return _lib
|
|
67
|
-
last_err: Optional[Exception] = None
|
|
68
|
-
for path in _candidate_paths():
|
|
69
|
-
if not Path(path).exists():
|
|
70
|
-
continue
|
|
71
|
-
try:
|
|
72
|
-
lib = ctypes.CDLL(path)
|
|
73
|
-
_wire(lib.ciris_verify_accord_custody_attestation)
|
|
74
|
-
except (OSError, AttributeError) as exc:
|
|
75
|
-
last_err = exc
|
|
76
|
-
continue
|
|
77
|
-
lib.ciris_verify_free.argtypes = [ctypes.c_void_p]
|
|
78
|
-
lib.ciris_verify_free.restype = None
|
|
79
|
-
_lib = lib
|
|
80
|
-
return _lib
|
|
81
|
-
raise RuntimeError(
|
|
82
|
-
"accord-custody FFI symbol not available — could not load the "
|
|
83
|
-
f"CIRISVerify shared library (last error: {last_err}). The library "
|
|
84
|
-
"must be built with the wheel (>= v6.7.0)."
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
def verify_accord_custody_attestation(
|
|
89
|
-
attestation_object: Any,
|
|
90
|
-
holder_member: dict,
|
|
91
|
-
yubico_root_der_hex: str,
|
|
92
|
-
) -> dict:
|
|
93
|
-
"""Verify an accord-holder custody attestation (CIRISVerify#91).
|
|
94
|
-
|
|
95
|
-
Args:
|
|
96
|
-
attestation_object: the signed ``accord_holder_custody_attestation``
|
|
97
|
-
CEG object (a JSON-able value, as produced by the holder ceremony).
|
|
98
|
-
holder_member: the holder's pinned hybrid pubkeys, resolved by the
|
|
99
|
-
caller from its directory by the bundle's ``holder_key_id`` —
|
|
100
|
-
``{"member_id": "...", "ed25519_public_key_base64": "...",
|
|
101
|
-
"mldsa65_public_key_base64": "..."}``.
|
|
102
|
-
yubico_root_der_hex: the **pinned** Yubico PIV attestation root, as
|
|
103
|
-
hex-encoded DER. The consumer pins the trust root; verify provides
|
|
104
|
-
only the verification.
|
|
105
|
-
|
|
106
|
-
Returns:
|
|
107
|
-
On admission: ``{"admitted": True, "hardware_class": "YubiKey_5_FIPS",
|
|
108
|
-
"custody_tier": ..., "firmware": ..., "serial": int?,
|
|
109
|
-
"fips_certified": True, "touch_always": True}``. On rejection:
|
|
110
|
-
``{"admitted": False, "reason": "..."}``. Admit **only** on
|
|
111
|
-
``admitted is True``.
|
|
112
|
-
|
|
113
|
-
Raises:
|
|
114
|
-
ValueError: the request itself is malformed (a caller error, NOT a
|
|
115
|
-
negative verdict — e.g. a non-hex root).
|
|
116
|
-
RuntimeError: the shared library / FFI symbol is unavailable.
|
|
117
|
-
"""
|
|
118
|
-
lib = _load_lib()
|
|
119
|
-
request = {
|
|
120
|
-
"attestation_object": attestation_object,
|
|
121
|
-
"holder_member": holder_member,
|
|
122
|
-
"yubico_root_der_hex": yubico_root_der_hex,
|
|
123
|
-
}
|
|
124
|
-
body = _json.dumps(request, ensure_ascii=False).encode("utf-8")
|
|
125
|
-
out_ptr = ctypes.POINTER(ctypes.c_ubyte)()
|
|
126
|
-
out_len = ctypes.c_size_t(0)
|
|
127
|
-
rc = lib.ciris_verify_accord_custody_attestation(
|
|
128
|
-
body, len(body), ctypes.byref(out_ptr), ctypes.byref(out_len)
|
|
129
|
-
)
|
|
130
|
-
if rc != _SUCCESS:
|
|
131
|
-
raise ValueError(
|
|
132
|
-
f"verify_accord_custody_attestation: malformed request (FFI code "
|
|
133
|
-
f"{rc}) — this is a caller error, distinct from a fail-closed "
|
|
134
|
-
"negative verdict"
|
|
135
|
-
)
|
|
136
|
-
n = out_len.value
|
|
137
|
-
if n == 0:
|
|
138
|
-
return {}
|
|
139
|
-
try:
|
|
140
|
-
raw = ctypes.string_at(out_ptr, n)
|
|
141
|
-
finally:
|
|
142
|
-
lib.ciris_verify_free(ctypes.cast(out_ptr, ctypes.c_void_p))
|
|
143
|
-
return _json.loads(raw)
|