Repository: influenceth/cairo-math-64x61 (language: python)

Issue:
Allow for non starknet
If you remove the %lang starknet from the pure cairo files, it can be reusable in pure cairo.


Discussion / hints:

Fix patch:
diff --git a/.gitignore b/.gitignore
index 24d5fea..f5270bc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,7 @@
 node_modules
 starknet-artifacts
 cache
+dist
+*/*.egg-info
+.DS_Store
+*/__pycache__
\ No newline at end of file
diff --git a/README.md b/README.md
index 5f2061e..551f865 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@
 A fixed point 64.61 math library for Cairo & Starknet
 
 ## Usage ##
-For use with `starknet-hardhat-plugin`, install via npm with `npm install --save-dev @influenceth/cairo-math-64x61` and add `./node_modules/@influenceth/cairo-math-64x61` to `cairoPaths` in your hardhat config (see https://github.com/Shard-Labs/starknet-hardhat-plugin#paths). Then you can import with, for example: `from contracts.Math64x61 import Math64x61_mul`
+Install with `pip install cairo_math_64x61` and import and use with `from cairo_math_64x61.math64x61 import Math64x61`. Previous installation as an npm module has been deprecated, the last available npm module is `v1.2.0`.
 
 ## Signed 64.61 Fixed Point Numbers ##
 A signed 64.61-bit fixed point number is a fraction in which the numerator is a signed 125-bit integer and the denominator is 2^61. Since the denominator stays the same there is no need to store it (as in a floating point value).
@@ -27,4 +27,4 @@ Can represent values in the range of -2^64 to 2^64 with precision to 4.34e-19.
 `Vec64x61` includes implementation of vector arithmetic (`add`, `sub`, `div`), dot product (`dot`), cross product (`cross`) and `norm`.
 
 ## Extensibility ##
-This library strives to adhere to the OpenZeppelin extensibility pattern: https://github.com/OpenZeppelin/cairo-contracts/blob/main/docs/Extensibility.md
+This library strives to adhere to the OpenZeppelin extensibility pattern: https://docs.openzeppelin.com/contracts-cairo/0.2.1/extensibility#libraries
diff --git a/contracts/Hyp64x61.cairo b/contracts/Hyp64x61.cairo
deleted file mode 100644
index 8cb8336..0000000
--- a/contracts/Hyp64x61.cairo
+++ /dev/null
@@ -1,71 +0,0 @@
-%lang starknet
-
-from Math64x61 import (
-    Math64x61_ONE,
-    Math64x61_mul,
-    Math64x61_div,
-    Math64x61_sqrt,
-    Math64x61_exp,
-    Math64x61_ln,
-    Math64x61_assert64x61
-)
-
-# Calculates hyperbolic sine of x (fixed point)
-func Hyp64x61_sinh {range_check_ptr} (x: felt) -> (res: felt):
-    alloc_locals
-
-    let (ex) = Math64x61_exp(x)
-    let (ex_i) = Math64x61_div(Math64x61_ONE, ex)
-    let (res) = Math64x61_div(ex - ex_i, 2 * Math64x61_ONE)
-    Math64x61_assert64x61(res)
-    return (res)
-end
-
-# Calculates hyperbolic cosine of x (fixed point)
-func Hyp64x61_cosh {range_check_ptr} (x: felt) -> (res: felt):
-    alloc_locals
-
-    let (ex) = Math64x61_exp(x)
-    let (ex_i) = Math64x61_div(Math64x61_ONE, ex)
-    let (res) = Math64x61_div(ex + ex_i, 2 * Math64x61_ONE)
-    Math64x61_assert64x61(res)
-    return (res)
-end
-
-# Calculates hyperbolic tangent of x (fixed point)
-func Hyp64x61_tanh {range_check_ptr} (x: felt) -> (res: felt):
-    alloc_locals
-
-    let (ex) = Math64x61_exp(x)
-    let (ex_i) = Math64x61_div(Math64x61_ONE, ex)
-    let (res) = Math64x61_div(ex - ex_i, ex + ex_i)
-    Math64x61_assert64x61(res)
-    return (res)
-end
-
-# Calculates inverse hyperbolic sine of x (fixed point)
-func Hyp64x61_asinh {range_check_ptr} (x: felt) -> (res: felt):
-    let (x2) = Math64x61_mul(x, x)
-    let (root) = Math64x61_sqrt(x2 + Math64x61_ONE)
-    let (res) = Math64x61_ln(x + root)
-    Math64x61_assert64x61(res)
-    return (res)
-end
-
-# Calculates inverse hyperbolic cosine of x (fixed point)
-func Hyp64x61_acosh {range_check_ptr} (x: felt) -> (res: felt):
-    let (x2) = Math64x61_mul(x, x)
-    let (root) = Math64x61_sqrt(x2 - Math64x61_ONE)
-    let (res) = Math64x61_ln(x + root)
-    Math64x61_assert64x61(res)
-    return (res)
-end
-
-# Calculates inverse hyperbolic tangent of x (fixed point)
-func Hyp64x61_atanh {range_check_ptr} (x: felt) -> (res: felt):
-    let (_ln_arg) = Math64x61_div(Math64x61_ONE + x, Math64x61_ONE - x)
-    let (_ln) = Math64x61_ln(_ln_arg)
-    let (res) = Math64x61_div(_ln, 2 * Math64x61_ONE)
-    Math64x61_assert64x61(res)
-    return (res)
-end
diff --git a/contracts/Math64x61.cairo b/contracts/Math64x61.cairo
deleted file mode 100644
index 7e0e026..0000000
--- a/contracts/Math64x61.cairo
+++ /dev/null
@@ -1,323 +0,0 @@
-%lang starknet
-
-from starkware.cairo.common.uint256 import Uint256
-from starkware.cairo.common.math_cmp import is_le, is_not_zero
-from starkware.cairo.common.pow import pow
-from starkware.cairo.common.math import (
-    assert_le,
-    assert_lt,
-    sqrt,
-    sign,
-    abs_value,
-    signed_div_rem,
-    unsigned_div_rem,
-    assert_not_zero
-)
-
-const Math64x61_INT_PART = 2 ** 64
-const Math64x61_FRACT_PART = 2 ** 61
-const Math64x61_BOUND = 2 ** 125
-const Math64x61_ONE = 1 * Math64x61_FRACT_PART
-const Math64x61_E = 6267931151224907085
-
-func Math64x61_assert64x61 {range_check_ptr} (x: felt):
-    assert_le(x, Math64x61_BOUND)
-    assert_le(-Math64x61_BOUND, x)
-    return ()
-end
-
-# Converts a fixed point value to a felt, truncating the fractional component
-func Math64x61_toFelt {range_check_ptr} (x: felt) -> (res: felt):
-    let (res, _) = signed_div_rem(x, Math64x61_FRACT_PART, Math64x61_BOUND)
-    return (res)
-end
-
-# Converts a felt to a fixed point value ensuring it will not overflow
-func Math64x61_fromFelt {range_check_ptr} (x: felt) -> (res: felt):
-    assert_le(x, Math64x61_INT_PART)
-    assert_le(-Math64x61_INT_PART, x)
-    return (x * Math64x61_FRACT_PART)
-end
-
-# Converts a fixed point 64.61 value to a uint256 value
-func Math64x61_toUint256 (x: felt) -> (res: Uint256):
-    let res = Uint256(low = x, high = 0)
-    return (res)
-end
-
-# Converts a uint256 value into a fixed point 64.61 value ensuring it will not overflow
-func Math64x61_fromUint256 {range_check_ptr} (x: Uint256) -> (res: felt):
-    assert x.high = 0
-    let (res) = Math64x61_fromFelt(x.low)
-    return (res)
-end
-
-# Calculates the floor of a 64.61 value
-func Math64x61_floor {range_check_ptr} (x: felt) -> (res: felt):
-    let (int_val, mod_val) = signed_div_rem(x, Math64x61_ONE, Math64x61_BOUND)
-    let res = x - mod_val
-    Math64x61_assert64x61(res)
-    return (res)
-end
-
-# Calculates the ceiling of a 64.61 value
-func Math64x61_ceil {range_check_ptr} (x: felt) -> (res: felt):
-    let (int_val, mod_val) = signed_div_rem(x, Math64x61_ONE, Math64x61_BOUND)
-    let res = (int_val + 1) * Math64x61_ONE
-    Math64x61_assert64x61(res)
-    return (res)
-end
-
-# Returns the minimum of two values
-func Math64x61_min {range_check_ptr} (x: felt, y: felt) -> (res: felt):
-    let (x_le) = is_le(x, y)
-
-    if x_le == 1:
-        return (x)
-    else:
-        return (y)
-    end
-end
-
-# Returns the maximum of two values
-func Math64x61_max {range_check_ptr} (x: felt, y: felt) -> (res: felt):
-    let (x_le) = is_le(x, y)
-
-    if x_le == 1:
-        return (y)
-    else:
-        return (x)
-    end
-end
-
-# Convenience addition method to assert no overflow before returning
-func Math64x61_add {range_check_ptr} (x: felt, y: felt) -> (res: felt):
-    let res = x + y
-    Math64x61_assert64x61(res)
-    return (res)
-end
-
-# Convenience subtraction method to assert no overflow before returning
-func Math64x61_sub {range_check_ptr} (x: felt, y: felt) -> (res: felt):
-    let res = x - y
-    Math64x61_assert64x61(res)
-    return (res)
-end
-
-# Multiples two fixed point values and checks for overflow before returning
-func Math64x61_mul {range_check_ptr} (x: felt, y: felt) -> (res: felt):
-    tempvar product = x * y
-    let (res, _) = signed_div_rem(product, Math64x61_FRACT_PART, Math64x61_BOUND)
-    Math64x61_assert64x61(res)
-    return (res)
-end
-
-# Divides two fixed point values and checks for overflow before returning
-# Both values may be signed (i.e. also allows for division by negative b)
-func Math64x61_div {range_check_ptr} (x: felt, y: felt) -> (res: felt):
-    alloc_locals
-    let (div) = abs_value(y)
-    let (div_sign) = sign(y)
-    tempvar product = x * Math64x61_FRACT_PART
-    let (res_u, _) = signed_div_rem(product, div, Math64x61_BOUND)
-    Math64x61_assert64x61(res_u)
-    return (res = res_u * div_sign)
-end
-
-# Calclates the value of x^y and checks for overflow before returning
-# x is a 64x61 fixed point value
-# y is a standard felt (int)
-func Math64x61__pow_int {range_check_ptr} (x: felt, y: felt) -> (res: felt):
-    alloc_locals
-    let (exp_sign) = sign(y)
-    let (exp_val) = abs_value(y)
-
-    if exp_sign == 0:
-        return (Math64x61_ONE)
-    end
-
-    if exp_sign == -1:
-        let (num) = Math64x61__pow_int(x, exp_val)
-        return Math64x61_div(Math64x61_ONE, num)
-    end
-
-    let (half_exp, rem) = unsigned_div_rem(exp_val, 2)
-    let (half_pow) = Math64x61__pow_int(x, half_exp)
-    let (res_p) = Math64x61_mul(half_pow, half_pow)
-
-    if rem == 0:
-        Math64x61_assert64x61(res_p)
-        return (res_p)
-    else:
-        let (res) = Math64x61_mul(res_p, x)
-        Math64x61_assert64x61(res)
-        return (res)
-    end
-end
-
-# Calclates the value of x^y and checks for overflow before returning
-# x is a 64x61 fixed point value
-# y is a 64x61 fixed point value
-func Math64x61_pow {range_check_ptr} (x: felt, y: felt) -> (res: felt):
-    alloc_locals
-    let (y_int, y_frac) = signed_div_rem(y, Math64x61_ONE, Math64x61_BOUND)
-
-    # use the more performant integer pow when y is an int
-    if y_frac == 0:
-        return Math64x61__pow_int(x, y_int)
-    end
-
-    # x^y = exp(y*ln(x)) for x > 0 (will error for x < 0
-    let (ln_x) = Math64x61_ln(x)
-    let (y_ln_x) = Math64x61_mul(y,ln_x)
-    let (res) = Math64x61_exp(y_ln_x)
-    return (res)
-    # Math64x61_assert64x61(res)
-    # return (res)
-end
-
-# Calculates the square root of a fixed point value
-# x must be positive
-func Math64x61_sqrt {range_check_ptr} (x: felt) -> (res: felt):
-    alloc_locals
-    let (root) = sqrt(x)
-    let (scale_root) = sqrt(Math64x61_FRACT_PART)
-    let (res, _) = signed_div_rem(root * Math64x61_FRACT_PART, scale_root, Math64x61_BOUND)
-    Math64x61_assert64x61(res)
-    return (res)
-end
-
-# Calculates the most significant bit where x is a fixed point value
-# TODO: use binary search to improve performance
-func Math64x61__msb {range_check_ptr} (x: felt) -> (res: felt):
-    alloc_locals
-
-    let (cmp) = is_le(x, Math64x61_FRACT_PART)
-
-    if cmp == 1:
-        return (0)
-    end
-
-    let (div, _) = unsigned_div_rem(x, 2)
-    let (rest) = Math64x61__msb(div)
-    local res = 1 + rest
-    Math64x61_assert64x61(res)
-    return (res)
-end
-
-# Calculates the binary exponent of x: 2^x
-func Math64x61_exp2 {range_check_ptr} (x: felt) -> (res: felt):
-    alloc_locals
-
-    let (exp_sign) = sign(x)
-
-    if exp_sign == 0:
-        return (Math64x61_ONE)
-    end
-
-    let (exp_value) = abs_value(x)
-    let (int_part, frac_part) = unsigned_div_rem(exp_value, Math64x61_FRACT_PART)
-    let (int_res) = Math64x61__pow_int(2 * Math64x61_ONE, int_part)
-
-    # 1.069e-7 maximum error
-    const a1 = 2305842762765193127
-    const a2 = 1598306039479152907
-    const a3 = 553724477747739017
-    const a4 = 128818789015678071
-    const a5 = 20620759886412153
-    const a6 = 4372943086487302
-
-    let (r6) = Math64x61_mul(a6, frac_part)
-    let (r5) = Math64x61_mul(r6 + a5, frac_part)
-    let (r4) = Math64x61_mul(r5 + a4, frac_part)
-    let (r3) = Math64x61_mul(r4 + a3, frac_part)
-    let (r2) = Math64x61_mul(r3 + a2, frac_part)
-    tempvar frac_res = r2 + a1
-
-    let (res_u) = Math64x61_mul(int_res, frac_res)
-    
-    if exp_sign == -1:
-        let (res_i) = Math64x61_div(Math64x61_ONE, res_u)
-        Math64x61_assert64x61(res_i)
-        return (res_i)
-    else:
-        Math64x61_assert64x61(res_u)
-        return (res_u)
-    end
-end
-
-# Calculates the natural exponent of x: e^x
-func Math64x61_exp {range_check_ptr} (x: felt) -> (res: felt):
-    const mod = 3326628274461080623
-    let (bin_exp) = Math64x61_mul(x, mod)
-    let (res) = Math64x61_exp2(bin_exp)
-    return (res)
-end
-
-# Calculates the binary logarithm of x: log2(x)
-# x must be greather than zero
-func Math64x61_log2 {range_check_ptr} (x: felt) -> (res: felt):
-    alloc_locals
-
-    if x == Math64x61_ONE:
-        return (0)
-    end
-
-    let (is_frac) = is_le(x, Math64x61_FRACT_PART - 1)
-
-    # Compute negative inverse binary log if 0 < x < 1
-    if is_frac == 1:
-        let (div) = Math64x61_div(Math64x61_ONE, x)
-        let (res_i) = Math64x61_log2(div)
-        return (-res_i)
-    end
-
-    let (x_over_two, _) = unsigned_div_rem(x, 2)
-    let (b) = Math64x61__msb(x_over_two)
-    let (divisor) = pow(2, b)
-    let (norm, _) = unsigned_div_rem(x, divisor)
-
-    # 4.233e-8 maximum error
-    const a1 = -7898418853509069178
-    const a2 = 18803698872658890801
-    const a3 = -23074885139408336243
-    const a4 = 21412023763986120774
-    const a5 = -13866034373723777071
-    const a6 = 6084599848616517800
-    const a7 = -1725595270316167421
-    const a8 = 285568853383421422
-    const a9 = -20957604075893688
-
-    let (r9) = Math64x61_mul(a9, norm)
-    let (r8) = Math64x61_mul(r9 + a8, norm)
-    let (r7) = Math64x61_mul(r8 + a7, norm)
-    let (r6) = Math64x61_mul(r7 + a6, norm)
-    let (r5) = Math64x61_mul(r6 + a5, norm)
-    let (r4) = Math64x61_mul(r5 + a4, norm)
-    let (r3) = Math64x61_mul(r4 + a3, norm)
-    let (r2) = Math64x61_mul(r3 + a2, norm)
-    local norm_res = r2 + a1
-
-    let (int_part) = Math64x61_fromFelt(b)
-    local res = int_part + norm_res
-    Math64x61_assert64x61(res)
-    return (res)
-end
-
-# Calculates the natural logarithm of x: ln(x)
-# x must be greater than zero
-func Math64x61_ln {range_check_ptr} (x: felt) -> (res: felt):
-    const ln_2 = 1598288580650331957
-    let (log2_x) = Math64x61_log2(x)
-    let (product) = Math64x61_mul(log2_x, ln_2)
-    return (product)
-end
-
-# Calculates the base 10 log of x: log10(x)
-# x must be greater than zero
-func Math64x61_log10 {range_check_ptr} (x: felt) -> (res: felt):
-    const log10_2 = 694127911065419642
-    let (log10_x) = Math64x61_log2(x)
-    let (product) = Math64x61_mul(log10_x, log10_2)
-    return (product)
-end
diff --git a/contracts/Trig64x61.cairo b/contracts/Trig64x61.cairo
deleted file mode 100644
index 66304f7..0000000
--- a/contracts/Trig64x61.cairo
+++ /dev/null
@@ -1,159 +0,0 @@
-%lang starknet
-
-from starkware.cairo.common.math_cmp import is_le
-from starkware.cairo.common.math import sign, abs_value, unsigned_div_rem, assert_not_zero
-from Math64x61 import (
-    Math64x61_FRACT_PART,
-    Math64x61_ONE,
-    Math64x61_mul,
-    Math64x61_div,
-    Math64x61_sqrt,
-    Math64x61_assert64x61
-)
-
-const Trig64x61_PI = 7244019458077122842
-const Trig64x61_HALF_PI = 3622009729038561421
-
-# Helper function to calculate Taylor series for sin
-func Trig64x61__sin_loop {range_check_ptr} (x: felt, i: felt, acc: felt) -> (res: felt):
-    alloc_locals
-
-    if i == -1:
-        return (acc)
-    end
-
-    let (num) = Math64x61_mul(x, x)
-    tempvar div = (2 * i + 2) * (2 * i + 3) * Math64x61_FRACT_PART
-    let (t) = Math64x61_div(num, div)
-    let (t_acc) = Math64x61_mul(t, acc)
-    let (next) = Trig64x61__sin_loop(x, i - 1, Math64x61_ONE - t_acc)
-    return (next)
-end
-
-# Calculates sin(x) with x in radians (fixed point)
-func Trig64x61_sin {range_check_ptr} (x: felt) -> (res: felt):
-    alloc_locals
-
-    let (_sign1) = sign(x) # extract sign
-    let (abs1) = abs_value(x)
-    let (_, x1) = unsigned_div_rem(abs1, 2 * Trig64x61_PI)
-    let (rem, x2) = unsigned_div_rem(x1, Trig64x61_PI)
-    local _sign2 = 1 - (2 * rem)
-    let (acc) = Trig64x61__sin_loop(x2, 6, Math64x61_ONE)
-    let (res2) = Math64x61_mul(x2, acc)
-    local res = res2 * _sign1 * _sign2
-    Math64x61_assert64x61(res)
-    return (res)
-end
-
-# Calculates cos(x) with x in radians (fixed point)
-func Trig64x61_cos {range_check_ptr} (x: felt) -> (res: felt):
-    tempvar shifted = Trig64x61_HALF_PI - x
-    let (res) = Trig64x61_sin(shifted)
-    return (res)
-end
-
-# Calculates tan(x) with x in radians (fixed point)
-func Trig64x61_tan {range_check_ptr} (x: felt) -> (res: felt):
-    alloc_locals
-
-    let (sinx) = Trig64x61_sin(x)
-    let (cosx) = Trig64x61_cos(x)
-    assert_not_zero(cosx)
-    let (res) = Math64x61_div(sinx, cosx)
-    return (res)
-end
-
-# Calculates arctan(x) (fixed point)
-# See https://stackoverflow.com/a/50894477 for range adjustments
-func Trig64x61_atan {range_check_ptr} (x: felt) -> (res: felt):
-    alloc_locals
-
-    const sqrt3_3 = 1331279082078542925 # sqrt(3) / 3
-    const pi_6 = 1207336576346187140 # pi / 6
-    const p_7 = 1614090106449585766 # 0.7
-    
-    # Calculate on positive values and re-assign later
-    let (_sign) = sign(x)
-    let (abs_x) = abs_value(x)
-
-    # Invert value when x > 1
-    let (_invert) = is_le(Math64x61_ONE, abs_x)
-    local x1a_num = abs_x * (1 - _invert) + _invert * Math64x61_ONE
-    tempvar x1a_div = abs_x * _invert + Math64x61_ONE - Math64x61_ONE * _invert
-    let (x1a) = Math64x61_div(x1a_num, x1a_div)
-
-    # Account for lack of precision in polynomaial when x > 0.7
-    let (_shift) = is_le(p_7, x1a)
-    local b = sqrt3_3 * _shift + Math64x61_ONE - _shift * Math64x61_ONE
-    local x1b_num = x1a - b
-    let (x1b_div_2) = Math64x61_mul(x1a, b)
-    tempvar x1b_div = Math64x61_ONE + x1b_div_2
-    let (x1b) = Math64x61_div(x1b_num, x1b_div)
-    local x1 = x1a * (1 - _shift) + x1b * _shift
-
-    # 6.769e-8 maximum error
-    const a1 = -156068910203
-    const a2 = 2305874223272159097
-    const a3 = -1025642721113314
-    const a4 = -755722092556455027
-    const a5 = -80090004380535356
-    const a6 = 732863004158132014
-    const a7 = -506263448524254433
-    const a8 = 114871904819177193
-    
-    let (r8) = Math64x61_mul(a8, x1)
-    let (r7) = Math64x61_mul(r8 + a7, x1)
-    let (r6) = Math64x61_mul(r7 + a6, x1)
-    let (r5) = Math64x61_mul(r6 + a5, x1)
-    let (r4) = Math64x61_mul(r5 + a4, x1)
-    let (r3) = Math64x61_mul(r4 + a3, x1)
-    let (r2) = Math64x61_mul(r3 + a2, x1)
-    tempvar z1 = r2 + a1
-
-    # Adjust for sign change, inversion, and shift
-    tempvar z2 = z1 + (pi_6 * _shift)
-    tempvar z3 = (z2 - (Trig64x61_HALF_PI * _invert)) * (1 - _invert * 2)
-    local res = z3 * _sign
-    Math64x61_assert64x61(res)
-    return (res)
-end
-
-# Calculates arcsin(x) for -1 <= x <= 1 (fixed point)
-# arcsin(x) = arctan(x / sqrt(1 - x^2))
-func Trig64x61_asin {range_check_ptr} (x: felt) -> (res: felt):
-    alloc_locals
-
-    let (_sign) = sign(x)
-    let (x1) = abs_value(x)
-
-    if x1 == Math64x61_ONE:
-        return (Trig64x61_HALF_PI * _sign)
-    end
-
-    let (x1_2) = Math64x61_mul(x1, x1)
-    let (div) = Math64x61_sqrt(Math64x61_ONE - x1_2)
-    let (atan_arg) = Math64x61_div(x1, div)
-    let (res_u) = Trig64x61_atan(atan_arg)
-    return (res_u * _sign)
-end
-
-# Calculates arccos(x) for -1 <= x <= 1 (fixed point)
-# arccos(x) = arcsin(sqrt(1 - x^2)) - arctan identity has discontinuity at zero
-func Trig64x61_acos {range_check_ptr} (x: felt) -> (res: felt):
-    alloc_locals
-
-    let (_sign) = sign(x)
-    let (x1) = abs_value(x)
-    let (x1_2) = Math64x61_mul(x1, x1)
-    let (asin_arg) = Math64x61_sqrt(Math64x61_ONE - x1_2)
-    let (res_u) = Trig64x61_asin(asin_arg)
-
-    if _sign == -1:
-        local res = Trig64x61_PI - res_u
-        Math64x61_assert64x61(res)
-        return (res)
-    else:
-        return (res_u)
-    end
-end
\ No newline at end of file
diff --git a/contracts/Vec64x61.cairo b/contracts/Vec64x61.cairo
deleted file mode 100644
index 865dcde..0000000
--- a/contracts/Vec64x61.cairo
+++ /dev/null
@@ -1,65 +0,0 @@
-%lang starknet
-
-from Math64x61 import (
-    Math64x61_assert64x61,
-    Math64x61_add,
-    Math64x61_sub,
-    Math64x61_mul,
-    Math64x61_sqrt
-)
-
-# Calculate the vector sum of two 3D vectors
-func Vec64x61_add {range_check_ptr} (a: (felt, felt, felt), b: (felt, felt, felt)) -> (res: (felt, felt, felt)):
-    let (x) = Math64x61_add(a[0], b[0])
-    let (y) = Math64x61_add(a[1], b[1])
-    let (z) = Math64x61_add(a[2], b[2])
-    return ((x, y, z))
-end
-
-# Calculates vector subtraction for two 3D vectors
-func Vec64x61_sub {range_check_ptr} (a: (felt, felt, felt), b: (felt, felt, felt)) -> (res: (felt, felt, felt)):
-    let (x) = Math64x61_sub(a[0], b[0])
-    let (y) = Math64x61_sub(a[1], b[1])
-    let (z) = Math64x61_sub(a[2], b[2])
-    return ((x, y, z))
-end
-
-# Calculates the scalar product of a 3D vector and a fixed point value
-func Vec64x61_mul {range_check_ptr} (a: (felt, felt, felt), b: felt) -> (res: (felt, felt, felt)):
-    let (x) = Math64x61_mul(a[0], b)
-    let (y) = Math64x61_mul(a[1], b)
-    let (z) = Math64x61_mul(a[2], b)
-    return ((x, y, z))
-end
-
-# Calculates the dot product of two 3D vectors
-func Vec64x61_dot {range_check_ptr} (a: (felt, felt, felt), b: (felt, felt, felt)) -> (res: felt):
-    let (x) = Math64x61_mul(a[0], b[0])
-    let (y) = Math64x61_mul(a[1], b[1])
-    let (z) = Math64x61_mul(a[2], b[2])
-    let (res) = Math64x61_add(x + y, z)
-    return (res)
-end
-
-# Calculates the cross product of two 3D vectors
-func Vec64x61_cross {range_check_ptr} (a: (felt, felt, felt), b: (felt, felt, felt)) -> (res: (felt, felt, felt)):
-    let (x1) = Math64x61_mul(a[1], b[2])
-    let (x2) = Math64x61_mul(a[2], b[1])
-    let (x) = Math64x61_sub(x1, x2)
-    let (y1) = Math64x61_mul(a[2], b[0])
-    let (y2) = Math64x61_mul(a[0], b[2])
-    let (y) = Math64x61_sub(y1, y2)
-    let (z1) = Math64x61_mul(a[0], b[1])
-    let (z2) = Math64x61_mul(a[1], b[0])
-    let (z) = Math64x61_sub(z1, z2)
-    return ((x, y, z))
-end
-
-# Calculates the length / norm (L2) of a 3D vector
-func Vec64x61_norm {range_check_ptr} (a: (felt, felt, felt)) -> (res: felt):
-    let (x2) = Math64x61_mul(a[0], a[0])
-    let (y2) = Math64x61_mul(a[1], a[1])
-    let (z2) = Math64x61_mul(a[2], a[2])
-    let (res) = Math64x61_sqrt(x2 + y2 + z2)
-    return (res)
-end
\ No newline at end of file
diff --git a/contracts/cairo_math_64x61/__init__.py b/contracts/cairo_math_64x61/__init__.py
new file mode 100644
index 0000000..f141800
--- /dev/null
+++ b/contracts/cairo_math_64x61/__init__.py
@@ -0,0 +1,11 @@
+"""StarkNet/Cairo development toolbelt."""
+
+try:
+    from importlib import metadata as importlib_metadata
+except ImportError:
+    import importlib_metadata
+
+try:
+    __version__ = importlib_metadata.version("cairo-math-64x61")
+except importlib_metadata.PackageNotFoundError:
+    __version__ = None
\ No newline at end of file
diff --git a/contracts/cairo_math_64x61/hyp64x61.cairo b/contracts/cairo_math_64x61/hyp64x61.cairo
new file mode 100644
index 0000000..6afda36
--- /dev/null
+++ b/contracts/cairo_math_64x61/hyp64x61.cairo
@@ -0,0 +1,63 @@
+from cairo_math_64x61.math64x61 import Math64x61
+
+namespace Hyp64x61:
+    # Calculates hyperbolic sine of x (fixed point)
+    func sinh {range_check_ptr} (x: felt) -> (res: felt):
+        alloc_locals
+
+        let (ex) = Math64x61.exp(x)
+        let (ex_i) = Math64x61.div(Math64x61.ONE, ex)
+        let (res) = Math64x61.div(ex - ex_i, 2 * Math64x61.ONE)
+        Math64x61.assert64x61(res)
+        return (res)
+    end
+
+    # Calculates hyperbolic cosine of x (fixed point)
+    func cosh {range_check_ptr} (x: felt) -> (res: felt):
+        alloc_locals
+
+        let (ex) = Math64x61.exp(x)
+        let (ex_i) = Math64x61.div(Math64x61.ONE, ex)
+        let (res) = Math64x61.div(ex + ex_i, 2 * Math64x61.ONE)
+        Math64x61.assert64x61(res)
+        return (res)
+    end
+
+    # Calculates hyperbolic tangent of x (fixed point)
+    func tanh {range_check_ptr} (x: felt) -> (res: felt):
+        alloc_locals
+
+        let (ex) = Math64x61.exp(x)
+        let (ex_i) = Math64x61.div(Math64x61.ONE, ex)
+        let (res) = Math64x61.div(ex - ex_i, ex + ex_i)
+        Math64x61.assert64x61(res)
+        return (res)
+    end
+
+    # Calculates inverse hyperbolic sine of x (fixed point)
+    func asinh {range_check_ptr} (x: felt) -> (res: felt):
+        let (x2) = Math64x61.mul(x, x)
+        let (root) = Math64x61.sqrt(x2 + Math64x61.ONE)
+        let (res) = Math64x61.ln(x + root)
+        Math64x61.assert64x61(res)
+        return (res)
+    end
+
+    # Calculates inverse hyperbolic cosine of x (fixed point)
+    func acosh {range_check_ptr} (x: felt) -> (res: felt):
+        let (x2) = Math64x61.mul(x, x)
+        let (root) = Math64x61.sqrt(x2 - Math64x61.ONE)
+        let (res) = Math64x61.ln(x + root)
+        Math64x61.assert64x61(res)
+        return (res)
+    end
+
+    # Calculates inverse hyperbolic tangent of x (fixed point)
+    func atanh {range_check_ptr} (x: felt) -> (res: felt):
+        let (_ln_arg) = Math64x61.div(Math64x61.ONE + x, Math64x61.ONE - x)
+        let (_ln) = Math64x61.ln(_ln_arg)
+        let (res) = Math64x61.div(_ln, 2 * Math64x61.ONE)
+        Math64x61.assert64x61(res)
+        return (res)
+    end
+end
diff --git a/contracts/cairo_math_64x61/hyp64x61_mock.cairo b/contracts/cairo_math_64x61/hyp64x61_mock.cairo
new file mode 100644
index 0000000..d9f91a6
--- /dev/null
+++ b/contracts/cairo_math_64x61/hyp64x61_mock.cairo
@@ -0,0 +1,39 @@
+%lang starknet
+
+from cairo_math_64x61.hyp64x61 import Hyp64x61
+
+@view
+func hyp64x61_sinh_test {range_check_ptr} (x: felt) -> (res: felt):
+    let (res) = Hyp64x61.sinh(x)
+    return (res)
+end
+
+@view
+func hyp64x61_cosh_test {range_check_ptr} (x: felt) -> (res: felt):
+    let (res) = Hyp64x61.cosh(x)
+    return (res)
+end
+
+@view
+func hyp64x61_tanh_test {range_check_ptr} (x: felt) -> (res: felt):
+    let (res) = Hyp64x61.tanh(x)
+    return (res)
+end
+
+@view
+func hyp64x61_asinh_test {range_check_ptr} (x: felt) -> (res: felt):
+    let (res) = Hyp64x61.asinh(x)
+    return (res)
+end
+
+@view
+func hyp64x61_acosh_test {range_check_ptr} (x: felt) -> (res: felt):
+    let (res) = Hyp64x61.acosh(x)
+    return (res)
+end
+
+@view
+func hyp64x61_atanh_test {range_check_ptr} (x: felt) -> (res: felt):
+    let (res) = Hyp64x61.atanh(x)
+    return (res)
+end
diff --git a/contracts/cairo_math_64x61/math64x61.cairo b/contracts/cairo_math_64x61/math64x61.cairo
new file mode 100644
index 0000000..b2dd6a0
--- /dev/null
+++ b/contracts/cairo_math_64x61/math64x61.cairo
@@ -0,0 +1,322 @@
+from starkware.cairo.common.uint256 import Uint256
+from starkware.cairo.common.math_cmp import is_le, is_not_zero
+from starkware.cairo.common.pow import pow as pow_int
+from starkware.cairo.common.math import (
+    assert_le,
+    assert_lt,
+    sqrt as sqrt_int,
+    sign,
+    abs_value,
+    signed_div_rem,
+    unsigned_div_rem,
+    assert_not_zero
+)
+
+namespace Math64x61:
+    const INT_PART = 2 ** 64
+    const FRACT_PART = 2 ** 61
+    const BOUND = 2 ** 125
+    const ONE = 1 * FRACT_PART
+    const E = 6267931151224907085
+
+    func assert64x61 {range_check_ptr} (x: felt):
+        assert_le(x, BOUND)
+        assert_le(-BOUND, x)
+        return ()
+    end
+
+    # Converts a fixed point value to a felt, truncating the fractional component
+    func toFelt {range_check_ptr} (x: felt) -> (res: felt):
+        let (res, _) = signed_div_rem(x, FRACT_PART, BOUND)
+        return (res)
+    end
+
+    # Converts a felt to a fixed point value ensuring it will not overflow
+    func fromFelt {range_check_ptr} (x: felt) -> (res: felt):
+        assert_le(x, INT_PART)
+        assert_le(-INT_PART, x)
+        return (x * FRACT_PART)
+    end
+
+    # Converts a fixed point 64.61 value to a uint256 value
+    func toUint256 (x: felt) -> (res: Uint256):
+        let res = Uint256(low = x, high = 0)
+        return (res)
+    end
+
+    # Converts a uint256 value into a fixed point 64.61 value ensuring it will not overflow
+    func fromUint256 {range_check_ptr} (x: Uint256) -> (res: felt):
+        assert x.high = 0
+        let (res) = fromFelt(x.low)
+        return (res)
+    end
+
+    # Calculates the floor of a 64.61 value
+    func floor {range_check_ptr} (x: felt) -> (res: felt):
+        let (int_val, mod_val) = signed_div_rem(x, ONE, BOUND)
+        let res = x - mod_val
+        assert64x61(res)
+        return (res)
+    end
+
+    # Calculates the ceiling of a 64.61 value
+    func ceil {range_check_ptr} (x: felt) -> (res: felt):
+        let (int_val, mod_val) = signed_div_rem(x, ONE, BOUND)
+        let res = (int_val + 1) * ONE
+        assert64x61(res)
+        return (res)
+    end
+
+    # Returns the minimum of two values
+    func min {range_check_ptr} (x: felt, y: felt) -> (res: felt):
+        let (x_le) = is_le(x, y)
+
+        if x_le == 1:
+            return (x)
+        else:
+            return (y)
+        end
+    end
+
+    # Returns the maximum of two values
+    func max {range_check_ptr} (x: felt, y: felt) -> (res: felt):
+        let (x_le) = is_le(x, y)
+
+        if x_le == 1:
+            return (y)
+        else:
+            return (x)
+        end
+    end
+
+    # Convenience addition method to assert no overflow before returning
+    func add {range_check_ptr} (x: felt, y: felt) -> (res: felt):
+        let res = x + y
+        assert64x61(res)
+        return (res)
+    end
+
+    # Convenience subtraction method to assert no overflow before returning
+    func sub {range_check_ptr} (x: felt, y: felt) -> (res: felt):
+        let res = x - y
+        assert64x61(res)
+        return (res)
+    end
+
+    # Multiples two fixed point values and checks for overflow before returning
+    func mul {range_check_ptr} (x: felt, y: felt) -> (res: felt):
+        tempvar product = x * y
+        let (res, _) = signed_div_rem(product, FRACT_PART, BOUND)
+        assert64x61(res)
+        return (res)
+    end
+
+    # Divides two fixed point values and checks for overflow before returning
+    # Both values may be signed (i.e. also allows for division by negative b)
+    func div {range_check_ptr} (x: felt, y: felt) -> (res: felt):
+        alloc_locals
+        let (div) = abs_value(y)
+        let (div_sign) = sign(y)
+        tempvar product = x * FRACT_PART
+        let (res_u, _) = signed_div_rem(product, div, BOUND)
+        assert64x61(res_u)
+        return (res = res_u * div_sign)
+    end
+
+    # Calclates the value of x^y and checks for overflow before returning
+    # x is a 64x61 fixed point value
+    # y is a 64x61 fixed point value
+    func pow {range_check_ptr} (x: felt, y: felt) -> (res: felt):
+        alloc_locals
+        let (y_int, y_frac) = signed_div_rem(y, ONE, BOUND)
+
+        # use the more performant integer pow when y is an int
+        if y_frac == 0:
+            return _pow_int(x, y_int)
+        end
+
+        # x^y = exp(y*ln(x)) for x > 0 (will error for x < 0
+        let (ln_x) = ln(x)
+        let (y_ln_x) = mul(y,ln_x)
+        let (res) = exp(y_ln_x)
+        return (res)
+        # assert64x61(res)
+        # return (res)
+    end
+
+    # Calculates the square root of a fixed point value
+    # x must be positive
+    func sqrt {range_check_ptr} (x: felt) -> (res: felt):
+        alloc_locals
+        let (root) = sqrt_int(x)
+        let (scale_root) = sqrt_int(FRACT_PART)
+        let (res, _) = signed_div_rem(root * FRACT_PART, scale_root, BOUND)
+        assert64x61(res)
+        return (res)
+    end
+
+    # Calculates the binary exponent of x: 2^x
+    func exp2 {range_check_ptr} (x: felt) -> (res: felt):
+        alloc_locals
+
+        let (exp_sign) = sign(x)
+
+        if exp_sign == 0:
+            return (ONE)
+        end
+
+        let (exp_value) = abs_value(x)
+        let (int_part, frac_part) = unsigned_div_rem(exp_value, FRACT_PART)
+        let (int_res) = _pow_int(2 * ONE, int_part)
+
+        # 1.069e-7 maximum error
+        const a1 = 2305842762765193127
+        const a2 = 1598306039479152907
+        const a3 = 553724477747739017
+        const a4 = 128818789015678071
+        const a5 = 20620759886412153
+        const a6 = 4372943086487302
+
+        let (r6) = mul(a6, frac_part)
+        let (r5) = mul(r6 + a5, frac_part)
+        let (r4) = mul(r5 + a4, frac_part)
+        let (r3) = mul(r4 + a3, frac_part)
+        let (r2) = mul(r3 + a2, frac_part)
+        tempvar frac_res = r2 + a1
+
+        let (res_u) = mul(int_res, frac_res)
+        
+        if exp_sign == -1:
+            let (res_i) = div(ONE, res_u)
+            assert64x61(res_i)
+            return (res_i)
+        else:
+            assert64x61(res_u)
+            return (res_u)
+        end
+    end
+
+    # Calculates the natural exponent of x: e^x
+    func exp {range_check_ptr} (x: felt) -> (res: felt):
+        const mod = 3326628274461080623
+        let (bin_exp) = mul(x, mod)
+        let (res) = exp2(bin_exp)
+        return (res)
+    end
+
+    # Calculates the binary logarithm of x: log2(x)
+    # x must be greather than zero
+    func log2 {range_check_ptr} (x: felt) -> (res: felt):
+        alloc_locals
+
+        if x == ONE:
+            return (0)
+        end
+
+        let (is_frac) = is_le(x, FRACT_PART - 1)
+
+        # Compute negative inverse binary log if 0 < x < 1
+        if is_frac == 1:
+            let (div_x) = div(ONE, x)
+            let (res_i) = log2(div_x)
+            return (-res_i)
+        end
+
+        let (x_over_two, _) = unsigned_div_rem(x, 2)
+        let (b) = _msb(x_over_two)
+        let (divisor) = pow_int(2, b)
+        let (norm, _) = unsigned_div_rem(x, divisor)
+
+        # 4.233e-8 maximum error
+        const a1 = -7898418853509069178
+        const a2 = 18803698872658890801
+        const a3 = -23074885139408336243
+        const a4 = 21412023763986120774
+        const a5 = -13866034373723777071
+        const a6 = 6084599848616517800
+        const a7 = -1725595270316167421
+        const a8 = 285568853383421422
+        const a9 = -20957604075893688
+
+        let (r9) = mul(a9, norm)
+        let (r8) = mul(r9 + a8, norm)
+        let (r7) = mul(r8 + a7, norm)
+        let (r6) = mul(r7 + a6, norm)
+        let (r5) = mul(r6 + a5, norm)
+        let (r4) = mul(r5 + a4, norm)
+        let (r3) = mul(r4 + a3, norm)
+        let (r2) = mul(r3 + a2, norm)
+        local norm_res = r2 + a1
+
+        let (int_part) = fromFelt(b)
+        local res = int_part + norm_res
+        assert64x61(res)
+        return (res)
+    end
+
+    # Calculates the natural logarithm of x: ln(x)
+    # x must be greater than zero
+    func ln {range_check_ptr} (x: felt) -> (res: felt):
+        const ln_2 = 1598288580650331957
+        let (log2_x) = log2(x)
+        let (product) = mul(log2_x, ln_2)
+        return (product)
+    end
+
+    # Calculates the base 10 log of x: log10(x)
+    # x must be greater than zero
+    func log10 {range_check_ptr} (x: felt) -> (res: felt):
+        const log10_2 = 694127911065419642
+        let (log10_x) = log2(x)
+        let (product) = mul(log10_x, log10_2)
+        return (product)
+    end
+
+    # Calclates the value of x^y and checks for overflow before returning
+    # x is a 64x61 fixed point value
+    # y is a standard felt (int)
+    func _pow_int {range_check_ptr} (x: felt, y: felt) -> (res: felt):
+        alloc_locals
+        let (exp_sign) = sign(y)
+        let (exp_val) = abs_value(y)
+
+        if exp_sign == 0:
+            return (ONE)
+        end
+
+        if exp_sign == -1:
+            let (num) = _pow_int(x, exp_val)
+            return div(ONE, num)
+        end
+
+        let (half_exp, rem) = unsigned_div_rem(exp_val, 2)
+        let (half_pow) = _pow_int(x, half_exp)
+        let (res_p) = mul(half_pow, half_pow)
+
+        if rem == 0:
+            assert64x61(res_p)
+            return (res_p)
+        else:
+            let (res) = mul(res_p, x)
+            assert64x61(res)
+            return (res)
+        end
+    end
+
+    # Calculates the most significant bit where x is a fixed point value
+    func _msb {range_check_ptr} (x: felt) -> (res: felt):
+        alloc_locals
+
+        let (cmp) = is_le(x, FRACT_PART)
+
+        if cmp == 1:
+            return (0)
+        end
+
+        let (div, _) = unsigned_div_rem(x, 2)
+        let (rest) = _msb(div)
+        local res = 1 + rest
+        assert64x61(res)
+        return (res)
+    end
+end
\ No newline at end of file
diff --git a/contracts/cairo_math_64x61/math64x61_mock.cairo b/contracts/cairo_math_64x61/math64x61_mock.cairo
new file mode 100644
index 0000000..c906e0c
--- /dev/null
+++ b/contracts/cairo_math_64x61/math64x61_mock.cairo
@@ -0,0 +1,82 @@
+%lang starknet
+
+from cairo_math_64x61.math64x61 import Math64x61
+
+@view
+func math64x61_floor_test {range_check_ptr} (x: felt) -> (res: felt):
+    let (res) = Math64x61.floor(x)
+    return (res)
+end
+
+@view
+func math64x61_ceil_test {range_check_ptr} (x: felt) -> (res: felt):
+    let (res) = Math64x61.ceil(x)
+    return (res)
+end
+
+@view
+func math64x61_min_test {range_check_ptr} (x: felt, y: felt) -> (res: felt):
+    let (res) = Math64x61.min(x, y)
+    return (res)
+end
+
+@view
+func math64x61_max_test {range_check_ptr} (x: felt, y: felt) -> (res: felt):
+    let (res) = Math64x61.max(x, y)
+    return (res)
+end
+
+@view
+func math64x61_mul_test {range_check_ptr} (x: felt, y: felt) -> (res: felt):
+    let (res) = Math64x61.mul(x, y)
+    return (res)
+end
+
+@view
+func math64x61_div_test {range_check_ptr} (x: felt, y: felt) -> (res: felt):
+    let (res) = Math64x61.div(x, y)
+    return (res)
+end
+
+@view
+func math64x61_pow_test {range_check_ptr} (x: felt, y: felt) -> (res: felt):
+    let (res) = Math64x61.pow(x, y)
+    return (res)
+end
+
+@view
+func math64x61_sqrt_test {range_check_ptr} (x: felt) -> (res: felt):
+    let (res) = Math64x61.sqrt(x)
+    return (res)
+end
+
+@view
+func math64x61_exp2_test {range_check_ptr} (x: felt) -> (res: felt):
+    let (res) = Math64x61.exp2(x)
+    return (res)
+end
+
+# Calculates the natural exponent of x: e^x
+@view
+func math64x61_exp_test {range_check_ptr} (x: felt) -> (res: felt):
+    let (res) = Math64x61.exp(x)
+    return (res)
+end
+
+@view
+func math64x61_log2_test {range_check_ptr} (x: felt) -> (res: felt):
+    let (res) = Math64x61.log2(x)
+    return (res)
+end
+
+@view
+func math64x61_ln_test {range_check_ptr} (x: felt) -> (res: felt):
+    let (res) = Math64x61.ln(x)
+    return (res)
+end
+
+@view
+func math64x61_log10_test {range_check_ptr} (x: felt) -> (res: felt):
+    let (res) = Math64x61.log10(x)
+    return (res)
+end
diff --git a/contracts/cairo_math_64x61/trig64x61.cairo b/contracts/cairo_math_64x61/trig64x61.cairo
new file mode 100644
index 0000000..bf230b3
--- /dev/null
+++ b/contracts/cairo_math_64x61/trig64x61.cairo
@@ -0,0 +1,152 @@
+from starkware.cairo.common.math_cmp import is_le
+from starkware.cairo.common.math import sign, abs_value, unsigned_div_rem, assert_not_zero
+from cairo_math_64x61.math64x61 import Math64x61
+
+namespace Trig64x61:
+    const PI = 7244019458077122842
+    const HALF_PI = 3622009729038561421
+
+    # Calculates sin(x) with x in radians (fixed point)
+    func sin {range_check_ptr} (x: felt) -> (res: felt):
+        alloc_locals
+
+        let (_sign1) = sign(x) # extract sign
+        let (abs1) = abs_value(x)
+        let (_, x1) = unsigned_div_rem(abs1, 2 * PI)
+        let (rem, x2) = unsigned_div_rem(x1, PI)
+        local _sign2 = 1 - (2 * rem)
+        let (acc) = _sin_loop(x2, 6, Math64x61.ONE)
+        let (res2) = Math64x61.mul(x2, acc)
+        local res = res2 * _sign1 * _sign2
+        Math64x61.assert64x61(res)
+        return (res)
+    end
+
+    # Calculates cos(x) with x in radians (fixed point)
+    func cos {range_check_ptr} (x: felt) -> (res: felt):
+        tempvar shifted = HALF_PI - x
+        let (res) = sin(shifted)
+        return (res)
+    end
+
+    # Calculates tan(x) with x in radians (fixed point)
+    func tan {range_check_ptr} (x: felt) -> (res: felt):
+        alloc_locals
+
+        let (sinx) = sin(x)
+        let (cosx) = cos(x)
+        assert_not_zero(cosx)
+        let (res) = Math64x61.div(sinx, cosx)
+        return (res)
+    end
+
+    # Calculates arctan(x) (fixed point)
+    # See https://stackoverflow.com/a/50894477 for range adjustments
+    func atan {range_check_ptr} (x: felt) -> (res: felt):
+        alloc_locals
+
+        const sqrt3_3 = 1331279082078542925 # sqrt(3) / 3
+        const pi_6 = 1207336576346187140 # pi / 6
+        const p_7 = 1614090106449585766 # 0.7
+        
+        # Calculate on positive values and re-assign later
+        let (_sign) = sign(x)
+        let (abs_x) = abs_value(x)
+
+        # Invert value when x > 1
+        let (_invert) = is_le(Math64x61.ONE, abs_x)
+        local x1a_num = abs_x * (1 - _invert) + _invert * Math64x61.ONE
+        tempvar x1a_div = abs_x * _invert + Math64x61.ONE - Math64x61.ONE * _invert
+        let (x1a) = Math64x61.div(x1a_num, x1a_div)
+
+        # Account for lack of precision in polynomaial when x > 0.7
+        let (_shift) = is_le(p_7, x1a)
+        local b = sqrt3_3 * _shift + Math64x61.ONE - _shift * Math64x61.ONE
+        local x1b_num = x1a - b
+        let (x1b_div_2) = Math64x61.mul(x1a, b)
+        tempvar x1b_div = Math64x61.ONE + x1b_div_2
+        let (x1b) = Math64x61.div(x1b_num, x1b_div)
+        local x1 = x1a * (1 - _shift) + x1b * _shift
+
+        # 6.769e-8 maximum error
+        const a1 = -156068910203
+        const a2 = 2305874223272159097
+        const a3 = -1025642721113314
+        const a4 = -755722092556455027
+        const a5 = -80090004380535356
+        const a6 = 732863004158132014
+        const a7 = -506263448524254433
+        const a8 = 114871904819177193
+        
+        let (r8) = Math64x61.mul(a8, x1)
+        let (r7) = Math64x61.mul(r8 + a7, x1)
+        let (r6) = Math64x61.mul(r7 + a6, x1)
+        let (r5) = Math64x61.mul(r6 + a5, x1)
+        let (r4) = Math64x61.mul(r5 + a4, x1)
+        let (r3) = Math64x61.mul(r4 + a3, x1)
+        let (r2) = Math64x61.mul(r3 + a2, x1)
+        tempvar z1 = r2 + a1
+
+        # Adjust for sign change, inversion, and shift
+        tempvar z2 = z1 + (pi_6 * _shift)
+        tempvar z3 = (z2 - (HALF_PI * _invert)) * (1 - _invert * 2)
+        local res = z3 * _sign
+        Math64x61.assert64x61(res)
+        return (res)
+    end
+
+    # Calculates arcsin(x) for -1 <= x <= 1 (fixed point)
+    # arcsin(x) = arctan(x / sqrt(1 - x^2))
+    func asin {range_check_ptr} (x: felt) -> (res: felt):
+        alloc_locals
+
+        let (_sign) = sign(x)
+        let (x1) = abs_value(x)
+
+        if x1 == Math64x61.ONE:
+            return (HALF_PI * _sign)
+        end
+
+        let (x1_2) = Math64x61.mul(x1, x1)
+        let (div) = Math64x61.sqrt(Math64x61.ONE - x1_2)
+        let (atan_arg) = Math64x61.div(x1, div)
+        let (res_u) = atan(atan_arg)
+        return (res_u * _sign)
+    end
+
+    # Calculates arccos(x) for -1 <= x <= 1 (fixed point)
+    # arccos(x) = arcsin(sqrt(1 - x^2)) - arctan identity has discontinuity at zero
+    func acos {range_check_ptr} (x: felt) -> (res: felt):
+        alloc_locals
+
+        let (_sign) = sign(x)
+        let (x1) = abs_value(x)
+        let (x1_2) = Math64x61.mul(x1, x1)
+        let (asin_arg) = Math64x61.sqrt(Math64x61.ONE - x1_2)
+        let (res_u) = asin(asin_arg)
+
+        if _sign == -1:
+            local res = PI - res_u
+            Math64x61.assert64x61(res)
+            return (res)
+        else:
+            return (res_u)
+        end
+    end
+
+    # Helper function to calculate Taylor series for sin
+    func _sin_loop {range_check_ptr} (x: felt, i: felt, acc: felt) -> (res: felt):
+        alloc_locals
+
+        if i == -1:
+            return (acc)
+        end
+
+        let (num) = Math64x61.mul(x, x)
+        tempvar div = (2 * i + 2) * (2 * i + 3) * Math64x61.FRACT_PART
+        let (t) = Math64x61.div(num, div)
+        let (t_acc) = Math64x61.mul(t, acc)
+        let (next) = _sin_loop(x, i - 1, Math64x61.ONE - t_acc)
+        return (next)
+    end
+end
\ No newline at end of file
diff --git a/contracts/cairo_math_64x61/trig64x61_mock.cairo b/contracts/cairo_math_64x61/trig64x61_mock.cairo
new file mode 100644
index 0000000..4d9bdc7
--- /dev/null
+++ b/contracts/cairo_math_64x61/trig64x61_mock.cairo
@@ -0,0 +1,39 @@
+%lang starknet
+
+from cairo_math_64x61.trig64x61 import Trig64x61
+
+@view
+func  trig64x61_sin_test {range_check_ptr} (x: felt) -> (res: felt):
+    let (res) = Trig64x61.sin(x)
+    return (res)
+end
+
+@view
+func trig64x61_cos_test {range_check_ptr} (x: felt) -> (res: felt):
+    let (res) = Trig64x61.cos(x)
+    return (res)
+end
+
+@view
+func trig64x61_tan_test {range_check_ptr} (x: felt) -> (res: felt):
+    let (res) = Trig64x61.tan(x)
+    return (res)
+end
+
+@view
+func trig64x61_atan_test {range_check_ptr} (x: felt) -> (res: felt):
+    let (res) = Trig64x61.atan(x)
+    return (res)
+end
+
+@view
+func trig64x61_asin_test {range_check_ptr} (x: felt) -> (res: felt):
+    let (res) = Trig64x61.asin(x)
+    return (res)
+end
+
+@view
+func  trig64x61_acos_test {range_check_ptr} (x: felt) -> (res: felt):
+    let (res) = Trig64x61.acos(x)
+    return (res)
+end
\ No newline at end of file
diff --git a/contracts/cairo_math_64x61/vec64x61.cairo b/contracts/cairo_math_64x61/vec64x61.cairo
new file mode 100644
index 0000000..d035ade
--- /dev/null
+++ b/contracts/cairo_math_64x61/vec64x61.cairo
@@ -0,0 +1,59 @@
+from cairo_math_64x61.math64x61 import Math64x61
+
+namespace Vec64x61:
+    # Calculate the vector sum of two 3D vectors
+    func add {range_check_ptr} (a: (felt, felt, felt), b: (felt, felt, felt)) -> (res: (felt, felt, felt)):
+        let (x) = Math64x61.add(a[0], b[0])
+        let (y) = Math64x61.add(a[1], b[1])
+        let (z) = Math64x61.add(a[2], b[2])
+        return ((x, y, z))
+    end
+
+    # Calculates vector subtraction for two 3D vectors
+    func sub {range_check_ptr} (a: (felt, felt, felt), b: (felt, felt, felt)) -> (res: (felt, felt, felt)):
+        let (x) = Math64x61.sub(a[0], b[0])
+        let (y) = Math64x61.sub(a[1], b[1])
+        let (z) = Math64x61.sub(a[2], b[2])
+        return ((x, y, z))
+    end
+
+    # Calculates the scalar product of a 3D vector and a fixed point value
+    func mul {range_check_ptr} (a: (felt, felt, felt), b: felt) -> (res: (felt, felt, felt)):
+        let (x) = Math64x61.mul(a[0], b)
+        let (y) = Math64x61.mul(a[1], b)
+        let (z) = Math64x61.mul(a[2], b)
+        return ((x, y, z))
+    end
+
+    # Calculates the dot product of two 3D vectors
+    func dot {range_check_ptr} (a: (felt, felt, felt), b: (felt, felt, felt)) -> (res: felt):
+        let (x) = Math64x61.mul(a[0], b[0])
+        let (y) = Math64x61.mul(a[1], b[1])
+        let (z) = Math64x61.mul(a[2], b[2])
+        let (res) = Math64x61.add(x + y, z)
+        return (res)
+    end
+
+    # Calculates the cross product of two 3D vectors
+    func cross {range_check_ptr} (a: (felt, felt, felt), b: (felt, felt, felt)) -> (res: (felt, felt, felt)):
+        let (x1) = Math64x61.mul(a[1], b[2])
+        let (x2) = Math64x61.mul(a[2], b[1])
+        let (x) = Math64x61.sub(x1, x2)
+        let (y1) = Math64x61.mul(a[2], b[0])
+        let (y2) = Math64x61.mul(a[0], b[2])
+        let (y) = Math64x61.sub(y1, y2)
+        let (z1) = Math64x61.mul(a[0], b[1])
+        let (z2) = Math64x61.mul(a[1], b[0])
+        let (z) = Math64x61.sub(z1, z2)
+        return ((x, y, z))
+    end
+
+    # Calculates the length / norm (L2) of a 3D vector
+    func norm {range_check_ptr} (a: (felt, felt, felt)) -> (res: felt):
+        let (x2) = Math64x61.mul(a[0], a[0])
+        let (y2) = Math64x61.mul(a[1], a[1])
+        let (z2) = Math64x61.mul(a[2], a[2])
+        let (res) = Math64x61.sqrt(x2 + y2 + z2)
+        return (res)
+    end
+end
\ No newline at end of file
diff --git a/contracts/cairo_math_64x61/vec64x61_mock.cairo b/contracts/cairo_math_64x61/vec64x61_mock.cairo
new file mode 100644
index 0000000..c1b43e7
--- /dev/null
+++ b/contracts/cairo_math_64x61/vec64x61_mock.cairo
@@ -0,0 +1,39 @@
+%lang starknet
+
+from cairo_math_64x61.vec64x61 import Vec64x61
+
+@view
+func vec64x61_add_test {range_check_ptr} (a: (felt, felt, felt), b: (felt, felt, felt)) -> (res: (felt, felt, felt)):
+    let (res) = Vec64x61.add(a, b)
+    return (res)
+end
+
+@view
+func vec64x61_sub_test {range_check_ptr} (a: (felt, felt, felt), b: (felt, felt, felt)) -> (res: (felt, felt, felt)):
+    let (res) = Vec64x61.sub(a, b)
+    return (res)
+end
+
+@view
+func vec64x61_mul_test {range_check_ptr} (a: (felt, felt, felt), b: felt) -> (res: (felt, felt, felt)):
+    let (res) = Vec64x61.mul(a, b)
+    return (res)
+end
+
+@view
+func vec64x61_dot_test {range_check_ptr} (a: (felt, felt, felt), b: (felt, felt, felt)) -> (res: felt):
+    let (res) = Vec64x61.dot(a, b)
+    return (res)
+end
+
+@view
+func vec64x61_cross_test {range_check_ptr} (a: (felt, felt, felt), b: (felt, felt, felt)) -> (res: (felt, felt, felt)):
+    let (res) = Vec64x61.cross(a, b)
+    return (res)
+end
+
+@view
+func vec64x61_norm_test {range_check_ptr} (a: (felt, felt, felt)) -> (res: felt):
+    let (res) = Vec64x61.norm(a)
+    return (res)
+end
\ No newline at end of file
diff --git a/contracts/mocks/Hyp64x61Mock.cairo b/contracts/mocks/Hyp64x61Mock.cairo
deleted file mode 100644
index 539a8dd..0000000
--- a/contracts/mocks/Hyp64x61Mock.cairo
+++ /dev/null
@@ -1,46 +0,0 @@
-%lang starknet
-
-from Hyp64x61 import (
-    Hyp64x61_sinh,
-    Hyp64x61_cosh,
-    Hyp64x61_tanh,
-    Hyp64x61_asinh,
-    Hyp64x61_acosh,
-    Hyp64x61_atanh
-)
-
-@view
-func Hyp64x61_sinh_test {range_check_ptr} (x: felt) -> (res: felt):
-    let (res) = Hyp64x61_sinh(x)
-    return (res)
-end
-
-@view
-func Hyp64x61_cosh_test {range_check_ptr} (x: felt) -> (res: felt):
-    let (res) = Hyp64x61_cosh(x)
-    return (res)
-end
-
-@view
-func Hyp64x61_tanh_test {range_check_ptr} (x: felt) -> (res: felt):
-    let (res) = Hyp64x61_tanh(x)
-    return (res)
-end
-
-@view
-func Hyp64x61_asinh_test {range_check_ptr} (x: felt) -> (res: felt):
-    let (res) = Hyp64x61_asinh(x)
-    return (res)
-end
-
-@view
-func Hyp64x61_acosh_test {range_check_ptr} (x: felt) -> (res: felt):
-    let (res) = Hyp64x61_acosh(x)
-    return (res)
-end
-
-@view
-func Hyp64x61_atanh_test {range_check_ptr} (x: felt) -> (res: felt):
-    let (res) = Hyp64x61_atanh(x)
-    return (res)
-end
diff --git a/contracts/mocks/Math64x61Mock.cairo b/contracts/mocks/Math64x61Mock.cairo
deleted file mode 100644
index d5d7a53..0000000
--- a/contracts/mocks/Math64x61Mock.cairo
+++ /dev/null
@@ -1,96 +0,0 @@
-%lang starknet
-
-from Math64x61 import (
-    Math64x61_floor,
-    Math64x61_ceil,
-    Math64x61_min,
-    Math64x61_max,
-    Math64x61_mul,
-    Math64x61_div,
-    Math64x61_pow,
-    Math64x61_sqrt,
-    Math64x61_exp2,
-    Math64x61_exp,
-    Math64x61_log2,
-    Math64x61_ln,
-    Math64x61_log10
-)
-
-@view
-func Math64x61_floor_test {range_check_ptr} (x: felt) -> (res: felt):
-    let (res) = Math64x61_floor(x)
-    return (res)
-end
-
-@view
-func Math64x61_ceil_test {range_check_ptr} (x: felt) -> (res: felt):
-    let (res) = Math64x61_ceil(x)
-    return (res)
-end
-
-@view
-func Math64x61_min_test {range_check_ptr} (x: felt, y: felt) -> (res: felt):
-    let (res) = Math64x61_min(x, y)
-    return (res)
-end
-
-@view
-func Math64x61_max_test {range_check_ptr} (x: felt, y: felt) -> (res: felt):
-    let (res) = Math64x61_max(x, y)
-    return (res)
-end
-
-@view
-func Math64x61_mul_test {range_check_ptr} (x: felt, y: felt) -> (res: felt):
-    let (res) = Math64x61_mul(x, y)
-    return (res)
-end
-
-@view
-func Math64x61_div_test {range_check_ptr} (x: felt, y: felt) -> (res: felt):
-    let (res) = Math64x61_div(x, y)
-    return (res)
-end
-
-@view
-func Math64x61_pow_test {range_check_ptr} (x: felt, y: felt) -> (res: felt):
-    let (res) = Math64x61_pow(x, y)
-    return (res)
-end
-
-@view
-func Math64x61_sqrt_test {range_check_ptr} (x: felt) -> (res: felt):
-    let (res) = Math64x61_sqrt(x)
-    return (res)
-end
-
-@view
-func Math64x61_exp2_test {range_check_ptr} (x: felt) -> (res: felt):
-    let (res) = Math64x61_exp2(x)
-    return (res)
-end
-
-# Calculates the natural exponent of x: e^x
-@view
-func Math64x61_exp_test {range_check_ptr} (x: felt) -> (res: felt):
-    let (res) = Math64x61_exp(x)
-    return (res)
-end
-
-@view
-func Math64x61_log2_test {range_check_ptr} (x: felt) -> (res: felt):
-    let (res) = Math64x61_log2(x)
-    return (res)
-end
-
-@view
-func Math64x61_ln_test {range_check_ptr} (x: felt) -> (res: felt):
-    let (res) = Math64x61_ln(x)
-    return (res)
-end
-
-@view
-func Math64x61_log10_test {range_check_ptr} (x: felt) -> (res: felt):
-    let (res) = Math64x61_log10(x)
-    return (res)
-end
diff --git a/contracts/mocks/Trig64x61Mock.cairo b/contracts/mocks/Trig64x61Mock.cairo
deleted file mode 100644
index c10afa9..0000000
--- a/contracts/mocks/Trig64x61Mock.cairo
+++ /dev/null
@@ -1,46 +0,0 @@
-%lang starknet
-
-from Trig64x61 import (
-    Trig64x61_sin,
-    Trig64x61_cos,
-    Trig64x61_tan,
-    Trig64x61_atan,
-    Trig64x61_asin,
-    Trig64x61_acos
-)
-
-@view
-func  Trig64x61_sin_test {range_check_ptr} (x: felt) -> (res: felt):
-    let (res) =  Trig64x61_sin(x)
-    return (res)
-end
-
-@view
-func Trig64x61_cos_test {range_check_ptr} (x: felt) -> (res: felt):
-    let (res) = Trig64x61_cos(x)
-    return (res)
-end
-
-@view
-func Trig64x61_tan_test {range_check_ptr} (x: felt) -> (res: felt):
-    let (res) = Trig64x61_tan(x)
-    return (res)
-end
-
-@view
-func Trig64x61_atan_test {range_check_ptr} (x: felt) -> (res: felt):
-    let (res) = Trig64x61_atan(x)
-    return (res)
-end
-
-@view
-func Trig64x61_asin_test {range_check_ptr} (x: felt) -> (res: felt):
-    let (res) = Trig64x61_asin(x)
-    return (res)
-end
-
-@view
-func  Trig64x61_acos_test {range_check_ptr} (x: felt) -> (res: felt):
-    let (res) =  Trig64x61_acos(x)
-    return (res)
-end
\ No newline at end of file
diff --git a/contracts/mocks/Vec64x61Mock.cairo b/contracts/mocks/Vec64x61Mock.cairo
deleted file mode 100644
index 80305e1..0000000
--- a/contracts/mocks/Vec64x61Mock.cairo
+++ /dev/null
@@ -1,46 +0,0 @@
-%lang starknet
-
-from Vec64x61 import (
-    Vec64x61_add,
-    Vec64x61_sub,
-    Vec64x61_mul,
-    Vec64x61_dot,
-    Vec64x61_cross,
-    Vec64x61_norm
-)
-
-@view
-func Vec64x61_add_test {range_check_ptr} (a: (felt, felt, felt), b: (felt, felt, felt)) -> (res: (felt, felt, felt)):
-    let (res) = Vec64x61_add(a, b)
-    return (res)
-end
-
-@view
-func Vec64x61_sub_test {range_check_ptr} (a: (felt, felt, felt), b: (felt, felt, felt)) -> (res: (felt, felt, felt)):
-    let (res) = Vec64x61_sub(a, b)
-    return (res)
-end
-
-@view
-func Vec64x61_mul_test {range_check_ptr} (a: (felt, felt, felt), b: felt) -> (res: (felt, felt, felt)):
-    let (res) = Vec64x61_mul(a, b)
-    return (res)
-end
-
-@view
-func Vec64x61_dot_test {range_check_ptr} (a: (felt, felt, felt), b: (felt, felt, felt)) -> (res: felt):
-    let (res) = Vec64x61_dot(a, b)
-    return (res)
-end
-
-@view
-func Vec64x61_cross_test {range_check_ptr} (a: (felt, felt, felt), b: (felt, felt, felt)) -> (res: (felt, felt, felt)):
-    let (res) = Vec64x61_cross(a, b)
-    return (res)
-end
-
-@view
-func Vec64x61_norm_test {range_check_ptr} (a: (felt, felt, felt)) -> (res: felt):
-    let (res) = Vec64x61_norm(a)
-    return (res)
-end
\ No newline at end of file
diff --git a/package.json b/package.json
index 3d3b50c..9549dc8 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@influenceth/cairo-math-64x61",
-  "version": "1.2.0",
+  "version": "1.3.0",
   "description": "Fixed point 64.61 math library for Cairo / Starknet",
   "repository": {
     "type": "git",
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..09a7495
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,30 @@
+[project]
+name = "cairo_math_64x61"
+version = "1.3.0"
+authors = [
+  { name="Unstoppable Games, Inc.", email="info@unstoppablegames.io" },
+]
+description = "Fixed point 64.61 math library for Cairo / Starknet"
+license = { file="LICENSE" }
+readme = "README.md"
+requires-python = ">=3.7"
+classifiers = [
+    "Programming Language :: Python :: 3",
+    "License :: OSI Approved :: MIT License",
+    "Operating System :: OS Independent",
+]
+
+[project.urls]
+"Homepage" = "https://github.com/influenceth/cairo-math-64x61"
+"Bug Tracker" = "https://github.com/influenceth/cairo-math-64x61/issues"
+
+[build-system]
+requires = ["setuptools>=61.0"]
+build-backend = "setuptools.build_meta"
+
+[tool.setuptools.packages.find]
+where = [ "contracts" ]
+include = [ "cairo_math_64x61" ]
+
+[tool.setuptools.package-data]
+cairo_math_64x61 = [ "*.cairo" ]
\ No newline at end of file


Test patch:
diff --git a/test/hyp64x61.spec.js b/test/hyp64x61.spec.js
index 0398dc1..897c016 100644
--- a/test/hyp64x61.spec.js
+++ b/test/hyp64x61.spec.js
@@ -13,7 +13,7 @@ describe('64.61 fixed point hyperbolic functions', function () {
   let contract;
 
   before(async () => {
-    const contractFactory = await starknet.getContractFactory('Hyp64x61Mock');
+    const contractFactory = await starknet.getContractFactory('cairo_math_64x61/hyp64x61_mock');
     contract = await contractFactory.deploy();
   });
 
@@ -21,7 +21,7 @@ describe('64.61 fixed point hyperbolic functions', function () {
     const xs = [ -10 , -2, -1, -0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75, 1, 2, 10 ];
 
     for (const x of xs) {
-      const { res } = await contract.call('Hyp64x61_sinh_test', { x: to64x61(x) });
+      const { res } = await contract.call('hyp64x61_sinh_test', { x: to64x61(x) });
       const exp = Math.sinh(x);
       expect(almost(from64x61(res), exp, ABS_TOL, REL_TOL), `${from64x61(res)} != ${exp}`).to.be.true;
     }
@@ -31,7 +31,7 @@ describe('64.61 fixed point hyperbolic functions', function () {
     const xs = [ -10 , -2, -1, -0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75, 1, 2, 10 ];
 
     for (const x of xs) {
-      const { res } = await contract.call('Hyp64x61_cosh_test', { x: to64x61(x) });
+      const { res } = await contract.call('hyp64x61_cosh_test', { x: to64x61(x) });
       const exp = Math.cosh(x);
       expect(almost(from64x61(res), exp, ABS_TOL, REL_TOL), `${from64x61(res)} != ${exp}`).to.be.true;
     }
@@ -41,7 +41,7 @@ describe('64.61 fixed point hyperbolic functions', function () {
     const xs = [ -10 , -2, -1, -0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75, 1, 2, 10 ];
 
     for (const x of xs) {
-      const { res } = await contract.call('Hyp64x61_tanh_test', { x: to64x61(x) });
+      const { res } = await contract.call('hyp64x61_tanh_test', { x: to64x61(x) });
       const exp = Math.tanh(x);
       expect(almost(from64x61(res), exp, ABS_TOL, REL_TOL), `${from64x61(res)} != ${exp}`).to.be.true;
     }
@@ -51,7 +51,7 @@ describe('64.61 fixed point hyperbolic functions', function () {
     const xs = [ -10 , -2, -1, -0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75, 1, 2, 10 ];
 
     for (const x of xs) {
-      const { res } = await contract.call('Hyp64x61_asinh_test', { x: to64x61(x) });
+      const { res } = await contract.call('hyp64x61_asinh_test', { x: to64x61(x) });
       const exp = Math.asinh(x);
       expect(almost(from64x61(res), exp, ABS_TOL, REL_TOL), `${from64x61(res)} != ${exp}`).to.be.true;
     }
@@ -61,7 +61,7 @@ describe('64.61 fixed point hyperbolic functions', function () {
     const xs = [ 1, 1.5, 2, 4, 10 ];
 
     for (const x of xs) {
-      const { res } = await contract.call('Hyp64x61_acosh_test', { x: to64x61(x) });
+      const { res } = await contract.call('hyp64x61_acosh_test', { x: to64x61(x) });
       const exp = Math.acosh(x);
       expect(almost(from64x61(res), exp, ABS_TOL, REL_TOL), `${from64x61(res)} != ${exp}`).to.be.true;
     }
@@ -71,7 +71,7 @@ describe('64.61 fixed point hyperbolic functions', function () {
     const xs = [ -0.95, -0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75, 0.95 ];
 
     for (const x of xs) {
-      const { res } = await contract.call('Hyp64x61_atanh_test', { x: to64x61(x) });
+      const { res } = await contract.call('hyp64x61_atanh_test', { x: to64x61(x) });
       const exp = Math.atanh(x);
       expect(almost(from64x61(res), exp, ABS_TOL, REL_TOL), `${from64x61(res)} != ${exp}`).to.be.true;
     }
diff --git a/test/math64x61.spec.js b/test/math64x61.spec.js
index 1e7a852..ddfffdc 100644
--- a/test/math64x61.spec.js
+++ b/test/math64x61.spec.js
@@ -13,7 +13,7 @@ describe('64.61 fixed point math', function () {
   let contract;
 
   before(async () => {
-    const contractFactory = await starknet.getContractFactory('Math64x61Mock');
+    const contractFactory = await starknet.getContractFactory('cairo_math_64x61/math64x61_mock');
     contract = await contractFactory.deploy();
   });
 
@@ -22,7 +22,7 @@ describe('64.61 fixed point math', function () {
     const xs = Array.from({ length: count }, () => Math.random() * 2 ** 32 - 2 ** 31);
 
     for (const x of xs) {
-      const { res } = await contract.call('Math64x61_floor_test', { x: to64x61(x) });
+      const { res } = await contract.call('math64x61_floor_test', { x: to64x61(x) });
       const exp = Math.floor(x);
       expect(from64x61(res)).to.eq(exp);
     }
@@ -33,7 +33,7 @@ describe('64.61 fixed point math', function () {
     const xs = Array.from({ length: count }, () => Math.random() * 2 ** 32 - 2 ** 31);
 
     for (const x of xs) {
-      const { res } = await contract.call('Math64x61_ceil_test', { x: to64x61(x) });
+      const { res } = await contract.call('math64x61_ceil_test', { x: to64x61(x) });
       const exp = Math.ceil(x);
       expect(from64x61(res)).to.eq(exp);
     }
@@ -46,7 +46,7 @@ describe('64.61 fixed point math', function () {
 
     for (const [ i, x ] of xs.entries()) {
       const y = ys[i];
-      const { res } = await contract.call('Math64x61_min_test', { x: to64x61(x), y: to64x61(y) });
+      const { res } = await contract.call('math64x61_min_test', { x: to64x61(x), y: to64x61(y) });
       const exp = Math.min(x, y);
       expect(from64x61(res)).to.eq(exp);
     }
@@ -59,7 +59,7 @@ describe('64.61 fixed point math', function () {
 
     for (const [ i, x ] of xs.entries()) {
       const y = ys[i];
-      const { res } = await contract.call('Math64x61_max_test', { x: to64x61(x), y: to64x61(y) });
+      const { res } = await contract.call('math64x61_max_test', { x: to64x61(x), y: to64x61(y) });
       const exp = Math.max(x, y);
       expect(from64x61(res)).to.eq(exp);
     }
@@ -72,7 +72,7 @@ describe('64.61 fixed point math', function () {
 
     for (const [ i, x ] of xs.entries()) {
       const y = ys[i];
-      const { res } = await contract.call('Math64x61_mul_test', {
+      const { res } = await contract.call('math64x61_mul_test', {
         x: to64x61(x),
         y: to64x61(y)
       });
@@ -89,7 +89,7 @@ describe('64.61 fixed point math', function () {
 
     for (const [ i, x ] of xs.entries()) {
       const y = ys[i];
-      const { res } = await contract.call('Math64x61_div_test', {
+      const { res } = await contract.call('math64x61_div_test', {
         x: to64x61(x),
         y: to64x61(y)
       });
@@ -105,7 +105,7 @@ describe('64.61 fixed point math', function () {
 
     for (const [ i, x ] of xs.entries()) {
       const y = ys[i];
-      const { res } = await contract.call('Math64x61_pow_test', {
+      const { res } = await contract.call('math64x61_pow_test', {
         x: to64x61(x),
         y: to64x61(y)
       });
@@ -119,7 +119,7 @@ describe('64.61 fixed point math', function () {
     const xs = [ 1, 64, 2 ** 32, 7.21 ** 2 ];
 
     for (const x of xs) {
-      const { res } = await contract.call('Math64x61_sqrt_test', { x: to64x61(x) });
+      const { res } = await contract.call('math64x61_sqrt_test', { x: to64x61(x) });
       const exp = Math.sqrt(x);
       expect(almost(from64x61(res), exp, ABS_TOL, REL_TOL), `${from64x61(res)} != ${exp}`).to.be.true;
     }
@@ -129,7 +129,7 @@ describe('64.61 fixed point math', function () {
     const xs = [ 0, 1, 3, 5.5, -1, -5.5 ];
 
     for (const x of xs) {
-      const { res } = await contract.call('Math64x61_exp2_test', { x: to64x61(x) });
+      const { res } = await contract.call('math64x61_exp2_test', { x: to64x61(x) });
       const exp = 2 ** x;
       expect(almost(from64x61(res), exp, ABS_TOL, REL_TOL), `${from64x61(res)} != ${exp}`).to.be.true;
     }
@@ -139,7 +139,7 @@ describe('64.61 fixed point math', function () {
     const xs = [ 0.5, 0.75, 1, 2, 5, 72.11 ];
 
     for (const x of xs) {
-      const { res } = await contract.call('Math64x61_log2_test', { x: to64x61(x) });
+      const { res } = await contract.call('math64x61_log2_test', { x: to64x61(x) });
       const exp = Math.log2(x);
       expect(almost(from64x61(res), exp, ABS_TOL, REL_TOL), `${from64x61(res)} != ${exp}`).to.be.true;
     }
@@ -149,7 +149,7 @@ describe('64.61 fixed point math', function () {
     const xs = [ 0.5, 1, Math.E, 5, 72.11 ];
 
     for (const x of xs) {
-      const { res } = await contract.call('Math64x61_ln_test', { x: to64x61(x) });
+      const { res } = await contract.call('math64x61_ln_test', { x: to64x61(x) });
       const exp = Math.log(x);
       expect(almost(from64x61(res), exp, ABS_TOL, REL_TOL), `${from64x61(res)} != ${exp}`).to.be.true;
     }
@@ -159,7 +159,7 @@ describe('64.61 fixed point math', function () {
     const xs = [ 0.5, 1, 2, 10, 72.11 ];
 
     for (const x of xs) {
-      const { res } = await contract.call('Math64x61_log10_test', { x: to64x61(x) });
+      const { res } = await contract.call('math64x61_log10_test', { x: to64x61(x) });
       const exp = Math.log10(x);
       expect(almost(from64x61(res), exp, ABS_TOL, REL_TOL), `${from64x61(res)} != ${exp}`).to.be.true;
     }
diff --git a/test/trig64x61.spec.js b/test/trig64x61.spec.js
index 724c55d..19e85aa 100644
--- a/test/trig64x61.spec.js
+++ b/test/trig64x61.spec.js
@@ -13,7 +13,7 @@ describe('64.61 fixed point trigonometric functions', function () {
   let contract;
 
   before(async () => {
-    const contractFactory = await starknet.getContractFactory('Trig64x61Mock');
+    const contractFactory = await starknet.getContractFactory('cairo_math_64x61/trig64x61_mock');
     contract = await contractFactory.deploy();
   });
 
@@ -21,7 +21,7 @@ describe('64.61 fixed point trigonometric functions', function () {
     const xs = [ -2.25, -2, -1.75, -1.5, -1.25, -1, -0.75, -0.5, -0.25 ];
 
     for (const x of xs) {
-      const { res } = await contract.call('Trig64x61_sin_test', { x: toFelt(PI.times(x)) });
+      const { res } = await contract.call('trig64x61_sin_test', { x: toFelt(PI.times(x)) });
       const exp = Math.sin(x * Math.PI);
       expect(almost(from64x61(res), exp, ABS_TOL, REL_TOL), `${from64x61(res)} != ${exp}`).to.be.true;
     }
@@ -31,7 +31,7 @@ describe('64.61 fixed point trigonometric functions', function () {
     const xs = [ 0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.25 ];
 
     for (const x of xs) {
-      const { res } = await contract.call('Trig64x61_sin_test', { x: toFelt(PI.times(x)) });
+      const { res } = await contract.call('trig64x61_sin_test', { x: toFelt(PI.times(x)) });
       const exp = Math.sin(x * Math.PI);
       expect(almost(from64x61(res), exp, ABS_TOL, REL_TOL), `${from64x61(res)} != ${exp}`).to.be.true;
     }
@@ -41,7 +41,7 @@ describe('64.61 fixed point trigonometric functions', function () {
     const xs = [ -2.25, -2, -1.75, -1.5, -1.25, -1, -0.75, -0.5, -0.25 ];
 
     for (const x of xs) {
-      const { res } = await contract.call('Trig64x61_cos_test', { x: toFelt(PI.times(x)) });
+      const { res } = await contract.call('trig64x61_cos_test', { x: toFelt(PI.times(x)) });
       const exp = Math.cos(x * Math.PI);
       expect(almost(from64x61(res), exp, ABS_TOL, REL_TOL), `${from64x61(res)} != ${exp}`).to.be.true;
     }
@@ -51,7 +51,7 @@ describe('64.61 fixed point trigonometric functions', function () {
     const xs = [ 0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.25 ];
 
     for (const x of xs) {
-      const { res } = await contract.call('Trig64x61_cos_test', { x: toFelt(PI.times(x)) });
+      const { res } = await contract.call('trig64x61_cos_test', { x: toFelt(PI.times(x)) });
       const exp = Math.cos(x * Math.PI);
       expect(almost(from64x61(res), exp, ABS_TOL, REL_TOL), `${from64x61(res)} != ${exp}`).to.be.true;
     }
@@ -61,7 +61,7 @@ describe('64.61 fixed point trigonometric functions', function () {
     const xs = [ -2.25, -2, -1.75, -1.25, -1, -0.75, -0.25 ];
 
     for (const x of xs) {
-      const { res } = await contract.call('Trig64x61_tan_test', { x: toFelt(PI.times(x)) });
+      const { res } = await contract.call('trig64x61_tan_test', { x: toFelt(PI.times(x)) });
       const exp = Math.tan(x * Math.PI);
       expect(almost(from64x61(res), exp, ABS_TOL, REL_TOL), `${from64x61(res)} != ${exp}`).to.be.true;
     }
@@ -71,7 +71,7 @@ describe('64.61 fixed point trigonometric functions', function () {
     const xs = [ 0, 0.25, 0.75, 1, 1.25, 1.75, 2, 2.25 ];
 
     for (const x of xs) {
-      const { res } = await contract.call('Trig64x61_tan_test', { x: toFelt(PI.times(x)) });
+      const { res } = await contract.call('trig64x61_tan_test', { x: toFelt(PI.times(x)) });
       const exp = Math.tan(x * Math.PI);
       expect(almost(from64x61(res), exp, ABS_TOL, REL_TOL), `${from64x61(res)} != ${exp}`).to.be.true;
     }
@@ -81,7 +81,7 @@ describe('64.61 fixed point trigonometric functions', function () {
     const xs = [ -1.5, -1 , -0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75, 1 ];
 
     for (const x of xs) {
-      const { res } = await contract.call('Trig64x61_atan_test', { x: to64x61(x) });
+      const { res } = await contract.call('trig64x61_atan_test', { x: to64x61(x) });
       const exp = Math.atan(x);
       expect(almost(from64x61(res), exp, ABS_TOL, REL_TOL), `${from64x61(res)} != ${exp}`).to.be.true;
     }
@@ -91,7 +91,7 @@ describe('64.61 fixed point trigonometric functions', function () {
     const xs = [ -1 , -0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75, 1 ];
 
     for (const x of xs) {
-      const { res } = await contract.call('Trig64x61_asin_test', { x: to64x61(x) });
+      const { res } = await contract.call('trig64x61_asin_test', { x: to64x61(x) });
       const exp = Math.asin(x);
       expect(almost(from64x61(res), exp, ABS_TOL, REL_TOL), `${from64x61(res)} != ${exp}`).to.be.true;
     }
@@ -101,7 +101,7 @@ describe('64.61 fixed point trigonometric functions', function () {
     const xs = [ -1 , -0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75, 1 ];
 
     for (const x of xs) {
-      const { res } = await contract.call('Trig64x61_acos_test', { x: to64x61(x) });
+      const { res } = await contract.call('trig64x61_acos_test', { x: to64x61(x) });
       const exp = Math.acos(x);
       expect(almost(from64x61(res), exp, ABS_TOL, REL_TOL), `${from64x61(res)} != ${exp}`).to.be.true;
     }
diff --git a/test/vec64x61.spec.js b/test/vec64x61.spec.js
index b26129f..f63b0f9 100644
--- a/test/vec64x61.spec.js
+++ b/test/vec64x61.spec.js
@@ -21,7 +21,7 @@ describe('64.61 vector math functions', function () {
   let contract;
 
   before(async () => {
-    const contractFactory = await starknet.getContractFactory('Vec64x61Mock');
+    const contractFactory = await starknet.getContractFactory('cairo_math_64x61/vec64x61_mock');
     contract = await contractFactory.deploy();
   });
 
@@ -32,7 +32,7 @@ describe('64.61 vector math functions', function () {
 
     for (const [ i, a ] of as.entries()) {
       const { res } = await contract.call(
-        'Vec64x61_add_test',
+        'vec64x61_add_test',
         { a: a.map((v) => to64x61(v)), b: bs[i].map((v) => to64x61(v)) }
       );
 
@@ -50,7 +50,7 @@ describe('64.61 vector math functions', function () {
 
     for (const [ i, a ] of as.entries()) {
       const { res } = await contract.call(
-        'Vec64x61_sub_test',
+        'vec64x61_sub_test',
         { a: a.map((v) => to64x61(v)), b: bs[i].map((v) => to64x61(v)) }
       );
 
@@ -68,7 +68,7 @@ describe('64.61 vector math functions', function () {
 
     for (const [ i, a ] of as.entries()) {
       const { res } = await contract.call(
-        'Vec64x61_mul_test',
+        'vec64x61_mul_test',
         { a: a.map((v) => to64x61(v)), b: to64x61(bs[i]) }
       );
 
@@ -86,7 +86,7 @@ describe('64.61 vector math functions', function () {
 
     for (const [ i, a ] of as.entries()) {
       const { res } = await contract.call(
-        'Vec64x61_dot_test',
+        'vec64x61_dot_test',
         { a: a.map((v) => to64x61(v)), b: bs[i].map((v) => to64x61(v)) }
       );
 
@@ -102,7 +102,7 @@ describe('64.61 vector math functions', function () {
 
     for (const [ i, a ] of as.entries()) {
       const { res } = await contract.call(
-        'Vec64x61_cross_test',
+        'vec64x61_cross_test',
         { a: a.map((v) => to64x61(v)), b: bs[i].map((v) => to64x61(v)) }
       );
 
@@ -119,7 +119,7 @@ describe('64.61 vector math functions', function () {
     const as = Array.from({ length: count }, () => randVec3(-(2 ** 32), 2 ** 32))
 
     for (let a of as) {
-      const { res } = await contract.call('Vec64x61_norm_test', { a: a.map((v) => to64x61(v)) });
+      const { res } = await contract.call('vec64x61_norm_test', { a: a.map((v) => to64x61(v)) });
       const exp = Math.hypot(...a);
       expect(almost(from64x61(res), exp, ABS_TOL, REL_TOL), `${from64x61(res)} != ${exp}`).to.be.true;
     }