Created
December 13, 2024 19:14
-
-
Save JSeam2/b9c57eafed405274345f885853bab55c to your computer and use it in GitHub Desktop.
SetLTV with EZKL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
def main(): | |
# gen-witness and prove | |
try: | |
res = requests.post( | |
url="https://archon-v0.ezkl.xyz/recipe", | |
headers={ | |
"X-API-KEY": "CHANGE_ME", | |
"Content-Type": "application/json", | |
}, | |
json={ | |
"commands": [ | |
{ | |
"artifact": "garch-deploy", | |
"binary": "ezkl", | |
"deployment": None, | |
"command": [ | |
"gen-witness", | |
"--data input.json", | |
"--compiled-circuit model.compiled", | |
"--output witness.json" | |
], | |
}, | |
{ | |
"artifact": "garch-deploy", | |
"deployment": None, | |
"binary": "ezkl", | |
"command": [ | |
"prove", | |
"--witness witness.json", | |
"--compiled-circuit model.compiled" , | |
"--pk-path pk.key", | |
"--proof-path proof.json", | |
], | |
"output_path": ["proof.json"] | |
}, | |
], | |
"data": [{ | |
"target_path": "input.json", | |
"data": { | |
"input_data": [[2548456776, 2414737740, 2479580419, 2395258336, 2525877267, 2539045378, 2489020277, 2446088064, 2415462234, 2452455849, 2378313076, 2493005698, 2551516607, 2567897858, 2640811378, 2578447323, 2643189059, 2587745996, 2701440300, 2615059107]] | |
} | |
}], | |
"response_settings": { | |
"callback": { | |
"chain": "arbitrumSepolia", | |
"contract_address": "0x1051c2925273b8d325333b22f2708e77659626b6", | |
"function_interface": "function ltvUpdate(uint256 type, address riskEngine, uint256 poolType, address pool, bytes calldata proof, uint256[] calldata instances)", | |
"function_args": '[0, "0xe18931401Bbcf26FC613D58C08ee9B4aC56b8AA7", 3, "0x2eba2c9c0999b0ad608070d0a19869De514a8A08", "proof", "instances"]', | |
}, | |
}, | |
# test calling the test halo2verifier | |
# "response_settings": { | |
# "callback": { | |
# "chain": "arbitrumSepolia", | |
# "contract_address": "0x6A172fA74Fe935850Cd75849C6A55b9E7e2f2b8d", | |
# "function_interface": "function verifyProof(bytes calldata proof, uint256[] calldata instances) public returns (bool)", | |
# "function_args": '["proof", "instances"]', | |
# } | |
# } | |
} | |
) | |
if res.status_code >= 400: | |
print(f"Error: HTTP {res.status_code}") | |
error_message = res.json().get('message', 'No error message provided') | |
print(f"Error message: {error_message}") | |
else: | |
data = res.json() | |
print(res.json()) | |
print(f"Request successful. Get results with `archon get -i {data['id']}`") | |
except Exception as e: | |
print(f"Error parsing JSON response: {str(e)}") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment