@chainlink/ace 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.foundry-version +1 -0
- package/.github/CODEOWNERS +1 -0
- package/.github/workflows/auto-release-version.yml +107 -0
- package/.github/workflows/create-version-pr.yml +95 -0
- package/.github/workflows/forge-docs.yml +90 -0
- package/.github/workflows/forge-test.yml +59 -0
- package/.solhint-test.json +18 -0
- package/.solhint.json +16 -0
- package/.solhintignore +3 -0
- package/.solhintignore-test +2 -0
- package/Glossary.md +141 -0
- package/LICENSE +59 -0
- package/README.md +218 -0
- package/assets/chainlink-logo.svg +21 -0
- package/chainlink-ace-License-grants +2 -0
- package/foundry.toml +33 -0
- package/getting_started/GETTING_STARTED.md +477 -0
- package/getting_started/MyVault.sol +48 -0
- package/getting_started/advanced/.env.example +36 -0
- package/getting_started/advanced/GETTING_STARTED_ADVANCED.md +431 -0
- package/getting_started/advanced/SanctionsList.sol +25 -0
- package/getting_started/advanced/SanctionsPolicy.sol +58 -0
- package/package.json +41 -0
- package/packages/cross-chain-identity/README.md +148 -0
- package/packages/cross-chain-identity/docs/API_GUIDE.md +120 -0
- package/packages/cross-chain-identity/docs/API_REFERENCE.md +271 -0
- package/packages/cross-chain-identity/docs/CONCEPTS.md +253 -0
- package/packages/cross-chain-identity/docs/CREDENTIAL_FLOW.md +195 -0
- package/packages/cross-chain-identity/docs/SECURITY.md +70 -0
- package/packages/cross-chain-identity/src/CredentialRegistry.sol +245 -0
- package/packages/cross-chain-identity/src/CredentialRegistryIdentityValidator.sol +339 -0
- package/packages/cross-chain-identity/src/CredentialRegistryIdentityValidatorPolicy.sol +71 -0
- package/packages/cross-chain-identity/src/IdentityRegistry.sol +123 -0
- package/packages/cross-chain-identity/src/TrustedIssuerRegistry.sol +140 -0
- package/packages/cross-chain-identity/src/interfaces/ICredentialDataValidator.sol +30 -0
- package/packages/cross-chain-identity/src/interfaces/ICredentialRegistry.sol +170 -0
- package/packages/cross-chain-identity/src/interfaces/ICredentialRequirements.sol +192 -0
- package/packages/cross-chain-identity/src/interfaces/ICredentialValidator.sol +37 -0
- package/packages/cross-chain-identity/src/interfaces/IIdentityRegistry.sol +85 -0
- package/packages/cross-chain-identity/src/interfaces/IIdentityValidator.sol +18 -0
- package/packages/cross-chain-identity/src/interfaces/ITrustedIssuerRegistry.sol +61 -0
- package/packages/cross-chain-identity/test/CredentialRegistry.t.sol +220 -0
- package/packages/cross-chain-identity/test/CredentialRegistryIdentityValidator.t.sol +554 -0
- package/packages/cross-chain-identity/test/CredentialRegistryIdentityValidatorPolicy.t.sol +114 -0
- package/packages/cross-chain-identity/test/IdentityRegistry.t.sol +106 -0
- package/packages/cross-chain-identity/test/IdentityValidator.t.sol +969 -0
- package/packages/cross-chain-identity/test/TrustedIssuerRegistry.t.sol +123 -0
- package/packages/cross-chain-identity/test/helpers/BaseProxyTest.sol +112 -0
- package/packages/cross-chain-identity/test/helpers/MockCredentialDataValidator.sol +26 -0
- package/packages/cross-chain-identity/test/helpers/MockCredentialRegistryReverting.sol +131 -0
- package/packages/policy-management/README.md +197 -0
- package/packages/policy-management/docs/API_GUIDE.md +290 -0
- package/packages/policy-management/docs/API_REFERENCE.md +173 -0
- package/packages/policy-management/docs/CONCEPTS.md +156 -0
- package/packages/policy-management/docs/CUSTOM_POLICIES_TUTORIAL.md +195 -0
- package/packages/policy-management/docs/POLICY_ORDERING_GUIDE.md +91 -0
- package/packages/policy-management/docs/SECURITY.md +57 -0
- package/packages/policy-management/src/core/Policy.sol +124 -0
- package/packages/policy-management/src/core/PolicyEngine.sol +382 -0
- package/packages/policy-management/src/core/PolicyFactory.sol +92 -0
- package/packages/policy-management/src/core/PolicyProtected.sol +126 -0
- package/packages/policy-management/src/extractors/ComplianceTokenForceTransferExtractor.sol +57 -0
- package/packages/policy-management/src/extractors/ComplianceTokenFreezeUnfreezeExtractor.sol +54 -0
- package/packages/policy-management/src/extractors/ComplianceTokenMintBurnExtractor.sol +61 -0
- package/packages/policy-management/src/extractors/ERC20ApproveExtractor.sol +57 -0
- package/packages/policy-management/src/extractors/ERC20TransferExtractor.sol +62 -0
- package/packages/policy-management/src/extractors/ERC3643ForcedTransferExtractor.sol +56 -0
- package/packages/policy-management/src/extractors/ERC3643FreezeUnfreezeExtractor.sol +55 -0
- package/packages/policy-management/src/extractors/ERC3643MintBurnExtractor.sol +51 -0
- package/packages/policy-management/src/extractors/ERC3643SetAddressFrozenExtractor.sol +51 -0
- package/packages/policy-management/src/interfaces/IExtractor.sol +17 -0
- package/packages/policy-management/src/interfaces/IMapper.sol +17 -0
- package/packages/policy-management/src/interfaces/IPolicy.sol +61 -0
- package/packages/policy-management/src/interfaces/IPolicyEngine.sol +264 -0
- package/packages/policy-management/src/interfaces/IPolicyProtected.sol +48 -0
- package/packages/policy-management/src/policies/AllowPolicy.sol +104 -0
- package/packages/policy-management/src/policies/BypassPolicy.sol +90 -0
- package/packages/policy-management/src/policies/IntervalPolicy.sol +223 -0
- package/packages/policy-management/src/policies/MaxPolicy.sol +73 -0
- package/packages/policy-management/src/policies/OnlyAuthorizedSenderPolicy.sol +84 -0
- package/packages/policy-management/src/policies/OnlyOwnerPolicy.sol +35 -0
- package/packages/policy-management/src/policies/PausePolicy.sol +82 -0
- package/packages/policy-management/src/policies/README.md +632 -0
- package/packages/policy-management/src/policies/RejectPolicy.sol +89 -0
- package/packages/policy-management/src/policies/RoleBasedAccessControlPolicy.sol +162 -0
- package/packages/policy-management/src/policies/SecureMintPolicy.sol +271 -0
- package/packages/policy-management/src/policies/VolumePolicy.sol +133 -0
- package/packages/policy-management/src/policies/VolumeRatePolicy.sol +192 -0
- package/packages/policy-management/test/PolicyEngine.t.sol +368 -0
- package/packages/policy-management/test/PolicyFactory.t.sol +114 -0
- package/packages/policy-management/test/PolicyProtectedToken.t.sol +75 -0
- package/packages/policy-management/test/extractors/ComplianceTokenForceTransferExtractor.t.sol +59 -0
- package/packages/policy-management/test/extractors/ComplianceTokenFreezeUnfreezeExtractor.t.sol +74 -0
- package/packages/policy-management/test/extractors/ComplianceTokenMintBurnExtractor.t.sol +92 -0
- package/packages/policy-management/test/extractors/ERC20ApproveExtractor.t.sol +58 -0
- package/packages/policy-management/test/extractors/ERC3643ForcedTransferExtractor.t.sol +59 -0
- package/packages/policy-management/test/extractors/ERC3643FreezeUnfreezeExtractor.t.sol +74 -0
- package/packages/policy-management/test/extractors/ERC3643MintBurnExtractor.t.sol +73 -0
- package/packages/policy-management/test/extractors/ERC3643SetAddressFrozenExtractor.t.sol +56 -0
- package/packages/policy-management/test/helpers/BaseProxyTest.sol +75 -0
- package/packages/policy-management/test/helpers/CustomMapper.sol +26 -0
- package/packages/policy-management/test/helpers/DummyExtractor.sol +11 -0
- package/packages/policy-management/test/helpers/ExpectedParameterPolicy.sol +39 -0
- package/packages/policy-management/test/helpers/MockAggregatorV3.sol +51 -0
- package/packages/policy-management/test/helpers/MockToken.sol +66 -0
- package/packages/policy-management/test/helpers/MockTokenExtractor.sol +34 -0
- package/packages/policy-management/test/helpers/PolicyAlwaysAllowed.sol +45 -0
- package/packages/policy-management/test/helpers/PolicyAlwaysContinue.sol +23 -0
- package/packages/policy-management/test/helpers/PolicyAlwaysRejected.sol +23 -0
- package/packages/policy-management/test/helpers/PolicyFailingRun.sol +22 -0
- package/packages/policy-management/test/policies/AllowPolicy.t.sol +174 -0
- package/packages/policy-management/test/policies/BypassPolicy.t.sol +159 -0
- package/packages/policy-management/test/policies/IntervalPolicy.t.sol +307 -0
- package/packages/policy-management/test/policies/MaxPolicy.t.sol +54 -0
- package/packages/policy-management/test/policies/OnlyAuthorizedSenderPolicy.t.sol +95 -0
- package/packages/policy-management/test/policies/OnlyOwnerPolicy.t.sol +47 -0
- package/packages/policy-management/test/policies/PausePolicy.t.sol +75 -0
- package/packages/policy-management/test/policies/RejectPolicy.t.sol +182 -0
- package/packages/policy-management/test/policies/RoleBasedAccessControlPolicy.t.sol +223 -0
- package/packages/policy-management/test/policies/SecureMintPolicy.t.sol +442 -0
- package/packages/policy-management/test/policies/VolumePolicy.t.sol +158 -0
- package/packages/policy-management/test/policies/VolumeRatePolicy.t.sol +165 -0
- package/packages/tokens/erc-20/src/ComplianceTokenERC20.sol +345 -0
- package/packages/tokens/erc-20/src/ComplianceTokenStoreERC20.sol +29 -0
- package/packages/tokens/erc-20/test/ComplianceTokenERC20.t.sol +556 -0
- package/packages/tokens/erc-20/test/helpers/BaseProxyTest.sol +75 -0
- package/packages/tokens/erc-3643/README.md +24 -0
- package/packages/tokens/erc-3643/src/ComplianceTokenERC3643.sol +564 -0
- package/packages/tokens/erc-3643/src/ComplianceTokenStoreERC3643.sol +30 -0
- package/packages/tokens/erc-3643/test/ComplianceTokenERC3643.t.sol +815 -0
- package/packages/tokens/erc-3643/test/helpers/BaseProxyTest.sol +76 -0
- package/packages/tokens/erc-3643/test/helpers/ExpectedContextPolicy.sol +32 -0
- package/packages/vendor/erc-3643/compliance/modular/IModularCompliance.sol +220 -0
- package/packages/vendor/erc-3643/registry/interface/IClaimTopicsRegistry.sol +101 -0
- package/packages/vendor/erc-3643/registry/interface/IIdentityRegistry.sol +251 -0
- package/packages/vendor/erc-3643/registry/interface/IIdentityRegistryStorage.sol +191 -0
- package/packages/vendor/erc-3643/registry/interface/ITrustedIssuersRegistry.sol +161 -0
- package/packages/vendor/erc-3643/token/IToken.sol +457 -0
- package/packages/vendor/onchain-id/interface/IClaimIssuer.sol +53 -0
- package/packages/vendor/onchain-id/interface/IERC734.sol +110 -0
- package/packages/vendor/onchain-id/interface/IERC735.sol +105 -0
- package/packages/vendor/onchain-id/interface/IIdentity.sol +26 -0
- package/packages/vendor/onchain-id/interface/IImplementationAuthority.sol +21 -0
- package/remappings.txt +6 -0
- package/script/DeployComplianceTokenERC20.s.sol +191 -0
- package/script/DeployComplianceTokenERC3643.s.sol +208 -0
- package/script/DeploySimpleComplianceToken.s.sol +38 -0
- package/script/getting_started/DeployGettingStarted.s.sol +74 -0
- package/script/getting_started/advanced/DeployAdvancedGettingStarted.s.sol +332 -0
- package/script/getting_started/advanced/DeploySanctionsList.s.sol +26 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# Cross-Chain Identity Concepts
|
|
2
|
+
|
|
3
|
+
## Abstract
|
|
4
|
+
|
|
5
|
+
The Cross-Chain Identity component provides a unified interface for managing cross-chain identity and verifiable credentials through interoperable smart contracts. It introduces the **Cross-Chain Identifier (CCID)**, a 32-byte identifier that anchors an identity across EVM-compatible blockchains, enabling credential issuance, verification, and revocation while preserving the distinct security properties of each chain.
|
|
6
|
+
|
|
7
|
+
By supporting both self-sovereign identity principles and delegated verification, this component accommodates a range of trust models and fosters broad interoperability. This approach reduces fragmentation by offering a single, chain-agnostic identity framework.
|
|
8
|
+
|
|
9
|
+
## Glossary of Key Terms
|
|
10
|
+
|
|
11
|
+
| Term | Role |
|
|
12
|
+
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
13
|
+
| **Credential Issuer** | An **offchain** entity (e.g., a KYC provider) trusted to verify real-world information and write the results (credentials) onchain. |
|
|
14
|
+
| **Identity Validator** | An **onchain** contract that your dApp calls to check if a user meets a set of credential requirements. |
|
|
15
|
+
| **Credential Source** | An **onchain** data structure that tells the Identity Validator which `IdentityRegistry` and `CredentialRegistry` to trust for a given credential type. |
|
|
16
|
+
| **CCID** | A **`bytes32` identifier** that represents a single, universal identity for a user across all their addresses and all EVM chains. |
|
|
17
|
+
|
|
18
|
+
## Why Cross-Chain Identity?
|
|
19
|
+
|
|
20
|
+
As the blockchain ecosystem grows, users often juggle multiple identities spread across various networks. Verifying credentials issued on one chain from another chain becomes cumbersome without complex bridging solutions. This fragmentation:
|
|
21
|
+
|
|
22
|
+
- **Increases attack surface** - Multiple identity systems mean multiple points of failure
|
|
23
|
+
- **Hampers cross-chain governance** - Applications can't easily verify users across chains
|
|
24
|
+
- **Reduces interoperability** - Each chain requires separate identity verification
|
|
25
|
+
- **Duplicates implementation work** - Developers rebuild identity systems per chain
|
|
26
|
+
|
|
27
|
+
By introducing a unified approach to identity and credential management, this component:
|
|
28
|
+
|
|
29
|
+
- Streamlines verification of identity claims across chains
|
|
30
|
+
- Reduces duplicated implementation work
|
|
31
|
+
- Bolsters security and privacy for decentralized applications
|
|
32
|
+
- Enables seamless multi-chain governance and access control
|
|
33
|
+
|
|
34
|
+
## Core Architecture
|
|
35
|
+
|
|
36
|
+
The Cross-Chain Identity component addresses two fundamental elements:
|
|
37
|
+
|
|
38
|
+
### 1. Cross-Chain Identifier (CCID)
|
|
39
|
+
|
|
40
|
+
A 32-byte identifier that ties one or more local blockchain addresses across blockchain networks to a single identity.
|
|
41
|
+
|
|
42
|
+
### 2. Credential Management
|
|
43
|
+
|
|
44
|
+
A uniform framework for issuing, validating, and managing credentials (e.g., KYC, AML, or custom types). By linking credentials to a CCID instead of individual addresses, the system makes cross-chain identity verification seamless.
|
|
45
|
+
|
|
46
|
+
## System Components
|
|
47
|
+
|
|
48
|
+
```mermaid
|
|
49
|
+
graph TD
|
|
50
|
+
APP["Application"]
|
|
51
|
+
CRQ["Credential Requirements<br><small>(required credentials and trusted sources)</small>"]
|
|
52
|
+
APP -->|Defines Requirements| CRQ
|
|
53
|
+
|
|
54
|
+
subgraph Credential Sources
|
|
55
|
+
CS1["Credential Source 1<br><small>Associated Type(s): <code>common.kyc</code><br/>Uses Identity Registry 1 + Credential Registry 1</small>"]
|
|
56
|
+
CS2["Credential Source 2<br><small>Associated Type(s): <code>common.aml</code><br/>Uses Identity Registry 2 + Credential Registry 2</small>"]
|
|
57
|
+
CS3["Credential Source 3<br><small>Associated Type(s): <code>common.accredited</code><br/>Uses Identity Registry 1 + Credential Registry 2</small>"]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
CRQ -->|Trusted Source| CS1
|
|
61
|
+
CRQ -->|Trusted Source| CS2
|
|
62
|
+
CRQ -->|Trusted Source| CS3
|
|
63
|
+
|
|
64
|
+
subgraph Registries
|
|
65
|
+
IR1["Identity Registry 1<br><small>(Maps local addresses to CCIDs)</small>"]
|
|
66
|
+
IR2["Identity Registry 2<br><small>(Maps local addresses to CCIDs)</small>"]
|
|
67
|
+
CR1["Credential Registry 1<br><small>(Manages credentials linked to CCIDs)</small>"]
|
|
68
|
+
CR2["Credential Registry 2<br><small>(Manages credentials linked to CCIDs)</small>"]
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
CS1 --> IR1
|
|
72
|
+
CS1 --> CR1
|
|
73
|
+
CS2 --> IR2
|
|
74
|
+
CS2 --> CR2
|
|
75
|
+
CS3 --> IR1
|
|
76
|
+
CS3 --> CR2
|
|
77
|
+
CR1 -->|References| IR1
|
|
78
|
+
CR2 -->|References| IR2
|
|
79
|
+
CR2 -->|References| IR1
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Key Components
|
|
83
|
+
|
|
84
|
+
- **Identity Registry**: Maintains mappings between local addresses and CCIDs. Each local address maps to exactly one CCID, though a single CCID can appear on multiple chains or with multiple addresses.
|
|
85
|
+
|
|
86
|
+
- **Credential Registry**: Manages the lifecycle of credentials linked to a CCID, including registration, removal, and renewal processes.
|
|
87
|
+
|
|
88
|
+
- **Credential Requirements**: An _optional_ registry for applications to define which credentials (e.g., "KYC" or "AML") they need, and from which trusted registries. It may also specify extra data validation steps.
|
|
89
|
+
|
|
90
|
+
- **Credential Sources**: Trusted sources that map specific Credential Type Identifiers to an **Identity Registry**, **Credential Registry**, and (optionally) a **Credential Data Validator**. A single source can handle multiple credential types.
|
|
91
|
+
|
|
92
|
+
- **Credential Issuer**: An offchain entity (e.g., service providers) authorized to conduct external checks (such as document verification, w3c credential validation, vLEI validation) and register the resulting credentials onchain.
|
|
93
|
+
|
|
94
|
+
- **Identity Validator**: A smart contract that lets applications validate accounts by leveraging the registries and validators.
|
|
95
|
+
|
|
96
|
+
For a visual representation of how these components interact, see the [Credential Issuance and Validation Flow](./CREDENTIAL_FLOW.md).
|
|
97
|
+
|
|
98
|
+
## Key Concepts
|
|
99
|
+
|
|
100
|
+
### Cross-Chain Identifier (CCID)
|
|
101
|
+
|
|
102
|
+
A **CCID** is a `bytes32` value representing a user's identity within the application domain and which can be used across multiple blockchains. Each chain maintains a local mapping between addresses (`address`) and a CCID, and one CCID can be referenced by multiple local addresses.
|
|
103
|
+
|
|
104
|
+
#### CCID Architecture
|
|
105
|
+
|
|
106
|
+
```mermaid
|
|
107
|
+
graph TB
|
|
108
|
+
subgraph "EVM Chain A"
|
|
109
|
+
IR_A["Identity Registry A<br><small>(Maps Local Address A1 & A2 to CCID)</small>"]
|
|
110
|
+
A1[Local Address A1]
|
|
111
|
+
A2[Local Address A2]
|
|
112
|
+
A1 --> IR_A
|
|
113
|
+
A2 --> IR_A
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
subgraph "EVM Chain B"
|
|
117
|
+
IR_B["Identity Registry B<br><small>(Maps Local Address B1 to CCID)</small>"]
|
|
118
|
+
B1[Local Address B1]
|
|
119
|
+
B1 --> IR_B
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
subgraph "EVM Chain N"
|
|
123
|
+
IR_N["Identity Registry N<br><small>(Maps Local Address N1 to CCID)</small>"]
|
|
124
|
+
N1[Local Address N1]
|
|
125
|
+
N1 --> IR_N
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
CCID["Cross-Chain ID<br><small>(CCID)</small>"]
|
|
129
|
+
IR_A -->|Maps to CCID| CCID
|
|
130
|
+
IR_B -->|Maps to CCID| CCID
|
|
131
|
+
IR_N -->|Maps to CCID| CCID
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
#### Generation and Uniqueness
|
|
135
|
+
|
|
136
|
+
- CCIDs are generated offchain (randomly or deterministically) and then registered onchain
|
|
137
|
+
- The component does not prescribe a specific creation method, only that any chosen approach MUST ensure uniqueness or collision resistance within the application domain
|
|
138
|
+
- A universal globally unique identifier is outside the scope of this package
|
|
139
|
+
|
|
140
|
+
#### Privacy and Correlation Considerations
|
|
141
|
+
|
|
142
|
+
This design allows a CCID to be associated to multiple blockchain addresses, including addresses on different blockchains. This design choice aids in identity verification across multiple blockchains and for actors that openly utilize multiple addresses on a single or even multiple blockchains.
|
|
143
|
+
|
|
144
|
+
When adopting or implementing this component, applications should consider the correlation effects, and take appropriate measures with regard to privacy, such as issuing multiple CCIDs per actor onchain while maintaining the correlation between CCIDs in offchain systems.
|
|
145
|
+
|
|
146
|
+
For a deeper dive on this topic, see the **[CCID Correlation and Anonymity](./SECURITY.md#5-ccid-correlation-and-anonymity)** section of the Security Guide.
|
|
147
|
+
|
|
148
|
+
### Credential Type Identifier
|
|
149
|
+
|
|
150
|
+
A **Credential Type Identifier** is a `bytes32` value denoting the type of credential in use (e.g., KYC, AML, Accredited Investor). While the component defines a set of common identifiers, implementations are free to create custom types.
|
|
151
|
+
|
|
152
|
+
#### Naming Scheme
|
|
153
|
+
|
|
154
|
+
Implementations MUST generate Credential Type Identifiers using a collision-resistant hash algorithm which outputs a `bytes32` value, where the pre-image is a human-readable namespaced string representing the requirement:
|
|
155
|
+
|
|
156
|
+
```solidity
|
|
157
|
+
keccak256("namespace.requirement_name")
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Examples:
|
|
161
|
+
|
|
162
|
+
```solidity
|
|
163
|
+
// Common KYC credential
|
|
164
|
+
keccak256("common.kyc")
|
|
165
|
+
|
|
166
|
+
// Custom application-specific credential
|
|
167
|
+
keccak256("com.app.level.gold")
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
#### Common vs. Custom
|
|
171
|
+
|
|
172
|
+
- **Common credential types** are prefixed with `common.` (e.g., `common.kyc`, `common.aml`)
|
|
173
|
+
- **Custom credentials** MUST NOT use the `common.` prefix - this reserved namespace ensures future extensions can safely expand `common.` credential definitions without conflicts
|
|
174
|
+
|
|
175
|
+
#### Common Credentials
|
|
176
|
+
|
|
177
|
+
| Identifier | Purpose |
|
|
178
|
+
| ------------------- | ------------------------------------------- |
|
|
179
|
+
| `common.kyc` | Identity has passed KYC checks |
|
|
180
|
+
| `common.kyb` | Identity has passed KYB checks |
|
|
181
|
+
| `common.aml` | Identity is not flagged by AML requirements |
|
|
182
|
+
| `common.accredited` | Identity is a qualified accredited investor |
|
|
183
|
+
|
|
184
|
+
### Credential Data
|
|
185
|
+
|
|
186
|
+
A credential in the **Credential Registry** can optionally include associated `bytes` of data. Depending on the use case, this data may be minimal (e.g., an offchain reference or a hashed proof) or more descriptive.
|
|
187
|
+
|
|
188
|
+
#### Privacy Considerations
|
|
189
|
+
|
|
190
|
+
Because many credential formats contain **personally identifiable information (PII)**, the component strongly encourages storing sensitive information offchain. The onchain credential data SHOULD be a pointer or a hash of the actual data, thus preserving user privacy.
|
|
191
|
+
|
|
192
|
+
#### Data Validation
|
|
193
|
+
|
|
194
|
+
The Credential Requirements contract can accept a **Credential Data Validator** contract when applications define requirements and, if present, MUST use it to validate the credential data (e.g., validating data structures).
|
|
195
|
+
|
|
196
|
+
**Important Security Note**: Data associated with a credential should be carefully considered and appropriately hashed. Without proper care, it could be possible to infer information, such as onchain credential expirations correlated to offchain credential expirations, such as on national IDs, passports, etc. Additionally, insufficiently hashed data could be susceptible to brute force information leaks.
|
|
197
|
+
|
|
198
|
+
### Credential Issuance and Validation Model
|
|
199
|
+
|
|
200
|
+
The system involves several key actors:
|
|
201
|
+
|
|
202
|
+
1. **Credential Issuer**
|
|
203
|
+
|
|
204
|
+
- An offchain entity that performs real-world identity verification, generates a CCID for the subject, and posts the credential(s), possibly containing PII-redacted credential(s) in the onchain registries
|
|
205
|
+
|
|
206
|
+
2. **Identity and Credential Registry**
|
|
207
|
+
|
|
208
|
+
- The Identity and Credential Registries are onchain registry contracts that maintain the identity of users, along with the verified credentials. These contracts can be used by onchain applications to verify the identity and inspect the list of issued credentials, and any associated data, of users
|
|
209
|
+
|
|
210
|
+
3. **Identity Validator**
|
|
211
|
+
- The Identity Validator is an onchain utility contract that allows an application to specify one or more sources of identity/credential registries, along with all the required credentials in order to be considered a valid user. The Identity Validator can additionally use the data associated with a credential to determine the validity of the credential. Using the Identity Validator, an application can perform identity checks based solely on the caller's address and need not be aware of the CCID concept nor the credential type identifiers.
|
|
212
|
+
|
|
213
|
+
For a visual representation of how these components interact, see the [Credential Issuance and Validation Flow](./CREDENTIAL_FLOW.md).
|
|
214
|
+
|
|
215
|
+
### Credential Flow
|
|
216
|
+
|
|
217
|
+
A typical **credential lifecycle** includes an offchain **Credential Issuer** that issues a credential about a **User** into the onchain **Registries**:
|
|
218
|
+
|
|
219
|
+
1. **Request**: The **User** initiates a credential request with a Credential Issuer (e.g., for KYC compliance)
|
|
220
|
+
2. **Issuance**: The **Credential Issuer** conducts offchain checks and, if successful, registers the resulting credential onchain under the user's CCID. This onchain action is authorized by a policy in the `PolicyEngine`.
|
|
221
|
+
3. **Validation**: Applications enforce compliance by protecting their functions with the `CredentialRegistryIdentityValidatorPolicy`. When a user calls a protected function, the policy automatically checks if they possess the required credentials.
|
|
222
|
+
|
|
223
|
+
### Context Parameter Usage
|
|
224
|
+
|
|
225
|
+
Throughout the component, many functions accept a `bytes context` parameter. This field acts as a flexible mechanism for passing additional data tied to authorization or compliance checks.
|
|
226
|
+
|
|
227
|
+
For example:
|
|
228
|
+
|
|
229
|
+
- An offchain Credential Issuer might embed cryptographic proofs (signatures or merkle proofs) to demonstrate that a credential meets certain offchain requirements
|
|
230
|
+
- A multi-signature governance process may supply aggregated approvals indicating that a credential registration is valid
|
|
231
|
+
|
|
232
|
+
By keeping `context` as a generic `bytes` array, implementers have freedom to define and decode any extra data relevant to their system, without overloading the core function signatures.
|
|
233
|
+
|
|
234
|
+
## Design Rationale
|
|
235
|
+
|
|
236
|
+
### Why Offchain Validation?
|
|
237
|
+
|
|
238
|
+
Because many credential formats (e.g., w3c Verifiable Credentials, vLEI credentials) contain personally identifiable information (PII), it is neither practical nor desirable to store such data fully onchain. Instead, this component enables **offchain validation** by a Credential Issuer, who then publishes only minimal onchain references. This approach preserves privacy while supporting a wide range of credential types and formats.
|
|
239
|
+
|
|
240
|
+
### Why CCID Instead of Addresses?
|
|
241
|
+
|
|
242
|
+
By decoupling credential issuance from individual addresses and relying on the Cross-Chain Identifier, this component fosters true cross-chain interoperability. Applications gain a unified identity reference across EVM networks, and implementers can seamlessly integrate new credential formats or enhanced validator logic without reworking the core registry contracts.
|
|
243
|
+
|
|
244
|
+
### Why Modular Architecture?
|
|
245
|
+
|
|
246
|
+
The modular design with separate registries and validators allows:
|
|
247
|
+
|
|
248
|
+
- **Flexibility**: Applications can choose which components they need
|
|
249
|
+
- **Upgradability**: Individual components can be upgraded without affecting others
|
|
250
|
+
- **Interoperability**: Different applications can share the same registries
|
|
251
|
+
- **Consistency**: Common interfaces enable ecosystem-wide compatibility
|
|
252
|
+
|
|
253
|
+
Tokens and applications can specify their credential requirements in a **Credential Requirements** contract. By referencing that contract, any application can confirm whether an account meets certain criteria, leveraging the same unified registry and validator interfaces. This ensures consistent handling of credentials across various ecosystems and eases the development of cross-chain or compliance-driven applications.
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# Credential Issuance and Validation Flow
|
|
2
|
+
|
|
3
|
+
This document provides a detailed walkthrough of the **complete lifecycle** of issuing and validating credentials within the Cross-Chain Identity framework, highlighting the roles of the **User**, an offchain **Credential Issuer**, and the onchain **Registries**.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The credential flow demonstrates how identity verification moves from offchain processes to onchain validation:
|
|
8
|
+
|
|
9
|
+
- A **Credential Issuer** is an authorized entity (e.g., a service provider) responsible for performing offchain checks and registering credentials onchain
|
|
10
|
+
- After a credential is registered, applications can verify it directly by consulting the onchain registries and validator utility contracts
|
|
11
|
+
- The Credential Issuer is no longer involved in day-to-day validation checks
|
|
12
|
+
|
|
13
|
+
## Complete Flow Diagram
|
|
14
|
+
|
|
15
|
+
```mermaid
|
|
16
|
+
sequenceDiagram
|
|
17
|
+
participant User
|
|
18
|
+
participant CredentialIssuer
|
|
19
|
+
box rgb(240,240,240) Onchain Contracts
|
|
20
|
+
participant IdentityRegistry
|
|
21
|
+
participant CredentialRegistry
|
|
22
|
+
participant CredentialDataValidator
|
|
23
|
+
participant IdentityValidator
|
|
24
|
+
participant Application
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
User ->> CredentialIssuer: 1. Request credential(s) verification (credentialTypeId, ...)
|
|
28
|
+
CredentialIssuer ->> CredentialIssuer: 2. Offchain verification (e.g., KYC/AML doc checks) and CCID generation
|
|
29
|
+
CredentialIssuer -->> IdentityRegistry: 3. registerIdentity(ccid, localAddress, context)
|
|
30
|
+
IdentityRegistry -->> CredentialIssuer: 4. Emit IdentityRegistered event
|
|
31
|
+
loop Each Verified Credential
|
|
32
|
+
CredentialIssuer -->> CredentialRegistry: 5. registerCredential(ccid, credentialTypeId, expiresAt, credentialData (optional), context)
|
|
33
|
+
CredentialRegistry -->> CredentialIssuer: 6. Emit CredentialRegistered event
|
|
34
|
+
end
|
|
35
|
+
Application ->> IdentityValidator: 7. validate(msg.sender, context)
|
|
36
|
+
IdentityValidator ->> IdentityRegistry: 8. getIdentity(address)
|
|
37
|
+
IdentityRegistry -->> IdentityValidator: 9. Return CCID
|
|
38
|
+
loop Each Required Credential
|
|
39
|
+
IdentityValidator ->> CredentialRegistry: 10. validate(ccid, requiredCredentialTypeId, context)
|
|
40
|
+
CredentialRegistry -->> IdentityValidator: 11. Return credentialValid(true/false)
|
|
41
|
+
IdentityValidator ->> CredentialDataValidator: 12. validateCredentialData(ccid, account, credentialTypeId, credentialData, context)
|
|
42
|
+
CredentialDataValidator -->> IdentityValidator: 13. Return dataValid(true/false)
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
IdentityValidator -->> Application: 14. Return identityValid(true/false)
|
|
46
|
+
alt identityValid == true
|
|
47
|
+
Application ->> User: 15. Grant Access
|
|
48
|
+
else identityValid == false
|
|
49
|
+
Application ->> User: 15. Deny Access
|
|
50
|
+
end
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Step-by-Step Breakdown
|
|
54
|
+
|
|
55
|
+
### 1. **Credential Verification Request**
|
|
56
|
+
|
|
57
|
+
The **User** requests a specific credential(s) (e.g., `credentialTypeId = common.kyc`) for their account address(es) from a trusted **Credential Issuer**.
|
|
58
|
+
|
|
59
|
+
**Example**: Alice wants to use a DeFi protocol that requires KYC verification. She contacts an authorized KYC provider.
|
|
60
|
+
|
|
61
|
+
### 2. **Offchain Verification**
|
|
62
|
+
|
|
63
|
+
The **Credential Issuer** conducts checks offchain (e.g., KYC/AML document reviews or other advanced verifications).
|
|
64
|
+
|
|
65
|
+
**What happens**:
|
|
66
|
+
|
|
67
|
+
- Document verification (passport, driver's license)
|
|
68
|
+
- Identity validation against government databases
|
|
69
|
+
- AML screening against sanctions lists
|
|
70
|
+
- CCID generation for the verified identity
|
|
71
|
+
|
|
72
|
+
### 3. **Identity Registration**
|
|
73
|
+
|
|
74
|
+
If valid, the **Credential Issuer** calls `registerIdentity()` on the **Identity Registry** to associate the user's local address(es) with the generated CCID.
|
|
75
|
+
|
|
76
|
+
```solidity
|
|
77
|
+
identityRegistry.registerIdentity(ccid, userAddress, context);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 4. **Identity Confirmation**
|
|
81
|
+
|
|
82
|
+
The **IdentityRegistry** emits a `IdentityRegistered` event, confirming successful address→CCID registration.
|
|
83
|
+
|
|
84
|
+
### 5. **Credential Registration**
|
|
85
|
+
|
|
86
|
+
If valid, the **Credential Issuer** calls `registerCredential()` on the **Credential Registry** to associate the verified credentials with the user's CCID.
|
|
87
|
+
|
|
88
|
+
```solidity
|
|
89
|
+
credentialRegistry.registerCredential(
|
|
90
|
+
ccid,
|
|
91
|
+
keccak256("common.kyc"),
|
|
92
|
+
expirationTimestamp,
|
|
93
|
+
credentialData, // Usually minimal/hashed for privacy
|
|
94
|
+
context
|
|
95
|
+
);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 6. **Credential Confirmation**
|
|
99
|
+
|
|
100
|
+
The **CredentialRegistry** emits a `CredentialRegistered` event, confirming successful credentials issuance.
|
|
101
|
+
|
|
102
|
+
### 7. **Identity Validation**
|
|
103
|
+
|
|
104
|
+
When needed, an **Application** calls `validate()` on the **IdentityValidator** to ensure the interacting account is valid and has the required credentials.
|
|
105
|
+
|
|
106
|
+
```solidity
|
|
107
|
+
bool isValid = identityValidator.validate(msg.sender, context);
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 8. **Identity Lookup**
|
|
111
|
+
|
|
112
|
+
The **IdentityValidator** calls `getIdentity()` on the **Identity Registry** to lookup the CCID for the account.
|
|
113
|
+
|
|
114
|
+
### 9. **CCID Returned**
|
|
115
|
+
|
|
116
|
+
The **IdentityRegistry** returns the CCID associated with the account.
|
|
117
|
+
|
|
118
|
+
### 10. **Credential Validation**
|
|
119
|
+
|
|
120
|
+
The **IdentityValidator** calls `validate()` on the **CredentialRegistry** to confirm the account has the required credential(s).
|
|
121
|
+
|
|
122
|
+
**Multiple checks may occur**:
|
|
123
|
+
|
|
124
|
+
- Does the CCID have a `common.kyc` credential?
|
|
125
|
+
- Is the credential still valid (not expired)?
|
|
126
|
+
- Does it meet minimum validation requirements?
|
|
127
|
+
|
|
128
|
+
### 11. **Credential Validation Outcome**
|
|
129
|
+
|
|
130
|
+
The **CredentialRegistry** returns whether the account's credentials are valid.
|
|
131
|
+
|
|
132
|
+
### 12. **Credential Data Validation** (Optional)
|
|
133
|
+
|
|
134
|
+
If needed, the **IdentityValidator** calls `validateCredentialData()` on the **CredentialDataValidator** to check the credential data for application-specific requirements.
|
|
135
|
+
|
|
136
|
+
**Examples**:
|
|
137
|
+
|
|
138
|
+
- Verify cryptographic proofs
|
|
139
|
+
- Check data structure compliance
|
|
140
|
+
- Validate credential metadata
|
|
141
|
+
|
|
142
|
+
### 13. **Data Validation Outcome**
|
|
143
|
+
|
|
144
|
+
The **CredentialDataValidator** returns whether the credential data is valid.
|
|
145
|
+
|
|
146
|
+
### 14. **Identity Validation Outcome**
|
|
147
|
+
|
|
148
|
+
The **IdentityValidator** returns whether the account is valid and contains the required credentials (including ensuring the minimum number of credentials).
|
|
149
|
+
|
|
150
|
+
### 15. **Access Granted/Denied**
|
|
151
|
+
|
|
152
|
+
The **Application** informs the **User** of the access decision.
|
|
153
|
+
|
|
154
|
+
## Key Features Demonstrated
|
|
155
|
+
|
|
156
|
+
### Multi-Credential Support
|
|
157
|
+
|
|
158
|
+
This flow checks one or more required credential types, accommodating complex compliance scenarios:
|
|
159
|
+
|
|
160
|
+
```solidity
|
|
161
|
+
// Example: Require both KYC and accredited investor status
|
|
162
|
+
bytes32[] memory requiredCredentials = new bytes32[](2);
|
|
163
|
+
requiredCredentials[0] = keccak256("common.kyc");
|
|
164
|
+
requiredCredentials[1] = keccak256("common.accredited");
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Flexible Validation Rules
|
|
168
|
+
|
|
169
|
+
- **minValidations** allows flexibility (e.g., requiring at least 2 valid KYC credentials from different sources)
|
|
170
|
+
- **invert** flag enables negative requirements (e.g., "must NOT be on sanctions list")
|
|
171
|
+
|
|
172
|
+
### Context-Aware Validation
|
|
173
|
+
|
|
174
|
+
The `context` parameter enables:
|
|
175
|
+
|
|
176
|
+
- Cryptographic proofs
|
|
177
|
+
- Time-sensitive validation
|
|
178
|
+
- Application-specific requirements
|
|
179
|
+
- Multi-signature governance approvals
|
|
180
|
+
|
|
181
|
+
### Privacy Preservation
|
|
182
|
+
|
|
183
|
+
- Sensitive PII stays offchain with the Credential Issuer
|
|
184
|
+
- Only hashes or minimal references stored onchain
|
|
185
|
+
- CCID provides identity anchor without revealing personal data
|
|
186
|
+
|
|
187
|
+
## Security Considerations
|
|
188
|
+
|
|
189
|
+
For a complete breakdown of security best practices when implementing this system, please see the full **[Security Considerations Guide](./SECURITY.md)**.
|
|
190
|
+
|
|
191
|
+
## Credential Lifecycle Diagram
|
|
192
|
+
|
|
193
|
+
This diagram shows the end-to-end flow, from offchain verification to onchain validation.
|
|
194
|
+
|
|
195
|
+
For practical code examples of how to perform these actions, see the [**API Guide**](./API_GUIDE.md).
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Cross-Chain Identity Security Considerations
|
|
2
|
+
|
|
3
|
+
> **Disclaimer:** This document provides a non-exhaustive list of security considerations and is intended for educational purposes only. It is not a substitute for a formal security audit. Every project has unique security requirements, and you are solely responsible for ensuring the security of your own implementation. Always conduct thorough testing and seek a professional audit for production systems.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
A Cross-Chain Identity system has multiple layers of trust and several critical security points. A compromised component can lead to fraudulent credentials being issued or validated, undermining the integrity of any application that relies on it.
|
|
8
|
+
|
|
9
|
+
This document outlines the critical security principles and best practices to consider when implementing and managing a Cross-Chain Identity system.
|
|
10
|
+
|
|
11
|
+
## 1. Credential Issuer Security
|
|
12
|
+
|
|
13
|
+
**The Principle:** The **Credential Issuer** is the most trusted entity in the system. It is the offchain actor that verifies real-world information and has the onchain authority to create identities and issue credentials. Its security is paramount.
|
|
14
|
+
|
|
15
|
+
**Considerations:**
|
|
16
|
+
|
|
17
|
+
- **Authorization:** How do you authorize a new Credential Issuer? Is it a single address, a multi-sig, or a DAO-governed role? How do you revoke this authority?
|
|
18
|
+
- **Issuance Policies:** Does the issuer have internal rules to prevent issuing improper credentials? For example, rate limiting or value checks.
|
|
19
|
+
- **Auditability:** Are all issuance and revocation actions logged in a way that can be audited, both offchain and onchain via events?
|
|
20
|
+
|
|
21
|
+
## 2. Registry Access Control & Integrity
|
|
22
|
+
|
|
23
|
+
**The Principle:** The onchain `IdentityRegistry` and `CredentialRegistry` contracts must be protected against unauthorized writes. Only authorized Credential Issuers should be able to modify them.
|
|
24
|
+
|
|
25
|
+
**Considerations:**
|
|
26
|
+
|
|
27
|
+
- **Role-Based Access:** Do you use distinct roles for different actions (e.g., an `ISSUER_ROLE` vs. a `REVOKER_ROLE`)?
|
|
28
|
+
- **Input Validation:** Are all inputs to functions like `registerIdentity` and `registerCredential` validated (e.g., checking for non-zero CCIDs or addresses)?
|
|
29
|
+
- **Rate Limiting:** Is there any onchain protection to prevent a compromised but still authorized issuer from spamming the registry with credentials?
|
|
30
|
+
- **Upgradability:** Are the registry contracts upgradeable? If so, what is the governance process for deploying a new version?
|
|
31
|
+
|
|
32
|
+
## 3. Data Privacy and PII Protection
|
|
33
|
+
|
|
34
|
+
**The Principle:** Personally Identifiable Information (PII) should NEVER be stored directly on the blockchain. The system is designed to keep sensitive data offchain.
|
|
35
|
+
|
|
36
|
+
**Considerations:**
|
|
37
|
+
|
|
38
|
+
- **Onchain Data:** What data is being stored in the `credentialData` field? It should only ever be a hash of the offchain data or a non-sensitive reference.
|
|
39
|
+
- **Hashing and Salting:** Are you using strong, collision-resistant hashing algorithms (like `keccak256`)?
|
|
40
|
+
- **Data Minimization:** Are you storing the absolute minimum amount of information onchain required for your use case?
|
|
41
|
+
|
|
42
|
+
## 4. Credential Lifecycle Management
|
|
43
|
+
|
|
44
|
+
**The Principle:** Credentials are not always permanent. A robust system must handle their expiration and revocation gracefully.
|
|
45
|
+
|
|
46
|
+
**Considerations:**
|
|
47
|
+
|
|
48
|
+
- **Expiration:** Does your system properly check for expired credentials? The `IdentityValidator` will not consider a credential valid if `block.timestamp > expiresAt`. Ensure your issuers set meaningful expiration dates.
|
|
49
|
+
- **Revocation:** What is the process for revoking a credential if a user's status changes? Who has the authority to do this? Is the revocation immediate?
|
|
50
|
+
|
|
51
|
+
## 5. CCID Correlation and Anonymity
|
|
52
|
+
|
|
53
|
+
**The Principle:** The core benefit of a CCID is creating a persistent, interoperable identity across chains. However, this onchain transparency can be a drawback for users who need to keep their activities separate for privacy reasons. It is crucial to balance the need for interoperability with the risk of unwanted correlation.
|
|
54
|
+
|
|
55
|
+
**Considerations:**
|
|
56
|
+
|
|
57
|
+
- **Unwanted Correlation:** Be aware that anyone can see which addresses are linked to the same CCID on a public blockchain. Does this create privacy risks for your users?
|
|
58
|
+
- **Domain-Specific IDs:** For enhanced privacy, consider using different CCIDs for the same user in different application domains. You can maintain the correlation in a secure offchain system while presenting separate identities onchain.
|
|
59
|
+
- **Temporary or Scoped IDs:** Could your use case be served by issuing temporary, time-limited, or single-use credentials or identifiers to reduce the long-term correlation footprint?
|
|
60
|
+
|
|
61
|
+
## 6. View Function Reliability
|
|
62
|
+
|
|
63
|
+
**The Principle:** View functions in Cross-Chain Identity interfaces must be completely reliable and never revert. This is critical for system integration and operational stability.
|
|
64
|
+
|
|
65
|
+
**Considerations:**
|
|
66
|
+
|
|
67
|
+
- **Non-Reverting Guarantee:** All view functions (`validate`, `validateCredentialData`, etc.) **MUST NOT revert under any circumstances**. Implementations must use defensive programming patterns such as try-catch blocks around external calls.
|
|
68
|
+
- **External Call Failures:** When making external calls to credential registries or data validators, handle failures gracefully by treating them as validation failures rather than allowing reverts to propagate.
|
|
69
|
+
- **Defensive Programming:** Use proper error handling, input validation, and fallback logic to ensure view functions always return a boolean result rather than reverting.
|
|
70
|
+
- **Integration Impact:** Remember that reverting view functions can break integrations with other contracts, particularly when used within policy engines or token transfer validations.
|