Skip to content

Commit

Permalink
Fix compilation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
fmkra committed Jan 2, 2024
1 parent dc63c9b commit dbcbab1
Show file tree
Hide file tree
Showing 7 changed files with 324 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/fri/fri_config.cairo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cairo_verifier::{
table_commitment::TableCommitmentConfig,
vector_commitment::{validate_vector_commitment, VectorCommitmentConfig},
vector_commitment::vector_commitment::{validate_vector_commitment, VectorCommitmentConfig},
};

const MAX_LAST_LAYER_LOG_DEGREE_BOUND: u32 = 15;
Expand Down
1 change: 0 additions & 1 deletion src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
mod channel;
mod vector_commitment;
mod common;
mod input_structs;
mod structs;
Expand Down
2 changes: 1 addition & 1 deletion src/table_commitment.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cairo_verifier::vector_commitment::{
use cairo_verifier::vector_commitment::vector_commitment::{
VectorCommitmentConfig, VectorUnsentCommitment, VectorCommitment, VectorCommitmentWitness
};

Expand Down
2 changes: 1 addition & 1 deletion src/vector_commitment.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mod vector_commitment;

#[cfg(test)]
mod tests;
mod tests;
2 changes: 1 addition & 1 deletion src/vector_commitment/tests.cairo
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mod test_vector_commitment;
mod test_vector_commitment;
269 changes: 267 additions & 2 deletions src/vector_commitment/tests/test_vector_commitment.cairo

Large diffs are not rendered by default.

58 changes: 53 additions & 5 deletions src/vector_commitment/vector_commitment.cairo
Original file line number Diff line number Diff line change
@@ -1,11 +1,59 @@
use cairo_verifier::common::flip_endianness::FlipEndiannessTrait;
use cairo_verifier::common::{
array_append::ArrayAppendTrait,
blake2s::blake2s,
};
use cairo_verifier::common::{array_append::ArrayAppendTrait, blake2s::blake2s,};
use poseidon::hades_permutation;


// Commitment for a vector of field elements.
#[derive(Drop, Copy)]
struct VectorCommitment {
config: VectorCommitmentConfig,
commitment_hash: felt252
}

#[derive(Drop, Copy)]
struct VectorCommitmentConfig {
height: felt252,
n_verifier_friendly_commitment_layers: felt252,
}

// A query to the vector commitment.
#[derive(Drop, Copy)]
struct VectorQuery {
index: felt252,
value: felt252,
}

// Witness for a decommitment over queries.
#[derive(Drop, Copy)]
struct VectorCommitmentWitness {
// The authentication values: all the siblings of the subtree generated by the queried indices,
// bottom layer up, left to right.
authentications: Span<felt252>,
}

// TODO: check if we shouldn't delet this
#[derive(Drop, Copy)]
struct VectorUnsentCommitment {
commitment_hash: felt252,
}

fn validate_vector_commitment(
config: VectorCommitmentConfig,
expected_height: felt252,
n_verifier_friendly_commitment_layers: felt252,
) {
assert(false, 'not implemented');
}

fn vector_commitment_decommit(
commitment: VectorCommitment,
n_queries: felt252,
queries: Array<VectorQuery>,
witness: VectorCommitmentWitness,
) {
assert(false, 'not implemented');
}

fn hash_blake_or_poseidon(x: felt252, y: felt252, is_verifier_friendly: bool) -> felt252 {
if is_verifier_friendly {
let (hash, _, _) = hades_permutation(x, y, 2);
Expand All @@ -21,4 +69,4 @@ fn truncated_blake2s(x: felt252, y: felt252) -> felt252 {
data.append_big_endian(y);
let hash = blake2s(data).flip_endianness() % 0x10000000000000000000000000000000000000000;
hash.try_into().unwrap()
}
}

0 comments on commit dbcbab1

Please sign in to comment.