remove powers
Important this will require something like !29 (merged) to land first
because Komodo already provides everything to generate trusted setups, it is arguable to have one already in the repo...
this is an attempt at removing it.
alternative
Note note the use of a Git version of Komodo instead of the crate on crates.io with the following
komodo = { version = "1.0.1", features = ["fs", "kzg"] }
there appears to be an issue with that crate for now, see komodo#13...
[package]
name = "komodo-setup"
version = "0.1.0"
edition = "2021"
[dependencies]
ark-bls12-381 = "0.4.0"
ark-ec = "0.4.2"
ark-ff = "0.4.2"
ark-poly = "0.4.2"
ark-poly-commit = { git = "https://gitlab.isae-supaero.fr/a.stevan/poly-commit", version = "0.4.0", rev = "19fc0d4" }
ark-serialize = "0.4.2"
ark-std = "0.4.0"
komodo = { git = "https://gitlab.isae-supaero.fr/dragoon/komodo", version = "1.0.1", tag = "1.0.1", features = ["fs", "kzg"] }
use ark_bls12_381::Bls12_381;
use ark_ec::pairing::Pairing;
use ark_poly::univariate::DensePolynomial;
use ark_poly::DenseUVPolynomial;
use ark_poly_commit::kzg10::KZG10;
use ark_serialize::{CanonicalSerialize, Compress};
use ark_std::ops::Div;
use ark_std::test_rng;
use komodo::{error::KomodoError, zk::trim};
use std::fs::File;
use std::io::{self, Write};
type UniPoly381 = DensePolynomial<<Bls12_381 as Pairing>::ScalarField>;
fn dump(
obj: impl CanonicalSerialize,
filename: impl ToString,
compress: Compress,
) -> io::Result<()> {
let mut file = File::create(filename.to_string())?;
let mut bytes = vec![0; obj.serialized_size(compress)];
obj.serialize_with_mode(&mut bytes[..], compress).unwrap();
file.write_all(&bytes)?;
Ok(())
}
fn generate_powers<E, P>(degree: usize, compress: Compress) -> Result<(), KomodoError>
where
E: Pairing,
P: DenseUVPolynomial<E::ScalarField>,
for<'a, 'b> &'a P: Div<&'b P, Output = P>,
{
let rng = &mut test_rng();
let params = KZG10::<E, P>::setup(degree, false, rng).expect("setup failed");
let (powers, verifier_key) = trim(params, degree);
dump(powers, "powers", compress).expect("failed to dump powers to disk");
dump(verifier_key, "verifier_key", compress).expect("failed to dump verifier key to disk");
Ok(())
}
fn main() {
generate_powers::<Bls12_381, UniPoly381>(64, Compress::No).expect("could not generate powers");
}
Edited by STEVAN Antoine
Merge request reports
Activity
Filter activity
added bookkeeping label
mentioned in issue komodo#13
assigned to @a.stevan
added 2 commits
enabled an automatic merge when all merge checks for 7fc79fd5 pass
mentioned in commit 36f1357d
Please register or sign in to reply