(t: ark_bn254::G1Affine)
| 411 | } |
| 412 | |
| 413 | pub fn hinted_check_double(t: ark_bn254::G1Affine) -> (Script, Vec<Hint>) { |
| 414 | let mut hints = vec![]; |
| 415 | |
| 416 | let (alpha, bias) = if t.is_zero() { |
| 417 | (ark_bn254::Fq::ZERO, ark_bn254::Fq::ZERO) |
| 418 | } else { |
| 419 | let alpha = (t.x.square() + t.x.square() + t.x.square()) / (t.y + t.y); |
| 420 | let bias = t.y - alpha * t.x; |
| 421 | (alpha, bias) |
| 422 | }; |
| 423 | |
| 424 | let (hinted_script1, hint1) = Self::hinted_check_tangent_line(t, alpha); |
| 425 | let (hinted_script2, hint2) = Self::hinted_double(t, alpha); |
| 426 | |
| 427 | if !t.is_zero() { |
| 428 | hints.push(Hint::Fq(alpha)); |
| 429 | hints.push(Hint::Fq(-bias)); |
| 430 | hints.extend(hint1); |
| 431 | hints.extend(hint2); |
| 432 | } |
| 433 | let script = script! { |
| 434 | { G1Affine::is_zero_keep_element() } // ... (dependent on input), x, y, 0/1 |
| 435 | OP_NOTIF // c3 (alpha), c4 (-bias), ... (other hints), x, y |
| 436 | for _ in 0..Fq::N_LIMBS { |
| 437 | OP_DEPTH OP_1SUB OP_ROLL |
| 438 | } // -bias, ..., x, y, alpha |
| 439 | { Fq::check_validity_and_keep_element() } |
| 440 | for _ in 0..Fq::N_LIMBS { |
| 441 | OP_DEPTH OP_1SUB OP_ROLL |
| 442 | } // x, y, alpha, -bias |
| 443 | { Fq::check_validity_and_keep_element() } |
| 444 | { Fq::copy(1) } // x, y, alpha, -bias, alpha |
| 445 | { Fq::copy(1) } // x, y, alpha, -bias, alpha, -bias |
| 446 | { Fq::copy(5) } // x, y, alpha, -bias, alpha, -bias, x |
| 447 | { Fq::roll(5) } // x, alpha, -bias, alpha, -bias, x, y |
| 448 | { hinted_script1 } // x, alpha, -bias, is_tangent_line_correct |
| 449 | OP_VERIFY // x, alpha, -bias |
| 450 | { Fq::roll(2) } // alpha, -bias, x |
| 451 | { hinted_script2 } // x', y' |
| 452 | OP_ENDIF |
| 453 | }; |
| 454 | (script, hints) |
| 455 | } |
| 456 | |
| 457 | pub fn identity() -> Script { |
| 458 | script! { |
nothing calls this directly
no test coverage detected