Skip to content

Commit d7f53c2

Browse files
authored
add validation of num of mocked segments (#374)
1 parent cc57122 commit d7f53c2

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

‎bitvm/src/chunk/api.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ use super::wrap_hasher::BLAKE3_HASH_LENGTH;
2121
pub const NUM_PUBS: usize = 1;
2222
pub const NUM_U256: usize = 14;
2323
pub const NUM_HASH: usize = 363;
24-
const VALIDATING_TAPS: usize = 1;
25-
const HASHING_TAPS: usize = NUM_HASH;
24+
pub const VALIDATING_TAPS: usize = 1;
25+
pub const HASHING_TAPS: usize = NUM_HASH;
2626
pub const NUM_TAPS: usize = HASHING_TAPS + VALIDATING_TAPS;
2727

2828
pub type PublicInputs = [ark_bn254::Fr; NUM_PUBS];

‎bitvm/src/chunk/api_compiletime_utils.rs‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::bn254::ell_coeffs::AffinePairing;
55
use crate::bn254::ell_coeffs::BnAffinePairing;
66
use crate::bn254::fp254impl::Fp254Impl;
77
use crate::bn254::fq::Fq;
8-
use crate::chunk::api::{NUM_PUBS, NUM_TAPS};
8+
use crate::chunk::api::{NUM_HASH, NUM_PUBS, NUM_TAPS, NUM_U256, VALIDATING_TAPS};
99
use crate::chunk::elements::ElementType;
1010
use crate::treepp;
1111
use ark_bn254::Bn254;
@@ -175,6 +175,10 @@ fn generate_segments_using_mock_proof(vk: Vkey, skip_evaluation: bool) -> Vec<Se
175175
pubs,
176176
&mut None,
177177
);
178+
assert_eq!(
179+
segments.len(),
180+
NUM_PUBS + NUM_U256 + NUM_HASH + VALIDATING_TAPS
181+
);
178182
segments
179183
}
180184

@@ -320,3 +324,17 @@ pub(crate) fn bitcom_scripts_from_segments(
320324
}
321325
bitcom_scripts
322326
}
327+
328+
#[cfg(test)]
329+
mod tests {
330+
use crate::chunk::api_compiletime_utils::generate_segments_using_mock_vk_and_mock_proof;
331+
332+
#[test]
333+
fn test_generate_segments_using_mock_proof() {
334+
let segments = generate_segments_using_mock_vk_and_mock_proof();
335+
assert_eq!(
336+
segments.len(),
337+
super::NUM_PUBS + super::NUM_U256 + super::NUM_HASH + super::VALIDATING_TAPS
338+
);
339+
}
340+
}

0 commit comments

Comments
 (0)