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

Function hinted_check_line_through_point

bitvm/src/bn254/g2.rs:687–722  ·  view source on GitHub ↗

check line through one point, that is: y - alpha * x - bias = 0 input on stack: x (2 elements) y (2 elements) input of parameters: c3: alpha c4: -bias output: true or false (consumed on stack)

(
    x: ark_bn254::Fq2,
    c3: ark_bn254::Fq2,
    _c4: ark_bn254::Fq2,
)

Source from the content-addressed store, hash-verified

685/// output:
686/// true or false (consumed on stack)
687pub fn hinted_check_line_through_point(
688 x: ark_bn254::Fq2,
689 c3: ark_bn254::Fq2,
690 _c4: ark_bn254::Fq2,
691) -> (Script, Vec<Hint>) {
692 let mut hints: Vec<Hint> = Vec::new();
693
694 // let (hinted_script1, hint1) = Fq2::hinted_mul_by_constant(x, &c3);
695 let (hinted_script1, hint1) = Fq2::hinted_mul(2, x, 0, c3);
696
697 let script = script! {
698
699 // [c3, c4, x, y]
700 {Fq2::roll(2)}
701 // [c3, c4, y, x]
702 {Fq2::copy(6)}
703 // [c3, c4, y, x,c3]
704 {hinted_script1}
705 // [c3, c4, y, alpha * x]
706 {Fq2::neg(0)}
707 // [c3, c4, y, -alpha * x]
708 {Fq2::add(2, 0)}
709 // [c3, c4, y - alpha * x]
710 {Fq2::copy(2)} // Fq2::push(c4),
711 // [c3, c4, y - alpha * x, -bias]
712 {Fq2::add(2, 0)}
713 // [c3, c4, y - alpha * x - bias]
714 {Fq2::push_zero()}
715 // [c3, c4, y - alpha * x - bias, 0]
716 {Fq2::equalverify()}
717 // [c3, c4]
718 };
719 hints.extend(hint1);
720
721 (script, hints)
722}
723
724/// check whether a tuple coefficient (alpha, -bias) of a chord line is satisfied with expected points T and Q (both are affine cooordinates)
725/// two aspects:

Calls

no outgoing calls