@cheny56/zk-client
v1.0.0
Published
A simple client SDK for interacting with ZK-enhanced features in PQC-Quorum.
Readme
ZK Client SDK
A simple client SDK for interacting with ZK-enhanced features in PQC-Quorum.
Overview
This SDK provides utilities for:
- Sending ZK-enhanced transactions
- Verifying ZK proofs
- Querying ZK transaction status
- Managing verification keys
Structure
zk-client/
├── js/ # JavaScript/TypeScript SDK
│ ├── index.js # Main SDK entry point
│ ├── zk-client.js # ZK RPC client
│ └── types.js # Type definitions
├── go/ # Go client library
│ └── client.go # Go ZK client
├── examples/ # Usage examples
│ ├── send-zk-tx.js # Send ZK transaction example
│ └── verify-proof.js # Verify proof example
└── README.md # This fileQuick Start
JavaScript
const { ZKClient } = require('./js');
// Connect to node
const client = new ZKClient('http://localhost:8545');
// Check if ZK is enabled
const enabled = await client.isZKEnabled();
console.log('ZK enabled:', enabled);
// Get supported proof systems
const systems = await client.getSupportedProofSystems();
console.log('Supported systems:', systems);
// Send a ZK transaction
const txHash = await client.sendZKTransaction({
from: '0x...',
to: '0x...',
zkProofSystem: 1, // Groth16
zkProof: '0x...',
zkPublicInputs: ['0x...'],
zkVerificationKeyHash: '0x...'
});Go
import "github.com/ethereum/go-ethereum/zk-client/go"
client, _ := zkclient.NewClient("http://localhost:8545")
// Check if ZK is enabled
enabled, _ := client.IsZKEnabled(context.Background())
// Send ZK transaction
txHash, _ := client.SendZKTransaction(context.Background(), zkclient.ZKTxArgs{
From: common.HexToAddress("0x..."),
To: &toAddr,
ZKProofSystem: zkclient.Groth16,
ZKProof: proofBytes,
})Proof Systems
| ID | Name | Description | Status | |----|------|-------------|--------| | 1 | Groth16 | ZK-SNARK over BN256 | ✅ Enabled | | 2 | PLONK | Universal SNARK | 🚧 Coming soon | | 3 | STARK | Transparent, PQ-secure | 🚧 Coming soon |
API Reference
JavaScript SDK
ZKClient(rpcUrl)
Create a new ZK client instance.
client.isZKEnabled(blockNumber?)
Check if ZK precompiles are enabled at the given block.
client.getSupportedProofSystems()
Get list of supported ZK proof systems.
client.sendZKTransaction(args)
Send a ZK-enhanced transaction.
client.sendRawZKTransaction(signedTx, args)
Send a pre-signed ZK transaction.
client.verifyProof(args)
Verify a ZK proof off-chain.
client.getZKTransactionInfo(txHash)
Get detailed information about a ZK transaction.
client.estimateZKGas(args)
Estimate gas for a ZK transaction.
ZK Identity Methods
client.getSupportedCredentialTypes()
Get list of supported credential types.
client.getSupportedPredicates()
Get list of supported predicates for selective disclosure.
client.createPresentationRequest(args)
Create a presentation request for credential verification.
const request = await client.createPresentationRequest({
verifier: '0x...',
credentialType: ZKClient.CredentialType.KYC,
predicates: [{
type: 'Comparison',
attribute: 'kycLevel',
operator: '>=',
value: '0x02'
}],
trustedIssuers: ['0x...'],
expiresInSeconds: 300
});client.verifyCredentialProof(proof, predicates)
Verify a credential proof against predicates.
client.getPermissionLevel(account)
Get the permission level for an account.
Credential Types
| Code | Name | Description | |------|------|-------------| | 1 | Identity | Basic identity credential | | 2 | KYC | Know Your Customer verification | | 3 | Age | Age verification | | 4 | Membership | Organization membership | | 5 | Role | Role/permission credential | | 6 | Accreditation | Accredited investor/entity | | 255 | Custom | Custom credential type |
Permission Levels
| Level | Name | Description | |-------|------|-------------| | 0 | None | No permissions | | 1 | Read | Can read state | | 2 | Transact | Can send transactions | | 3 | ContractDeploy | Can deploy contracts | | 4 | Admin | Full admin access |
Configuration
The SDK requires a connection to a PQC-Quorum node with ZK features enabled.
Genesis Configuration
{
"config": {
"zkPrecompileBlock": 0
}
}Notes
- This SDK is in early development
- API may change as ZK features evolve
- Proof generation should be done off-chain using gnark or similar libraries
License
LGPL-3.0
