Created
December 13, 2024 18:48
-
-
Save JSeam2/ce91a9e2a4362a440c79ddab541c294c to your computer and use it in GitHub Desktop.
Onchain Callbacks 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": "REPLACE_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": "", | |
| # "function_interface": "function ltvUpdate(uint256, address, uint256, address, bytes, uint256[])", | |
| # "function_args": '["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