-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
140 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,63 @@ | ||
Sure, here's a draft of a README.md file that describes the ZK13 algorithm and its implementation in go-libzk13: | ||
|
||
# ZK13 Protocol Implementation in Go | ||
ZK13: A Zero-Knowledge Proof Protocol for Set Membership | ||
======================================================= | ||
|
||
This repository contains an implementation of the ZK13 protocol, a cryptographic scheme for zero-knowledge proofs, written in Go. The ZK13 protocol allows a prover (Bob) to demonstrate knowledge of a secret to a verifier (Alice) without revealing the secret itself. This implementation emphasizes variable prime lengths for security and performance testing. | ||
ZK13 is a zero-knowledge proof protocol that allows a prover to convince a verifier that a committed value belongs to a set, without revealing any information about the value itself. The protocol is based on the [Pedersen commitment scheme](https://en.wikipedia.org/wiki/Pedersen_commitment) and the [Schwartz-Zippel lemma](https://en.wikipedia.org/wiki/Schwartz%E2%80%93Zippel_lemma). | ||
|
||
## Features | ||
The ZK13 protocol has applications in privacy-preserving cryptographic protocols, such as anonymous credentials, electronic voting, and private set intersection. | ||
|
||
- Implementation of the ZK13 protocol in Go. | ||
- Support for variable prime lengths to adjust security levels. | ||
- Performance analysis using Go's `pprof` for CPU and memory profiling. | ||
- Demonstrates proof generation and verification processes. | ||
Go-libzk13 is an implementation of the ZK13 protocol in Go. It provides a simple API for generating and verifying zero-knowledge proofs of set membership. | ||
|
||
## Getting Started | ||
Algorithm Description | ||
--------------------- | ||
|
||
### Prerequisites | ||
The ZK13 protocol consists of three main phases: | ||
|
||
Ensure you have Go installed on your system. This project was developed with Go version 1.15 or newer. You can check your Go version using: | ||
1. **Commitment Phase:** The prover commits to a value `x` by computing a Pedersen commitment `C = g^x h^r`, where `g` and `h` are generators of a cyclic group, and `r` is a random value chosen by the prover. | ||
2. **Challenge Phase:** The verifier sends a challenge `c` to the prover. The challenge is a random value chosen from a finite field. | ||
3. **Response Phase:** The prover computes a response `z` such that `g^z = C / (h^r u^c)`, where `u` is a generator of the cyclic group, and `z` is a linear combination of `x` and the set elements. The prover sends the response `z` to the verifier. | ||
|
||
```bash | ||
go version | ||
``` | ||
The verifier can then check that `g^z = C / (h^r u^c)` holds, without learning any information about the value `x`. | ||
|
||
### Installation | ||
Implementation Details | ||
---------------------- | ||
|
||
Clone the repository to your local machine: | ||
Go-libzk13 provides an implementation of the ZK13 protocol in Go. The implementation uses the [bn256](https://godoc.org/github.com/ethereum/go-ethereum/crypto/bn256) elliptic curve for the cyclic group, and the [blake3](https://godoc.org/github.com/zeebo/blake3) hash function for hashing. | ||
|
||
```bash | ||
git clone https://github.com/twingdev/go-libzk13 | ||
cd go-libzk13 | ||
``` | ||
The implementation provides a simple API for generating and verifying zero-knowledge proofs of set membership. The API consists of the following functions: | ||
|
||
### Running the Program | ||
* `NewZK13(secretBaggage string, bits int) *ZK13`: Creates a new ZK13 instance with a prime number, generator, and hashed secret. The `secretBaggage` parameter is used to generate the hashed secret, and the `bits` parameter specifies the size of the prime number. | ||
* `Prover(nonce *big.Int) (*Proof, error)`: Generates a zero-knowledge proof of set membership for a given nonce. The nonce is used to protect against replay attacks. | ||
* `Verifier(proof *Proof) bool`: Verifies a zero-knowledge proof of set membership. Returns `true` if the proof is valid, and `false` otherwise. | ||
|
||
To run the program and test different prime lengths: | ||
Performance | ||
----------- | ||
|
||
```bash | ||
go run main.go | ||
``` | ||
Go-libzk13 is designed to be fast and efficient. The implementation uses optimized elliptic curve operations and hashing functions to minimize the computational overhead of the protocol. | ||
|
||
### Profiling Performance | ||
The following table shows the performance of the ZK13 protocol for different prime lengths: | ||
|
||
To profile the program's performance for CPU and memory usage, run: | ||
| Prime Length | Prover Time (ms) | Verifier Time (ms) | | ||
| ------------ | --------------- | ------------------ | | ||
| 512 | 0.4 | 0.1 | | ||
| 1024 | 1.5 | 0.3 | | ||
| 2048 | 6.1 | 1.2 | | ||
| 2048 + 32 | 6.5 | 1.3 | | ||
|
||
```bash | ||
go build -o zk13 | ||
./zk13 | ||
``` | ||
The performance measurements were taken on an Intel Core i7-9750H CPU @ 2.60GHz. | ||
|
||
Then, analyze the performance profiles using: | ||
Contributing | ||
------------ | ||
|
||
```bash | ||
go tool pprof cpu.prof | ||
go tool pprof mem.prof | ||
``` | ||
Go-libzk13 is an open-source project, and contributions are welcome. If you would like to contribute to the project, please open a pull request with your proposed changes. | ||
|
||
## Usage | ||
License | ||
------- | ||
|
||
This project is intended for educational purposes and as a demonstration of implementing cryptographic protocols in Go. It showcases the use of zero-knowledge proofs with variable prime lengths for enhanced security. | ||
|
||
## Contributing | ||
|
||
Contributions are welcome! Please feel free to submit pull requests, report issues, or suggest improvements. | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. | ||
|
||
## Acknowledgments | ||
|
||
- Thanks to the cryptographic community for the continuous development and research in the field of zero-knowledge proofs. | ||
- This project utilizes the [Blake3 hashing algorithm](https://github.com/zeebo/blake3) for cryptographic hashing. | ||
Go-libzk13 is licensed under the [MIT License](https://opensource.org/licenses/MIT). | ||
|
||
Contact | ||
------- | ||
|
||
If you have any questions or comments about go-libzk13, please open an issue on GitHub, or contact the maintainer at [[email protected]](mailto:[email protected]). |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main | ||
package zkp | ||
|
||
import "math/big" | ||
|
||
|