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

Function test_ubigint_to_le_bits

bitvm/src/bigint/bits.rs:408–456  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

406
407 #[test]
408 fn test_ubigint_to_le_bits() {
409 let mut prng = ChaCha20Rng::seed_from_u64(0);
410
411 for _ in 0..10 {
412 let a: BigUint = prng.sample(RandomBits::new(U254::N_BITS as u64));
413
414 let mut bits = vec![];
415 let mut cur = a.clone();
416 for _ in 0..U254::N_BITS {
417 bits.push(if cur.bit(0) { 1 } else { 0 });
418 cur.shr_assign(1);
419 }
420
421 let script = script! {
422 { U254::push_u32_le(&a.to_u32_digits()) }
423 { U254::convert_to_le_bits() }
424 for i in 0..U254::N_BITS {
425 { bits[i as usize] }
426 OP_EQUALVERIFY
427 }
428 OP_TRUE
429 };
430
431 run(script);
432 }
433
434 for _ in 0..10 {
435 let a: BigUint = prng.sample(RandomBits::new(U64::N_BITS as u64));
436
437 let mut bits = vec![];
438 let mut cur = a.clone();
439 for _ in 0..U64::N_BITS {
440 bits.push(if cur.bit(0) { 1 } else { 0 });
441 cur.shr_assign(1);
442 }
443
444 let script = script! {
445 { U64::push_u32_le(&a.to_u32_digits()) }
446 { U64::convert_to_le_bits() }
447 for i in 0..U64::N_BITS {
448 { bits[i as usize] }
449 OP_EQUALVERIFY
450 }
451 OP_TRUE
452 };
453
454 run(script);
455 }
456 }
457
458 #[test]
459 fn test_ubigint_to_be_bits_toaltstack() {

Callers

nothing calls this directly

Calls 3

runFunction · 0.85
cloneMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected