zk_dtypes
zk_dtypes is a stand-alone implementation of several NumPy dtype extensions
used in Zero Knowledge libraries inspired by
ml_dtypes, including:
-
Narrow integer:
int2int4uint2uint4
-
Prime Field:
babybearbabybear_montgoldilocksgoldilocks_montkoalabearkoalabear_montmersenne31
-
Extension Field:
babybearx4babybearx4_montgoldilocksx3goldilocksx3_montkoalabearx4koalabearx4_montmersenne31x2
-
Binary field:
binary_field_t0binary_field_t1binary_field_t2binary_field_t3binary_field_t4binary_field_t5binary_field_t6binary_field_t7
-
Elliptic curve:
bn254_sfbn254_sf_montbn254_g1_affinebn254_g1_affine_montbn254_g1_jacobianbn254_g1_jacobian_montbn254_g1_xyzzbn254_g1_xyzz_montbn254_g2_affinebn254_g2_affine_montbn254_g2_jacobianbn254_g2_jacobian_montbn254_g2_xyzzbn254_g2_xyzz_mont
Prerequisite
- Follow the bazel installation guide.
Build instructions
-
Clone the zk_dtypes repo
git clone https://github.com/fractalyze/zk_dtypes
-
Build zk_dtypes
bazel build //...
-
Test zk_dtypes
bazel test //...
Installation
The zk_dtypes package is tested with Python versions 3.11-3.13, 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 zk_dtypes/tests
Installation from source
To build and install the package from source, run:
pip install .
Installation from prebuilt binary
Use USE_BAZEL_OUTPUT=1 for a faster installation that uses pre-built Bazel
artifacts. This is the recommended path for development.
-
On Linux / macOS
# Build the shared library (.so) bazel build //zk_dtypes:_zk_dtypes_ext.so # Install using the Bazel output USE_BAZEL_OUTPUT=1 pip install .
-
On Windows
# Build the Python extension (.pyd) bazel build //zk_dtypes:_zk_dtypes_ext.pyd # Install using the Bazel output (PowerShell syntax) $env:USE_BAZEL_OUTPUT=1; pip install .
Example Usage
>>> from zk_dtypes import babybear_mont
>>> import numpy as np
>>> a = np.array([-1, -3, 2**30, 7], dtype=babybear_mont)
>>> b = np.array([5, 2, 4, 10], dtype=babybear_mont)
>>> a + b
array([4, 2013265920, 1073741828, 17], dtype=babybear_mont)
Importing zk_dtypes also registers the data types with numpy, so that they may
be referred to by their string name:
>>> np.dtype('babybear_mont')
dtype(babybear_mont)
See examples/zk_dtypes_examples.ipynb for more examples.
Benchmarks
Benchmarks are disabled by default (though CI verifies their validity). To
execute a specific benchmark (e.g., field_mul_benchmark), run the following
command manually:
bazel run -c opt //zk_dtypes:field_mul_benchmark
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:
- The EIGEN project, licensed under the MPL 2.0 license (see LICENSE.eigen).
- Chromium, licensed under the Free-BSD 3-Clause license (see LICENSE.chromium).
Metadata
Release files for zk-dtypes 0.0.17
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| zk_dtypes-0.0.17-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl | CPython 3.13 | CPython 3.13 | Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 | Details |
| zk_dtypes-0.0.17-cp313-cp313-macosx_11_0_arm64.whl | CPython 3.13 | CPython 3.13 | macOS 11.0+ ARM64 | Details |
| zk_dtypes-0.0.17-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 | Details |
| zk_dtypes-0.0.17-cp312-cp312-macosx_11_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 11.0+ ARM64 | Details |
| zk_dtypes-0.0.17-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl | CPython 3.11 | CPython 3.11 | Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 | Details |
| zk_dtypes-0.0.17-cp311-cp311-macosx_11_0_arm64.whl | CPython 3.11 | CPython 3.11 | macOS 11.0+ ARM64 | Details |
Total release size: 8.7 MB
Release files / zk_dtypes-0.0.17-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | zk_dtypes-0.0.17-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
0ef7f686122f0a5b555f5f6b73cf9b1ba0226876929bef2c8852ca244d2ba43d
|
|
BLAKE2b-256 checksum How to use checksums |
6b06be85fad8b3b7a9850e258d5588b7fb0c2bb08a272a462293cd6e8f57f2d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 22, 2026.
Transparency logRelease files / zk_dtypes-0.0.17-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | zk_dtypes-0.0.17-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e9c063f77f4b65886dca7fa619e73d88cc8a96196447e7fb80a9a3d5ac82cc20
|
|
BLAKE2b-256 checksum How to use checksums |
1e7c7eef89fc136d5e02f20bfc9414a5b1b9fc709d53c4bcecb0143d70d022fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 22, 2026.
Transparency logRelease files / zk_dtypes-0.0.17-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | zk_dtypes-0.0.17-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
6ed751f93bc1fbcc4a366fe52a151b19dc7d73c0e2f7ac94fe9c47ad27edf8b2
|
|
BLAKE2b-256 checksum How to use checksums |
eb84f46eb91da185effde463a5980e18e669c73af62e384e8dfc035cd2c77784
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 22, 2026.
Transparency logRelease files / zk_dtypes-0.0.17-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | zk_dtypes-0.0.17-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
a653d6d8391212c794295d426c5d17d5d86812eec4b853db3209d02ef94b3bd0
|
|
BLAKE2b-256 checksum How to use checksums |
4bfe8590d06665642c87f39dbd098a39704a5b6c5436c0ff98052a967a32b374
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 22, 2026.
Transparency logRelease files / zk_dtypes-0.0.17-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | zk_dtypes-0.0.17-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
c44ee3d4920eab319b7294f75fe85dd41671bfd088a34d3bc20d62ff22b810f3
|
|
BLAKE2b-256 checksum How to use checksums |
f87b8e52259e0f7a1b1414a38df1787563ac5ea7f149d57127d06d8db9d624bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 22, 2026.
Transparency logRelease files / zk_dtypes-0.0.17-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | zk_dtypes-0.0.17-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
13f21e420694265ced92e672fb11dd4de70395fa98dcedfb94cbb705cabd6c23
|
|
BLAKE2b-256 checksum How to use checksums |
1e646d0f4ee6e3126a9b91040f9b2920817aaa30db440f2384d13017cd5f2d30
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 22, 2026.
Transparency log