export circom-compatible verifying key
This commit is contained in:
parent
40e2e31e76
commit
02245e457c
@ -43,6 +43,7 @@ struct ProvingKeyJson {
|
|||||||
pub vk_delta_2: Vec<Vec<String>>,
|
pub vk_delta_2: Vec<Vec<String>>,
|
||||||
#[serde(rename = "hExps")]
|
#[serde(rename = "hExps")]
|
||||||
pub h: Vec<Vec<String>>,
|
pub h: Vec<Vec<String>>,
|
||||||
|
// Todo: add json fields: nPublic, nVars, polsA, polsB, polsC, protocol: groth
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
@ -54,6 +55,9 @@ struct VerifyingKeyJson {
|
|||||||
pub vk_gamma_2: Vec<Vec<String>>,
|
pub vk_gamma_2: Vec<Vec<String>>,
|
||||||
pub vk_delta_2: Vec<Vec<String>>,
|
pub vk_delta_2: Vec<Vec<String>>,
|
||||||
pub vk_alfabeta_12: Vec<Vec<Vec<String>>>,
|
pub vk_alfabeta_12: Vec<Vec<Vec<String>>>,
|
||||||
|
pub protocol: String,
|
||||||
|
#[serde(rename = "nPublic")]
|
||||||
|
pub inputs_count: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@ -97,6 +101,8 @@ fn main() {
|
|||||||
vk_gamma_2: p2_to_vec(¶ms.vk.gamma_g2),
|
vk_gamma_2: p2_to_vec(¶ms.vk.gamma_g2),
|
||||||
vk_delta_2: p2_to_vec(¶ms.vk.delta_g2),
|
vk_delta_2: p2_to_vec(¶ms.vk.delta_g2),
|
||||||
vk_alfabeta_12: pairing_to_vec(&Bn256::pairing(params.vk.alpha_g1, params.vk.beta_g2)),
|
vk_alfabeta_12: pairing_to_vec(&Bn256::pairing(params.vk.alpha_g1, params.vk.beta_g2)),
|
||||||
|
inputs_count: params.vk.ic.len() - 1,
|
||||||
|
protocol: String::from("groth"),
|
||||||
};
|
};
|
||||||
|
|
||||||
let pk_json = serde_json::to_string(&proving_key).unwrap();
|
let pk_json = serde_json::to_string(&proving_key).unwrap();
|
||||||
|
@ -26,14 +26,13 @@ cargo run --release --bin verify_contribution circuit.json circom2.params circom
|
|||||||
cargo run --release --bin contribute circom3.params circom4.params askldfjklasdf
|
cargo run --release --bin contribute circom3.params circom4.params askldfjklasdf
|
||||||
cargo run --release --bin verify_contribution circuit.json circom3.params circom4.params
|
cargo run --release --bin verify_contribution circuit.json circom3.params circom4.params
|
||||||
|
|
||||||
# generate resulting keys
|
|
||||||
cargo run --release --bin export_keys circom4.params vk.json pk.json
|
|
||||||
# create dummy keys in circom format
|
# create dummy keys in circom format
|
||||||
echo "Generating dummy key files..."
|
echo "Generating dummy key files..."
|
||||||
npx snarkjs setup --protocol groth
|
npx snarkjs setup --protocol groth
|
||||||
|
# generate resulting keys
|
||||||
|
cargo run --release --bin export_keys circom4.params vk.json pk.json
|
||||||
# patch dummy keys with actual keys params
|
# patch dummy keys with actual keys params
|
||||||
cargo run --release --bin copy_json proving_key.json pk.json transformed_pk.json
|
cargo run --release --bin copy_json proving_key.json pk.json transformed_pk.json
|
||||||
cargo run --release --bin copy_json verification_key.json vk.json transformed_vk.json
|
|
||||||
|
|
||||||
# generate solidity verifier
|
# generate solidity verifier
|
||||||
cargo run --release --bin generate_verifier circom4.params verifier.sol
|
cargo run --release --bin generate_verifier circom4.params verifier.sol
|
||||||
@ -41,4 +40,4 @@ cargo run --release --bin generate_verifier circom4.params verifier.sol
|
|||||||
# try to generate and verify proof
|
# try to generate and verify proof
|
||||||
npx snarkjs calculatewitness
|
npx snarkjs calculatewitness
|
||||||
cargo run --release --bin prove circuit.json witness.json circom4.params proof.json public.json
|
cargo run --release --bin prove circuit.json witness.json circom4.params proof.json public.json
|
||||||
npx snarkjs verify --vk transformed_vk.json --proof proof.json
|
npx snarkjs verify --vk vk.json --proof proof.json
|
Loading…
Reference in New Issue
Block a user