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

Function test_limb_to_le_bits

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

Source from the content-addressed store, hash-verified

280
281 #[test]
282 fn test_limb_to_le_bits() {
283 println!(
284 "limb_to_le_bits(29): {:?} bytes",
285 script! { {limb_to_le_bits(29)} }.len()
286 );
287 let mut prng = ChaCha20Rng::seed_from_u64(0);
288
289 for _ in 0..100 {
290 let mut a: u32 = prng.gen();
291 a %= 1 << 29;
292
293 let mut bits = vec![];
294 let mut cur = a;
295 for _ in 0..29 {
296 bits.push(cur % 2);
297 cur /= 2;
298 }
299
300 let script = script! {
301 { a }
302 { limb_to_le_bits(29) }
303 for i in 0..29 {
304 { bits[i] }
305 OP_EQUALVERIFY
306 }
307 OP_TRUE
308 };
309
310 run(script);
311 }
312
313 for _ in 0..100 {
314 let mut a: u32 = prng.gen();
315 a %= 1 << 15;
316
317 let mut bits = vec![];
318 let mut cur = a;
319 for _ in 0..15 {
320 bits.push(cur % 2);
321 cur /= 2;
322 }
323
324 let script = script! {
325 { a }
326 { limb_to_le_bits(15) }
327 for i in 0..15 {
328 { bits[i] }
329 OP_EQUALVERIFY
330 }
331 OP_TRUE
332 };
333
334 run(script);
335 }
336
337 for a in 0..4 {
338 let script = script! {
339 { a }

Callers

nothing calls this directly

Calls 2

runFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected