Documentation Index
Fetch the complete documentation index at: https://core.anylayer.org/llms.txt
Use this file to discover all available pages before exploring further.
Overview
ZKScore implements zero-knowledge proof technology to enable privacy-preserving reputation verification without revealing sensitive data.
Privacy Features
Selective Disclosure
Prove specific claims without revealing all data:
// Prove score > 500 without revealing exact score
const proof = await client.generateZKProof({
type: 'score_threshold',
user: 'alice.zks',
threshold: 500
});
// Verify proof without seeing actual score
const isValid = await client.verifyZKProof(proof, {
type: 'score_threshold',
threshold: 500
});
Achievement Proofs
// Prove achievement without revealing other achievements
const achievementProof = await client.generateZKProof({
type: 'achievement',
user: 'alice.zks',
achievementId: 'defi-pioneer'
});
// Verify achievement proof
const hasAchievement = await client.verifyZKProof(achievementProof, {
type: 'achievement',
achievementId: 'defi-pioneer'
});
Privacy-Preserving Access Control
ZK Gating
class ZKPrivacyGate {
constructor(client) {
this.client = client;
}
async checkPrivateAccess(userAddress, requirements) {
try {
const proofs = [];
// Generate proofs for each requirement
for (const requirement of requirements) {
const proof = await this.client.generateZKProof({
type: requirement.type,
user: userAddress,
...requirement.params
});
proofs.push(proof);
}
return {
hasAccess: true,
proofs: proofs,
privacyLevel: 'high'
};
} catch (error) {
return {
hasAccess: false,
error: error.message
};
}
}
async verifyPrivateAccess(proofs, requirements) {
try {
for (let i = 0; i < proofs.length; i++) {
const proof = proofs[i];
const requirement = requirements[i];
const isValid = await this.client.verifyZKProof(proof, requirement);
if (!isValid) {
return { hasAccess: false, reason: 'Invalid proof' };
}
}
return { hasAccess: true, privacyLevel: 'high' };
} catch (error) {
return { hasAccess: false, error: error.message };
}
}
}
Encrypted Attestations
Private Attestation Creation
// Create encrypted attestation
const encryptedAttestation = await client.createEncryptedAttestation({
recipient: 'alice.zks',
schema: 'private_skill_verification',
data: {
skill: 'Advanced Solidity',
level: 9,
salary: 150000, // Private salary information
company: 'Crypto Corp'
},
encryptionKey: 'recipient_public_key',
expiration: Math.floor(Date.now() / 1000) + (365 * 24 * 60 * 60)
});
console.log('Encrypted attestation created:', encryptedAttestation.id);
Attestation Decryption
// Decrypt attestation (only recipient can decrypt)
const decryptedData = await client.decryptAttestation(
encryptedAttestation.id,
'recipient_private_key'
);
console.log('Decrypted data:', decryptedData);
Privacy Settings
User Privacy Controls
// Set privacy preferences
await client.setPrivacySettings({
user: 'alice.zks',
settings: {
scoreVisibility: 'threshold_only', // Only show if above threshold
achievementVisibility: 'selective', // Only show specific achievements
attestationVisibility: 'encrypted', // Encrypt sensitive attestations
dataSharing: 'minimal' // Minimal data sharing
}
});
// Get privacy settings
const settings = await client.getPrivacySettings('alice.zks');
console.log('Privacy settings:', settings);
Data Minimization
// Request minimal data
const minimalScore = await client.getScore('alice.zks', {
privacy: 'minimal',
reveal: 'threshold_only',
threshold: 500
});
// Only reveals if score >= 500, doesn't reveal exact score
console.log('Meets threshold:', minimalScore.meetsThreshold);
Advanced Privacy Features
Homomorphic Encryption
// Perform computations on encrypted data
const encryptedScore = await client.getEncryptedScore('alice.zks');
const encryptedThreshold = await client.encryptValue(500);
// Check if encrypted score > encrypted threshold without decrypting
const comparison = await client.compareEncryptedValues(
encryptedScore,
encryptedThreshold
);
console.log('Score meets threshold:', comparison.result);
Multi-Party Computation
// Collaborative score verification
const mpcResult = await client.multiPartyComputation({
participants: ['alice.zks', 'bob.zks', 'charlie.zks'],
computation: 'average_score',
privacy: 'high'
});
console.log('Average score:', mpcResult.average);
console.log('Individual scores remain private:', mpcResult.private);
Privacy Compliance
GDPR Compliance
// GDPR-compliant data handling
const gdprCompliantScore = await client.getScore('alice.zks', {
compliance: 'gdpr',
dataRetention: 'minimal',
consentRequired: true
});
// Data portability
const exportData = await client.exportUserData('alice.zks', {
format: 'json',
includePrivate: false
});
Data Anonymization
// Anonymize user data
const anonymizedData = await client.anonymizeData({
user: 'alice.zks',
level: 'high',
preserveFunctionality: true
});
console.log('Anonymized data:', anonymizedData);
Privacy Best Practices
Implementation Guidelines
- Minimal Data Collection: Only collect necessary data
- Encryption: Encrypt sensitive data at rest and in transit
- Access Controls: Implement strict access controls
- Audit Logs: Maintain privacy audit logs
- User Consent: Obtain explicit consent for data processing
Privacy by Design
- Default Privacy: Set privacy as the default
- Transparency: Be transparent about data usage
- User Control: Give users control over their data
- Regular Audits: Conduct regular privacy audits
- Compliance: Ensure regulatory compliance
Privacy Testing
Privacy Verification
// Test privacy features
const privacyTest = await client.testPrivacyFeatures({
user: 'alice.zks',
tests: [
'selective_disclosure',
'encrypted_attestations',
'data_minimization',
'access_control'
]
});
console.log('Privacy test results:', privacyTest);