def log_get_consistency_proof( leafs=6, old_hash="64fd4d81ed081f789ca5827f9a3f05215a58a66c23d1ba6c8986ec02e729464a2c5ca0cd881931ea14d8bc79087976ee9de07a8cf7c13d1f1a11aa6180d2f261" ): old_path, full_path = consistency_proof(leafs) return { "root": get_root_node().to_json(), "leaf nodes": get_leafs().count(), "inclusion": validate_chain({"hash": old_hash}, old_path), "consistency": validate_chain({"hash": get_root_node().hash}, full_path), "inclusion_path": old_path, "path": full_path }
def log_get_validation_id(id): node = (db.session.query(Node).filter(Node.leaf_index == id)).first() if node is None: return {"status": "No such object"}, 400 path = audit_proof(node) path["validation"] = validate_chain(path["root"], path["path"]) return path
def log_get_validation(hash): node = (db.session.query(Node).filter(Node.hash == hash)).first() if node is None: return "No such object", 400 path = audit_proof(node) path["validation"] = validate_chain(path["root"], path["path"]) print(path["validation"]) return path
def log_get_inclusion_proof( leafs=6, old_hash="64fd4d81ed081f789ca5827f9a3f05215a58a66c23d1ba6c8986ec02e729464a2c5ca0cd881931ea14d8bc79087976ee9de07a8cf7c13d1f1a11aa6180d2f261" ): old_path = inclusion_proof(leafs) return { "inclusion": validate_chain({"hash": old_hash}, old_path), "path": old_path }
def log_validate_chain(id): data = request.get_json(silent=True) if not data.get("root"): return {"status": "No valid root"}, 400 if not data.get("path"): return {"status": "No valid path"}, 400 ret = validate_chain(data["root"], data["chain"]) if ret: return {"status": ret, "root": data["root"]} return {"status": ret}, 300