Skip to main content

zk_dtypes is a stand-alone implementation of several NumPy dtype extensions used in Zero Knowledge.

Project description

zk_dtypes

CI

zk_dtypes is a stand-alone implementation of several NumPy dtype extensions used in Zero Knowledge libraries inspired by ml_dtypes, including:

  • Narrow integer:

    • int2
    • int4
    • uint2
    • uint4
  • Field:

    • babybear
    • babybear_std
    • goldilocks
    • goldilocks_std
    • koalabear
    • koalabear_std
    • mersenne31
    • mersenne31_std
  • Elliptic curve:

    • bn254_sf
    • bn254_sf_std
    • bn254_g1_affine
    • bn254_g1_affine_std
    • bn254_g1_jacobian
    • bn254_g1_jacobian_std
    • bn254_g1_xyzz
    • bn254_g1_xyzz_std
    • bn254_g2_affine
    • bn254_g2_affine_std
    • bn254_g2_jacobian
    • bn254_g2_jacobian_std
    • bn254_g2_xyzz
    • bn254_g2_xyzz_std

Prerequisite

  1. Follow the bazel installation guide.

Build instructions

  1. Clone the zk_dtypes repo

    git clone https://github.com/fractalyze/zk_dtypes
    
  2. Build zk_dtypes

    bazel build //...
    
  3. Test zk_dtypes

    bazel test //...
    

Installation

The zk_dtypes package is tested with Python versions 3.9-3.12, and can be installed with the following command:

pip install zk_dtypes

To test your installation, you can run the following:

pip install absl-py pytest
pytest --pyargs zk_dtypes/tests

To build from source, clone the repository and run:

pip install .

Example Usage

>>> from zk_dtypes import babybear
>>> import numpy as np
>>> a = np.array([-1, -3, 2**30, 7], dtype=babybear)
>>> b = np.array([5, 2, 4, 10], dtype=babybear)
>>> a + b
array([4, 2013265920, 1073741828, 17], dtype=babybear)

Importing zk_dtypes also registers the data types with numpy, so that they may be referred to by their string name:

>>> np.dtype('babybear')
dtype(babybear)

License

The zk_dtypes source code is a modified derivative of the ml_dtypes project and inherits the original Apache 2.0 License (see LICENSE). All subsequent modifications comply with and are released under the same license.

Pre-compiled Wheels Dependencies

Note that pre-compiled wheels utilize the following dependencies:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

zk_dtypes-0.0.1-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (9.0 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

zk_dtypes-0.0.1-cp314-cp314t-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (8.8 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

zk_dtypes-0.0.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (8.9 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

zk_dtypes-0.0.1-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (8.7 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

zk_dtypes-0.0.1-cp314-cp314-macosx_15_0_arm64.whl (601.6 kB view details)

Uploaded CPython 3.14macOS 15.0+ ARM64

zk_dtypes-0.0.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (8.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

zk_dtypes-0.0.1-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (8.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

zk_dtypes-0.0.1-cp313-cp313-macosx_15_0_arm64.whl (601.9 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

zk_dtypes-0.0.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (8.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

zk_dtypes-0.0.1-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (8.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

zk_dtypes-0.0.1-cp312-cp312-macosx_15_0_arm64.whl (601.9 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

zk_dtypes-0.0.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (8.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

zk_dtypes-0.0.1-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (8.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

zk_dtypes-0.0.1-cp311-cp311-macosx_15_0_arm64.whl (601.4 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

File details

Details for the file zk_dtypes-0.0.1-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for zk_dtypes-0.0.1-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ebbe7ce84d6f28aebb10b1cb03bf080f9d764c9a2a68de8f4c33d4c20e3873b9
MD5 f15b3e9660d128be2371567644f5e51a
BLAKE2b-256 04bb37d1a63d0c360560e3a1f183fca2e6079ab647c0a4932ff53f8eada20dc9

See more details on using hashes here.

File details

Details for the file zk_dtypes-0.0.1-cp314-cp314t-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for zk_dtypes-0.0.1-cp314-cp314t-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5dbffbbda6788e28cc55602daf7b95923239bcb9991a784c639cccbf4acd74b2
MD5 61941cf83ff328112da5b8401ddabe20
BLAKE2b-256 2c7230a56ae0f676a75ba1619ab880069933127f99222b668f380a8f723d1504

See more details on using hashes here.

File details

Details for the file zk_dtypes-0.0.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for zk_dtypes-0.0.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 da5188a47c54c496ba8fc201d0726290b6c57f79c5ed6888bd709ca16812dc79
MD5 0a90d2a713d76d63589608d57722b893
BLAKE2b-256 043470b8b92497a426b392498ca5e3cb5e08ef4875558fc8ac5309dd78ecee7c

See more details on using hashes here.

File details

Details for the file zk_dtypes-0.0.1-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for zk_dtypes-0.0.1-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6b0add39581b6c32e31f457a361e941e1004fd532b0a6ec27525842b40ce4cd7
MD5 4c99e40e2c588fca91473b6b43befe80
BLAKE2b-256 30a84ef98023fbe5e62a260c8f990a36f4d3cbb5d7e8b3689a0d8e1a5e1ddb82

See more details on using hashes here.

File details

Details for the file zk_dtypes-0.0.1-cp314-cp314-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for zk_dtypes-0.0.1-cp314-cp314-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 38e0d7da4cce1b90105d2eafed3407e19d2553a843a07b496ad9a250f3ea913d
MD5 14c934c6bb3747b717d23638b5496d55
BLAKE2b-256 f2223fa9b2a5b38f92f2e79d6b5ce96788d7a78d8e349b3283cee1132831e876

See more details on using hashes here.

File details

Details for the file zk_dtypes-0.0.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for zk_dtypes-0.0.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d686faf4fa7d06b99e8059e65269791a7e61703511a813c9c52d3dca52c0c7cb
MD5 33917e01463cfd394814a67f718da754
BLAKE2b-256 b708f3e4aa64bd299959cc1da64d0caf192d6a56801447a4b134d612271fdf93

See more details on using hashes here.

File details

Details for the file zk_dtypes-0.0.1-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for zk_dtypes-0.0.1-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c529b10117545848dfa5c853f706662f5ca5e26c65fbb81fdaf173b1799c379e
MD5 f49f46249cb539c7a517e10311e00ab1
BLAKE2b-256 c2b56aa9e9e507949eb66dcddc4655d01d0aae39d9e9ecec8c45365a418ab338

See more details on using hashes here.

File details

Details for the file zk_dtypes-0.0.1-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for zk_dtypes-0.0.1-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 991c56e430cddd8ff4dbf55dc89bd6949855c1e3383767ac1e0815755cc1cedc
MD5 a5ecadec1c212251203c61e77d0a9f38
BLAKE2b-256 ce7facc0fa1f4ab6e43afb9067c74810291aa2ffc2f9277bef2937a49b6aaee6

See more details on using hashes here.

File details

Details for the file zk_dtypes-0.0.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for zk_dtypes-0.0.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 adfba0e753b00a53f0d60d482f99f42413e24c2bac214abc2d0de9b25fff4866
MD5 417c8f87fda771fd19460c66ef4f87fc
BLAKE2b-256 471ca9430fa43cc5fbed4dcfd3c639de0bf8f6cc5eb6260415546fd036b29d5b

See more details on using hashes here.

File details

Details for the file zk_dtypes-0.0.1-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for zk_dtypes-0.0.1-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 774718127980221e24df992a5ee512607031a076ea5363e7d4899174107e709d
MD5 ab57e836a944ae59dd9fc81b631580b5
BLAKE2b-256 01b79363014ace4b9c321f8d95e34e52490cf3400c181978445663f3c9df0752

See more details on using hashes here.

File details

Details for the file zk_dtypes-0.0.1-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for zk_dtypes-0.0.1-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 c12fd8ac45b0489d1806588ec8370333b0a69e2ecba1479a674135aedae28ebc
MD5 d9ff56bc6f7622a448ffee6e67b0b68c
BLAKE2b-256 6a16fec7989ff8745437584b97063efa677386f7ed486a796701d4f5cc36af93

See more details on using hashes here.

File details

Details for the file zk_dtypes-0.0.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for zk_dtypes-0.0.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 38674d7fbf38ed312c0e5e7ee946a725126cfb442772e21827471ae3905d401e
MD5 16a24bd8c8a438f7ac95713352d9d488
BLAKE2b-256 6b15d19208d05f894a6e4562168c28d9ca820a3e90ee24ecbe8f46e72fe1f90f

See more details on using hashes here.

File details

Details for the file zk_dtypes-0.0.1-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for zk_dtypes-0.0.1-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 66526028d812e820b48f90eaf973b135b8395961ad4e4f0d7b8493f4a1384840
MD5 c019e2e0343ea40fb7a35a404ab2325d
BLAKE2b-256 ed3196d6f93132dd86f3041234f0dcf488cd36e198d95e72f590f9addeced494

See more details on using hashes here.

File details

Details for the file zk_dtypes-0.0.1-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for zk_dtypes-0.0.1-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ff0d16a681d7d091b7771355e15157c8778778780eb2d7655624698f2e053a39
MD5 eb235c14022be00d72cd5a912f7fb37e
BLAKE2b-256 0cbf6bea310352c6c79f666a8ddf8aa92c824916821a0ad1bd603fb6c14e6675

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page