-
Notifications
You must be signed in to change notification settings - Fork 3
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
ZK-643: add circuits&secrets to shielder_bindings crate #84
Conversation
|
crates/shielder_bindings/build.rs
Outdated
/// This script builds artifacts, which are later | ||
/// embedded into the wasm binary. | ||
/// To speedup the build process, we cache the artifacts after the first build. | ||
/// | ||
/// When working locally, the `artifacts/` directory should be cleaned after the circuits are changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: //!
instead of ///
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
crates/shielder_bindings/build.rs
Outdated
gen_deposit(&full_params); | ||
generate_new_account(&full_params); | ||
generate_withdraw(&full_params); | ||
println!("cargo:rerun-if-changed=../shielder-circuits"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it matter when we print? in particular, should we print this before heavy work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah it matters, moved to the top
} | ||
|
||
impl From<halo2_proofs::plonk::Error> for VerificationError { | ||
fn from(error: halo2_proofs::plonk::Error) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you might want to ensure that the variant makes sense in this context to avoid confusing error propagation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure how to check the variant, there are plenty of them and they all are low-level
impl WasmCircuit for Circuit<DepositProverKnowledge<F, RANGE_PROOF_CHUNK_SIZE>> { | ||
fn load_files() -> (Params, ProvingKey, u32) { | ||
let params = unmarshall_params(include_bytes!("../../artifacts/deposit/params.bin")) | ||
.expect("Failed to unmarshall params"); | ||
|
||
let (k, pk) = unmarshall_pk::< | ||
<DepositProverKnowledge<F, RANGE_PROOF_CHUNK_SIZE> as ProverKnowledge<F>>::Circuit, | ||
>(include_bytes!("../../artifacts/deposit/pk.bin")) | ||
.expect("Failed to unmarshall pk"); | ||
|
||
(params, pk, k) | ||
} | ||
} | ||
|
||
impl WasmCircuit for Circuit<NewAccountProverKnowledge<F>> { | ||
fn load_files() -> (Params, ProvingKey, u32) { | ||
let params = unmarshall_params(include_bytes!("../../artifacts/new_account/params.bin")) | ||
.expect("Failed to unmarshall params"); | ||
let (k, pk) = | ||
unmarshall_pk::<<NewAccountProverKnowledge<F> as ProverKnowledge<F>>::Circuit>( | ||
include_bytes!("../../artifacts/new_account/pk.bin"), | ||
) | ||
.expect("Failed to unmarshall pk"); | ||
|
||
(params, pk, k) | ||
} | ||
} | ||
|
||
impl WasmCircuit for Circuit<WithdrawProverKnowledge<F, RANGE_PROOF_CHUNK_SIZE>> { | ||
fn load_files() -> (Params, ProvingKey, u32) { | ||
let params = unmarshall_params(include_bytes!("../../artifacts/withdraw/params.bin")) | ||
.expect("Failed to unmarshall params"); | ||
let (k, pk) = unmarshall_pk::< | ||
<WithdrawProverKnowledge<F, RANGE_PROOF_CHUNK_SIZE> as ProverKnowledge<F>>::Circuit, | ||
>(include_bytes!("../../artifacts/withdraw/pk.bin")) | ||
.expect("Failed to unmarshall pk"); | ||
|
||
(params, pk, k) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I strongly suggest unifying these functions with a single helper
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added macro for that
This PR completes the code refactor of
shielder-wasm
bindings into newshielder_bindings
crate. Particularly:/circuits
module with better error handlingsecrets.rs
moduleIn next PR, going to delete
shielder-wasm
crate, changeshielder-sdk-crypto-wasm
to useshielder_bindings
and change CI to compile it.