a
��tb�( � @ sP d dl Z d dlZd dlZd dlZd dlZd dlmZmZmZ d dl m
Z
ddlmZm
Z
mZmZmZmZmZ ej�ej�e�d�Ze�ee��Zed Zed Zed Zed
Zed Zed Z e�!e�"ed
��Z#e#dks�J �e�$� Z%e%dks�J �d
e# e k �rek �sn J �e d Z&e&d ee&d fZ'e d Z(e&ddgk�sJJ �e(ddgk�s\J �ee)e)f Z*G dd� de+�Z,e)e)d�dd�Z-e)d�dd�Z.e)ed�dd�Z/e)e)d�dd �Z0e)e)d!�d"d#�Z1d4e)e)ee) e)d$�d%d&�Z2d5e)e)ee) e*d$�d'd(�Z3e)eeed)�d*d+�Z4e)e)e)ee)ef e5d,�d-d.�Z6e)e)d/�d0d1�Z7e)ed/�d2d3�Z8dS )6� N)�Optional�Tuple�Union)�
generate_k� )�ECPoint�div_mod�ec_add� ec_double�ec_mult�is_quad_residue�sqrt_modzpedersen_params.json�FIELD_PRIME� FIELD_GEN�ALPHA�BETA�EC_ORDER�CONSTANT_POINTS� �� �� l h�!y�(5s�RD�5q>3��pp ,0j�q�l �& \�tl
�1NSTt�64_�x��l �O�/v�k#�f~V�G�ijg�7�2fa�
�l \�m0 �C2:�WF4�)�b�
}@r{��4V c s e Zd Z� fdd�Z� ZS )�InvalidPublicKeyErrorc s t � �d� d S )NzFGiven x coordinate does not represent any point on the elliptic curve.)�super�__init__)�self�� __class__� ��/Users/okudajunta/Library/Mobile Documents/com~apple~CloudDocs/solidity/dydx-v3-rust/./src/stark/starkex/starkex_resources/python_signature.pyr C s zInvalidPublicKeyError.__init__)�__name__�
__module__�__qualname__r �
__classcell__r r r r r B s r )�stark_key_x_coordinate�returnc C s: | }|| | t | t t }t|t�s0t� �t|t�S )z�
Given the x coordinate of a stark_key, returns a possible y coordinate such that together the
point (x,y) is on the curve.
Note that the real y coordinate is either y or -y.
If x is invalid stark_key it throws an error.
)r r r r r r
)r# �x� y_squaredr r r �get_y_coordinateG s
r'