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

WIP

parent 2b94a059
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,7 @@ thiserror = "1.0.50" ...@@ -25,6 +25,7 @@ thiserror = "1.0.50"
tracing = "0.1.40" tracing = "0.1.40"
tracing-subscriber = "0.3.17" tracing-subscriber = "0.3.17"
ark-poly-commit = { git = "https://gitlab.isae-supaero.fr/a.stevan/poly-commit", version = "0.4.0", rev = "19fc0d4", optional = true } ark-poly-commit = { git = "https://gitlab.isae-supaero.fr/a.stevan/poly-commit", version = "0.4.0", rev = "19fc0d4", optional = true }
fri = { path = "../fri", optional = true}
[workspace] [workspace]
members = [ members = [
...@@ -41,6 +42,7 @@ rand = "0.8.5" ...@@ -41,6 +42,7 @@ rand = "0.8.5"
[features] [features]
kzg = ["dep:ark-poly-commit"] kzg = ["dep:ark-poly-commit"]
aplonk = ["dep:ark-poly-commit"] aplonk = ["dep:ark-poly-commit"]
fri = ["dep:fri"]
fs = [] fs = []
[package.metadata.docs.rs] [package.metadata.docs.rs]
......
use ark_ff::PrimeField;
use ark_poly::DenseUVPolynomial;
use ark_std::{
ops::Div,
rand::{thread_rng, Rng},
};
use rs_merkle::Hasher;
use tracing::{debug, info};
use crate::{algebra, error::KomodoError, fec};
use fri::{
frida::{FridaBuilder, FridaCommitment},
rng::FriChallenger,
utils::{to_evaluations, MerkleProof},
};
/// representation of a block of proven data.
///
/// this is a wrapper around a [`fec::Shard`] with some additional cryptographic
/// information that allows to prove the integrity of said shard.
#[derive(Clone, PartialEq)]
pub struct Block<F: PrimeField, H: Hasher> {
pub shard: fec::Shard<F>,
proof: MerkleProof<H>,
commit: FridaCommitment<F, H>,
}
pub fn prove<const N: usize, F: PrimeField, H: Hasher, P>(
bytes: &[u8],
shards: Vec<fec::Shard<F>>,
k: usize,
domain_size: usize,
blowup_factor: usize,
remainder_plus_one: usize,
nb_queries: usize,
) -> Result<Vec<Block<F, H>>, KomodoError>
where
P: DenseUVPolynomial<F>,
for<'a, 'b> &'a P: Div<&'b P, Output = P>,
<H as rs_merkle::Hasher>::Hash: AsRef<[u8]>,
{
info!("encoding and proving {} bytes", bytes.len());
debug!("splitting bytes into rows");
let elements: Vec<F> = algebra::split_data_into_field_elements(bytes, k);
let rows = elements.chunks(k).map(|c| c.to_vec()).collect::<Vec<_>>();
info!(
"data is composed of {} rows and {} elements",
rows.len(),
elements.len()
);
let evaluations = rows
.into_iter()
.map(|r| to_evaluations(r, domain_size))
.collect::<Vec<_>>();
let builder = FridaBuilder::<F, H>::new::<N, _>(
&evaluations,
FriChallenger::<H>::default(),
blowup_factor,
remainder_plus_one,
nb_queries,
);
let mut rng = thread_rng();
let position = rng.gen_range(0..domain_size);
let proof = builder.prove_shards(&[position]);
//let commit = FridaCommitment::from(builder);
//
//commit
// .verify::<N, _>(
// FriChallenger::<H>::default(),
// params.nb_queries,
// params.nb_coeffs,
// params.domain_size,
// )
// .unwrap();
//
//assert!(proof.verify(
// commit.tree_root(),
// &[position],
// &[H::hash_item(
// &nth_evaluations(&evaluations, position).collect::<Vec<_>>()
// )],
// params.domain_size
//));
Ok(vec![])
}
...@@ -51,6 +51,8 @@ pub mod aplonk; ...@@ -51,6 +51,8 @@ pub mod aplonk;
mod conversions; mod conversions;
pub mod error; pub mod error;
pub mod fec; pub mod fec;
#[cfg(feature = "fri")]
pub mod fri;
#[cfg(feature = "fs")] #[cfg(feature = "fs")]
pub mod fs; pub mod fs;
#[cfg(feature = "kzg")] #[cfg(feature = "kzg")]
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment