From 9a8134e475876107a3d45b0608204a03fc5215bd Mon Sep 17 00:00:00 2001 From: Filip Krawczyk Date: Wed, 31 Jul 2024 21:57:57 +0200 Subject: [PATCH] Features support --- .tool-versions | 2 +- Scarb.toml | 16 +- src/air/layouts.cairo | 30 +-- src/air/public_input.cairo | 34 ++- src/common/hasher.cairo | 40 ++-- src/deserialization/stark.cairo | 30 +-- src/deserialization/traces.cairo | 54 ++--- src/fri/tests.cairo | 6 +- src/fri/tests/test_fri_verify.cairo | 26 +-- src/lib.cairo | 40 ++-- src/oods.cairo | 83 ++++--- .../tests/test_proof_of_work.cairo | 46 ++-- src/queries/tests.cairo | 4 +- src/stark.cairo | 82 ++++--- src/stark/stark_commit.cairo | 66 +++--- src/stark/stark_verify.cairo | 29 +-- src/stark/tests.cairo | 7 +- src/stark/tests/test_stark_commit.cairo | 60 +++-- src/stark/tests/test_stark_proof_verify.cairo | 36 ++- src/stark/tests/test_stark_verify.cairo | 32 ++- src/table_commitment/tests.cairo | 5 +- .../test_table_commitment_decommit.cairo | 28 +-- .../test_vector_commitment_decommit.cairo | 206 +++++++++--------- 23 files changed, 448 insertions(+), 514 deletions(-) diff --git a/.tool-versions b/.tool-versions index 823941bd8..95447a073 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -scarb 2.6.3 +scarb nightly-2024-04-20 starknet-foundry 0.24.0 diff --git a/Scarb.toml b/Scarb.toml index 7139039eb..339feba0d 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -10,4 +10,18 @@ casm = true [lib] sierra = true -casm = false \ No newline at end of file +casm = false + +[features] + +recursive = [] +recursive_with_poseidon = [] +dex = [] +small = [] +starknet = [] +starknet_with_keccak = [] + +keccak = [] +blake2s = [] + +default = ["recursive", "keccak"] \ No newline at end of file diff --git a/src/air/layouts.cairo b/src/air/layouts.cairo index f92f4f388..33040aba3 100644 --- a/src/air/layouts.cairo +++ b/src/air/layouts.cairo @@ -1,20 +1,12 @@ -// === DEX BEGIN === -// mod dex; -// === DEX END === -// === RECURSIVE BEGIN === +#[cfg(feature: 'dex')] +mod dex; +#[cfg(feature: 'recursive')] mod recursive; -// === RECURSIVE END === -// === RECURSIVE_WITH_POSEIDON BEGIN === -// mod recursive_with_poseidon; -// === RECURSIVE_WITH_POSEIDON END === -// === SMALL BEGIN === -// mod small; -// === SMALL END === -// === STARKNET BEGIN === -// mod starknet; -// === STARKNET END === -// === STARKNET_WITH_KECCAK BEGIN === -// mod starknet_with_keccak; -// === STARKNET_WITH_KECCAK END === - - +#[cfg(feature: 'recursive_with_poseidon')] +mod recursive_with_poseidon; +#[cfg(feature: 'small')] +mod small; +#[cfg(feature: 'starknet')] +mod starknet; +#[cfg(feature: 'starknet_with_keccak')] +mod starknet_with_keccak; diff --git a/src/air/public_input.cairo b/src/air/public_input.cairo index b89b475b9..04b8aebcc 100644 --- a/src/air/public_input.cairo +++ b/src/air/public_input.cairo @@ -1,23 +1,5 @@ use cairo_verifier::{ domains::StarkDomains, air::constants::{MAX_ADDRESS, INITIAL_PC}, - // === DEX BEGIN === - // air::layouts::dex::constants::segments, - // === DEX END === - // === RECURSIVE BEGIN === - air::layouts::recursive::constants::segments, - // === RECURSIVE END === - // === RECURSIVE_WITH_POSEIDON BEGIN === - // air::layouts::recursive_with_poseidon::constants::segments, - // === RECURSIVE_WITH_POSEIDON END === - // === SMALL BEGIN === - // air::layouts::small::constants::segments, - // === SMALL END === - // === STARKNET BEGIN === - // air::layouts::starknet::constants::segments, - // === STARKNET END === - // === STARKNET_WITH_KECCAK BEGIN === - // air::layouts::starknet_with_keccak::constants::segments, - // === STARKNET_WITH_KECCAK END === air::public_memory::{ Page, PageTrait, ContinuousPageHeader, get_continuous_pages_product, AddrValueSize }, @@ -26,9 +8,21 @@ use cairo_verifier::{ math::{pow, Felt252PartialOrd, Felt252Div}, }, }; - use core::{pedersen::PedersenTrait, hash::{HashStateTrait, HashStateExTrait, Hash}}; use poseidon::poseidon_hash_span; +#[cfg(feature: 'dex')] +use cairo_verifier::air::layouts::dex::constants::segments; +#[cfg(feature: 'recursive')] +use cairo_verifier::air::layouts::recursive::constants::segments; +#[cfg(feature: 'recursive_with_poseidon')] +use cairo_verifier::air::layouts::recursive_with_poseidon::constants::segments; +#[cfg(feature: 'small')] +use cairo_verifier::air::layouts::small::constants::segments; +#[cfg(feature: 'starknet')] +use cairo_verifier::air::layouts::starknet::constants::segments; +#[cfg(feature: 'starknet_with_keccak')] +use cairo_verifier::air::layouts::starknet_with_keccak::constants::segments; + #[derive(Drop, Copy, PartialEq, Serde)] struct SegmentInfo { @@ -184,6 +178,8 @@ fn verify_cairo1_public_input(public_input: @PublicInput) -> (felt252, felt252) (program_hash, output_hash) } +#[cfg(feature: 'recursive')] +#[cfg(feature: 'keccak')] #[cfg(test)] mod tests { use super::get_public_input_hash; diff --git a/src/common/hasher.cairo b/src/common/hasher.cairo index a8827ac3b..918112c28 100644 --- a/src/common/hasher.cairo +++ b/src/common/hasher.cairo @@ -3,22 +3,25 @@ use cairo_verifier::common::{ flip_endianness::FlipEndiannessTrait }; -// === BLAKE2S BEGIN === -// fn hash_n_bytes(mut data: Array, n: u8, hash_len: bool) -> u256 { -// if hash_len { -// data.append(n); -// } -// blake2s_u8(data) -// } -// fn hash_truncated(data: Array) -> felt252 { -// truncated_blake2s(data) -// } -// fn hash(data: Array) -> u256 { -// blake2s(data) -// } -// === BLAKE2S END === +#[cfg(feature: 'blake2s')] +fn hash_n_bytes(mut data: Array, n: u8, hash_len: bool) -> u256 { + if hash_len { + data.append(n); + } + blake2s_u8(data) +} -// === KECCAK BEGIN === +#[cfg(feature: 'blake2s')] +fn hash_truncated(data: Array) -> felt252 { + truncated_blake2s(data) +} + +#[cfg(feature: 'blake2s')] +fn hash(data: Array) -> u256 { + blake2s(data) +} + +#[cfg(feature: 'keccak')] fn hash_n_bytes(mut data: Array, n: u8, hash_len: bool) -> u256 { if hash_len { keccak::cairo_keccak(ref data, n.into(), 1) @@ -26,15 +29,16 @@ fn hash_n_bytes(mut data: Array, n: u8, hash_len: bool) -> u256 { keccak::cairo_keccak(ref data, 0, 0) } } + +#[cfg(feature: 'keccak')] fn hash_truncated(mut data: Array) -> felt252 { (keccak::cairo_keccak(ref data, 0, 0) .flip_endianness() % 0x10000000000000000000000000000000000000000) .try_into() .unwrap() } + +#[cfg(feature: 'keccak')] fn hash(mut data: Array) -> u256 { keccak::cairo_keccak(ref data, 0, 0) } -// === KECCAK END === - - diff --git a/src/deserialization/stark.cairo b/src/deserialization/stark.cairo index caed9bfc1..bf75f2e32 100644 --- a/src/deserialization/stark.cairo +++ b/src/deserialization/stark.cairo @@ -3,24 +3,6 @@ use cairo_verifier::{ public_input::{ContinuousPageHeader, PublicInput, SegmentInfo}, public_memory::{AddrValue, Page}, }, - // === DEX BEGIN === - // air::layouts::dex::traces::TracesConfig, - // === DEX END === - // === RECURSIVE BEGIN === - air::layouts::recursive::traces::TracesConfig, - // === RECURSIVE END === - // === RECURSIVE_WITH_POSEIDON BEGIN === - // air::layouts::recursive_with_poseidon::traces::TracesConfig, - // === RECURSIVE_WITH_POSEIDON END === - // === SMALL BEGIN === - // air::layouts::small::traces::TracesConfig, - // === SMALL END === - // === STARKNET BEGIN === - // air::layouts::starknet::traces::TracesConfig, - // === STARKNET END === - // === STARKNET_WITH_KECCAK BEGIN === - // air::layouts::starknet_with_keccak::traces::TracesConfig, - // === STARKNET_WITH_KECCAK END === deserialization::{ traces::{ TracesConfigWithSerde, TracesDecommitmentWithSerde, TracesWitnessWithSerde, @@ -32,6 +14,18 @@ use cairo_verifier::{ }, stark::{StarkProof, StarkConfig, StarkUnsentCommitment, StarkWitness}, }; +#[cfg(feature: 'dex')] +use cairo_verifier::air::layouts::dex::traces::TracesConfig; +#[cfg(feature: 'recursive')] +use cairo_verifier::air::layouts::recursive::traces::TracesConfig; +#[cfg(feature: 'recursive_with_poseidon')] +use cairo_verifier::air::layouts::recursive_with_poseidon::traces::TracesConfig; +#[cfg(feature: 'small')] +use cairo_verifier::air::layouts::small::traces::TracesConfig; +#[cfg(feature: 'starknet')] +use cairo_verifier::air::layouts::starknet::traces::TracesConfig; +#[cfg(feature: 'starknet_with_keccak')] +use cairo_verifier::air::layouts::starknet_with_keccak::traces::TracesConfig; #[derive(Drop, Serde)] struct StarkProofWithSerde { diff --git a/src/deserialization/traces.cairo b/src/deserialization/traces.cairo index acf2bdf33..00ca33766 100644 --- a/src/deserialization/traces.cairo +++ b/src/deserialization/traces.cairo @@ -1,34 +1,4 @@ use cairo_verifier::{ - // === DEX BEGIN === - // air::layouts::dex::{ - // traces::TracesConfig, traces::{TracesUnsentCommitment, TracesDecommitment, TracesWitness} - // }, - // === DEX END === - // === RECURSIVE BEGIN === - air::layouts::recursive::{ - traces::TracesConfig, traces::{TracesUnsentCommitment, TracesDecommitment, TracesWitness} - }, - // === RECURSIVE END === - // === RECURSIVE_WITH_POSEIDON BEGIN === - // air::layouts::recursive_with_poseidon::{ - // traces::TracesConfig, traces::{TracesUnsentCommitment, TracesDecommitment, TracesWitness} - // }, - // === RECURSIVE_WITH_POSEIDON END === - // === SMALL BEGIN === - // air::layouts::small::{ - // traces::TracesConfig, traces::{TracesUnsentCommitment, TracesDecommitment, TracesWitness} - // }, - // === SMALL END === - // === STARKNET BEGIN === - // air::layouts::starknet::{ - // traces::TracesConfig, traces::{TracesUnsentCommitment, TracesDecommitment, TracesWitness} - // }, - // === STARKNET END === - // === STARKNET_WITH_KECCAK BEGIN === - // air::layouts::starknet_with_keccak::{ - // traces::TracesConfig, traces::{TracesUnsentCommitment, TracesDecommitment, TracesWitness} - // }, - // === STARKNET_WITH_KECCAK END === deserialization::{ vector::{ VectorCommitmentConfig, VectorCommitmentWitness, VectorCommitmentConfigWithSerde, @@ -43,6 +13,30 @@ use cairo_verifier::{ TableCommitmentConfig, TableCommitmentWitness, TableDecommitment }, }; +#[cfg(feature: 'dex')] +use cairo_verifier::air::layouts::dex::{ + traces::TracesConfig, traces::{TracesUnsentCommitment, TracesDecommitment, TracesWitness} +}; +#[cfg(feature: 'recursive')] +use cairo_verifier::air::layouts::recursive::{ + traces::TracesConfig, traces::{TracesUnsentCommitment, TracesDecommitment, TracesWitness} +}; +#[cfg(feature: 'recursive_with_poseidon')] +use cairo_verifier::air::layouts::recursive_with_poseidon::{ + traces::TracesConfig, traces::{TracesUnsentCommitment, TracesDecommitment, TracesWitness} +}; +#[cfg(feature: 'small')] +use cairo_verifier::air::layouts::small::{ + traces::TracesConfig, traces::{TracesUnsentCommitment, TracesDecommitment, TracesWitness} +}; +#[cfg(feature: 'starknet')] +use cairo_verifier::air::layouts::starknet::{ + traces::TracesConfig, traces::{TracesUnsentCommitment, TracesDecommitment, TracesWitness} +}; +#[cfg(feature: 'starknet_with_keccak')] +use cairo_verifier::air::layouts::starknet_with_keccak::{ + traces::TracesConfig, traces::{TracesUnsentCommitment, TracesDecommitment, TracesWitness} +}; #[derive(Drop, Serde)] struct TracesConfigWithSerde { diff --git a/src/fri/tests.cairo b/src/fri/tests.cairo index a638aa54b..5ec0bba40 100644 --- a/src/fri/tests.cairo +++ b/src/fri/tests.cairo @@ -1,8 +1,10 @@ -// === RECURSIVE BEGIN === +#[cfg(recursive: 'recursive')] mod test_fri_commit; +#[cfg(recursive: 'recursive')] mod test_fri_config; +#[cfg(recursive: 'recursive')] mod test_fri_verify; -// === RECURSIVE END === + mod test_fri_formula; mod test_last_layer; mod test_next_layer; diff --git a/src/fri/tests/test_fri_verify.cairo b/src/fri/tests/test_fri_verify.cairo index 4629871b1..a083c8538 100644 --- a/src/fri/tests/test_fri_verify.cairo +++ b/src/fri/tests/test_fri_verify.cairo @@ -2,20 +2,19 @@ use cairo_verifier::{ fri::fri::fri_verify, tests::{stone_proof_fibonacci, stone_proof_fibonacci_keccak} }; -// === BLAKE2S BEGIN === -// #[test] -// #[available_gas(9999999999)] -// fn test_fri_verify() { -// let queries = stone_proof_fibonacci::queries::get().span(); -// let commitment = stone_proof_fibonacci::fri::commitment::get(); -// let decommitment = stone_proof_fibonacci::fri::decommitment::get(); -// let witness = stone_proof_fibonacci::fri::witness::get(); +#[cfg(feature: 'blake2s')] +#[test] +#[available_gas(9999999999)] +fn test_fri_verify() { + let queries = stone_proof_fibonacci::queries::get().span(); + let commitment = stone_proof_fibonacci::fri::commitment::get(); + let decommitment = stone_proof_fibonacci::fri::decommitment::get(); + let witness = stone_proof_fibonacci::fri::witness::get(); -// fri_verify(queries, commitment, decommitment, witness) -// } -// === BLAKE2S END === + fri_verify(queries, commitment, decommitment, witness) +} -// === KECCAK BEGIN === +#[cfg(feature: 'keccak')] #[test] #[available_gas(9999999999)] fn test_fri_verify() { @@ -26,6 +25,3 @@ fn test_fri_verify() { fri_verify(queries, commitment, decommitment, witness) } -// === KECCAK END === - - diff --git a/src/lib.cairo b/src/lib.cairo index 2c34ff582..8b2e46c89 100644 --- a/src/lib.cairo +++ b/src/lib.cairo @@ -1,7 +1,4 @@ mod air; -// === RECURSIVE BEGIN === -mod benches; -// === RECURSIVE END === mod channel; mod common; mod deserialization; @@ -15,33 +12,30 @@ mod table_commitment; mod vector_commitment; mod verifier; -// === RECURSIVE BEGIN === +#[cfg(feature: 'recursive')] +mod benches; +#[cfg(feature: 'recursive')] mod tests; -// === RECURSIVE END === use cairo_verifier::{ air::public_input::CairoVersion, deserialization::stark::StarkProofWithSerde, stark::{StarkProof, StarkProofImpl}, - // === DEX BEGIN === - // air::layouts::dex::public_input::DexPublicInputImpl as PublicInputImpl, - // === DEX END === - // === RECURSIVE BEGIN === - air::layouts::recursive::public_input::RecursivePublicInputImpl as PublicInputImpl, -// === RECURSIVE END === -// === RECURSIVE_WITH_POSEIDON BEGIN === -// air::layouts::recursive_with_poseidon::public_input::RecursiveWithPoseidonPublicInputImpl as PublicInputImpl, -// === RECURSIVE_WITH_POSEIDON END === -// === SMALL BEGIN === -// air::layouts::small::public_input::SmallPublicInputImpl as PublicInputImpl, -// === SMALL END === -// === STARKNET BEGIN === -// air::layouts::starknet::public_input::StarknetPublicInputImpl as PublicInputImpl, -// === STARKNET END === -// === STARKNET_WITH_KECCAK BEGIN === -// air::layouts::starknet_with_keccak::public_input::StarknetWithKeccakPublicInputImpl as PublicInputImpl, -// === STARKNET_WITH_KECCAK END === }; +#[cfg(feature: 'dex')] +use cairo_verifier::air::layouts::dex::public_input::DexPublicInputImpl as PublicInputImpl; +#[cfg(feature: 'recursive')] +use cairo_verifier::air::layouts::recursive::public_input::RecursivePublicInputImpl as PublicInputImpl; +#[cfg(feature: 'recursive_with_poseidon')] +use cairo_verifier::air::layouts::recursive_with_poseidon::public_input::RecursiveWithPoseidonPublicInputImpl as PublicInputImpl; +#[cfg(feature: 'small')] +use cairo_verifier::air::layouts::small::public_input::SmallPublicInputImpl as PublicInputImpl; +#[cfg(feature: 'starknet')] +use cairo_verifier::air::layouts::starknet::public_input::StarknetPublicInputImpl as PublicInputImpl; +#[cfg(feature: 'starknet_with_keccak')] +use cairo_verifier::air::layouts::starknet_with_keccak::public_input::StarknetWithKeccakPublicInputImpl as PublicInputImpl; + + const SECURITY_BITS: felt252 = 50; fn main(mut serialized: Span, cairo_version: CairoVersion) -> (felt252, felt252) { diff --git a/src/oods.cairo b/src/oods.cairo index 615abf613..c388022a3 100644 --- a/src/oods.cairo +++ b/src/oods.cairo @@ -1,49 +1,43 @@ use cairo_verifier::{ common::array_extend::ArrayExtendTrait, - // === DEX BEGIN === - // air::layouts::dex::{ - // AIRComposition, AIROods, DexAIRCompositionImpl, DexAIROodsImpl, - // global_values::InteractionElements, public_input::PublicInput, traces::TracesDecommitment, - // constants::CONSTRAINT_DEGREE, - // }, - // === DEX END === - // === RECURSIVE BEGIN === - air::layouts::recursive::{ - AIRComposition, AIROods, RecursiveAIRCompositionImpl, RecursiveAIROodsImpl, - global_values::InteractionElements, public_input::PublicInput, traces::TracesDecommitment, - constants::CONSTRAINT_DEGREE, - }, - // === RECURSIVE END === - // === RECURSIVE_WITH_POSEIDON BEGIN === - // air::layouts::recursive_with_poseidon::{ - // AIRComposition, AIROods, RecursiveWithPoseidonAIRCompositionImpl, - // RecursiveWithPoseidonAIROodsImpl, global_values::InteractionElements, - // public_input::PublicInput, traces::TracesDecommitment, constants::CONSTRAINT_DEGREE, - // }, - // === RECURSIVE_WITH_POSEIDON END === - // === SMALL BEGIN === - // air::layouts::small::{ - // AIRComposition, AIROods, SmallAIRCompositionImpl, SmallAIROodsImpl, - // global_values::InteractionElements, public_input::PublicInput, traces::TracesDecommitment, - // constants::CONSTRAINT_DEGREE, - // }, - // === SMALL END === - // === STARKNET BEGIN === - // air::layouts::starknet::{ - // AIRComposition, AIROods, StarknetAIRCompositionImpl, StarknetAIROodsImpl, - // global_values::InteractionElements, public_input::PublicInput, traces::TracesDecommitment, - // constants::CONSTRAINT_DEGREE, - // }, - // === STARKNET END === - // === STARKNET_WITH_KECCAK BEGIN === - // air::layouts::starknet_with_keccak::{ - // AIRComposition, AIROods, StarknetWithKeccakAIRCompositionImpl, - // StarknetWithKeccakAIROodsImpl, global_values::InteractionElements, - // public_input::PublicInput, traces::TracesDecommitment, constants::CONSTRAINT_DEGREE, - // }, - // === STARKNET_WITH_KECCAK END === table_commitment::table_commitment::TableDecommitment }; +#[cfg(feature: 'dex')] +use cairo_verifier::air::layouts::dex::{ + AIRComposition, AIROods, DexAIRCompositionImpl, DexAIROodsImpl, + global_values::InteractionElements, public_input::PublicInput, traces::TracesDecommitment, + constants::CONSTRAINT_DEGREE, +}; +#[cfg(feature: 'recursive')] +use cairo_verifier::air::layouts::recursive::{ + AIRComposition, AIROods, RecursiveAIRCompositionImpl, RecursiveAIROodsImpl, + global_values::InteractionElements, public_input::PublicInput, traces::TracesDecommitment, + constants::CONSTRAINT_DEGREE, +}; +#[cfg(feature: 'recursive_with_poseidon')] +use cairo_verifier::air::layouts::recursive_with_poseidon::{ + AIRComposition, AIROods, RecursiveWithPoseidonAIRCompositionImpl, + RecursiveWithPoseidonAIROodsImpl, global_values::InteractionElements, + public_input::PublicInput, traces::TracesDecommitment, constants::CONSTRAINT_DEGREE, +}; +#[cfg(feature: 'small')] +use cairo_verifier::air::layouts::small::{ + AIRComposition, AIROods, SmallAIRCompositionImpl, SmallAIROodsImpl, + global_values::InteractionElements, public_input::PublicInput, traces::TracesDecommitment, + constants::CONSTRAINT_DEGREE, +}; +#[cfg(feature: 'starknet')] +use cairo_verifier::air::layouts::starknet::{ + AIRComposition, AIROods, StarknetAIRCompositionImpl, StarknetAIROodsImpl, + global_values::InteractionElements, public_input::PublicInput, traces::TracesDecommitment, + constants::CONSTRAINT_DEGREE, +}; +#[cfg(feature: 'starknet_with_keccak')] +use cairo_verifier::air::layouts::starknet_with_keccak::{ + AIRComposition, AIROods, StarknetWithKeccakAIRCompositionImpl, + StarknetWithKeccakAIROodsImpl, global_values::InteractionElements, + public_input::PublicInput, traces::TracesDecommitment, constants::CONSTRAINT_DEGREE, +}; #[derive(Drop)] struct OodsEvaluationInfo { @@ -141,7 +135,7 @@ fn eval_oods_boundary_poly_at_points( evaluations } -// === RECURSIVE BEGIN === +#[cfg(feature: 'recursive')] #[cfg(test)] mod tests { use cairo_verifier::oods::verify_oods; @@ -166,6 +160,3 @@ mod tests { ); } } -// === RECURSIVE END === - - diff --git a/src/proof_of_work/tests/test_proof_of_work.cairo b/src/proof_of_work/tests/test_proof_of_work.cairo index 809f5009a..fb3c76df2 100644 --- a/src/proof_of_work/tests/test_proof_of_work.cairo +++ b/src/proof_of_work/tests/test_proof_of_work.cairo @@ -1,27 +1,27 @@ use cairo_verifier::proof_of_work::proof_of_work::verify_proof_of_work; -// === BLAKE2S BEGIN === -// #[test] -// #[available_gas(9999999999)] -// fn test_verify_proof_of_work_0() { -// let digest: u256 = 0x1c5a5f4381df1f5cd7ca1d48a19d8ff802a71d94169de38382621fdc5514a10a; -// let nonce: u64 = 0x1683b; -// let n_bits: u8 = 20; -// verify_proof_of_work(digest, n_bits, nonce); -// } -// -// #[test] -// #[should_panic] -// #[available_gas(9999999999)] -// fn test_verify_proof_of_work_1() { -// let digest: u256 = 0x1c5a5f4381df1f5cd7ca1d48a19d8ff802a71d94169de38382621fdc5514a10a; -// let nonce: u64 = 0x1683b + 1; -// let n_bits: u8 = 20; -// verify_proof_of_work(digest, n_bits, nonce); -// } -// === BLAKE2S END === +#[cfg(feature: 'blake2s')] +#[test] +#[available_gas(9999999999)] +fn test_verify_proof_of_work_0() { + let digest: u256 = 0x1c5a5f4381df1f5cd7ca1d48a19d8ff802a71d94169de38382621fdc5514a10a; + let nonce: u64 = 0x1683b; + let n_bits: u8 = 20; + verify_proof_of_work(digest, n_bits, nonce); +} + +#[cfg(feature: 'blake2s')] +#[test] +#[should_panic] +#[available_gas(9999999999)] +fn test_verify_proof_of_work_1() { + let digest: u256 = 0x1c5a5f4381df1f5cd7ca1d48a19d8ff802a71d94169de38382621fdc5514a10a; + let nonce: u64 = 0x1683b + 1; + let n_bits: u8 = 20; + verify_proof_of_work(digest, n_bits, nonce); +} -// === KECCAK BEGIN === +#[cfg(feature: 'keccak')] #[test] #[available_gas(9999999999)] fn test_verify_proof_of_work_0() { @@ -33,6 +33,7 @@ fn test_verify_proof_of_work_0() { verify_proof_of_work(digest, n_bits, nonce); } +#[cfg(feature: 'keccak')] #[test] #[should_panic] #[available_gas(9999999999)] @@ -44,6 +45,3 @@ fn test_verify_proof_of_work_1() { let n_bits: u8 = 0x1e; verify_proof_of_work(digest, n_bits, nonce); } -// === KECCAK END === - - diff --git a/src/queries/tests.cairo b/src/queries/tests.cairo index 52798feed..93f2e2b48 100644 --- a/src/queries/tests.cairo +++ b/src/queries/tests.cairo @@ -1,5 +1,5 @@ -// === RECURSIVE BEGIN === +#[cfg(feature: 'recursive')] mod test_generate_queries; -// === RECURSIVE END === + mod test_queries_to_points; mod test_usort; diff --git a/src/stark.cairo b/src/stark.cairo index 09d08521f..0f36b69b3 100644 --- a/src/stark.cairo +++ b/src/stark.cairo @@ -7,50 +7,6 @@ mod tests; use cairo_verifier::{ air::{ public_input::{PublicInput, get_public_input_hash}, - // === DEX BEGIN === - // layouts::dex::{ - // traces::{TracesConfig, TracesConfigTrait}, public_input::DexPublicInputImpl, - // traces::{TracesUnsentCommitment, TracesCommitment, TracesDecommitment, TracesWitness}, - // constants::{NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND} - // }, - // === DEX END === - // === RECURSIVE BEGIN === - layouts::recursive::{ - traces::{TracesConfig, TracesConfigTrait}, public_input::RecursivePublicInputImpl, - traces::{TracesUnsentCommitment, TracesCommitment, TracesDecommitment, TracesWitness}, - constants::{NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND}, - }, - // === RECURSIVE END === - // === RECURSIVE_WITH_POSEIDON BEGIN === - // layouts::recursive_with_poseidon::{ - // traces::{TracesConfig, TracesConfigTrait}, - // public_input::RecursiveWithPoseidonPublicInputImpl, - // traces::{TracesUnsentCommitment, TracesCommitment, TracesDecommitment, TracesWitness}, - // constants::{NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND} - // }, - // === RECURSIVE_WITH_POSEIDON END === - // === SMALL BEGIN === - // layouts::small::{ - // traces::{TracesConfig, TracesConfigTrait}, public_input::SmallPublicInputImpl, - // traces::{TracesUnsentCommitment, TracesCommitment, TracesDecommitment, TracesWitness}, - // constants::{NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND} - // }, - // === SMALL END === - // === STARKNET BEGIN === - // layouts::starknet::{ - // traces::{TracesConfig, TracesConfigTrait}, public_input::StarknetPublicInputImpl, - // traces::{TracesUnsentCommitment, TracesCommitment, TracesDecommitment, TracesWitness}, - // constants::{NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND} - // }, - // === STARKNET END === - // === STARKNET_WITH_KECCAK BEGIN === - // layouts::starknet_with_keccak::{ - // traces::{TracesConfig, TracesConfigTrait}, - // public_input::StarknetWithKeccakPublicInputImpl, - // traces::{TracesUnsentCommitment, TracesCommitment, TracesDecommitment, TracesWitness}, - // constants::{NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND} - // }, - // === STARKNET_WITH_KECCAK END === }, channel::channel::{Channel, ChannelImpl}, fri::{ @@ -67,6 +23,44 @@ use cairo_verifier::{ }, vector_commitment::vector_commitment::VectorCommitmentConfigTrait, }; +#[cfg(feature: 'dex')] +use cairo_verifier::air::layouts::dex::{ + traces::{TracesConfig, TracesConfigTrait}, public_input::DexPublicInputImpl, + traces::{TracesUnsentCommitment, TracesCommitment, TracesDecommitment, TracesWitness}, + constants::{NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND} +}; +#[cfg(feature: 'recursive')] +use cairo_verifier::air::layouts::recursive::{ + traces::{TracesConfig, TracesConfigTrait}, public_input::RecursivePublicInputImpl, + traces::{TracesUnsentCommitment, TracesCommitment, TracesDecommitment, TracesWitness}, + constants::{NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND}, +}; +#[cfg(feature: 'recursive_with_poseidon')] +use cairo_verifier::air::layouts::recursive_with_poseidon::{ + traces::{TracesConfig, TracesConfigTrait}, + public_input::RecursiveWithPoseidonPublicInputImpl, + traces::{TracesUnsentCommitment, TracesCommitment, TracesDecommitment, TracesWitness}, + constants::{NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND} +}; +#[cfg(feature: 'small')] +use cairo_verifier::air::layouts::small::{ + traces::{TracesConfig, TracesConfigTrait}, public_input::SmallPublicInputImpl, + traces::{TracesUnsentCommitment, TracesCommitment, TracesDecommitment, TracesWitness}, + constants::{NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND} +}; +#[cfg(feature: 'starknet')] +use cairo_verifier::air::layouts::starknet::{ + traces::{TracesConfig, TracesConfigTrait}, public_input::StarknetPublicInputImpl, + traces::{TracesUnsentCommitment, TracesCommitment, TracesDecommitment, TracesWitness}, + constants::{NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND} +}; +#[cfg(feature: 'starknet_with_keccak')] +use cairo_verifier::air::layouts::starknet_with_keccak::{ + traces::{TracesConfig, TracesConfigTrait}, + public_input::StarknetWithKeccakPublicInputImpl, + traces::{TracesUnsentCommitment, TracesCommitment, TracesDecommitment, TracesWitness}, + constants::{NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND} +}; #[derive(Drop, Serde)] struct StarkProof { diff --git a/src/stark/stark_commit.cairo b/src/stark/stark_commit.cairo index fa6c7e506..1658aac8b 100644 --- a/src/stark/stark_commit.cairo +++ b/src/stark/stark_commit.cairo @@ -1,46 +1,40 @@ use cairo_verifier::{ - // === DEX BEGIN === - // air::layouts::dex::{ - // constants::{CONSTRAINT_DEGREE, N_CONSTRAINTS, MASK_SIZE}, public_input::PublicInput, - // traces::traces_commit, - // }, - // === DEX END === - // === RECURSIVE BEGIN === - air::layouts::recursive::{ - constants::{CONSTRAINT_DEGREE, N_CONSTRAINTS, MASK_SIZE}, public_input::PublicInput, - traces::traces_commit, - }, - // === RECURSIVE END === - // === RECURSIVE_WITH_POSEIDON BEGIN === - // air::layouts::recursive_with_poseidon::{ - // constants::{CONSTRAINT_DEGREE, N_CONSTRAINTS, MASK_SIZE}, public_input::PublicInput, - // traces::traces_commit, - // }, - // === RECURSIVE_WITH_POSEIDON END === - // === SMALL BEGIN === - // air::layouts::small::{ - // constants::{CONSTRAINT_DEGREE, N_CONSTRAINTS, MASK_SIZE}, public_input::PublicInput, - // traces::traces_commit, - // }, - // === SMALL END === - // === STARKNET BEGIN === - // air::layouts::starknet::{ - // constants::{CONSTRAINT_DEGREE, N_CONSTRAINTS, MASK_SIZE}, public_input::PublicInput, - // traces::traces_commit, - // }, - // === STARKNET END === - // === STARKNET_WITH_KECCAK BEGIN === - // air::layouts::starknet_with_keccak::{ - // constants::{CONSTRAINT_DEGREE, N_CONSTRAINTS, MASK_SIZE}, public_input::PublicInput, - // traces::traces_commit, - // }, - // === STARKNET_WITH_KECCAK END === channel::channel::{Channel, ChannelTrait}, common::powers_array::powers_array, domains::StarkDomains, fri::fri::fri_commit, stark::{StarkUnsentCommitment, StarkConfig, StarkCommitment}, proof_of_work::proof_of_work::proof_of_work_commit, table_commitment::table_commitment::table_commit, oods::verify_oods, }; +#[cfg(feature: 'dex')] +use cairo_verifier::air::layouts::dex::{ + constants::{CONSTRAINT_DEGREE, N_CONSTRAINTS, MASK_SIZE}, public_input::PublicInput, + traces::traces_commit, +}; +#[cfg(feature: 'recursive')] +use cairo_verifier::air::layouts::recursive::{ + constants::{CONSTRAINT_DEGREE, N_CONSTRAINTS, MASK_SIZE}, public_input::PublicInput, + traces::traces_commit, +}; +#[cfg(feature: 'recursive_with_poseidon')] +use cairo_verifier::air::layouts::recursive_with_poseidon::{ + constants::{CONSTRAINT_DEGREE, N_CONSTRAINTS, MASK_SIZE}, public_input::PublicInput, + traces::traces_commit, +}; +#[cfg(feature: 'small')] +use cairo_verifier::air::layouts::small::{ + constants::{CONSTRAINT_DEGREE, N_CONSTRAINTS, MASK_SIZE}, public_input::PublicInput, + traces::traces_commit, +}; +#[cfg(feature: 'starknet')] +use cairo_verifier::air::layouts::starknet::{ + constants::{CONSTRAINT_DEGREE, N_CONSTRAINTS, MASK_SIZE}, public_input::PublicInput, + traces::traces_commit, +}; +#[cfg(feature: 'starknet_with_keccak')] +use cairo_verifier::air::layouts::starknet_with_keccak::{ + constants::{CONSTRAINT_DEGREE, N_CONSTRAINTS, MASK_SIZE}, public_input::PublicInput, + traces::traces_commit, +}; // STARK commitment phase. diff --git a/src/stark/stark_verify.cairo b/src/stark/stark_verify.cairo index 0944a079b..4b6c9fca4 100644 --- a/src/stark/stark_verify.cairo +++ b/src/stark/stark_verify.cairo @@ -2,26 +2,21 @@ use cairo_verifier::{ queries::queries::queries_to_points, domains::StarkDomains, fri::fri::{FriDecommitment, fri_verify}, stark::{StarkUnsentCommitment, StarkWitness, StarkCommitment}, - // === DEX BEGIN === - // air::layouts::dex::traces::traces_decommit, // === DEX END === - // === RECURSIVE BEGIN === - air::layouts::recursive::traces::traces_decommit, - // === RECURSIVE END === - // === RECURSIVE_WITH_POSEIDON BEGIN === - // air::layouts::recursive_with_poseidon::traces::traces_decommit, - // === RECURSIVE_WITH_POSEIDON END === - // === SMALL BEGIN === - // air::layouts::small::traces::traces_decommit, - // === SMALL END === - // === STARKNET BEGIN === - // air::layouts::starknet::traces::traces_decommit, - // === STARKNET END === - // === STARKNET_WITH_KECCAK BEGIN === - // air::layouts::starknet_with_keccak::traces::traces_decommit, - // === STARKNET_WITH_KECCAK END === table_commitment::table_commitment::table_decommit, oods::{OodsEvaluationInfo, eval_oods_boundary_poly_at_points}, }; +#[cfg(feature: 'dex')] +use cairo_verifier::air::layouts::dex::traces::traces_decommit; +#[cfg(feature: 'recursive')] +use cairo_verifier::air::layouts::recursive::traces::traces_decommit; +#[cfg(feature: 'recursive_with_poseidon')] +use cairo_verifier::air::layouts::recursive_with_poseidon::traces::traces_decommit; +#[cfg(feature: 'small')] +use cairo_verifier::air::layouts::small::traces::traces_decommit; +#[cfg(feature: 'starknet')] +use cairo_verifier::air::layouts::starknet::traces::traces_decommit; +#[cfg(feature: 'starknet_with_keccak')] +use cairo_verifier::air::layouts::starknet_with_keccak::traces::traces_decommit; // STARK verify phase. fn stark_verify( diff --git a/src/stark/tests.cairo b/src/stark/tests.cairo index 5834fa134..ad2f5f1ef 100644 --- a/src/stark/tests.cairo +++ b/src/stark/tests.cairo @@ -1,7 +1,6 @@ -// === RECURSIVE BEGIN === +#[cfg(feature: 'recursive')] mod test_stark_commit; +#[cfg(feature: 'recursive')] mod test_stark_proof_verify; +#[cfg(feature: 'recursive')] mod test_stark_verify; -// === RECURSIVE END === - - diff --git a/src/stark/tests/test_stark_commit.cairo b/src/stark/tests/test_stark_commit.cairo index 620694c6a..2c666263a 100644 --- a/src/stark/tests/test_stark_commit.cairo +++ b/src/stark/tests/test_stark_commit.cairo @@ -3,35 +3,34 @@ use cairo_verifier::{ tests::{stone_proof_fibonacci, stone_proof_fibonacci_keccak} }; -// === BLAKE2S BEGIN === -// #[test] -// #[available_gas(9999999999)] -// fn test_stark_commit() { -// let mut channel = ChannelTrait::new_with_counter( -// 0xaf91f2c71f4a594b1575d258ce82464475c82d8fb244142d0db450491c1b52, 0x0 -// ); -// -// let public_input = stone_proof_fibonacci::public_input::get(); -// let unsent_commitment = stone_proof_fibonacci::stark::unsent_commitment::get(); -// let config = stone_proof_fibonacci::stark::config::get(); -// let stark_domains = stone_proof_fibonacci::stark::domains::get(); -// -// assert( -// stark_commit( -// ref channel, @public_input, @unsent_commitment, @config, @stark_domains -// ) == stone_proof_fibonacci::stark::commitment::get(), -// 'Invalid value' -// ); -// -// assert( -// channel.digest == 0x9c769c7e0797cf043b06b980072a798b141f2bc41b14e85ad93ba178b13de7, -// 'Invalid value' -// ); -// assert(channel.counter == 0x0, 'Invalid value'); -// } -// === BLAKE2S END === - -// === KECCAK BEGIN === +#[cfg(feature: 'blake2s')] +#[test] +#[available_gas(9999999999)] +fn test_stark_commit() { + let mut channel = ChannelTrait::new_with_counter( + 0xaf91f2c71f4a594b1575d258ce82464475c82d8fb244142d0db450491c1b52, 0x0 + ); + + let public_input = stone_proof_fibonacci::public_input::get(); + let unsent_commitment = stone_proof_fibonacci::stark::unsent_commitment::get(); + let config = stone_proof_fibonacci::stark::config::get(); + let stark_domains = stone_proof_fibonacci::stark::domains::get(); + + assert( + stark_commit( + ref channel, @public_input, @unsent_commitment, @config, @stark_domains + ) == stone_proof_fibonacci::stark::commitment::get(), + 'Invalid value' + ); + + assert( + channel.digest == 0x9c769c7e0797cf043b06b980072a798b141f2bc41b14e85ad93ba178b13de7, + 'Invalid value' + ); + assert(channel.counter == 0x0, 'Invalid value'); +} + +#[cfg(feature: 'keccak')] #[test] #[available_gas(9999999999)] fn test_stark_commit() { @@ -57,6 +56,3 @@ fn test_stark_commit() { ); assert(channel.counter == 0x0, 'Invalid value'); } -// === KECCAK END === - - diff --git a/src/stark/tests/test_stark_proof_verify.cairo b/src/stark/tests/test_stark_proof_verify.cairo index 03b492b63..8ac3fe4c7 100644 --- a/src/stark/tests/test_stark_proof_verify.cairo +++ b/src/stark/tests/test_stark_proof_verify.cairo @@ -3,24 +3,23 @@ use cairo_verifier::{ tests::{stone_proof_fibonacci, stone_proof_fibonacci_keccak} }; -// === BLAKE2S BEGIN === -// #[test] -// #[available_gas(99999999999)] -// fn test_stark_proof_fibonacci_verify() { -// let security_bits: felt252 = 50; -// -// let stark_proof = StarkProof { -// config: stone_proof_fibonacci::stark::config::get(), -// public_input: stone_proof_fibonacci::public_input::get(), -// unsent_commitment: stone_proof_fibonacci::stark::unsent_commitment::get(), -// witness: stone_proof_fibonacci::stark::witness::get(), -// }; -// -// stark_proof.verify(security_bits); -// } -// === BLAKE2S END === +#[cfg(feature: 'blake2s')] +#[test] +#[available_gas(99999999999)] +fn test_stark_proof_fibonacci_verify() { + let security_bits: felt252 = 50; + + let stark_proof = StarkProof { + config: stone_proof_fibonacci::stark::config::get(), + public_input: stone_proof_fibonacci::public_input::get(), + unsent_commitment: stone_proof_fibonacci::stark::unsent_commitment::get(), + witness: stone_proof_fibonacci::stark::witness::get(), + }; -// === KECCAK BEGIN === + stark_proof.verify(security_bits); +} + +#[cfg(feature: 'keccak')] #[test] #[available_gas(9999999999)] fn test_stark_proof_fibonacci_verify() { @@ -35,6 +34,3 @@ fn test_stark_proof_fibonacci_verify() { stark_proof.verify(security_bits); } -// === KECCAK END === - - diff --git a/src/stark/tests/test_stark_verify.cairo b/src/stark/tests/test_stark_verify.cairo index 79ed05e3e..529360355 100644 --- a/src/stark/tests/test_stark_verify.cairo +++ b/src/stark/tests/test_stark_verify.cairo @@ -4,22 +4,21 @@ use cairo_verifier::{ tests::{stone_proof_fibonacci, stone_proof_fibonacci_keccak} }; -// === BLAKE2S BEGIN === -// #[test] -// #[available_gas(9999999999)] -// fn test_stark_verify() { -// let queries = stone_proof_fibonacci::queries::get().span(); -// let commitment = stone_proof_fibonacci::stark::commitment::get(); -// let witness = stone_proof_fibonacci::stark::witness::get(); -// let stark_domains = stone_proof_fibonacci::stark::domains::get(); -// -// stark_verify( -// NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND, queries, commitment, witness, stark_domains, -// ) -// } -// === BLAKE2S END === +#[cfg(feature: 'blake2s')] +#[test] +#[available_gas(9999999999)] +fn test_stark_verify() { + let queries = stone_proof_fibonacci::queries::get().span(); + let commitment = stone_proof_fibonacci::stark::commitment::get(); + let witness = stone_proof_fibonacci::stark::witness::get(); + let stark_domains = stone_proof_fibonacci::stark::domains::get(); + + stark_verify( + NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND, queries, commitment, witness, stark_domains, + ) +} -// === KECCAK BEGIN === +#[cfg(feature: 'keccak')] #[test] #[available_gas(9999999999)] fn test_stark_verify() { @@ -32,6 +31,3 @@ fn test_stark_verify() { NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND, queries, commitment, witness, stark_domains, ) } -// === KECCAK END === - - diff --git a/src/table_commitment/tests.cairo b/src/table_commitment/tests.cairo index 41b571eff..0c8eab34c 100644 --- a/src/table_commitment/tests.cairo +++ b/src/table_commitment/tests.cairo @@ -1,6 +1,3 @@ mod test_table_commitment_commit; -// === RECURSIVE BEGIN === +#[cfg(feature: 'recursive')] mod test_table_commitment_decommit; -// === RECURSIVE END === - - diff --git a/src/table_commitment/tests/test_table_commitment_decommit.cairo b/src/table_commitment/tests/test_table_commitment_decommit.cairo index 6fecdb096..69755a9f5 100644 --- a/src/table_commitment/tests/test_table_commitment_decommit.cairo +++ b/src/table_commitment/tests/test_table_commitment_decommit.cairo @@ -9,20 +9,19 @@ use cairo_verifier::{ tests::{stone_proof_fibonacci_keccak, stone_proof_fibonacci} }; -// === BLAKE2S BEGIN === -// #[test] -// #[available_gas(9999999999)] -// fn test_table_commitment_decommit() { -// let commitment = stone_proof_fibonacci::traces::commitment::get().original; -// let queries = stone_proof_fibonacci::queries::get().span(); -// let decommitment = stone_proof_fibonacci::traces::decommitment::get().original; -// let witness = stone_proof_fibonacci::traces::witness::get().original; -// -// table_decommit(commitment, queries, decommitment, witness); -// } -// === BLAKE2S END === +#[cfg(feature: 'blake2s')] +#[test] +#[available_gas(9999999999)] +fn test_table_commitment_decommit() { + let commitment = stone_proof_fibonacci::traces::commitment::get().original; + let queries = stone_proof_fibonacci::queries::get().span(); + let decommitment = stone_proof_fibonacci::traces::decommitment::get().original; + let witness = stone_proof_fibonacci::traces::witness::get().original; + + table_decommit(commitment, queries, decommitment, witness); +} -// === KECCAK BEGIN === +#[cfg(feature: 'keccak')] #[test] #[available_gas(9999999999)] fn test_table_commitment_decommit() { @@ -33,6 +32,3 @@ fn test_table_commitment_decommit() { table_decommit(commitment, queries, decommitment, witness); } -// === KECCAK END === - - diff --git a/src/vector_commitment/tests/test_vector_commitment_decommit.cairo b/src/vector_commitment/tests/test_vector_commitment_decommit.cairo index 0129cbd85..09f44f301 100644 --- a/src/vector_commitment/tests/test_vector_commitment_decommit.cairo +++ b/src/vector_commitment/tests/test_vector_commitment_decommit.cairo @@ -3,112 +3,111 @@ use cairo_verifier::vector_commitment::vector_commitment::{ vector_commitment_decommit, }; -// === BLAKE2S BEGIN === -// #[test] -// #[available_gas(9999999999)] -// fn test_vector_commitment_decommit_1() { -// let commitment = VectorCommitment { -// config: VectorCommitmentConfig { -// height: 0x9, n_verifier_friendly_commitment_layers: 0x64, -// }, -// commitment_hash: 0x1e9b0fa29ebe52b9c9a43a1d44e555ce42da3199370134d758735bfe9f40269 -// }; +#[cfg(feature: 'blake2s')] +#[test] +#[available_gas(9999999999)] +fn test_vector_commitment_decommit_1() { + let commitment = VectorCommitment { + config: VectorCommitmentConfig { + height: 0x9, n_verifier_friendly_commitment_layers: 0x64, + }, + commitment_hash: 0x1e9b0fa29ebe52b9c9a43a1d44e555ce42da3199370134d758735bfe9f40269 + }; -// let queries = array![ -// VectorQuery { -// index: 0x73, value: 0x12346ea425a6aebc8c323a401410cc325aabaf99b54e600a7271f146488aa2d -// }, -// VectorQuery { -// index: 0xa5, value: 0x1aabe006a27bfa5f93bde192ff552adbef87058e62546c831ed14ce94866ac1 -// }, -// VectorQuery { -// index: 0xb0, value: 0x7205a2b5f5f403b8053b4e4ac65e2a484c007f6d118524fe28b7cdf2a56bb8a -// }, -// VectorQuery { -// index: 0xf8, value: 0x5d49462d844a3f203c59d39fa005cbe153c78e6ac831987f19c0d6dfae38fad -// }, -// VectorQuery { -// index: 0x115, value: 0x53d21587a9cb08d1b9402a4b8c2a9d37942b26963936200fea3122eaaf870b1 -// }, -// VectorQuery { -// index: 0x11c, value: 0x7c3355a75f6b36a95068b68d48e7539cd97531b7478e2cf7d2dc85b32bafc66 -// }, -// VectorQuery { -// index: 0x12f, value: 0xb6f3a522577229ac26f12df90daaf376afbd960ee4b0ab07f270bf9c5da56a -// }, -// VectorQuery { -// index: 0x13c, value: 0x174cfc44eb57da0eda6ae9407db71c5144940f05ef51f858bc8e229d15703e2 -// }, -// VectorQuery { -// index: 0x153, value: 0x2220da78b33e155482bdf0534dc30fc17fe059a7b9e30f710ee2681a8151484 -// }, -// VectorQuery { -// index: 0x1f4, value: 0x566b71a4f84556a3816d911c5dfb45f75cc962d9829acd0dd56e81517cc73b8 -// }, -// ] -// .span(); + let queries = array![ + VectorQuery { + index: 0x73, value: 0x12346ea425a6aebc8c323a401410cc325aabaf99b54e600a7271f146488aa2d + }, + VectorQuery { + index: 0xa5, value: 0x1aabe006a27bfa5f93bde192ff552adbef87058e62546c831ed14ce94866ac1 + }, + VectorQuery { + index: 0xb0, value: 0x7205a2b5f5f403b8053b4e4ac65e2a484c007f6d118524fe28b7cdf2a56bb8a + }, + VectorQuery { + index: 0xf8, value: 0x5d49462d844a3f203c59d39fa005cbe153c78e6ac831987f19c0d6dfae38fad + }, + VectorQuery { + index: 0x115, value: 0x53d21587a9cb08d1b9402a4b8c2a9d37942b26963936200fea3122eaaf870b1 + }, + VectorQuery { + index: 0x11c, value: 0x7c3355a75f6b36a95068b68d48e7539cd97531b7478e2cf7d2dc85b32bafc66 + }, + VectorQuery { + index: 0x12f, value: 0xb6f3a522577229ac26f12df90daaf376afbd960ee4b0ab07f270bf9c5da56a + }, + VectorQuery { + index: 0x13c, value: 0x174cfc44eb57da0eda6ae9407db71c5144940f05ef51f858bc8e229d15703e2 + }, + VectorQuery { + index: 0x153, value: 0x2220da78b33e155482bdf0534dc30fc17fe059a7b9e30f710ee2681a8151484 + }, + VectorQuery { + index: 0x1f4, value: 0x566b71a4f84556a3816d911c5dfb45f75cc962d9829acd0dd56e81517cc73b8 + }, + ] + .span(); -// let witness = VectorCommitmentWitness { -// authentications: array![ -// 0x2e9de49846b184d454c30e3b4854167583093da20c5ddef5e3ba2885524d006, -// 0xf3fb7305323c5fa68ad49a509a9c470e2396af41bfd2c9cf86228504436a3, -// 0x9dc63f0ac48b17304af16748798567f21bb25f8cbeaa48a462a74b3e0c5d79, -// 0x5d35649398cb24bc00458a32d01c61a8450c7a30cc5b95043f4e2b30df01360, -// 0x4493f60ea79053f2a96439d50d6335fd35e13599190e1656b724eacac658e37, -// 0x7f58b9c9c333dc5b31e3ee5e8a98d8cab0c84b3a886042b279dc2f2c408d92b, -// 0x349a976371b7aef1b1992908fefa423b9e5d4d0be58092ff6e5ead51ecf1ca4, -// 0x3ffacb144085ca3c572a314c6bb0e01b253827231285fba4084e3b624438ace, -// 0x55d22158d5bfad58ddf2633f24a3fae4642afbcea1cb9155e8b54c2a432fbfd, -// 0x63c1598794322bd8f1686e89c94dc60b0bb4f7940b5427af72187091e71ef63, -// 0xebaa8e9ab29cfba43cdc1f2cacb9cbc08b2cb17317fed571718e5e66b42488, -// 0xa31370f89d85108378244beeea13a2b2c379d16cde55c2fcd674f4296ddabe, -// 0x4285440535fff0ba31e970a1948a09951ff740c91c6d6cf4635527877c55ff1, -// 0x49eb1420843ac1a3178010c314906d28f6118e8b36620ce4469dffca27a047d, -// 0x4e65200356931c3ea1e20e087b5bff96ba268239ed2e2f784def64f5760418d, -// 0x103809d798aab5452c77f42bc4c8fcfcfa9e6efdfe24077e41928a52daf1dc8, -// 0x4253b3498a013d4473d43686f9e509be7541daf00afae0d7216f7019bc75d8f, -// 0x689297a643de6bd5955e314f94367af901eac67eeef51a52e40c0205cf8023, -// 0x2ca9dcef95643af6ec5ee055d1a05720f2e3f5e6226de5b206c4a78482963b8, -// 0x72fbddae565406f284bb4dd89623c29c821b6187dd7dfc292dbbddd4094077, -// 0x30e5ea3c2280db52829548ae99a71faa030b4e4bb87679b427f76c594aaa05a, -// 0x45ba1eda942e1085af97db6e189996903cfa09db90e52b4589e16df981f1601, -// 0x8c36a69368bea30f8ecf7de3e461a03b0cdd004ae08a3d44281b093fc63f2, -// 0x5c7194878dcb2d4ba69da97c1a878f96dd78d97612c882ba7179bafe92a6a90, -// 0x20c37b922bb713f2b6772a9ae014715f418fe5da4d53fe9b00cc2fe851f233a, -// 0x3a7e7c684904e82bf0be54290299b6d83f448bac5c6e9ea4d1cd1e844eccb70, -// 0x1ebbb30dbcb3b4fd0da33cf84d456101bbe9147b1a65507901715b3490649c6, -// 0x1409c71e0dcf4a620856775508ce1b4c7d55e4229ac5fd41a3f8ecee097eb39, -// 0x18cdf340cc64b00bf134c9e55396f79eddfbda8e2090542380c5c4967ee790b, -// 0x18add43c036948c8d7e767ae22056e1f5f1a9d1daad6b9a8f2e7da996f4a1c2, -// 0x30e7224d1c98b75e019b60bbe320e358ef35b1adaf12aad044744e640c2a4d, -// 0x25a8793c928ecacb2e84802830fa101fb3839455957921ed7bcb39549b1f80, -// 0x65dd0f91032712c4a8b1b5c35cd6ebdb654efb5e56085a2eef0def4bde4d066, -// 0x4a50e2b14315602b8c97c9d2304db828806c37b751203bb7dad534d7b45d21d, -// 0x5afdcfcf55c58dbf5ad58b17f16514da8dac3e69501fb399c30333ab3050c3, -// 0x20f5ecf9107f9d3e33f462948d955b70d5ec5573a679ae548998c41b5eec730, -// 0x1f70d9f6c203312c6aabf4d191cd4cbc68f8c92bebf561cb8e20ce9fc07ef55, -// 0x14e877449f7005ee874020d6759ce808345e20c3fae4a62e7f12c2c457f71ec, -// 0x780b4537e060e0f1e88ca7337d5d43ef2d4bbb4b48e4899c55ea9a5e7120b5a, -// 0x608a4544987ef3599043e9a8b4aa0598f8d71dee81e46104ca6ac186e2c8044, -// 0x58cbd95dd12e8761a99011f0ae970fe73e03b7d7e43b614510ee7a6a2efe7d3, -// 0x5c533c05cbf2af6d819bdf23272e567b7a49c2c2bd799201ed0e32ce9ff092b, -// 0x342bb671b7d40601d4031045068abfbf2c578f7e4a380e180dbf2b0c8fef6, -// 0x2da269eab1f7e247c0caf3bcac1bb0e5e7abacde34bc54a9de3e0a82a36cfff, -// 0x117cc37e078928598470cfe43e1b6c66c6365d1cf601bc5daf1055a0f8210db, -// 0x4640956c2daa074399825b0404260bee0898f9d24b1c807f5c43159e7a9b019, -// 0x1da36b1fb01d0470d48c3eb4c92263eadb7b58c8829f2ee77e3287a6e39c902, -// 0x78dac96e95e86f83b4a426bd0505d84b5ea967822d0fca9f3bd28331164d94b, -// 0x1d50c82e363d8e7fa2641c9f2137b99832372d1879a2ee02b2c824a4cb620dd, -// 0x2fd5a64db6093c9efda84ba327a43043e41310626073e58331c9f2f9f2db20f -// ] -// .span(), -// }; + let witness = VectorCommitmentWitness { + authentications: array![ + 0x2e9de49846b184d454c30e3b4854167583093da20c5ddef5e3ba2885524d006, + 0xf3fb7305323c5fa68ad49a509a9c470e2396af41bfd2c9cf86228504436a3, + 0x9dc63f0ac48b17304af16748798567f21bb25f8cbeaa48a462a74b3e0c5d79, + 0x5d35649398cb24bc00458a32d01c61a8450c7a30cc5b95043f4e2b30df01360, + 0x4493f60ea79053f2a96439d50d6335fd35e13599190e1656b724eacac658e37, + 0x7f58b9c9c333dc5b31e3ee5e8a98d8cab0c84b3a886042b279dc2f2c408d92b, + 0x349a976371b7aef1b1992908fefa423b9e5d4d0be58092ff6e5ead51ecf1ca4, + 0x3ffacb144085ca3c572a314c6bb0e01b253827231285fba4084e3b624438ace, + 0x55d22158d5bfad58ddf2633f24a3fae4642afbcea1cb9155e8b54c2a432fbfd, + 0x63c1598794322bd8f1686e89c94dc60b0bb4f7940b5427af72187091e71ef63, + 0xebaa8e9ab29cfba43cdc1f2cacb9cbc08b2cb17317fed571718e5e66b42488, + 0xa31370f89d85108378244beeea13a2b2c379d16cde55c2fcd674f4296ddabe, + 0x4285440535fff0ba31e970a1948a09951ff740c91c6d6cf4635527877c55ff1, + 0x49eb1420843ac1a3178010c314906d28f6118e8b36620ce4469dffca27a047d, + 0x4e65200356931c3ea1e20e087b5bff96ba268239ed2e2f784def64f5760418d, + 0x103809d798aab5452c77f42bc4c8fcfcfa9e6efdfe24077e41928a52daf1dc8, + 0x4253b3498a013d4473d43686f9e509be7541daf00afae0d7216f7019bc75d8f, + 0x689297a643de6bd5955e314f94367af901eac67eeef51a52e40c0205cf8023, + 0x2ca9dcef95643af6ec5ee055d1a05720f2e3f5e6226de5b206c4a78482963b8, + 0x72fbddae565406f284bb4dd89623c29c821b6187dd7dfc292dbbddd4094077, + 0x30e5ea3c2280db52829548ae99a71faa030b4e4bb87679b427f76c594aaa05a, + 0x45ba1eda942e1085af97db6e189996903cfa09db90e52b4589e16df981f1601, + 0x8c36a69368bea30f8ecf7de3e461a03b0cdd004ae08a3d44281b093fc63f2, + 0x5c7194878dcb2d4ba69da97c1a878f96dd78d97612c882ba7179bafe92a6a90, + 0x20c37b922bb713f2b6772a9ae014715f418fe5da4d53fe9b00cc2fe851f233a, + 0x3a7e7c684904e82bf0be54290299b6d83f448bac5c6e9ea4d1cd1e844eccb70, + 0x1ebbb30dbcb3b4fd0da33cf84d456101bbe9147b1a65507901715b3490649c6, + 0x1409c71e0dcf4a620856775508ce1b4c7d55e4229ac5fd41a3f8ecee097eb39, + 0x18cdf340cc64b00bf134c9e55396f79eddfbda8e2090542380c5c4967ee790b, + 0x18add43c036948c8d7e767ae22056e1f5f1a9d1daad6b9a8f2e7da996f4a1c2, + 0x30e7224d1c98b75e019b60bbe320e358ef35b1adaf12aad044744e640c2a4d, + 0x25a8793c928ecacb2e84802830fa101fb3839455957921ed7bcb39549b1f80, + 0x65dd0f91032712c4a8b1b5c35cd6ebdb654efb5e56085a2eef0def4bde4d066, + 0x4a50e2b14315602b8c97c9d2304db828806c37b751203bb7dad534d7b45d21d, + 0x5afdcfcf55c58dbf5ad58b17f16514da8dac3e69501fb399c30333ab3050c3, + 0x20f5ecf9107f9d3e33f462948d955b70d5ec5573a679ae548998c41b5eec730, + 0x1f70d9f6c203312c6aabf4d191cd4cbc68f8c92bebf561cb8e20ce9fc07ef55, + 0x14e877449f7005ee874020d6759ce808345e20c3fae4a62e7f12c2c457f71ec, + 0x780b4537e060e0f1e88ca7337d5d43ef2d4bbb4b48e4899c55ea9a5e7120b5a, + 0x608a4544987ef3599043e9a8b4aa0598f8d71dee81e46104ca6ac186e2c8044, + 0x58cbd95dd12e8761a99011f0ae970fe73e03b7d7e43b614510ee7a6a2efe7d3, + 0x5c533c05cbf2af6d819bdf23272e567b7a49c2c2bd799201ed0e32ce9ff092b, + 0x342bb671b7d40601d4031045068abfbf2c578f7e4a380e180dbf2b0c8fef6, + 0x2da269eab1f7e247c0caf3bcac1bb0e5e7abacde34bc54a9de3e0a82a36cfff, + 0x117cc37e078928598470cfe43e1b6c66c6365d1cf601bc5daf1055a0f8210db, + 0x4640956c2daa074399825b0404260bee0898f9d24b1c807f5c43159e7a9b019, + 0x1da36b1fb01d0470d48c3eb4c92263eadb7b58c8829f2ee77e3287a6e39c902, + 0x78dac96e95e86f83b4a426bd0505d84b5ea967822d0fca9f3bd28331164d94b, + 0x1d50c82e363d8e7fa2641c9f2137b99832372d1879a2ee02b2c824a4cb620dd, + 0x2fd5a64db6093c9efda84ba327a43043e41310626073e58331c9f2f9f2db20f + ] + .span(), + }; -// vector_commitment_decommit(commitment, queries, witness); -// } -// === BLAKE2S END === + vector_commitment_decommit(commitment, queries, witness); +} -// === KECCAK BEGIN === +#[cfg(feature: 'keccak')] #[test] #[available_gas(9999999999)] fn test_vector_commitment_decommit() { @@ -211,6 +210,3 @@ fn test_vector_commitment_decommit() { vector_commitment_decommit(commitment, queries, witness); } -// === KECCAK END === - -