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

WIP

parent 7460c931
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,7 @@ use crate::{algebra, error::KomodoError, fec};
use fri::{
frida::{FridaBuilder, FridaCommitment},
rng::FriChallenger,
utils::{to_evaluations, MerkleProof},
utils::{to_evaluations, HasherExt, MerkleProof},
};
/// representation of a block of proven data.
......@@ -63,30 +63,56 @@ where
nb_queries,
);
let mut rng = thread_rng();
let position = rng.gen_range(0..domain_size);
let commit = FridaCommitment::from(builder.clone());
let proof = builder.prove_shards(&[position]);
Ok(shards
.iter()
.map(|s| Block {
shard: s.clone(),
proof: builder.prove_shards(&[s
.linear_combination
.iter()
.filter(|x| !x.is_zero())
.collect::<Vec<F>>()
.first()
.unwrap()
.into()]),
commit: commit.clone(),
})
.collect())
}
pub fn verify<const N: usize, F: PrimeField, H: Hasher, P>(
block: Block<F, H>,
k: usize,
domain_size: usize,
blowup_factor: usize,
remainder_plus_one: usize,
nb_queries: usize,
) -> Result<(), KomodoError>
where
P: DenseUVPolynomial<F>,
for<'a, 'b> &'a P: Div<&'b P, Output = P>,
<H as rs_merkle::Hasher>::Hash: AsRef<[u8]>,
{
block
.commit
.verify::<N, _>(
FriChallenger::<H>::default(),
nb_queries,
nb_coeffs,
domain_size,
)
.unwrap();
//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
//));
assert!(block.proof.verify(
block.commit.tree_root(),
&[position],
&[H::hash_item(
&nth_evaluations(&evaluations, position).collect::<Vec<_>>()
)],
domain_size,
));
Ok(vec![])
Ok(())
}
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