loopgrid-verify 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.
@@ -0,0 +1,6 @@
1
+ """Standalone offline verification for LoopGrid evidence bundles."""
2
+
3
+ from .verifier import verify_bundle
4
+ from .version import __version__
5
+
6
+ __all__ = ["verify_bundle", "__version__"]
@@ -0,0 +1,3 @@
1
+ from .cli import main
2
+
3
+ main()
loopgrid_verify/cli.py ADDED
@@ -0,0 +1,96 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+
5
+ from .verifier import verify_bundle
6
+ from .version import __version__
7
+
8
+
9
+ def build_parser() -> argparse.ArgumentParser:
10
+ parser = argparse.ArgumentParser(
11
+ prog="loopgrid-verify",
12
+ description="Offline verifier for LoopGrid evidence bundles",
13
+ )
14
+ parser.add_argument(
15
+ "bundle",
16
+ help="Path to a LoopGrid evidence ZIP bundle",
17
+ )
18
+ parser.add_argument(
19
+ "--tsa-ca-file",
20
+ default=None,
21
+ help="Trusted CA bundle for RFC3161 signer validation via OpenSSL",
22
+ )
23
+ parser.add_argument(
24
+ "--expected-key-id",
25
+ default=None,
26
+ help="Pin the expected LoopGrid signer key id, e.g. ed25519:abc123...",
27
+ )
28
+ parser.add_argument(
29
+ "--trusted-public-key",
30
+ default=None,
31
+ help="Pin signer identity to an out-of-band trusted PEM public key",
32
+ )
33
+ parser.add_argument(
34
+ "--version",
35
+ action="version",
36
+ version=f"%(prog)s {__version__}",
37
+ )
38
+ return parser
39
+
40
+
41
+ def _has_failure(result: dict, reason: str) -> bool:
42
+ return any(
43
+ isinstance(item, dict) and item.get("reason") == reason
44
+ for item in (result.get("failures") or [])
45
+ )
46
+
47
+
48
+ def main() -> None:
49
+ args = build_parser().parse_args()
50
+
51
+ result = verify_bundle(
52
+ args.bundle,
53
+ args.tsa_ca_file,
54
+ args.expected_key_id,
55
+ args.trusted_public_key,
56
+ )
57
+
58
+ # Keep CLI output intentionally concise and avoid printing the full
59
+ # verification object. Detailed structured results remain available
60
+ # through the Python verify_bundle() API.
61
+ print("LOOPGRID EVIDENCE VERIFICATION")
62
+
63
+ bundle_integrity = result.get("bundle_integrity") or {}
64
+
65
+ if result["valid"] and bundle_integrity.get("attested"):
66
+ print("[OK] VERIFIED")
67
+ print("[DETAIL] Bundle integrity: attested")
68
+
69
+ elif result["valid"]:
70
+ print("[OK] LEDGER VERIFIED")
71
+ print(
72
+ "[WARN] Legacy/unattested bundle: exported file bytes are not "
73
+ "covered by a signed bundle attestation."
74
+ )
75
+
76
+ else:
77
+ print("[FAIL] INVALID")
78
+
79
+ if _has_failure(result, "bundle_file_digest_mismatch"):
80
+ print("[DETAIL] Bundle file digest mismatch.")
81
+ elif _has_failure(result, "trusted_public_key_mismatch"):
82
+ print("[DETAIL] Trusted public key mismatch.")
83
+ elif _has_failure(result, "expected_key_id_mismatch"):
84
+ print("[DETAIL] Expected signer key ID mismatch.")
85
+ elif _has_failure(result, "bundle_attestation_signature_invalid"):
86
+ print("[DETAIL] Bundle attestation signature is invalid.")
87
+ elif _has_failure(result, "bundle_attestation_digest_mismatch"):
88
+ print("[DETAIL] Bundle attestation digest mismatch.")
89
+ else:
90
+ print("[DETAIL] Verification checks failed.")
91
+
92
+ raise SystemExit(0 if result["valid"] else 2)
93
+
94
+
95
+ if __name__ == "__main__":
96
+ main()
@@ -0,0 +1,372 @@
1
+ from __future__ import annotations
2
+ import argparse,base64,hashlib,json,subprocess,tempfile,zipfile
3
+ from pathlib import Path
4
+ from cryptography.hazmat.primitives import hashes,serialization
5
+ from cryptography.hazmat.primitives.asymmetric import ec,utils
6
+ from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
7
+
8
+
9
+ def canonical_json(obj)->bytes:
10
+ return json.dumps(obj,sort_keys=True,separators=(",",":"),ensure_ascii=False,allow_nan=False).encode("utf-8")
11
+
12
+ def sha256_hex(data:bytes)->str:return hashlib.sha256(data).hexdigest()
13
+
14
+ def _lines(z,name):
15
+ try:return [json.loads(x) for x in z.read(name).decode().splitlines() if x.strip()]
16
+ except KeyError:return []
17
+
18
+ def _json_file(z,name,default=None):
19
+ try:return json.loads(z.read(name))
20
+ except KeyError:return default
21
+
22
+ def _policy_digest(policy,workspace_id=None):
23
+ if not isinstance(policy,dict):return None
24
+ required={
25
+ "workspace_id":policy.get("workspace_id") or workspace_id,
26
+ "policy_id":policy.get("policy_id"),
27
+ "version":policy.get("version"),
28
+ "rule":policy.get("rule"),
29
+ }
30
+ return sha256_hex(canonical_json(required))
31
+
32
+
33
+ def _public_key_id(public)->str:
34
+ if isinstance(public,Ed25519PublicKey):
35
+ raw=public.public_bytes(serialization.Encoding.Raw,serialization.PublicFormat.Raw)
36
+ return "ed25519:"+sha256_hex(raw)[:16]
37
+ if isinstance(public,ec.EllipticCurvePublicKey):
38
+ pem=public.public_bytes(serialization.Encoding.PEM,serialization.PublicFormat.SubjectPublicKeyInfo)
39
+ return "aws-kms:"+sha256_hex(pem)[:16]
40
+ return "unknown:"+sha256_hex(public.public_bytes(serialization.Encoding.DER,serialization.PublicFormat.SubjectPublicKeyInfo))[:16]
41
+
42
+
43
+ def _verify_sig(public,algorithm,hex_hash,signature_b64):
44
+ try:
45
+ sig=base64.b64decode(signature_b64);digest=bytes.fromhex(hex_hash)
46
+ if algorithm=="Ed25519":
47
+ if not isinstance(public,Ed25519PublicKey):return False
48
+ public.verify(sig,digest);return True
49
+ if algorithm=="ECDSA_SHA_256":
50
+ if not isinstance(public,ec.EllipticCurvePublicKey):return False
51
+ public.verify(sig,digest,ec.ECDSA(utils.Prehashed(hashes.SHA256())));return True
52
+ return False
53
+ except Exception:return False
54
+
55
+
56
+ def _verify_rfc3161_imprint(raw: bytes, expected_digest: str) -> dict:
57
+ """Validate RFC3161 status, SHA-256 algorithm and message imprint without OpenSSL."""
58
+ try:
59
+ from asn1crypto import tsp
60
+
61
+ resp = tsp.TimeStampResp.load(raw)
62
+ status = resp["status"]["status"].native
63
+ if status not in {"granted", "granted_with_mods"}:
64
+ return {"valid": False, "status": status, "reason": "timestamp_status_not_granted"}
65
+ token = resp["time_stamp_token"]
66
+ content = token["content"]["encap_content_info"]["content"]
67
+ info = content.parsed
68
+ imprint = info["message_imprint"]["hashed_message"].native.hex()
69
+ algorithm = info["message_imprint"]["hash_algorithm"]["algorithm"].native
70
+ valid = algorithm == "sha256" and imprint.lower() == expected_digest.lower()
71
+ return {
72
+ "valid": valid,
73
+ "status": status,
74
+ "algorithm": algorithm,
75
+ "imprint": imprint,
76
+ "gen_time": str(info["gen_time"].native),
77
+ }
78
+ except Exception as exc:
79
+ return {"valid": False, "reason": "timestamp_parse_error", "detail": type(exc).__name__}
80
+
81
+
82
+ def _signed_body(e):
83
+ return {k:e.get(k) for k in ["event_id","decision_id","workspace_id","event_type","occurred_at","actor","privacy_mode","payload_commitment","payload"]}
84
+
85
+
86
+ def _verify_bundle_file_attestation(z,manifest,public,computed_key_id):
87
+ failures=[];warnings=[]
88
+ bundle_schema=manifest.get('bundle_schema')
89
+ result={
90
+ "status":"legacy_unattested",
91
+ "attested":False,
92
+ "attestation_schema":None,
93
+ "hash_algorithm":None,
94
+ "files_checked":0,
95
+ "signature_valid":None,
96
+ "attestation_digest_valid":None,
97
+ }
98
+ integrity_declared=manifest.get('bundle_integrity') or {}
99
+ attestation_expected=(
100
+ integrity_declared.get('mode')=='signed_file_attestation'
101
+ or 'bundle-attestation.json' in z.namelist()
102
+ )
103
+ if not attestation_expected:
104
+ warnings.append({
105
+ "reason":"bundle_file_attestation_unavailable",
106
+ "detail":"Legacy/unattested bundle: signed ledger verification is available, but exported file bytes are not covered by a bundle-level file attestation.",
107
+ })
108
+ return result,failures,warnings
109
+
110
+ try:
111
+ attestation=json.loads(z.read('bundle-attestation.json'))
112
+ except KeyError:
113
+ failures.append({"reason":"bundle_attestation_missing"})
114
+ result["status"]="invalid"
115
+ return result,failures,warnings
116
+ except Exception as exc:
117
+ failures.append({"reason":"bundle_attestation_unreadable","detail":type(exc).__name__})
118
+ result["status"]="invalid"
119
+ return result,failures,warnings
120
+
121
+ result["attestation_schema"]=attestation.get('attestation_schema')
122
+ result["hash_algorithm"]=attestation.get('hash_algorithm')
123
+ if attestation.get('attestation_schema')!='loopgrid/bundle-attestation/1':
124
+ failures.append({"reason":"bundle_attestation_schema_invalid","attestation_schema":attestation.get('attestation_schema')})
125
+ if attestation.get('bundle_schema')!=bundle_schema:
126
+ failures.append({"reason":"bundle_attestation_bundle_schema_mismatch"})
127
+ if attestation.get('decision_id')!=manifest.get('decision_id'):
128
+ failures.append({"reason":"bundle_attestation_decision_mismatch"})
129
+ if attestation.get('workspace_id')!=manifest.get('workspace_id'):
130
+ failures.append({"reason":"bundle_attestation_workspace_mismatch"})
131
+ if attestation.get('hash_algorithm')!='SHA-256':
132
+ failures.append({"reason":"bundle_attestation_hash_algorithm_invalid","algorithm":attestation.get('hash_algorithm')})
133
+
134
+ declared_signer=attestation.get('signer') or {}
135
+ if declared_signer.get('key_id')!=computed_key_id:
136
+ failures.append({
137
+ "reason":"bundle_attestation_key_id_mismatch",
138
+ "attestation_key_id":declared_signer.get('key_id'),
139
+ "computed_key_id":computed_key_id,
140
+ })
141
+ manifest_key_id=(manifest.get('signer') or {}).get('key_id') or (manifest.get('integrity') or {}).get('key_id')
142
+ if manifest_key_id and declared_signer.get('key_id')!=manifest_key_id:
143
+ failures.append({"reason":"bundle_attestation_manifest_key_id_mismatch"})
144
+
145
+ body={k:attestation.get(k) for k in [
146
+ 'attestation_schema','bundle_schema','decision_id','workspace_id','hash_algorithm','files','signer'
147
+ ]}
148
+ computed_attestation_digest=sha256_hex(canonical_json(body))
149
+ declared_digest=attestation.get('attestation_digest')
150
+ result["attestation_digest_valid"]=declared_digest==computed_attestation_digest
151
+ if not result["attestation_digest_valid"]:
152
+ failures.append({
153
+ "reason":"bundle_attestation_digest_mismatch",
154
+ "computed":computed_attestation_digest,
155
+ "declared":declared_digest,
156
+ })
157
+
158
+ algorithm=declared_signer.get('algorithm') or (manifest.get('signer') or {}).get('algorithm') or 'Ed25519'
159
+ result["signature_valid"]=_verify_sig(public,algorithm,computed_attestation_digest,attestation.get('signature',''))
160
+ if not result["signature_valid"]:
161
+ failures.append({"reason":"bundle_attestation_signature_invalid","algorithm":algorithm})
162
+
163
+ files=attestation.get('files')
164
+ if not isinstance(files,dict) or not files:
165
+ failures.append({"reason":"bundle_attestation_files_missing"})
166
+ files={}
167
+ if 'manifest.json' not in files:
168
+ failures.append({"reason":"bundle_attestation_manifest_digest_missing"})
169
+ if 'bundle-attestation.json' in files:
170
+ failures.append({"reason":"bundle_attestation_self_reference"})
171
+
172
+ archive_names=[n for n in z.namelist() if not n.endswith('/')]
173
+ if len(archive_names)!=len(set(archive_names)):
174
+ failures.append({"reason":"duplicate_archive_entry"})
175
+ archive_set=set(archive_names)
176
+ expected_set=set(files)|{'bundle-attestation.json'}
177
+ for missing in sorted(expected_set-archive_set):
178
+ failures.append({"reason":"attested_file_missing","file":missing})
179
+ for extra in sorted(archive_set-expected_set):
180
+ failures.append({"reason":"unattested_archive_file","file":extra})
181
+
182
+ for name,declared_hash in sorted(files.items()):
183
+ if not isinstance(name,str) or not isinstance(declared_hash,str):
184
+ failures.append({"reason":"bundle_attestation_file_entry_invalid","file":str(name)})
185
+ continue
186
+ try:
187
+ raw=z.read(name)
188
+ except KeyError:
189
+ continue
190
+ actual=sha256_hex(raw)
191
+ result["files_checked"]+=1
192
+ if actual!=declared_hash:
193
+ failures.append({
194
+ "reason":"bundle_file_digest_mismatch",
195
+ "file":name,
196
+ "computed":actual,
197
+ "declared":declared_hash,
198
+ })
199
+
200
+ manifest_files=manifest.get('files') or {}
201
+ for role,name in manifest_files.items():
202
+ if not name:
203
+ continue
204
+ if name=='bundle-attestation.json':
205
+ continue
206
+ if name not in files:
207
+ failures.append({"reason":"manifest_file_not_attested","role":role,"file":name})
208
+
209
+ result["attested"]=not failures
210
+ result["status"]='attested' if result["attested"] else 'invalid'
211
+ return result,failures,warnings
212
+
213
+
214
+ def verify_bundle(path:str,tsa_ca_file:str|None=None,expected_key_id:str|None=None,trusted_public_key:str|None=None)->dict:
215
+ failures=[];warnings=[]
216
+ with zipfile.ZipFile(path) as z:
217
+ manifest=json.loads(z.read('manifest.json'))
218
+ bundled_pem=z.read('public-key.pem');public=serialization.load_pem_public_key(bundled_pem)
219
+ computed_key_id=_public_key_id(public);manifest_key_id=(manifest.get('signer') or {}).get('key_id') or (manifest.get('integrity') or {}).get('key_id')
220
+ bundle_schema=manifest.get('bundle_schema')
221
+ if bundle_schema and bundle_schema!='loopgrid/evidence-bundle/2':
222
+ warnings.append({"reason":"unknown_bundle_schema","bundle_schema":bundle_schema})
223
+ bundle_integrity,bundle_failures,bundle_warnings=_verify_bundle_file_attestation(z,manifest,public,computed_key_id)
224
+ failures.extend(bundle_failures);warnings.extend(bundle_warnings)
225
+
226
+ # For attested bundles, authenticate the exact exported bytes before parsing
227
+ # auxiliary JSON/JSONL documents. This prevents malformed tampered files from
228
+ # turning a clean verification failure into a parser exception.
229
+ if (manifest.get('bundle_integrity') or {}).get('mode')=='signed_file_attestation' and bundle_failures:
230
+ return {
231
+ "valid":False,"events":0,"witnesses":0,"disclosures":0,
232
+ "failures":failures,"warnings":warnings,
233
+ "decision_id":manifest.get('decision_id'),"workspace_id":manifest.get('workspace_id'),
234
+ "software_version":manifest.get('software_version'),"evidence_profile":manifest.get('version'),
235
+ "bundle_schema":bundle_schema,
236
+ "signature_algorithm":manifest.get('signer',{}).get('algorithm') or manifest.get('integrity',{}).get('signature_algorithm'),
237
+ "key_identity":{
238
+ "computed_key_id":computed_key_id,
239
+ "manifest_key_id":manifest_key_id,
240
+ "manifest_match":not manifest_key_id or computed_key_id==manifest_key_id,
241
+ "expected_key_id":expected_key_id,
242
+ "expected_key_match":None if expected_key_id is None else computed_key_id==expected_key_id,
243
+ "trusted_public_key_supplied":bool(trusted_public_key),
244
+ "trusted_public_key_match":None,
245
+ "trust_note":"An embedded public key proves bundle integrity under that key. Pin --expected-key-id or --trusted-public-key when signer identity/authenticity must be established out of band."
246
+ },
247
+ "bundle_integrity":bundle_integrity,"checkpoint":{"present":False,"signature_valid":None,"linked_to_bundle_chain":None},
248
+ "timestamp":{"present":'timestamp.tsr' in z.namelist(),"imprint_valid":None,"trust_validated":None},
249
+ "lifecycle":manifest.get('lifecycle'),"policy_digest":(manifest.get('policy') or {}).get('policy_digest')
250
+ }
251
+
252
+ events=_lines(z,'events.jsonl');witnesses=_lines(z,'chain-witness.jsonl');disclosures=_lines(z,'disclosures.jsonl')
253
+ signer_doc=_json_file(z,'signer.json')
254
+ verification_doc=_json_file(z,'verification.json')
255
+ lifecycle_doc=_json_file(z,'lifecycle.json')
256
+ policy_doc=_json_file(z,'policy/policy.json')
257
+ if signer_doc and signer_doc.get('key_id') and signer_doc.get('key_id')!=computed_key_id:
258
+ failures.append({"reason":"signer_document_key_id_mismatch","signer_key_id":signer_doc.get('key_id'),"computed_key_id":computed_key_id})
259
+ if lifecycle_doc is not None and manifest.get('lifecycle') is not None and lifecycle_doc!=manifest.get('lifecycle'):
260
+ failures.append({"reason":"lifecycle_document_mismatch"})
261
+ if verification_doc and verification_doc.get('decision_id') not in {None,manifest.get('decision_id')}:
262
+ failures.append({"reason":"verification_document_decision_mismatch"})
263
+ if policy_doc:
264
+ digest=_policy_digest(policy_doc,manifest.get('workspace_id'))
265
+ declared=policy_doc.get('policy_digest')
266
+ manifest_digest=(manifest.get('policy') or {}).get('policy_digest')
267
+ if declared and digest!=declared:
268
+ failures.append({"reason":"policy_digest_mismatch","computed":digest,"declared":declared})
269
+ if manifest_digest and digest!=manifest_digest:
270
+ failures.append({"reason":"manifest_policy_digest_mismatch","computed":digest,"manifest":manifest_digest})
271
+ if manifest_key_id and computed_key_id!=manifest_key_id:
272
+ failures.append({"reason":"manifest_public_key_id_mismatch","manifest_key_id":manifest_key_id,"computed_key_id":computed_key_id})
273
+ if expected_key_id and computed_key_id!=expected_key_id:
274
+ failures.append({"reason":"expected_key_id_mismatch","expected_key_id":expected_key_id,"computed_key_id":computed_key_id})
275
+ trusted_key_match=None
276
+ if trusted_public_key:
277
+ try:
278
+ trusted=serialization.load_pem_public_key(Path(trusted_public_key).read_bytes())
279
+ trusted_der=trusted.public_bytes(serialization.Encoding.DER,serialization.PublicFormat.SubjectPublicKeyInfo)
280
+ bundle_der=public.public_bytes(serialization.Encoding.DER,serialization.PublicFormat.SubjectPublicKeyInfo)
281
+ trusted_key_match=trusted_der==bundle_der
282
+ if not trusted_key_match:failures.append({"reason":"trusted_public_key_mismatch"})
283
+ except Exception as e:
284
+ failures.append({"reason":"trusted_public_key_unreadable","detail":type(e).__name__})
285
+
286
+ # Verify target events and opaque continuity witnesses in workspace-ledger order.
287
+ nodes=[]
288
+ for e in events:nodes.append({"seq":e['seq'],"event":e,"proof":e['proof'],"opaque":False})
289
+ for w in witnesses:nodes.append({"seq":w['seq'],"event":None,"proof":w['proof'],"opaque":True})
290
+ nodes.sort(key=lambda n:n['seq'])
291
+ prev=None
292
+ for node in nodes:
293
+ proof=node['proof'];seq=node['seq'];alg=proof.get('signature_algorithm') or manifest.get('integrity',{}).get('signature_algorithm') or manifest.get('signer',{}).get('algorithm') or 'Ed25519'
294
+ proof_key_id=proof.get('key_id')
295
+ if proof_key_id and proof_key_id!=computed_key_id:
296
+ failures.append({"seq":seq,"reason":"proof_key_id_mismatch","proof_key_id":proof_key_id,"computed_key_id":computed_key_id})
297
+ if not node['opaque']:
298
+ e=node['event'];expected_content=sha256_hex(canonical_json(_signed_body(e)))
299
+ if expected_content!=proof.get('content_hash'):failures.append({"seq":seq,"reason":"content_hash_mismatch"})
300
+ try:expected_chain=sha256_hex(bytes.fromhex(proof.get('previous_chain_hash','0'*64))+bytes.fromhex(expected_content))
301
+ except Exception:
302
+ expected_chain='';failures.append({"seq":seq,"reason":"malformed_chain_hash"})
303
+ if expected_chain!=proof.get('chain_hash'):failures.append({"seq":seq,"reason":"chain_hash_mismatch"})
304
+ if prev is not None and proof.get('previous_chain_hash')!=prev:failures.append({"seq":seq,"reason":"previous_chain_hash_mismatch"})
305
+ if not _verify_sig(public,alg,proof.get('chain_hash',''),proof.get('signature','')):failures.append({"seq":seq,"reason":"signature_invalid","algorithm":alg})
306
+ prev=proof.get('chain_hash')
307
+
308
+ # Verify optional full-payload disclosures against the commitments sealed in events.
309
+ by_id={e['event_id']:e for e in events}
310
+ for d in disclosures:
311
+ e=by_id.get(d.get('event_id'))
312
+ if not e:failures.append({"event_id":d.get('event_id'),"reason":"orphan_disclosure"});continue
313
+ digest=sha256_hex(canonical_json(d.get('payload')))
314
+ if digest!=e.get('payload_commitment') or digest!=d.get('payload_commitment'):failures.append({"event_id":d.get('event_id'),"reason":"disclosure_commitment_mismatch"})
315
+
316
+ # Checkpoint proof + RFC3161 timestamp. Imprint validation is portable; optional
317
+ # certificate-chain trust verification still uses OpenSSL when a CA bundle is supplied.
318
+ cp=manifest.get('checkpoint') or {}
319
+ checkpoint={"present":bool(cp),"signature_valid":None,"linked_to_bundle_chain":None}
320
+ if cp:
321
+ cp_digest=cp.get('chain_hash')
322
+ cp_sig=cp.get('signature')
323
+ cp_alg=cp.get('signature_algorithm') or manifest.get('signer',{}).get('algorithm')
324
+ cp_key=cp.get('key_id')
325
+ if cp_key and cp_key!=computed_key_id:
326
+ failures.append({"reason":"checkpoint_key_id_mismatch","checkpoint_key_id":cp_key,"computed_key_id":computed_key_id})
327
+ checkpoint['signature_valid']=bool(cp_digest and cp_sig and _verify_sig(public,cp_alg,cp_digest,cp_sig))
328
+ if not checkpoint['signature_valid']:
329
+ failures.append({"reason":"checkpoint_signature_invalid"})
330
+ cp_seq=cp.get('ledger_seq')
331
+ matched=next((n for n in nodes if n.get('seq')==cp_seq),None)
332
+ checkpoint['linked_to_bundle_chain']=bool(matched and matched.get('proof',{}).get('chain_hash')==cp_digest)
333
+ if not checkpoint['linked_to_bundle_chain']:
334
+ warnings.append({"reason":"checkpoint_not_linked_to_bundle_chain","detail":"Bundle remains event-verifiable, but this checkpoint is not bridged by included nodes."})
335
+
336
+ timestamp={"present":'timestamp.tsr' in z.namelist(),"imprint_valid":None,"trust_validated":None}
337
+ if timestamp['present']:
338
+ digest=cp.get('chain_hash') if cp else None
339
+ if not digest:
340
+ failures.append({"reason":"timestamp_checkpoint_missing"})
341
+ else:
342
+ imprint_result=_verify_rfc3161_imprint(z.read('timestamp.tsr'),digest)
343
+ timestamp['imprint_valid']=imprint_result.get('valid') is True
344
+ timestamp['status']=imprint_result.get('status')
345
+ timestamp['algorithm']=imprint_result.get('algorithm')
346
+ timestamp['gen_time']=imprint_result.get('gen_time')
347
+ if not timestamp['imprint_valid']:
348
+ failures.append({"reason":"timestamp_imprint_invalid","detail":imprint_result.get('reason') or 'imprint mismatch'})
349
+
350
+ if timestamp['present'] and tsa_ca_file:
351
+ try:
352
+ digest=cp.get('chain_hash')
353
+ if not digest:raise ValueError('checkpoint chain hash missing')
354
+ with tempfile.NamedTemporaryFile(suffix='.tsr',delete=False) as f:f.write(z.read('timestamp.tsr'));ts_path=f.name
355
+ r=subprocess.run(['openssl','ts','-verify','-digest',digest,'-in',ts_path,'-CAfile',tsa_ca_file],capture_output=True,text=True,timeout=10)
356
+ timestamp['trust_validated']=r.returncode==0
357
+ if r.returncode!=0:failures.append({"reason":"timestamp_trust_invalid","detail":r.stderr[-300:]})
358
+ except Exception as e:warnings.append({"reason":"timestamp_trust_not_checked","detail":type(e).__name__})
359
+ elif timestamp['present']:
360
+ warnings.append({"reason":"timestamp_present_trust_not_checked","detail":"RFC3161 imprint is valid; pass --tsa-ca-file for signer certificate-chain trust validation."})
361
+
362
+ key_identity={
363
+ "computed_key_id":computed_key_id,
364
+ "manifest_key_id":manifest_key_id,
365
+ "manifest_match":not manifest_key_id or computed_key_id==manifest_key_id,
366
+ "expected_key_id":expected_key_id,
367
+ "expected_key_match":None if expected_key_id is None else computed_key_id==expected_key_id,
368
+ "trusted_public_key_supplied":bool(trusted_public_key),
369
+ "trusted_public_key_match":trusted_key_match,
370
+ "trust_note":"An embedded public key proves bundle integrity under that key. Pin --expected-key-id or --trusted-public-key when signer identity/authenticity must be established out of band."
371
+ }
372
+ return {"valid":not failures,"events":len(events),"witnesses":len(witnesses),"disclosures":len(disclosures),"failures":failures,"warnings":warnings,"decision_id":manifest.get('decision_id'),"workspace_id":manifest.get('workspace_id'),"software_version":manifest.get('software_version'),"evidence_profile":manifest.get('version'),"bundle_schema":manifest.get('bundle_schema') or 'legacy','signature_algorithm':manifest.get('signer',{}).get('algorithm') or manifest.get('integrity',{}).get('signature_algorithm'),"key_identity":key_identity,"bundle_integrity":bundle_integrity,"checkpoint":checkpoint,"timestamp":timestamp,"lifecycle":manifest.get('lifecycle'),"policy_digest":(manifest.get('policy') or {}).get('policy_digest')}
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
@@ -0,0 +1,240 @@
1
+ Metadata-Version: 2.4
2
+ Name: loopgrid-verify
3
+ Version: 0.1.0
4
+ Summary: Standalone offline verifier for LoopGrid evidence bundles
5
+ Author: LoopGrid
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://loopgrid.io
8
+ Project-URL: Repository, https://github.com/loopgridio/loopgrid-verify
9
+ Project-URL: Issues, https://github.com/loopgridio/loopgrid-verify/issues
10
+ Project-URL: Documentation, https://github.com/loopgridio/loopgrid-verify#readme
11
+ Keywords: ai-agents,evidence,verification,audit,cryptography,ed25519,tamper-evident
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Security :: Cryptography
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: cryptography<47,>=42
27
+ Requires-Dist: asn1crypto<2,>=1.5
28
+ Provides-Extra: dev
29
+ Requires-Dist: build<2,>=1.2; extra == "dev"
30
+ Requires-Dist: pytest<10,>=8; extra == "dev"
31
+ Requires-Dist: twine<8,>=5; extra == "dev"
32
+ Dynamic: license-file
33
+
34
+ # LoopGrid Verify
35
+
36
+ **Standalone offline verification for LoopGrid evidence bundles.**
37
+
38
+ `loopgrid-verify` verifies exported LoopGrid evidence without connecting to a LoopGrid server. It is designed for design partners, reviewers, auditors, operators, and engineering teams that want to inspect a portable evidence bundle independently of the running LoopGrid service.
39
+
40
+ Current package: **0.1.0 design preview**
41
+
42
+ ## Install
43
+
44
+ ```bash
45
+ pip install loopgrid-verify
46
+ ```
47
+
48
+ Python 3.10–3.13 is supported.
49
+
50
+ ## Verify a bundle
51
+
52
+ ```bash
53
+ loopgrid-verify evidence.zip
54
+ ```
55
+
56
+ For higher-assurance verification, pin signer identity using an out-of-band trusted public key:
57
+
58
+ ```bash
59
+ loopgrid-verify evidence.zip \
60
+ --trusted-public-key trusted-public-key.pem
61
+ ```
62
+
63
+ Or pin the expected LoopGrid signer key ID:
64
+
65
+ ```bash
66
+ loopgrid-verify evidence.zip \
67
+ --expected-key-id ed25519:0123456789abcdef
68
+ ```
69
+
70
+ For an RFC3161 timestamp token, the verifier validates the timestamp status, SHA-256 message imprint, and imprint match locally. To additionally validate the timestamp signer certificate chain, provide a trusted CA bundle and ensure `openssl` is available:
71
+
72
+ ```bash
73
+ loopgrid-verify evidence.zip \
74
+ --tsa-ca-file tsa-ca.pem
75
+ ```
76
+
77
+ ## Verification result
78
+
79
+ A valid attested bundle prints:
80
+
81
+ ```text
82
+ LOOPGRID EVIDENCE VERIFICATION
83
+ [OK] VERIFIED
84
+ ```
85
+
86
+ A modified or otherwise invalid bundle prints:
87
+
88
+ ```text
89
+ LOOPGRID EVIDENCE VERIFICATION
90
+ [FAIL] INVALID
91
+ ```
92
+
93
+ and exits with status code `2`.
94
+
95
+ Legacy Evidence Bundle v2 exports created before signed file attestation remain ledger-verifiable. They are explicitly labeled:
96
+
97
+ ```text
98
+ [OK] LEDGER VERIFIED
99
+ [WARN] Legacy/unattested bundle: exported file bytes are not covered by a signed bundle attestation.
100
+ ```
101
+
102
+ ## What is verified
103
+
104
+ For current attested Evidence Bundle v2 exports, the verifier checks:
105
+
106
+ - the signed bundle-attestation digest;
107
+ - the attestation signature;
108
+ - SHA-256 digests for attested exported files;
109
+ - missing, duplicate, and unexpected archive entries;
110
+ - the embedded signer key identity;
111
+ - optional out-of-band public-key or key-ID pinning;
112
+ - signed event content hashes and signatures;
113
+ - workspace hash-chain continuity across events and proof-only witnesses;
114
+ - disclosed payload commitments when disclosures are included;
115
+ - policy digest consistency;
116
+ - lifecycle and verification-document consistency;
117
+ - checkpoint signatures and linkage when present;
118
+ - RFC3161 timestamp imprint validity when present;
119
+ - optional RFC3161 signer certificate-chain trust when `--tsa-ca-file` is supplied.
120
+
121
+ ## Trust model
122
+
123
+ The public key embedded in an evidence bundle proves that the bundle is internally consistent under that key. It does **not**, by itself, establish who controls that key.
124
+
125
+ When signer authenticity matters, pin trust out of band using:
126
+
127
+ ```text
128
+ --trusted-public-key
129
+ ```
130
+
131
+ or:
132
+
133
+ ```text
134
+ --expected-key-id
135
+ ```
136
+
137
+ This distinction is intentional: bundle integrity and signer authenticity are separate questions.
138
+
139
+ ## Python API
140
+
141
+ ```python
142
+ from loopgrid_verify import verify_bundle
143
+
144
+ result = verify_bundle(
145
+ "evidence.zip",
146
+ trusted_public_key="trusted-public-key.pem",
147
+ )
148
+
149
+ if result["valid"]:
150
+ print("verified")
151
+ else:
152
+ print(result["failures"])
153
+ ```
154
+
155
+ The API is:
156
+
157
+ ```python
158
+ verify_bundle(
159
+ path,
160
+ tsa_ca_file=None,
161
+ expected_key_id=None,
162
+ trusted_public_key=None,
163
+ ) -> dict
164
+ ```
165
+
166
+ ## What this verifier does not determine
167
+
168
+ `loopgrid-verify` checks cryptographic and structural evidence properties. It does not determine whether an AI decision was correct, safe, fair, lawful, compliant, or otherwise appropriate. It is evidence-verification infrastructure, not a legal or regulatory compliance determination.
169
+
170
+ ## Server-independent by design
171
+
172
+ Verification does not require:
173
+
174
+ - a LoopGrid server;
175
+ - a database;
176
+ - Docker;
177
+ - an API key;
178
+ - an MCP server;
179
+ - a network connection.
180
+
181
+ The only optional external executable is `openssl`, and only when certificate-chain trust validation is requested for an RFC3161 timestamp using `--tsa-ca-file`.
182
+
183
+ ## Development
184
+
185
+ ```bash
186
+ python -m venv .venv
187
+ ```
188
+
189
+ Windows PowerShell:
190
+
191
+ ```powershell
192
+ .\.venv\Scripts\Activate.ps1
193
+ python -m pip install --upgrade pip
194
+ pip install -e ".[dev]"
195
+ python -m pytest -q
196
+ python scripts/release_check.py
197
+ ```
198
+
199
+ macOS/Linux:
200
+
201
+ ```bash
202
+ source .venv/bin/activate
203
+ python -m pip install --upgrade pip
204
+ pip install -e ".[dev]"
205
+ python -m pytest -q
206
+ python scripts/release_check.py
207
+ ```
208
+
209
+ Build:
210
+
211
+ ```bash
212
+ python -m build
213
+ python -m twine check dist/*
214
+ ```
215
+
216
+ ## Fixture coverage
217
+
218
+ The test suite includes:
219
+
220
+ - a current signed-file-attested Evidence Bundle v2;
221
+ - the same bundle with `report.html` modified;
222
+ - a legacy/unattested Evidence Bundle v2;
223
+ - the correct trusted public key;
224
+ - a deliberately incorrect trusted public key.
225
+
226
+ The tampered bundle must fail verification. The legacy bundle may pass signed-ledger verification only with the explicit `legacy_unattested` status/warning.
227
+
228
+ ## Release posture
229
+
230
+ `0.1.0` is a design-preview verifier release. The package is intended for technical evaluation and design-partner workflows. It is not a legal-compliance certification tool.
231
+
232
+ ## Related projects
233
+
234
+ - LoopGrid core: `https://github.com/cybertechsoft/loopgrid`
235
+ - LoopGrid MCP: `https://github.com/loopgridio/loopgrid-mcp`
236
+ - Website: `https://loopgrid.io`
237
+
238
+ ## License
239
+
240
+ Apache-2.0. See `LICENSE`.
@@ -0,0 +1,11 @@
1
+ loopgrid_verify/__init__.py,sha256=kv7J5doxEwuyiz0IQjeHGjMtHFRwvPnNbzA9Zu8e5-Q,183
2
+ loopgrid_verify/__main__.py,sha256=bYt9eEaoRQWdejEHFD8REx9jxVEdZptECFsV7F49Ink,30
3
+ loopgrid_verify/cli.py,sha256=8SW3Azssp6OmgBUglHvj_2ujjTudF4k2w5J_2UV484g,2964
4
+ loopgrid_verify/verifier.py,sha256=aRC0jylD_UDFyR9nZdvkqnL8S0aLBhkcbsyTK2oJjX8,22344
5
+ loopgrid_verify/version.py,sha256=kUR5RAFc7HCeiqdlX36dZOHkUI5wI6V_43RpEcD8b-0,22
6
+ loopgrid_verify-0.1.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
7
+ loopgrid_verify-0.1.0.dist-info/METADATA,sha256=NGnvrLMXGCn6NHet7ORjx-fkQ_Bptba0ZxCTqgb384Y,6697
8
+ loopgrid_verify-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
9
+ loopgrid_verify-0.1.0.dist-info/entry_points.txt,sha256=iinW0TbtLmSGqZ_ei3iCJSEut6LCx3gmHg_yAta1FBw,61
10
+ loopgrid_verify-0.1.0.dist-info/top_level.txt,sha256=6pqEgJp6LisGJ7sivjHz3HZ801w65Q9iRVp4PnGj2iY,16
11
+ loopgrid_verify-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ loopgrid-verify = loopgrid_verify.cli:main
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1 @@
1
+ loopgrid_verify