This repository contains a zero-knowledge proof system implementation that provides cryptographic proof capabilities for secure message exchange. The system allows a seller to prove they have encrypted a message for a buyer without revealing the message itself.
The ZK-Proof system implements cryptographic operations for:
- Generating and verifying zero-knowledge proofs
- Encrypting and decrypting messages
- Managing cryptographic keys
The system is available through both a gRPC API server and a command-line interface.
- Zero-Knowledge Proofs: Generate and verify proofs that demonstrate knowledge of a message without revealing it
- Secure Message Encryption: Encrypt messages using ECIES-like encryption with the secp256k1 curve
- Key Management: Generate, marshal, and unmarshal ECDSA key pairs
- Multi-Interface Access: Access functionality via HTTP/gRPC API or CLI
The system is structured as follows:
skavenge-zk-proof/
├── api/ # API implementation
│ ├── proto/ # Protocol buffer definitions
│ └── zkproof/ # Generated gRPC code
├── cmd/ # Command-line applications
│ ├── test/ # Test client
│ └── zkserver/ # Server implementation
├── zk/ # Core cryptographic functionality
- ProofSystem: Main component that handles all cryptographic operations
- Server: gRPC server that exposes the proof system functionality
- CLI: Command-line interface for direct interaction
The system provides the following gRPC endpoints:
| Endpoint | Description |
|---|---|
EncryptMessage |
Encrypts a message using a public key |
DecryptMessage |
Decrypts a message using a private key |
GeneratePartialProof |
Generates a partial proof for a transaction |
VerifyProof |
Verifies a proof for a transaction |
- The seller has a message and wants to transfer it to a buyer
- The seller encrypts the message for themselves (
sellerCipherText) - The seller encrypts the same message for the buyer (
buyerCipherText) - The system generates a proof that:
- The seller knows the original message
- Both ciphertexts encrypt the same message
- The buyer can decrypt their ciphertext to access the message
The verification process confirms that:
- The proof is mathematically valid (using elliptic curve operations)
- The seller ciphertext matches what was used in proof generation
- The buyer ciphertext hash matches what's stored in the proof
The system uses the following cryptographic primitives:
- Curve: secp256k1 (same as used in Bitcoin)
- Hash Function: Keccak-256 (SHA-3)
- Encryption: ECIES (Elliptic Curve Integrated Encryption Scheme)
- ZKP Method: Custom Schnorr-like signature scheme
- Go 1.17 or higher
- Protocol Buffers compiler (for development)
# Clone the repository
git clone https://github.com/deelawn/skavenge-zk-proof.git
cd skavenge-zk-proof
# Build the server
make build# Start the server with default configuration
./bin/zkserver
# Start with custom config
./bin/zkserver --config=/path/to/config.yamlThe server configuration can be customized in config.yaml:
server:
host: "0.0.0.0"
port: 8080
security:
readTimeout: 5s
writeTimeout: 10s
idleTimeout: 120sclient := zkproof.NewServiceClient(conn)
resp, err := client.EncryptMessage(context.Background(), &zkproof.EncryptMessageRequest{
Message: []byte("secret message"),
PubKey: publicKeyBytes,
})resp, err := client.GeneratePartialProof(context.Background(), &zkproof.GeneratePartialProofRequest{
Message: []byte("secret message"),
SellerPubKey: sellerPubKeyBytes,
BuyerPubKey: buyerPubKeyBytes,
SellerCipherText: sellerCipherTextBytes,
})resp, err := client.VerifyProof(context.Background(), &zkproof.VerifyProofRequest{
Proof: &zkproof.Proof{
C: c.String(),
S: s.String(),
R1: r1Bytes,
R2: r2Bytes,
BuyerPubKey: buyerPubKeyBytes,
SellerPubKey: sellerPubKeyBytes,
BuyerCipherHash: buyerCipherHashBytes,
},
SellerCipherText: sellerCipherTextBytes,
})The repository includes comprehensive tests for the core cryptographic functionality:
# Run all tests
make test
# Run specific tests
go test ./zk/...As outlined in the project plan:
- Add TLS support for the HTTP/gRPC server
- Implement authentication and authorization
- Add rate limiting for APIs
- Add metrics and monitoring
- Support for additional key formats
- Interactive CLI mode
See CONTRIBUTING.md for information on how to contribute to this project.
[Include license information here]