| 621 | } |
| 622 | |
| 623 | pub fn hinted_check_tangent_line_keep_elements( |
| 624 | t: ark_bn254::G2Affine, |
| 625 | c3: ark_bn254::Fq2, |
| 626 | c4: ark_bn254::Fq2, |
| 627 | ) -> (Script, Vec<Hint>) { |
| 628 | let mut hints = Vec::new(); |
| 629 | |
| 630 | let (hinted_script3, hint3) = hinted_check_line_through_point(t.x, c3, c4); |
| 631 | let (hinted_script1, hint1) = Fq2::hinted_mul(2, t.y.double(), 0, c3); |
| 632 | let (hinted_script2, hint2) = Fq2::hinted_square(t.x); |
| 633 | |
| 634 | // [a, b, x, y] |
| 635 | let scr = script!( |
| 636 | // [a, b, x, y] |
| 637 | {Fq2::copy(2)} {Fq2::copy(2)} |
| 638 | // [a, b, x, y, x, y] |
| 639 | {Fq2::toaltstack()} {Fq2::toaltstack()} |
| 640 | // [a, b, x, y] |
| 641 | {hinted_script3} |
| 642 | // [a, b] |
| 643 | {Fq2::fromaltstack()} {Fq2::fromaltstack()} |
| 644 | // [a, b, x, y] |
| 645 | // alpha * (2 * T.y) = 3 * T.x^2 |
| 646 | {Fq2::copy(0)} |
| 647 | {Fq2::double(0)} |
| 648 | {// [a, b, x, y, 2y] |
| 649 | Fq2::copy(8)} |
| 650 | {// [a, b, x, y, 2y, a] |
| 651 | hinted_script1} |
| 652 | {// [T.x, T.y, alpha * (2 * T.y)] |
| 653 | Fq2::copy(4)} |
| 654 | {hinted_script2} |
| 655 | {Fq2::copy(0)} |
| 656 | {Fq2::double(0)} |
| 657 | {Fq2::add(2, 0)} |
| 658 | {// [T.x, T.y, alpha * (2 * T.y), 3 * T.x^2] |
| 659 | Fq2::neg(0)} |
| 660 | {Fq2::add(2, 0)} |
| 661 | {Fq2::push_zero()} |
| 662 | {Fq2::equalverify()} |
| 663 | // [T.x, T.y] |
| 664 | // [a, b, x, y] |
| 665 | ); |
| 666 | |
| 667 | hints.extend(hint3); |
| 668 | hints.extend(hint1); |
| 669 | hints.extend(hint2); |
| 670 | |
| 671 | (scr, hints) |
| 672 | } |
| 673 | |
| 674 | /// check line through one point, that is: |
| 675 | /// y - alpha * x - bias = 0 |