Fix lib and types exposures
This commit is contained in:
parent
b0d957c85c
commit
d3161e5a7a
@ -6,6 +6,8 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
blake2 = "0.10"
|
||||
ark-serialize = "0.4.2"
|
||||
ark-poly = "0.4.2"
|
||||
kzgrs = { path = "../kzgrs" }
|
||||
rand = "0.8.5"
|
||||
|
@ -1,3 +1,8 @@
|
||||
use ark_serialize::CanonicalSerialize;
|
||||
use blake2::digest::{Update, VariableOutput};
|
||||
use kzgrs::Commitment;
|
||||
use std::io::Cursor;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Chunk(Vec<u8>);
|
||||
pub struct Row(Vec<Chunk>);
|
||||
@ -68,3 +73,23 @@ impl FromIterator<Row> for ChunksMatrix {
|
||||
Self(iter.into_iter().collect())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn hash_column_and_commitment<const HASH_SIZE: usize>(
|
||||
column: &Column,
|
||||
commitment: &Commitment,
|
||||
) -> [u8; HASH_SIZE] {
|
||||
use ark_serialize::CanonicalSerialize;
|
||||
let mut hasher = blake2::Blake2bVar::new(HASH_SIZE)
|
||||
.unwrap_or_else(|e| panic!("Blake2b should work for size {HASH_SIZE}, {e}"));
|
||||
hasher.update(column.as_bytes().as_ref());
|
||||
let mut buff = Cursor::new(vec![]);
|
||||
commitment
|
||||
.serialize_uncompressed(&mut buff)
|
||||
.expect("Serialization of commitment should work");
|
||||
hasher.update(buff.into_inner().as_ref());
|
||||
hasher
|
||||
.finalize_boxed()
|
||||
.to_vec()
|
||||
.try_into()
|
||||
.unwrap_or_else(|_| panic!("Size is guaranteed by constant {HASH_SIZE:?}"))
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
// std
|
||||
// crates
|
||||
use crate::Commitment;
|
||||
use ark_bls12_381::fr::Fr;
|
||||
use ark_ff::{BigInteger256, PrimeField, Zero};
|
||||
use ark_poly::domain::general::GeneralEvaluationDomain;
|
||||
|
@ -28,7 +28,7 @@ pub fn generate_element_proof(
|
||||
element_index: usize,
|
||||
polynomial: &DensePolynomial<Fr>,
|
||||
global_parameters: &UniversalParams<Bls12_381>,
|
||||
domain: &GeneralEvaluationDomain<Fr>,
|
||||
domain: GeneralEvaluationDomain<Fr>,
|
||||
) -> Result<Proof<Bls12_381>, KzgRsError> {
|
||||
let u = domain.element(element_index);
|
||||
let v = polynomial.evaluate(&u);
|
||||
|
@ -1,5 +1,5 @@
|
||||
pub mod common;
|
||||
mod global_parameters;
|
||||
pub mod global_parameters;
|
||||
pub mod kzg;
|
||||
pub mod rs;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user