parameters: (p1: JacobianPoint, ec=default_ec, FE=Fq)
return_statement: return JacobianPoint(X_p, Y_p, Z_p, False, ec)
docstring: Jacobian elliptic curve point doubling, see
      http://www.hyperelliptic.org/EFD/oldefd/jacobian.html
docstring_summary: Jacobian elliptic curve point doubling, see
      http://www.hyperelliptic.org/EFD/oldefd/jacobian.html
docstring_tokens: Jacobian elliptic curve point doubling see http : // www . hyperelliptic . org / EFD / oldefd / jacobian . html
function: def double_point_jacobian(p1: JacobianPoint, ec=default_ec, FE=Fq) -> JacobianPoint:
      """
      Jacobian elliptic curve point doubling, see
      http://www.hyperelliptic.org/EFD/oldefd/jacobian.html
      """
      X, Y, Z = p1.x, p1.y, p1.z
      if Y == FE.zero(ec.q) or p1.infinity:
          return JacobianPoint(FE.one(ec.q), FE.one(ec.q), FE.zero(ec.q), True, ec)
  
      # S = 4*X*Y^2
      S = Fq(ec.q, 4) * X * Y * Y
  
      Z_sq = Z * Z
      Z_4th = Z_sq * Z_sq
      Y_sq = Y * Y
      Y_4th = Y_sq * Y_sq
  
      # M = 3*X^2 + a*Z^4
      M = Fq(ec.q, 3) * X * X
      M += ec.a * Z_4th
  
      # X' = M^2 - 2*S
      X_p = M * M - Fq(ec.q, 2) * S
      # Y' = M*(S - X') - 8*Y^4
      Y_p = M * (S - X_p) - Fq(ec.q, 8) * Y_4th
      # Z' = 2*Y*Z
      Z_p = Fq(ec.q, 2) * Y * Z
      return JacobianPoint(X_p, Y_p, Z_p, False, ec)
function_tokens: def double_point_jacobian ( p1 : JacobianPoint , ec = default_ec , FE = Fq ) -> JacobianPoint : X , Y , Z = p1 . x , p1 . y , p1 . z if Y == FE . zero ( ec . q ) or p1 . infinity : return JacobianPoint ( FE . one ( ec . q ) , FE . one ( ec . q ) , FE . zero ( ec . q ) , True , ec ) # S = 4*X*Y^2 S = Fq ( ec . q , 4 ) * X * Y * Y Z_sq = Z * Z Z_4th = Z_sq * Z_sq Y_sq = Y * Y Y_4th = Y_sq * Y_sq # M = 3*X^2 + a*Z^4 M = Fq ( ec . q , 3 ) * X * X M += ec . a * Z_4th # X' = M^2 - 2*S X_p = M * M - Fq ( ec . q , 2 ) * S # Y' = M*(S - X') - 8*Y^4 Y_p = M * ( S - X_p ) - Fq ( ec . q , 8 ) * Y_4th # Z' = 2*Y*Z Z_p = Fq ( ec . q , 2 ) * Y * Z return JacobianPoint ( X_p , Y_p , Z_p , False , ec )