1
1
mirror of https://github.com/anoma/juvix.git synced 2024-10-26 09:45:47 +03:00
juvix/scripts/gen_stone_params.py
Łukasz Czajka 7d559b1f18
CASM serialization (#2679)
* Closes #2563 

Checklist
------------

- [x] Serialization of the Haskell CASM representation to the JSON
format accepted by the Cairo VM.
- [x] Add the `cairo` target to the `compile` commands.
- [x] Output via the Cairo `output` builtin.
- [x] Relativize jumps. Cairo VM doesn't actually support absolute
jumps.
- [x] Test the translation from CASM to Cairo by running the output in
the Cairo VM
- [x] Add Cairo VM to the CI
2024-03-26 17:18:52 +01:00

46 lines
939 B
Python
Executable File

#!/usr/bin/env python
#
# This script generates appropriate Stone prover parameters with the right
# bounds for the number of execution steps.
#
# Invocation: gen_stone_params.py prog_public_input.json
#
import json
import sys
import math
if len(sys.argv) != 2:
sys.exit("Usage: gen_stone_params.py prog_public_input.json")
f = open(sys.argv[1])
data = json.load(f)
f.close()
n = int(math.log2(data["n_steps"])) - 6
if n < 0:
sys.exit("Too few execution steps (at least 64 required)")
fri_step_list = [0, 4]
while n > 3:
fri_step_list.append(3)
n -= 3
if n > 0:
fri_step_list.append(n)
out = {
"field": "PrimeField0",
"stark": {
"fri": {
"fri_step_list": fri_step_list,
"last_layer_degree_bound": 64,
"n_queries": 18,
"proof_of_work_bits": 24,
},
"log_n_cosets": 4,
},
"use_extension_field": False,
}
print(json.dumps(out))