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

Function test_emulate_fq_to_nibbles

bitvm/src/chunk/helpers.rs:177–200  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

175 #[test]
176 #[allow(clippy::needless_range_loop)]
177 fn test_emulate_fq_to_nibbles() {
178 let mut prng = ChaCha20Rng::seed_from_u64(1777);
179 let p = ark_bn254::Fq::rand(&mut prng);
180 pub(crate) fn emulate_fq_to_nibbles_scripted(msg: ark_bn254::Fq) -> [u8; 64] {
181 let scr = script! {
182 {Fq::push(msg)}
183 {unpack_limbs_to_nibbles()}
184 };
185 let exec_result = execute_script(scr);
186 let mut arr = [0u8; 64];
187 for i in 0..exec_result.final_stack.len() {
188 let v = exec_result.final_stack.get(i);
189 if v.is_empty() {
190 arr[i] = 0;
191 } else {
192 arr[i] = v[0];
193 }
194 }
195 arr
196 }
197 let pb1 = extern_bigint_to_nibbles(p.into_bigint());
198 let pb2 = emulate_fq_to_nibbles_scripted(p);
199 assert_eq!(pb1, pb2);
200 }
201
202 #[test]
203 #[allow(clippy::needless_range_loop)]

Callers

nothing calls this directly

Calls 2

extern_bigint_to_nibblesFunction · 0.85

Tested by

no test coverage detected