zk_dtypes is a stand-alone implementation of several NumPy dtype extensions used in Zero Knowledge.
Project description
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).
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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zk_dtypes-0.0.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: zk_dtypes-0.0.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 10.6 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0adafb9dee3d927eff393e01cfcc3a63df871f1e73e924c5a3ffbac7e1eb38f3
|
|
| MD5 |
ef9c254d3117e756175299d74298e911
|
|
| BLAKE2b-256 |
c528c63b920f38174cdb15d34c3702350ea6ec5344d9442aae331fd7d548b2a1
|
Provenance
The following attestation bundles were made for zk_dtypes-0.0.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish.yml on fractalyze/zk_dtypes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zk_dtypes-0.0.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
0adafb9dee3d927eff393e01cfcc3a63df871f1e73e924c5a3ffbac7e1eb38f3 - Sigstore transparency entry: 984991103
- Sigstore integration time:
-
Permalink:
fractalyze/zk_dtypes@b4c0e689266f61b65b04b6f45f508a43594169a3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/fractalyze
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b4c0e689266f61b65b04b6f45f508a43594169a3 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file zk_dtypes-0.0.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: zk_dtypes-0.0.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 10.4 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2188560c753ebab58b33f6df50067b1cbd9a6d7e3dd48c0b6372bd00cc3e4e0a
|
|
| MD5 |
4dce35dcee15f8b2491e9b4fe52d6392
|
|
| BLAKE2b-256 |
87dbd224c3fc98bfeff70be82d153626db20fa22ed2a087c9d70af4aab85a5c7
|
Provenance
The following attestation bundles were made for zk_dtypes-0.0.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
publish.yml on fractalyze/zk_dtypes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zk_dtypes-0.0.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
2188560c753ebab58b33f6df50067b1cbd9a6d7e3dd48c0b6372bd00cc3e4e0a - Sigstore transparency entry: 984991092
- Sigstore integration time:
-
Permalink:
fractalyze/zk_dtypes@b4c0e689266f61b65b04b6f45f508a43594169a3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/fractalyze
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b4c0e689266f61b65b04b6f45f508a43594169a3 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file zk_dtypes-0.0.4-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: zk_dtypes-0.0.4-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 794.9 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7671e199eed8127b1099ce1772c1ca6349c3a67a4314e95cfbc18f4590f3b640
|
|
| MD5 |
466c75ef10eeef5f52992f2861326526
|
|
| BLAKE2b-256 |
22488eef6375b3c18dd640abd8e003b9c926e9e573a64b67c8a075f11a89cc5b
|
Provenance
The following attestation bundles were made for zk_dtypes-0.0.4-cp313-cp313-macosx_11_0_arm64.whl:
Publisher:
publish.yml on fractalyze/zk_dtypes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zk_dtypes-0.0.4-cp313-cp313-macosx_11_0_arm64.whl -
Subject digest:
7671e199eed8127b1099ce1772c1ca6349c3a67a4314e95cfbc18f4590f3b640 - Sigstore transparency entry: 984991098
- Sigstore integration time:
-
Permalink:
fractalyze/zk_dtypes@b4c0e689266f61b65b04b6f45f508a43594169a3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/fractalyze
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b4c0e689266f61b65b04b6f45f508a43594169a3 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file zk_dtypes-0.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: zk_dtypes-0.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 10.6 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4e80e3e6ffd158c94c9f41fde9e9b8ab8910bc0bb83d029faf55fe8a9157827
|
|
| MD5 |
f8962eb49c92f88e516c62c9654e6247
|
|
| BLAKE2b-256 |
4cee5779a831c5541b1fc879d7ce295ffe872fa7814cee1e5aab19689ffa56f4
|
Provenance
The following attestation bundles were made for zk_dtypes-0.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish.yml on fractalyze/zk_dtypes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zk_dtypes-0.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
d4e80e3e6ffd158c94c9f41fde9e9b8ab8910bc0bb83d029faf55fe8a9157827 - Sigstore transparency entry: 984991090
- Sigstore integration time:
-
Permalink:
fractalyze/zk_dtypes@b4c0e689266f61b65b04b6f45f508a43594169a3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/fractalyze
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b4c0e689266f61b65b04b6f45f508a43594169a3 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file zk_dtypes-0.0.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: zk_dtypes-0.0.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 10.4 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
865f88917d78a156b7c3190f510b72577a06136726e28b4268434880ace6bf8f
|
|
| MD5 |
cca84da898daf190b1a8b1e9bd453897
|
|
| BLAKE2b-256 |
f578177132d1c87ea2ca57a03e323621de98020fec6c14cfe6241444a761ff53
|
Provenance
The following attestation bundles were made for zk_dtypes-0.0.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
publish.yml on fractalyze/zk_dtypes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zk_dtypes-0.0.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
865f88917d78a156b7c3190f510b72577a06136726e28b4268434880ace6bf8f - Sigstore transparency entry: 984991096
- Sigstore integration time:
-
Permalink:
fractalyze/zk_dtypes@b4c0e689266f61b65b04b6f45f508a43594169a3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/fractalyze
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b4c0e689266f61b65b04b6f45f508a43594169a3 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file zk_dtypes-0.0.4-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: zk_dtypes-0.0.4-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 794.9 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9281b0e87372d2a1124142295d151f5aa830e154afe1e09bf866fb58d08055a
|
|
| MD5 |
236f286577426e7c4b4ffd116ec3da34
|
|
| BLAKE2b-256 |
c4e88dc6f88acb7a8a023abaf529d1e67a9c034366048e8028cd0341eecbb402
|
Provenance
The following attestation bundles were made for zk_dtypes-0.0.4-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
publish.yml on fractalyze/zk_dtypes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zk_dtypes-0.0.4-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
a9281b0e87372d2a1124142295d151f5aa830e154afe1e09bf866fb58d08055a - Sigstore transparency entry: 984991082
- Sigstore integration time:
-
Permalink:
fractalyze/zk_dtypes@b4c0e689266f61b65b04b6f45f508a43594169a3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/fractalyze
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b4c0e689266f61b65b04b6f45f508a43594169a3 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file zk_dtypes-0.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: zk_dtypes-0.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 10.6 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
397148e0c525860ad0bd31dbf4e3d411de2a30af4ff0ca5035111b0ed2f11ff7
|
|
| MD5 |
52875d7cef4a2c20c3c92cc421cb73fb
|
|
| BLAKE2b-256 |
cd7b113222d49656d382c11ad25f67d8be34b03dfb92816a415a0831422381ed
|
Provenance
The following attestation bundles were made for zk_dtypes-0.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish.yml on fractalyze/zk_dtypes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zk_dtypes-0.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
397148e0c525860ad0bd31dbf4e3d411de2a30af4ff0ca5035111b0ed2f11ff7 - Sigstore transparency entry: 984991085
- Sigstore integration time:
-
Permalink:
fractalyze/zk_dtypes@b4c0e689266f61b65b04b6f45f508a43594169a3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/fractalyze
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b4c0e689266f61b65b04b6f45f508a43594169a3 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file zk_dtypes-0.0.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: zk_dtypes-0.0.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 10.4 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61ff2a4189ee2063ee1915962d23743f80cbe76be0e11ae8a75d41153a8209db
|
|
| MD5 |
a1f45de5fc9b5a9ff3a05eef8e92cbb1
|
|
| BLAKE2b-256 |
ddc0aad03a4756b1eb2f675212494cbe511344ed8f9cb4c396aac05695758e7b
|
Provenance
The following attestation bundles were made for zk_dtypes-0.0.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
publish.yml on fractalyze/zk_dtypes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zk_dtypes-0.0.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
61ff2a4189ee2063ee1915962d23743f80cbe76be0e11ae8a75d41153a8209db - Sigstore transparency entry: 984991072
- Sigstore integration time:
-
Permalink:
fractalyze/zk_dtypes@b4c0e689266f61b65b04b6f45f508a43594169a3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/fractalyze
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b4c0e689266f61b65b04b6f45f508a43594169a3 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file zk_dtypes-0.0.4-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: zk_dtypes-0.0.4-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 794.5 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6104027379b7c31a6f458e9cd1f10d584fad6a3395a374a6f2cbcee9e7bb22b6
|
|
| MD5 |
38bdb67c959356116e7695fede223377
|
|
| BLAKE2b-256 |
ff0496b6595bdf567a09bb7e833ee80d04b6fbe344b047d0157c199716ba3dca
|
Provenance
The following attestation bundles were made for zk_dtypes-0.0.4-cp311-cp311-macosx_11_0_arm64.whl:
Publisher:
publish.yml on fractalyze/zk_dtypes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zk_dtypes-0.0.4-cp311-cp311-macosx_11_0_arm64.whl -
Subject digest:
6104027379b7c31a6f458e9cd1f10d584fad6a3395a374a6f2cbcee9e7bb22b6 - Sigstore transparency entry: 984991076
- Sigstore integration time:
-
Permalink:
fractalyze/zk_dtypes@b4c0e689266f61b65b04b6f45f508a43594169a3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/fractalyze
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b4c0e689266f61b65b04b6f45f508a43594169a3 -
Trigger Event:
workflow_dispatch
-
Statement type: