(
segments: &[Segment],
wots_pubkeys: PublicKeys,
)
| 272 | } |
| 273 | |
| 274 | pub(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)] |
| 329 | mod tests { |
no test coverage detected