Spaces:
Sleeping
Sleeping
Update proof_engine.py
Browse files- proof_engine.py +6 -5
proof_engine.py
CHANGED
|
@@ -5,19 +5,20 @@ import json
|
|
| 5 |
import time
|
| 6 |
from typing import Dict
|
| 7 |
|
| 8 |
-
def
|
| 9 |
"""
|
| 10 |
-
|
| 11 |
"""
|
| 12 |
payload = {
|
| 13 |
"input": input_data,
|
| 14 |
-
"output":
|
| 15 |
-
"timestamp": time.time()
|
| 16 |
}
|
|
|
|
| 17 |
canonical = json.dumps(payload, sort_keys=True, separators=(",", ":"))
|
| 18 |
proof_hash = hashlib.sha256(canonical.encode()).hexdigest()
|
| 19 |
|
| 20 |
return {
|
|
|
|
| 21 |
"payload": payload,
|
| 22 |
-
"proof": proof_hash
|
| 23 |
}
|
|
|
|
| 5 |
import time
|
| 6 |
from typing import Dict
|
| 7 |
|
| 8 |
+
def generate_proof(input_data: Dict, output_data: Dict) -> Dict:
|
| 9 |
"""
|
| 10 |
+
Generates a reproducible proof hash.
|
| 11 |
"""
|
| 12 |
payload = {
|
| 13 |
"input": input_data,
|
| 14 |
+
"output": output_data,
|
| 15 |
+
"timestamp": int(time.time()),
|
| 16 |
}
|
| 17 |
+
|
| 18 |
canonical = json.dumps(payload, sort_keys=True, separators=(",", ":"))
|
| 19 |
proof_hash = hashlib.sha256(canonical.encode()).hexdigest()
|
| 20 |
|
| 21 |
return {
|
| 22 |
+
"hash": proof_hash,
|
| 23 |
"payload": payload,
|
|
|
|
| 24 |
}
|