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
-
Field:
babybearbabybear_stdgoldilocksgoldilocks_stdkoalabearkoalabear_stdmersenne31mersenne31_std
-
Elliptic curve:
bn254_sfbn254_sf_stdbn254_g1_affinebn254_g1_affine_stdbn254_g1_jacobianbn254_g1_jacobian_stdbn254_g1_xyzzbn254_g1_xyzz_stdbn254_g2_affinebn254_g2_affine_stdbn254_g2_jacobianbn254_g2_jacobian_stdbn254_g2_xyzzbn254_g2_xyzz_std
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.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:
- 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.1-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: zk_dtypes-0.0.1-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 9.0 MB
- Tags: CPython 3.14t, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebbe7ce84d6f28aebb10b1cb03bf080f9d764c9a2a68de8f4c33d4c20e3873b9
|
|
| MD5 |
f15b3e9660d128be2371567644f5e51a
|
|
| BLAKE2b-256 |
04bb37d1a63d0c360560e3a1f183fca2e6079ab647c0a4932ff53f8eada20dc9
|
File details
Details for the file zk_dtypes-0.0.1-cp314-cp314t-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: zk_dtypes-0.0.1-cp314-cp314t-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 8.8 MB
- Tags: CPython 3.14t, manylinux: glibc 2.26+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5dbffbbda6788e28cc55602daf7b95923239bcb9991a784c639cccbf4acd74b2
|
|
| MD5 |
61941cf83ff328112da5b8401ddabe20
|
|
| BLAKE2b-256 |
2c7230a56ae0f676a75ba1619ab880069933127f99222b668f380a8f723d1504
|
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
- Download URL: zk_dtypes-0.0.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 8.9 MB
- Tags: CPython 3.14, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da5188a47c54c496ba8fc201d0726290b6c57f79c5ed6888bd709ca16812dc79
|
|
| MD5 |
0a90d2a713d76d63589608d57722b893
|
|
| BLAKE2b-256 |
043470b8b92497a426b392498ca5e3cb5e08ef4875558fc8ac5309dd78ecee7c
|
File details
Details for the file zk_dtypes-0.0.1-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: zk_dtypes-0.0.1-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 8.7 MB
- Tags: CPython 3.14, manylinux: glibc 2.26+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b0add39581b6c32e31f457a361e941e1004fd532b0a6ec27525842b40ce4cd7
|
|
| MD5 |
4c99e40e2c588fca91473b6b43befe80
|
|
| BLAKE2b-256 |
30a84ef98023fbe5e62a260c8f990a36f4d3cbb5d7e8b3689a0d8e1a5e1ddb82
|
File details
Details for the file zk_dtypes-0.0.1-cp314-cp314-macosx_15_0_arm64.whl.
File metadata
- Download URL: zk_dtypes-0.0.1-cp314-cp314-macosx_15_0_arm64.whl
- Upload date:
- Size: 601.6 kB
- Tags: CPython 3.14, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38e0d7da4cce1b90105d2eafed3407e19d2553a843a07b496ad9a250f3ea913d
|
|
| MD5 |
14c934c6bb3747b717d23638b5496d55
|
|
| BLAKE2b-256 |
f2223fa9b2a5b38f92f2e79d6b5ce96788d7a78d8e349b3283cee1132831e876
|
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
- Download URL: zk_dtypes-0.0.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 8.9 MB
- Tags: CPython 3.13, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d686faf4fa7d06b99e8059e65269791a7e61703511a813c9c52d3dca52c0c7cb
|
|
| MD5 |
33917e01463cfd394814a67f718da754
|
|
| BLAKE2b-256 |
b708f3e4aa64bd299959cc1da64d0caf192d6a56801447a4b134d612271fdf93
|
File details
Details for the file zk_dtypes-0.0.1-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: zk_dtypes-0.0.1-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 8.7 MB
- Tags: CPython 3.13, manylinux: glibc 2.26+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c529b10117545848dfa5c853f706662f5ca5e26c65fbb81fdaf173b1799c379e
|
|
| MD5 |
f49f46249cb539c7a517e10311e00ab1
|
|
| BLAKE2b-256 |
c2b56aa9e9e507949eb66dcddc4655d01d0aae39d9e9ecec8c45365a418ab338
|
File details
Details for the file zk_dtypes-0.0.1-cp313-cp313-macosx_15_0_arm64.whl.
File metadata
- Download URL: zk_dtypes-0.0.1-cp313-cp313-macosx_15_0_arm64.whl
- Upload date:
- Size: 601.9 kB
- Tags: CPython 3.13, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
991c56e430cddd8ff4dbf55dc89bd6949855c1e3383767ac1e0815755cc1cedc
|
|
| MD5 |
a5ecadec1c212251203c61e77d0a9f38
|
|
| BLAKE2b-256 |
ce7facc0fa1f4ab6e43afb9067c74810291aa2ffc2f9277bef2937a49b6aaee6
|
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
- Download URL: zk_dtypes-0.0.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 8.9 MB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
adfba0e753b00a53f0d60d482f99f42413e24c2bac214abc2d0de9b25fff4866
|
|
| MD5 |
417c8f87fda771fd19460c66ef4f87fc
|
|
| BLAKE2b-256 |
471ca9430fa43cc5fbed4dcfd3c639de0bf8f6cc5eb6260415546fd036b29d5b
|
File details
Details for the file zk_dtypes-0.0.1-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: zk_dtypes-0.0.1-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 8.6 MB
- Tags: CPython 3.12, manylinux: glibc 2.26+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
774718127980221e24df992a5ee512607031a076ea5363e7d4899174107e709d
|
|
| MD5 |
ab57e836a944ae59dd9fc81b631580b5
|
|
| BLAKE2b-256 |
01b79363014ace4b9c321f8d95e34e52490cf3400c181978445663f3c9df0752
|
File details
Details for the file zk_dtypes-0.0.1-cp312-cp312-macosx_15_0_arm64.whl.
File metadata
- Download URL: zk_dtypes-0.0.1-cp312-cp312-macosx_15_0_arm64.whl
- Upload date:
- Size: 601.9 kB
- Tags: CPython 3.12, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c12fd8ac45b0489d1806588ec8370333b0a69e2ecba1479a674135aedae28ebc
|
|
| MD5 |
d9ff56bc6f7622a448ffee6e67b0b68c
|
|
| BLAKE2b-256 |
6a16fec7989ff8745437584b97063efa677386f7ed486a796701d4f5cc36af93
|
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
- Download URL: zk_dtypes-0.0.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 8.9 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38674d7fbf38ed312c0e5e7ee946a725126cfb442772e21827471ae3905d401e
|
|
| MD5 |
16a24bd8c8a438f7ac95713352d9d488
|
|
| BLAKE2b-256 |
6b15d19208d05f894a6e4562168c28d9ca820a3e90ee24ecbe8f46e72fe1f90f
|
File details
Details for the file zk_dtypes-0.0.1-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: zk_dtypes-0.0.1-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 8.7 MB
- Tags: CPython 3.11, manylinux: glibc 2.26+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66526028d812e820b48f90eaf973b135b8395961ad4e4f0d7b8493f4a1384840
|
|
| MD5 |
c019e2e0343ea40fb7a35a404ab2325d
|
|
| BLAKE2b-256 |
ed3196d6f93132dd86f3041234f0dcf488cd36e198d95e72f590f9addeced494
|
File details
Details for the file zk_dtypes-0.0.1-cp311-cp311-macosx_15_0_arm64.whl.
File metadata
- Download URL: zk_dtypes-0.0.1-cp311-cp311-macosx_15_0_arm64.whl
- Upload date:
- Size: 601.4 kB
- Tags: CPython 3.11, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff0d16a681d7d091b7771355e15157c8778778780eb2d7655624698f2e053a39
|
|
| MD5 |
eb235c14022be00d72cd5a912f7fb37e
|
|
| BLAKE2b-256 |
0cbf6bea310352c6c79f666a8ddf8aa92c824916821a0ad1bd603fb6c14e6675
|