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

Method hinted_mul_by_constant

bitvm/src/bn254/fq.rs:133–155  ·  view source on GitHub ↗

TODO: Optimize by using the constant feature

(
        a: ark_bn254::Fq,
        constant: &ark_bn254::Fq,
    )

Source from the content-addressed store, hash-verified

131
132 // TODO: Optimize by using the constant feature
133 pub fn hinted_mul_by_constant(
134 a: ark_bn254::Fq,
135 constant: &ark_bn254::Fq,
136 ) -> (Script, Vec<Hint>) {
137 let mut hints = Vec::new();
138 let x = BigInt::from_str(&a.to_string()).unwrap();
139 let y = BigInt::from_str(&constant.to_string()).unwrap();
140 let modulus = &Fq::modulus_as_bigint();
141 let q = (x * y) / modulus;
142
143 let script = script! {
144 for _ in 0..Self::N_LIMBS {
145 OP_DEPTH OP_1SUB OP_ROLL // hints
146 }
147 // { Fq::push(ark_bn254::Fq::from_str(&q.to_string()).unwrap()) }
148 { Fq::roll(1) }
149 { Fq::push(*constant) }
150 { Fq::tmul() }
151 };
152 hints.push(Hint::BigIntegerTmulLC1(q));
153
154 (script, hints)
155 }
156
157 pub fn hinted_mul_keep_element(
158 mut a_depth: u32,

Callers

nothing calls this directly

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected