parameters: (point1, point2)
return_statement: return result
docstring: Returns the result of point1 + point2 according to the group law.
docstring_summary: Returns the result of point1 + point2 according to the group law.
docstring_tokens: Returns the result of point1 + point2 according to the group law .
function: def point_add(point1, point2):
      """Returns the result of point1 + point2 according to the group law."""
      assert is_on_curve(point1)
      assert is_on_curve(point2)
  
      if point1 is None:
          # 0 + point2 = point2
          return point2
      if point2 is None:
          # point1 + 0 = point1
          return point1
  
      x1, y1 = point1
      x2, y2 = point2
  
      if x1 == x2 and y1 != y2:
          # point1 + (-point1) = 0
          return None
  
      if x1 == x2:
          # This is the case point1 == point2.
          m = (3 * x1 * x1 + curve.a) * inverse_mod(2 * y1, curve.p)
      else:
          # This is the case point1 != point2.
          m = (y1 - y2) * inverse_mod(x1 - x2, curve.p)
  
      x3 = m * m - x1 - x2
      y3 = y1 + m * (x3 - x1)
      result = (x3 % curve.p, -y3 % curve.p)
  
      assert is_on_curve(result)
  
      return result
function_tokens: def point_add ( point1 , point2 ) : assert is_on_curve ( point1 ) assert is_on_curve ( point2 ) if point1 is None : # 0 + point2 = point2 return point2 if point2 is None : # point1 + 0 = point1 return point1 x1 , y1 = point1 x2 , y2 = point2 if x1 == x2 and y1 != y2 : # point1 + (-point1) = 0 return None if x1 == x2 : # This is the case point1 == point2. m = ( 3 * x1 * x1 + curve . a ) * inverse_mod ( 2 * y1 , curve . p ) else : # This is the case point1 != point2. m = ( y1 - y2 ) * inverse_mod ( x1 - x2 , curve . p ) x3 = m * m - x1 - x2 y3 = y1 + m * ( x3 - x1 ) result = ( x3 % curve . p , - y3 % curve . p ) assert is_on_curve ( result ) return result