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

Function chunk_hash_c

bitvm/src/chunk/taps_ext_miller.rs:234–298  ·  view source on GitHub ↗
(
    hint_in_c: Vec<ark_ff::BigInt<4>>,
)

Source from the content-addressed store, hash-verified

232}
233
234pub(crate) fn chunk_hash_c(
235 hint_in_c: Vec<ark_ff::BigInt<4>>,
236) -> (ark_bn254::Fq6, bool, Script, Vec<Hint>) {
237 assert_eq!(hint_in_c.len(), 6);
238
239 let mock_f = ark_bn254::Fq6::ONE;
240 let are_valid_fps = hint_in_c
241 .iter()
242 .filter(|f| **f < ark_bn254::Fq::MODULUS)
243 .count()
244 == hint_in_c.len();
245
246 let f = if are_valid_fps {
247 let fvec = hint_in_c
248 .iter()
249 .map(|f| ark_bn254::Fq::from(*f))
250 .collect::<Vec<ark_bn254::Fq>>();
251 ark_bn254::Fq6::new(
252 ark_bn254::Fq2::new(fvec[0], fvec[1]),
253 ark_bn254::Fq2::new(fvec[2], fvec[3]),
254 ark_bn254::Fq2::new(fvec[4], fvec[5]),
255 )
256 } else {
257 mock_f
258 };
259
260 let ops_scr = script! {
261 // [] [fhash, fqs]
262 for _ in 0..6 {
263 {Fq::fromaltstack()}
264 }
265 // [fqs, fqs] [fhash]
266 {Fq6::copy(0)}
267 for _ in 0..6 {
268 { Fq::is_valid() }
269 OP_TOALTSTACK
270 }
271 {1}
272 for _ in 0..6 {
273 OP_FROMALTSTACK
274 OP_BOOLAND
275 }
276 // are_valid_fps -> 1 -> verify_final_hash
277 // not_valid_fps -> 0 -> skip verify_final_hash
278 // [fqs, 0/1] [fhash]
279 OP_IF
280 // [fs] [fhash]
281 {1} // verify_final_hash
282 // [fs, 1] [fhash]
283 OP_ELSE
284 // [fs] [fhash]
285 {Fq6::drop()}
286 {Fq6::push(mock_f)}
287 {0} // skip verify_final hash
288 // [mock_fs, 0] [fhash]
289 OP_ENDIF
290 // [fs, 0/1] [fhash]
291 };

Callers 2

wrap_hint_hash_cFunction · 0.85
test_tap_hash_cFunction · 0.85

Calls 1

lenMethod · 0.80

Tested by 1

test_tap_hash_cFunction · 0.68