Complete guide to test and use CompZ SDK with real Zcash blockchain integration.
Test CompZ functionality without any blockchain setup:
# Install dependencies
cd /Users/satyamsinghal/Desktop/Products/CompZ
pip install -e .
# Test normalization and hashing
cd examples
python3 tamper_detection_demo.pyWhat this shows:
- β Deterministic JSON normalization
- β SHA-256 hash computation
- β Tampering detection logic
- β±οΈ Takes: 10 seconds
Test the full workflow with demo mode (no blockchain):
cd examples
python3 basic_usage.pyWhat this shows:
- β SDK client initialization
- β Data normalization
- β Hash computation
- β Full API flow (simulated)
- β±οΈ Takes: 30 seconds
Note: Demo mode shows the flow but doesn't use real blockchain (gateway endpoint not deployed yet).
Test with actual Zcash blockchain transactions:
# Run automated setup
./scripts/setup_testnet.sh
# Follow prompts to:
# 1. Start Zcash node
# 2. Generate z-address
# 3. Fund from faucet
# 4. Configure .env
# Run real blockchain test
cd examples
python3 self_hosted_example.pyWhat this shows:
- β Real Zcash node connection
- β Shielded transaction creation
- β Memo field storage
- β On-chain verification
- β Block explorer integration
- β±οΈ Takes: 2-4 hours (blockchain sync) + 5 minutes
cd /Users/satyamsinghal/Desktop/Products/CompZ
# Install in development mode
pip install -e .
# Verify installation
compz version
# Should output: CompZ SDK v1.0.0# Create test file: test_normalize.py
from compz.normalize import normalize_json
data = {
"b": 2,
"a": 1,
"_internal": "removed",
"empty": None
}
normalized = normalize_json(data)
print(normalized)
# Output: {"a":1,"b":2}Run:
python3 test_normalize.py# Create test file: test_hash.py
from compz.hash import hash_compliance, create_memo
data = {"repo_id": "test", "risk_score": 25.5}
hash_value = hash_compliance(data)
memo = create_memo(hash_value)
print(f"Hash: {hash_value}")
print(f"Memo: {memo}")
# Output:
# Hash: 0x...
# Memo: compz:v1:0x...Run:
python3 test_hash.pycd examples
python3 tamper_detection_demo.pyExpected output:
Original Hash: 0x3f7a2b8c...
Tampered Hash: 0x9d1e5f6a...
β TAMPERING DETECTED!
compz statusExpected output:
CompZ SDK Status
Version: 1.0.0
Mode: demo
Network: testnet
cd examples
compz anchor compliance_result.jsonExpected output:
π Loaded: compliance_result.json
π Size: 1234 bytes
π Using CompZ Demo Mode (testnet)
π Normalized data: 1234 bytes
π Hash: 0xabc123...
β
Successfully anchored!
Hash: 0xabc123...
TXID: [txid]
Network: testnet
Mode: demo
# Check Docker
docker --version
docker-compose --version
# Check disk space (need 100GB+)
df -h
# Check internet connection
ping -c 3 google.com# Start node
docker-compose up -d zcashd
# Check if running
docker ps
# View logs
docker logs -f compz-zcashd
# Press Ctrl+C to exit logs# Check sync status
docker exec compz-zcashd zcash-cli -testnet getblockchaininfo
# Look for these fields:
# "blocks": 2800000, <- Current block
# "headers": 2800000, <- Target block
# When blocks == headers, sync is complete!Sync times:
- Testnet: 2-4 hours
- Mainnet: 24-48 hours
# Generate Sapling shielded address
docker exec compz-zcashd zcash-cli -testnet z_getnewaddress sapling
# Save output, looks like:
# ztestsapling1abc123def456...xyz789- Visit: https://faucet.testnet.z.cash/
- Paste your z-address
- Complete CAPTCHA
- Click "Send"
- Wait 2-3 minutes
Check balance:
docker exec compz-zcashd zcash-cli -testnet z_getbalance "YOUR_ZADDR"
# Should show: 0.01 (or similar)# Copy example config
cp .env.example .env
# Edit .env file
nano .env
# Or use your preferred editorAdd these values:
ZCASH_RPC_URL=http://localhost:18232
ZCASH_RPC_USER=compz
ZCASH_RPC_PASS=compz_secure_password_change_this
ZCASH_DEFAULT_ADDRESS=ztestsapling1abc123...xyz789 # YOUR ADDRESS
ZCASH_TESTNET=truecd examples
python3 self_hosted_example.pyExpected output:
============================================================
CompZ SDK - Real Zcash Testnet Integration
============================================================
π Checking prerequisites...
β
All environment variables configured
============================================================
β
Self-Hosted Mode - Real Zcash Testnet
============================================================
β
Using self-hosted mode
π Network: testnet
π Mode: self-hosted
...
π‘ Sending shielded transaction to Zcash testnet...
...
β
SUCCESS - Anchored to Blockchain!
π Hash: 0xabc123...
π TXID: 9c8f7e6d5c4b3a2...
π Explorer: https://explorer.testnet.z.cash/tx/9c8f7e6d...
β
VERIFICATION SUCCESSFUL
- Copy the TXID from output
- Visit: https://explorer.testnet.z.cash/
- Paste TXID in search
- You should see your transaction!
Note: The memo is encrypted in shielded transactions. Only you (with viewing key) can read it.
# View transaction details (requires viewing key)
docker exec compz-zcashd zcash-cli -testnet z_viewtransaction YOUR_TXID
# Look for "memo" field in output
# Should contain: "636f6d707a3a76313a..." (hex-encoded "compz:v1:0x...")# Create test file: test_verify.py
from compz import CompZClient
import json
client = CompZClient()
# Original data
original = {"repo_id": "test", "risk_score": 25.5}
result = client.anchor(original)
# Try to verify with original data
verify1 = client.verify(original, result.txid)
print(f"Original data: {verify1.valid}") # Should be True
# Try to verify with modified data
modified = {"repo_id": "test", "risk_score": 5.0} # Changed!
verify2 = client.verify(modified, result.txid)
print(f"Modified data: {verify2.valid}") # Should be False# Create test workflow: test_ci.sh
#!/bin/bash
echo "Running compliance scan..."
# Your scan tool here
echo "Anchoring to blockchain..."
compz anchor compliance.json -o proof.json
TXID=$(jq -r '.txid' proof.json)
echo "Proof TXID: $TXID"
echo "Share this TXID with auditors for verification"- Install SDK:
pip install -e . - Run
compz version - Test normalization:
python3 test_normalize.py - Test hashing:
python3 test_hash.py - Run tampering demo:
python3 tamper_detection_demo.py - Test CLI status:
compz status
- Docker installed and running
- Start Zcash node:
docker-compose up -d - Node synced: blocks == headers
- Z-address generated
- Address funded (>0.001 ZEC)
-
.envconfigured - Run self-hosted example
- Transaction on block explorer
- Verification successful
Solution:
cd /Users/satyamsinghal/Desktop/Products/CompZ
pip install -e .Solution:
# Start Docker Desktop app
# Or on Linux:
sudo systemctl start dockerSolution:
# Check peers
docker exec compz-zcashd zcash-cli -testnet getpeerinfo | grep addr
# Should show multiple peers
# If not, restart:
docker-compose restart zcashdSolution:
# Check balance
docker exec compz-zcashd zcash-cli -testnet z_getbalance YOUR_ADDR
# If 0, get more from faucet:
# https://faucet.testnet.z.cash/Explanation: Memos are in shielded transactions. You need:
- The viewing key (automatic if you own the address)
- Use
z_viewtransactioncommand
docker exec compz-zcashd zcash-cli -testnet z_viewtransaction TXIDExplanation: Demo gateway is not deployed yet. Use self-hosted mode for real testing.
You know CompZ is working when:
- β Normalization works: Same data always produces same JSON
- β Hashing is deterministic: Same data always produces same hash
- β Tampering detected: Modified data fails verification
- β Transaction sent: Real TXID received
- β On block explorer: Transaction visible on chain
- β Verification passes: Original data matches on-chain hash
- β CLI works: All commands execute successfully
# Check status
compz status
# Anchor compliance data
compz anchor data.json
# Verify against blockchain
compz verify data.json TXID
# Check node status
docker exec compz-zcashd zcash-cli -testnet getinfo
# Check balance
docker exec compz-zcashd zcash-cli -testnet z_getbalance ADDR
# View logs
docker logs -f compz-zcashd
# Stop everything
docker-compose downfrom compz import CompZClient
# Initialize client
client = CompZClient() # Auto-detects mode
# Anchor data
result = client.anchor(compliance_data)
print(result.txid)
# Verify data
verified = client.verify(compliance_data, txid)
print(verified.valid)
# Check status
status = client.get_status()
print(status['mode'])After testing:
-
For Development:
- Integrate into your CI/CD pipeline
- Add to security scanning workflow
- Automate compliance reporting
-
For Production:
- Switch to mainnet
- Set up monitoring
- Configure backups
-
For Auditors:
- Share TXIDs for verification
- Provide verification instructions
- Demonstrate immutability
- Documentation: Check
BLOCKCHAIN_SETUP.md - Issues: https://github.com/Compliledger/CompZ/issues
- Examples: See
examples/directory
You're ready to test! Start with Option 1 (instant test) and work your way up to real blockchain integration.