Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/om/pipeline/seal-reuse-check.py # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / om / pipeline / seal-reuse-check.py` 42 lines · 2081 bytes Raw Blame History 1 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 # External independent SHA256 oracle for the Omega normalized-command memo. 3 import ctypes,hashlib,json,random,sys,time 4 from pathlib import Path 5 l=ctypes.CDLL(sys.argv[1]);fn=l.omega_native_mcreseal 6 fn.argtypes=[ctypes.POINTER(ctypes.c_uint64),ctypes.c_void_p,ctypes.c_uint64,ctypes.c_void_p,ctypes.c_uint64,ctypes.c_uint64,ctypes.c_void_p,ctypes.c_uint64,ctypes.c_void_p,ctypes.c_uint64] 7 U=ctypes.c_ubyte 8 b=(U*1024)();q=(U*1024)();c=(U*2048)();o=(U*32)();r=ctypes.c_uint64() 9 rng=random.Random(710) 10 for a in (b,q): 11 for i in range(1024):a[i]=rng.randrange(256) 12 def digest(n): 13 v=bytearray(q[:384]);v[40:44]=bytes(4);v[48:52]=bytes(4) 14 return hashlib.sha256(bytes(b[:896+n*4])+v+bytes(q[512:896])).digest() 15 cases=0 16 def check(n): 17 global cases 18 for i in range(32):o[i]=255 19 rc=fn(ctypes.byref(r),b,1024,q,1024,n,c,2048,o,32) 20 assert rc==0,(rc,n) 21 if 1<=n<=32:assert r.value==0 and bytes(o)==digest(n),(n,r.value,bytes(o).hex(),digest(n).hex()) 22 else:assert r.value==2**64-1 and bytes(o)==bytes(32) 23 cases+=1 24 for n in (0,1,2,10,31,32,33,2**64-1,10):check(n);check(n) 25 # Every byte of both inputs: covered mutations must refresh, ignored bytes must retain exact digest. 26 for a in (b,q): 27 for i in range(1024): 28 a[i]^=1;check(32);check(32);a[i]^=1;check(32) 29 # Same bytes interpreted with each argument count, both directions. 30 for n in list(range(1,33))+list(range(32,0,-1)):check(n);check(n) 31 # Zero commands have equal overlapping prefixes across argument counts. 32 for a in (b,q): 33 for i in range(1024):a[i]=0 34 for n in (32,1,32,2,31,10):check(n);check(n) 35 check(10);start=time.perf_counter_ns() 36 for i in range(256): 37 assert fn(ctypes.byref(r),b,1024,q,1024,10,c,2048,o,32)==0 and r.value==0 38 elapsed=time.perf_counter_ns()-start 39 # Refresh cold memo as well, proving no prior command is required. 40 for i in range(2048):c[i]=0 41 check(10) 42 print(json.dumps({'pass':True,'oracle_cases':cases,'warm_calls':256,'warm_total_ns':elapsed,'all_input_byte_mutations':2048,'oracle':'Python hashlib.sha256 over original normalized byte contract'}))