dydx-v3-rust 0.1.7

Rust SDK for dYdX v3 API
Documentation
a

��tb+�@s�ddlmZddlZddlZddlmZeeefZeed�dd�Z	eee
d�dd	�Zeeed�d
d�Zeeeed�d
d�Z
eeeed�dd�Zeeed�dd�Zeeeed�dd�Zeeeeed�dd�ZdS)�)�TupleN��igcdex)�digits�returncCs |tj_dttjj�dd�S)zX
    Returns pi as a string of decimal digits without the decimal point ("314...").
    �3�N)�mpmath�mpZdps�str�pi)r�r
��/Users/okudajunta/Library/Mobile Documents/com~apple~CloudDocs/solidity/dydx-v3-rust/./src/stark/starkex/starkex_resources/math_utils.py�pi_as_stringsr)�n�prcCst�||�S)z9
    Returns True if n is a quadratic residue mod p.
    )�sympy�is_quad_residue�rrr
r
rr$srcCsttj||dd��S)zG
    Finds the minimum positive integer m such that (m*m) % p == n
    T)Z	all_roots)�minr�sqrt_modrr
r
rr+sr)r�mrrcCs(t||�\}}}|dksJ�|||S)zK
    Finds a nonnegative integer 0 <= x < p such that (m * x) % p == n
    �r)rrr�a�b�cr
r
r�div_mod2sr)�point1�point2rrcCs�|d|d|dksJ�t|d|d|d|d|�}|||d|d|}||d||d|}||fS)z�
    Gets two points on an elliptic curve mod p and returns their sum.
    Assumes the points are given in affine form (x, y) and have different x coordinates.
    rr�r)rrrr�x�yr
r
r�ec_add;s
$r")�pointrrcCs|\}}|||fS)z,
    Given a point (x,y) return (x, -y)
    r
)r#rr r!r
r
r�ec_negGsr$)r#�alpharrcCsx|d|dksJ�td|d|d|d|d|�}||d|d|}||d||d|}||fS)z�
    Doubles a point on an elliptic curve with the equation y^2 = x^3 + alpha*x + beta mod p.
    Assumes the point is given in affine form (x, y) and has y != 0.
    rr�rr)r#r%rrr r!r
r
r�	ec_doubleOs
(r')rr#r%rrcCsL|dkr|S|ddkr2t|dt|||�||�Stt|d|||�||�S)z�
    Multiplies by m a point on the elliptic curve with equation y^2 = x^3 + alpha*x + beta mod p.
    Assumes the point is given in affine form (x, y) and that 0 < m < order(point).
    rrr)�ec_multr'r")rr#r%rr
r
rr([s
r()�typingrr	rZsympy.core.numbersr�int�ECPointrr�boolrrrr"r$r'r(r
r
r
r�<module>s