Skip to content

Commit

Permalink
Merge pull request #467 from kroma-network/fix/remove-cs-serializatio…
Browse files Browse the repository at this point in the history
…n-from-write-fn

fix(halo2)!: remove constraint system serialization from `vk.write()`
  • Loading branch information
chokobole authored Jul 11, 2024
2 parents 03a69f6 + 5f139c6 commit 2dad785
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions vendors/halo2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ Tachyon can easily replace existing Halo2 implementations that generate proofs a
+ // Please remember to release `pk` and `pk_bytes` immediately after
+ // deserialization, as it can occupy big memory.
+ let mut pk_bytes: Vec<u8> = vec![];
+ pk.write(&mut pk_bytes, halo2_proofs::SerdeFormat::RawBytesUnchecked)
+ .unwrap();
+ pk.write_including_cs(&mut pk_bytes).unwrap();
+ fixed_values = pk.drop_but_fixed_values();
+ (TachyonProvingKey::from(pk_bytes.as_slice()), fixed_values)
+ };
Expand Down
6 changes: 2 additions & 4 deletions vendors/halo2/src/circuits/shuffle_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,7 @@ mod test {

let (mut tachyon_pk, fixed_values) = {
let mut pk_bytes: Vec<u8> = vec![];
pk.write(&mut pk_bytes, halo2_proofs::SerdeFormat::RawBytesUnchecked)
.unwrap();
pk.write_including_cs(&mut pk_bytes).unwrap();
let fixed_values = pk.drop_but_fixed_values();
(TachyonProvingKey::from(pk_bytes.as_slice()), fixed_values)
};
Expand Down Expand Up @@ -341,8 +340,7 @@ mod test {
let params = ParamsKZG::<Bn256>::unsafe_setup_with_s(K, s);
let pk = keygen_pk2(&params, &circuit).unwrap();
let mut pk_bytes: Vec<u8> = vec![];
pk.write(&mut pk_bytes, halo2_proofs::SerdeFormat::RawBytesUnchecked)
.unwrap();
pk.write_including_cs(&mut pk_bytes).unwrap();

let rng = XORShiftRng::from_seed(SEED);

Expand Down
6 changes: 2 additions & 4 deletions vendors/halo2/src/circuits/simple_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,7 @@ mod test {

let (mut tachyon_pk, fixed_values) = {
let mut pk_bytes: Vec<u8> = vec![];
pk.write(&mut pk_bytes, halo2_proofs::SerdeFormat::RawBytesUnchecked)
.unwrap();
pk.write_including_cs(&mut pk_bytes).unwrap();
let fixed_values = pk.drop_but_fixed_values();
(TachyonProvingKey::from(pk_bytes.as_slice()), fixed_values)
};
Expand Down Expand Up @@ -449,8 +448,7 @@ mod test {
let params = ParamsKZG::<Bn256>::unsafe_setup_with_s(k, s.clone());
let pk = keygen_pk2(&params, &circuit).expect("vk should not fail");
let mut pk_bytes: Vec<u8> = vec![];
pk.write(&mut pk_bytes, halo2_proofs::SerdeFormat::RawBytesUnchecked)
.unwrap();
pk.write_including_cs(&mut pk_bytes).unwrap();

let rng = XORShiftRng::from_seed(SEED);

Expand Down
6 changes: 2 additions & 4 deletions vendors/halo2/src/circuits/simple_lookup_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ mod test {

let (mut tachyon_pk, fixed_values) = {
let mut pk_bytes: Vec<u8> = vec![];
pk.write(&mut pk_bytes, halo2_proofs::SerdeFormat::RawBytesUnchecked)
.unwrap();
pk.write_including_cs(&mut pk_bytes).unwrap();
let fixed_values = pk.drop_but_fixed_values();
(TachyonProvingKey::from(pk_bytes.as_slice()), fixed_values)
};
Expand Down Expand Up @@ -212,8 +211,7 @@ mod test {
let params = ParamsKZG::<Bn256>::unsafe_setup_with_s(k, s.clone());
let pk = keygen_pk2(&params, &circuit).expect("vk should not fail");
let mut pk_bytes: Vec<u8> = vec![];
pk.write(&mut pk_bytes, halo2_proofs::SerdeFormat::RawBytesUnchecked)
.unwrap();
pk.write_including_cs(&mut pk_bytes).unwrap();

let rng = XORShiftRng::from_seed(SEED);

Expand Down
3 changes: 1 addition & 2 deletions vendors/halo2/src/proving_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ mod test {
let params = ParamsKZG::<Bn256>::unsafe_setup_with_s(k, s);
let pk = keygen_pk2(&params, &circuit).expect("vk should not fail");
let mut pk_bytes: Vec<u8> = vec![];
pk.write(&mut pk_bytes, halo2_proofs::SerdeFormat::RawBytesUnchecked)
.unwrap();
pk.write_including_cs(&mut pk_bytes).unwrap();
let tachyon_pk = ProvingKey::<G1Affine>::from(pk_bytes.as_slice());

assert_eq!(
Expand Down

0 comments on commit 2dad785

Please sign in to comment.