Skip to content
Snippets Groups Projects
Verified Commit 7bf2aa40 authored by STEVAN Antoine's avatar STEVAN Antoine :crab:
Browse files

refactor example

parent c7f6af78
No related branches found
No related tags found
No related merge requests found
...@@ -8,24 +8,32 @@ use rs_merkle::Hasher; ...@@ -8,24 +8,32 @@ use rs_merkle::Hasher;
use fri::algorithms::Blake3; use fri::algorithms::Blake3;
use komodo::error::KomodoError; use komodo::error::KomodoError;
fn run<F: PrimeField, H: Hasher, P>() -> Result<(), KomodoError> fn run<const N: usize, F: PrimeField, H: Hasher, P>(
bytes: &[u8],
k: usize,
n: usize,
bf: usize,
rpo: usize,
q: usize,
) -> Result<(), KomodoError>
where where
P: DenseUVPolynomial<F>, P: DenseUVPolynomial<F>,
for<'a, 'b> &'a P: Div<&'b P, Output = P>, for<'a, 'b> &'a P: Div<&'b P, Output = P>,
<H as rs_merkle::Hasher>::Hash: AsRef<[u8]>, <H as rs_merkle::Hasher>::Hash: AsRef<[u8]>,
{ {
// the code parameters and the data to manipulate
let (k, n) = (4, 16);
let bytes = include_bytes!("../assets/dragoon_133x133.png").to_vec();
eprintln!("loaded {} bytes of data", bytes.len());
let shards = komodo::fri::encode::<F>(&bytes, k, n); let shards = komodo::fri::encode::<F>(&bytes, k, n);
let blocks = komodo::fri::prove::<2, F, H, P>(shards, 1, 1, 50).unwrap(); let blocks = komodo::fri::prove::<N, F, H, P>(shards, bf, rpo, q).unwrap();
komodo::fri::verify::<2, F, H, P>(blocks[0].clone(), n, 50).unwrap();
for block in blocks {
komodo::fri::verify::<N, F, H, P>(block, n, q).unwrap();
}
Ok(()) Ok(())
} }
fn main() { fn main() {
run::<Fr, Blake3, DensePolynomial<Fr>>().unwrap(); let bytes = include_bytes!("../assets/dragoon_133x133.png").to_vec();
eprintln!("loaded {} bytes of data", bytes.len());
run::<2, Fr, Blake3, DensePolynomial<Fr>>(&bytes, 4, 16, 1, 1, 50).unwrap();
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment