Name | luce-otp JSON |
Version |
0.1.1
JSON |
| download |
home_page | None |
Summary | A Python package for zero-knowledge OTP proof using Rust and Groth16 zk-SNARKs |
upload_time | 2024-10-07 13:08:57 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.6 |
license | MIT |
keywords |
zk-snark
otp
zero-knowledge
rust
python
maturin
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 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`:
```bash
pip install luce_otp
```
Ensure that you have Rust and Maturin installed in your environment. If not, you can install Rust using [rustup](https://rustup.rs/) and install Maturin with:
```bash
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.
```python
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).
```python
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.
```python
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:
```bash
pip install maturin
```
You also need to have Rust installed. You can install it by running:
```bash
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`:
```bash
maturin develop
```
### 3. Run Tests
You can write Python test scripts to test the functionality of the package. Here’s an example test script:
```python
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.
Raw data
{
"_id": null,
"home_page": null,
"name": "luce-otp",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "zk-SNARK, OTP, zero-knowledge, Rust, Python, Maturin",
"author": null,
"author_email": "Ankur Lohachab <ankur.lohachab@maastrichtuniversity.nl>",
"download_url": null,
"platform": null,
"description": "\n# luce_otp\n\n`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.\n\n**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.\n\n## Features\n\n- **Zero-Knowledge Proof**: Prove knowledge of a 20-bit OTP without revealing it.\n- **zk-SNARK**: Use zk-SNARKs (Groth16) for efficient proof generation and verification.\n- **Integration with Python**: Easily integrate Rust-powered zk-SNARKs into Python using PyO3 and Maturin.\n\n## Installation\n\nTo install the package, use `pip`:\n\n```bash\npip install luce_otp\n```\n\nEnsure that you have Rust and Maturin installed in your environment. If not, you can install Rust using [rustup](https://rustup.rs/) and install Maturin with:\n\n```bash\npip install maturin\n```\n\n## Usage\n\nHere\u2019s how you can use `luce_otp` to generate and verify zero-knowledge proofs for an OTP.\n\n### 1. Setup Parameters\n\nBefore generating or verifying proofs, you need to set up the proving and verification parameters. This step is done only once.\n\n```python\nimport luce_otp\n\n# This will generate the parameters and store them in 'params.bin' and 'vk.bin'\nluce_otp.setup_parameters()\n```\n\n### 2. Generate a Proof\n\nOnce 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).\n\n```python\notp = 123456 # Example OTP\nproof, public_inputs = luce_otp.generate_proof(otp)\n\n# 'proof' contains the generated zk-SNARK proof\n# 'public_inputs' contains the packed hash that will be verified\n```\n\n### 3. Verify the Proof\n\nTo 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.\n\n```python\nis_valid = luce_otp.verify_proof(proof, public_inputs)\nif is_valid:\n print(\"Proof is valid!\")\nelse:\n print(\"Proof is invalid!\")\n```\n\n## Testing\n\nTo ensure the correctness of the package, you can run basic tests by following these steps:\n\n### 1. Install Dependencies\n\nMake sure you have all the necessary Python dependencies installed in your environment:\n\n```bash\npip install maturin\n```\n\nYou also need to have Rust installed. You can install it by running:\n\n```bash\ncurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\n```\n\n### 2. Build and Install the Package Locally\n\nIf you're developing the package locally, you can build and install it into your virtual environment using `maturin`:\n\n```bash\nmaturin develop\n```\n\n### 3. Run Tests\n\nYou can write Python test scripts to test the functionality of the package. Here\u2019s an example test script:\n\n```python\nimport luce_otp\n\ndef test_luce_otp():\n # Set up parameters\n luce_otp.setup_parameters()\n\n # Generate proof\n otp = 123456\n proof, public_inputs = luce_otp.generate_proof(otp)\n\n # Verify proof\n is_valid = luce_otp.verify_proof(proof, public_inputs)\n assert is_valid, \"Proof verification failed.\"\n\n print(\"All tests passed.\")\n\nif __name__ == \"__main__\":\n test_luce_otp()\n```\n\n## Disclaimer\n\n**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.\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python package for zero-knowledge OTP proof using Rust and Groth16 zk-SNARKs",
"version": "0.1.1",
"project_urls": null,
"split_keywords": [
"zk-snark",
" otp",
" zero-knowledge",
" rust",
" python",
" maturin"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fed47e80bf4d8c09905d79e31dd3008bc9eca9feef29a9f9db36f4242ef0e1dc",
"md5": "cde97da5a50ae0b1404f48497ff74628",
"sha256": "360ac03a7fa733d80830b9af44a913b85512b16dde11332734a738f1b4da89f3"
},
"downloads": -1,
"filename": "luce_otp-0.1.1-cp311-cp311-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "cde97da5a50ae0b1404f48497ff74628",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.6",
"size": 516605,
"upload_time": "2024-10-07T13:08:57",
"upload_time_iso_8601": "2024-10-07T13:08:57.325337Z",
"url": "https://files.pythonhosted.org/packages/fe/d4/7e80bf4d8c09905d79e31dd3008bc9eca9feef29a9f9db36f4242ef0e1dc/luce_otp-0.1.1-cp311-cp311-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-07 13:08:57",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "luce-otp"
}