MCPcopy Create free account
hub / github.com/BitVM/BitVM / bitcom_scripts_from_segments

Function bitcom_scripts_from_segments

bitvm/src/chunk/api_compiletime_utils.rs:274–326  ·  view source on GitHub ↗
(
    segments: &[Segment],
    wots_pubkeys: PublicKeys,
)

Source from the content-addressed store, hash-verified

272}
273
274pub(crate) fn bitcom_scripts_from_segments(
275 segments: &[Segment],
276 wots_pubkeys: PublicKeys,
277) -> Vec<treepp::Script> {
278 let mut bitcom_scripts: Vec<treepp::Script> = vec![];
279
280 let mut pubkeys_arr = vec![];
281 pubkeys_arr.extend_from_slice(
282 &wots_pubkeys
283 .0
284 .iter()
285 .map(|f| WOTSPubKey::P256(*f))
286 .collect::<Vec<WOTSPubKey>>(),
287 );
288 pubkeys_arr.extend_from_slice(
289 &wots_pubkeys
290 .1
291 .iter()
292 .map(|f| WOTSPubKey::P256(*f))
293 .collect::<Vec<WOTSPubKey>>(),
294 );
295 pubkeys_arr.extend_from_slice(
296 &wots_pubkeys
297 .2
298 .iter()
299 .map(|f| WOTSPubKey::PHash(*f))
300 .collect::<Vec<WOTSPubKey>>(),
301 );
302
303 for seg in segments {
304 if seg.scr_type == ScriptType::NonDeterministic {
305 continue;
306 }
307
308 let mut index_of_bitcommitted_msg = vec![];
309 if !seg.scr_type.is_final_script() {
310 index_of_bitcommitted_msg.push(seg.id);
311 };
312 let sec_in: Vec<u32> = seg.parameter_ids.iter().map(|(f, _)| *f).collect();
313 index_of_bitcommitted_msg.extend_from_slice(&sec_in);
314
315 let mut locking_scr = script! {};
316 for index in index_of_bitcommitted_msg {
317 locking_scr = script! {
318 {locking_scr}
319 {checksig_verify_to_limbs(&pubkeys_arr[index as usize])}
320 {Fq::toaltstack()}
321 };
322 }
323 bitcom_scripts.push(locking_scr);
324 }
325 bitcom_scripts
326}
327
328#[cfg(test)]
329mod tests {

Calls 2

is_final_scriptMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected