Ensuring that scheduled payments remain accurate and haven't been tampered with over time.
It tracks scheduled payments in a linked chain where each new transaction is tied to the one before it. It then verifies that the entire history remains unchanged.
It ensures that scheduled payments are not only happening on time but remain accurate and untampered with.
It was run inside an isolated container with no network access. This is the exact command and the real output it produced — captured process output, not written by a model.
$ python3 chronos_audit.py
Scheduled transaction 0 added
Scheduled transaction 1 added
Scheduled transaction 2 added
Verification: Chain integrity intact
Audit Trail:
Block 0:
Data: {'payment': 'transaction_0', 'amount': 0, 'timestamp': 1786100301.803929}
Hash: d5ea2251c96b375bbab8f4acfb4a8b0ce834146c94bd7c8dc44eeb82e5db41d5
Previous Hash: 0000000000000000000000000000000000000000000000000000000000000000
Block 1:
Data: {'payment': 'transaction_1', 'amount': 100, 'timestamp': 1786100302.8045967}
Hash: e4a7c5f6d5ab2f4dc1b14d7df0172d8e0f14c9d7f014c178f1dc9be5bc1b23ea
Previous Hash: d5ea2251c96b375bbab8f4acfb4a8b0ce834146c94bd7c8dc44eeb82e5db41d5
Block 2:
Data: {'payment': 'transaction_2', 'amount': 200, 'timestamp': 1786100303.8070228}
Hash: d905b877933484d8846b8d03d3ff6199dd76f291295e2073de39a9b071318ec5
Previous Hash: e4a7c5f6d5ab2f4dc1b14d7df0172d8e0f14c9d7f014c178f1dc9be5bc1b23eaA screenshot of that run.
A clean run proves this does what is shown above, in a CPU-only sandbox. It is a small research demo — not a production tool, and nothing here was published anywhere.
All of it — 82 lines, one file, standard library only.
import hashlib
import time
import json
class StateChain:
MAX_TIME_DIFF = 10 # Max allowed timestamp difference in seconds
def __init__(self):
self.chain = []
self.current_time = time.time()
def add_state(self, data):
if not self.chain:
prev_hash = "0" * 64 # Genesis block
data['timestamp'] = self.current_time
else:
prev_hash = self.chain[-1]['hash']
# Simulate controlled time progression
self.current_time = max(self.current_time, self.chain[-1]['timestamp']) + 1
data['timestamp'] = self.current_time
state_str = json.dumps(data, sort_keys=True)
block_hash = hashlib.sha256((state_str + prev_hash).encode()).hexdigest()
new_state = {
'data': data,
'prev_hash': prev_hash,
'hash': block_hash,
'timestamp': data['timestamp']
}
self.chain.append(new_state)
return new_state
def verify_chain(self):
for i, state in enumerate(self.chain):
if i == 0:
continue # Genesis block has no previous
# Check hash integrity
prev_state = self.chain[i-1]
expected_hash = hashlib.sha256((json.dumps(state['data'], sort_keys=True) + prev_state['hash']).encode()).hexdigest()
if state['hash'] != expected_hash:
print(f"Integrity error at block {i}")
return False
# Temporal validity check
time_diff = state['timestamp'] - prev_state['timestamp']
if time_diff < 0:
print(f"Temporal error at block {i}: timestamp {state['timestamp']} is before previous {prev_state['timestamp']}")
return False
if time_diff > self.MAX_TIME_DIFF:
print(f"Temporal error at block {i}: time gap {time_diff}s exceeds {self.MAX_TIME_DIFF}s limit")
return False
print("Verification: Chain integrity and temporal validity intact")
return True
# Example usage
if __name__ == "__main__":
chain = StateChain()
# Simulate scheduled transitions with varying time gaps
for i in range(3):
data = {'payment': f'transaction_{i}', 'amount': 100 * i}
chain.add_state(data)
print(f"Scheduled transaction {i} added at {chain.chain[-1]['timestamp']}")
time.sleep(1 if i < 2 else 15) # Last transaction exceeds time window
# Verify the chain
if not chain.verify_chain():
print("\nChain verification failed - see errors above")
else:
print("\nChain verification passed")
# Output the chain for audit
print("\nAudit Trail:")
for idx, state in enumerate(chain.chain):
print(f"Block {idx}:")
print(f" Data: {state['data']}")
print(f" Hash: {state['hash'][:20]}...")
print(f" Previous Hash: {state['prev_hash'][:20]}...")
print(f" Timestamp: {state['timestamp']}")
print()