Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Centralize RiscZero constants definition by creating Rust bindings for py/ts. #270

Open
feltroidprime opened this issue Dec 11, 2024 · 2 comments
Assignees
Labels
enhancement Enhancement of the code, not introducing new features.

Comments

@feltroidprime
Copy link
Collaborator

feltroidprime commented Dec 11, 2024

Currently, the same constants (CONTROL ROOT & CONTROL_ID) are defined in multiple locations.

In python :

# https://github.com/risc0/risc0-ethereum/blob/main/contracts/src/groth16/ControlID.sol
RISC0_CONTROL_ROOT = 0x8CDAD9242664BE3112ABA377C5425A4DF735EB1C6966472B561D2855932C0469
RISC0_BN254_CONTROL_ID = (
0x04446E66D300EB7FB45C9726BB53C793DDA407A62E9601618BB43C5C14657AC0
)

In rust :
pub fn get_risc0_constants() -> (BigUint, BigUint) {
let risc0_control_root = BigUint::from_str_radix(
"8CDAD9242664BE3112ABA377C5425A4DF735EB1C6966472B561D2855932C0469",
16,
)
.unwrap();
let risc0_bn254_control_id = BigUint::from_str_radix(
"04446E66D300EB7FB45C9726BB53C793DDA407A62E9601618BB43C5C14657AC0",
16,
)
.unwrap();
(risc0_control_root, risc0_bn254_control_id)
}

In typescript :
//https://github.com/risc0/risc0-ethereum/blob/main/contracts/src/groth16/ControlID.sol
const RISC0_CONTROL_ROOT = BigInt("0x8CDAD9242664BE3112ABA377C5425A4DF735EB1C6966472B561D2855932C0469");
const RISC0_BN254_CONTROL_ID = BigInt("0x04446E66D300EB7FB45C9726BB53C793DDA407A62E9601618BB43C5C14657AC0");

Keep them in rust only and create a python / wasm binding so that updating them is easier.
Note : the tools/garaga_rs package has already multiple examples of python / wasm bindings.
The documentation on the gitbook has also useful infos on how to make the bindings although not complete.

@feltroidprime feltroidprime added the enhancement Enhancement of the code, not introducing new features. label Dec 11, 2024
@augustin-v
Copy link

Hello, I would love to work on this. I'm really excited about Garaga with the latest Noir compatibility update and would be honored to be a part of it.
I have just completed implementing a L1 gas prices sampling oracle to Katana in Rust so I believe to be able to tackle this issue. I'll make sure to communicate if I encounter any problems.

@augustin-v
Copy link

@feltroidprime Thank you, on it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement of the code, not introducing new features.
Projects
None yet
Development

No branches or pull requests

2 participants