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

Method hinted_square

bitvm/src/bn254/fq.rs:420–437  ·  view source on GitHub ↗

TODO: Optimize using the sqaure feature

(a: ark_bn254::Fq)

Source from the content-addressed store, hash-verified

418
419 // TODO: Optimize using the sqaure feature
420 pub fn hinted_square(a: ark_bn254::Fq) -> (Script, Vec<Hint>) {
421 let mut hints = Vec::new();
422 let x = &BigInt::from_str(&a.to_string()).unwrap();
423 let modulus = &Fq::modulus_as_bigint();
424 let q = (x * x) / modulus;
425 let script = script! {
426 for _ in 0..Self::N_LIMBS {
427 OP_DEPTH OP_1SUB OP_ROLL // hints
428 }
429 // { Fq::push(ark_bn254::Fq::from_str(&q.to_string()).unwrap()) }
430 { Fq::roll(1) }
431 { Fq::copy(0) }
432 { Fq::tmul() }
433 };
434 hints.push(Hint::BigIntegerTmulLC1(q));
435
436 (script, hints)
437 }
438
439 pub fn hinted_inv(a: ark_bn254::Fq) -> (Script, Vec<Hint>) {
440 let mut hints = Vec::new();

Callers

nothing calls this directly

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected