luce_otp
luce_otp is a Python extension module for generating and verifying zero-knowledge proofs (ZKP) for a one-time password (OTP) using Rust and zk-SNARKs. It leverages the Groth16 proving system to ensure privacy, allowing users to prove knowledge of an OTP without revealing the OTP itself.
Note: This package is intended for research purposes only and is not meant for use in production environments. Further testing is necessary to ensure its correctness, security, and performance.
Features
- Zero-Knowledge Proof: Prove knowledge of a 20-bit OTP without revealing it.
- zk-SNARK: Use zk-SNARKs (Groth16) for efficient proof generation and verification.
- Integration with Python: Easily integrate Rust-powered zk-SNARKs into Python using PyO3 and Maturin.
Installation
To install the package, use pip:
pip install luce_otp
Ensure that you have Rust and Maturin installed in your environment. If not, you can install Rust using rustup and install Maturin with:
pip install maturin
Usage
Here’s how you can use luce_otp to generate and verify zero-knowledge proofs for an OTP.
1. Setup Parameters
Before generating or verifying proofs, you need to set up the proving and verification parameters. This step is done only once.
import luce_otp
# This will generate the parameters and store them in 'params.bin' and 'vk.bin'
luce_otp.setup_parameters()
2. Generate a Proof
Once the parameters are set up, you can generate a zero-knowledge proof for a given OTP. The OTP should be a 20-bit number (i.e., between 0 and 999,999).
otp = 123456 # Example OTP
proof, public_inputs = luce_otp.generate_proof(otp)
# 'proof' contains the generated zk-SNARK proof
# 'public_inputs' contains the packed hash that will be verified
3. Verify the Proof
To verify the proof, pass both the proof and the public inputs to the verification function. The function returns True if the proof is valid, and False otherwise.
is_valid = luce_otp.verify_proof(proof, public_inputs)
if is_valid:
print("Proof is valid!")
else:
print("Proof is invalid!")
Testing
To ensure the correctness of the package, you can run basic tests by following these steps:
1. Install Dependencies
Make sure you have all the necessary Python dependencies installed in your environment:
pip install maturin
You also need to have Rust installed. You can install it by running:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
2. Build and Install the Package Locally
If you're developing the package locally, you can build and install it into your virtual environment using maturin:
maturin develop
3. Run Tests
You can write Python test scripts to test the functionality of the package. Here’s an example test script:
import luce_otp
def test_luce_otp():
# Set up parameters
luce_otp.setup_parameters()
# Generate proof
otp = 123456
proof, public_inputs = luce_otp.generate_proof(otp)
# Verify proof
is_valid = luce_otp.verify_proof(proof, public_inputs)
assert is_valid, "Proof verification failed."
print("All tests passed.")
if __name__ == "__main__":
test_luce_otp()
Disclaimer
Note: This package is designed for research purposes only and is not meant for use in production environments. The underlying cryptographic methods, though well-studied, have not been extensively tested in this implementation. Further testing is necessary to ensure that the library is secure, bug-free, and performant under different environments and workloads. Use this package with caution in critical systems.
Metadata
Release files for luce-otp 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| luce_otp-0.1.1-cp311-cp311-macosx_11_0_arm64.whl | CPython 3.11 | CPython 3.11 | macOS 11.0+ ARM64 | Details for luce_otp-0.1.1-cp311-cp311-macosx_11_0_arm64.whl |
Release files / luce_otp-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | luce_otp-0.1.1-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 516.6 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
360ac03a7fa733d80830b9af44a913b85512b16dde11332734a738f1b4da89f3
|
|
BLAKE2b-256 checksum How to use checksums |
fed47e80bf4d8c09905d79e31dd3008bc9eca9feef29a9f9db36f4242ef0e1dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.5
|
Security for luce-otp 0.1.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.