|
| 1 | +# Registry Contracts |
| 2 | + |
| 3 | +The `trust-anchor-did-ethr` package forms the on-chain foundation of the SSI ecosystem. It provides the smart contracts necessary for decentralized identity management, governance, and revocation. |
| 4 | + |
| 5 | +## Overview and Purpose |
| 6 | + |
| 7 | +The smart contracts are responsible for defining organizational identities, establishing a governing authority (Trust Anchor), and maintaining pointers to off-chain revocation data. There are three primary components: |
| 8 | + |
| 9 | +1. **`EthereumDIDRegistry`**: The standard registry mapping Ethereum addresses to their Decentralized Identifiers (DIDs). |
| 10 | +2. **`DIDMultisigController`**: A multisig governance contract that acts as the highest authority (Trust Anchor). |
| 11 | +3. **`CompanyCRSetRegistry`**: A registry mapping company DIDs to their Credential Revocation Set (CRSet) IPFS CIDs. |
| 12 | + |
| 13 | +## Technical Details |
| 14 | + |
| 15 | +### 1. EthereumDIDRegistry |
| 16 | + |
| 17 | +- **Methodology**: Implements the [`did:ethr`](https://github.com/decentralized-identity/ethr-did-resolver) method. |
| 18 | +- **Features**: Allows changing identity owners, adding/revoking delegates, and setting attributes via direct calls or meta-transactions (signed payloads). |
| 19 | + |
| 20 | +### 2. DIDMultisigController |
| 21 | + |
| 22 | +- **Architecture**: An M-of-N multisig wallet designed to control identities. |
| 23 | +- **Layers**: |
| 24 | + - **Speed Layer (Single Admin)**: A single owner can execute calls to external contracts (`execCall`), allowing fast administrative operations on sub-identities. |
| 25 | + - **Security Layer (Consensus)**: Requires quorum (M-of-N) or unanimous approval for critical system changes (e.g., changing the Trust Anchor's own identity, adding/removing multisig owners, or proposing proxy upgrades). |
| 26 | + |
| 27 | +### 3. CompanyCRSetRegistry |
| 28 | + |
| 29 | +- **Architecture**: Maps a company's DID to an IPFS Content Identifier (CID). The CID points to a Bloom Filter Cascade representing revoked credentials. |
| 30 | +- **Governance**: Owned by the `DIDMultisigController` (Trust Anchor). Only the Trust Anchor can add or remove authorized company admins. |
| 31 | +- **Usage**: Authorized company admins update their own CID (`updateRevocationCID()`) without interacting directly with raw DID documents. |
| 32 | + |
| 33 | +## Usage Examples |
| 34 | + |
| 35 | +### Deploying the Contracts |
| 36 | + |
| 37 | +Deployment is handled via Hardhat Ignition (`ignition/modules/CompanyCRSet.ts`): |
| 38 | + |
| 39 | +```bash |
| 40 | +cd packages/trust-anchor-did-ethr |
| 41 | +npx hardhat ignition deploy ignition/modules/CompanyCRSet.ts --network localhost |
| 42 | +``` |
| 43 | + |
| 44 | +### Trust Anchor Adding a Company Admin |
| 45 | + |
| 46 | +The `CompanyCRSetRegistry` relies on the Trust Anchor to whitelist company administrators: |
| 47 | + |
| 48 | +```solidity |
| 49 | +// Only the Trust Anchor (Multisig) can call this |
| 50 | +function addCompanyAdmin(address companyDID, address admin) external onlyOwner { |
| 51 | + if (companyDID == address(0) || admin == address(0)) revert InvalidAddress(); |
| 52 | + if (companyAdmins[companyDID][admin]) revert AdminAlreadyExists(); |
| 53 | +
|
| 54 | + companyAdmins[companyDID][admin] = true; |
| 55 | + emit CompanyAdminAdded(companyDID, admin, block.timestamp); |
| 56 | +} |
| 57 | +``` |
| 58 | + |
| 59 | +### Company Updating Revocation CID |
| 60 | + |
| 61 | +Once authorized, a company admin updates the IPFS hash for their revoked credentials: |
| 62 | + |
| 63 | +```solidity |
| 64 | +// Called directly by the whitelisted company admin |
| 65 | +function updateRevocationCID(address companyDID, string calldata newCID) external onlyCompanyAdmin(companyDID) { |
| 66 | + if (bytes(newCID).length == 0) revert EmptyCID(); |
| 67 | +
|
| 68 | + revocationCIDs[companyDID] = newCID; |
| 69 | + emit RevocationCIDUpdated(companyDID, newCID, msg.sender, block.timestamp); |
| 70 | +} |
| 71 | +``` |
| 72 | + |
| 73 | +### Creating a Multisig Proposal |
| 74 | + |
| 75 | +To execute a sensitive action on the Trust Anchor identity itself, a proposal must be created and approved: |
| 76 | + |
| 77 | +```javascript |
| 78 | +// Create a proposal to add a new owner to the multisig |
| 79 | +const txPropose = await multisigController.proposeAddOwner(newOwnerAddress); |
| 80 | +const receipt = await txPropose.wait(); |
| 81 | +const proposalId = receipt.logs[0].args.id; |
| 82 | + |
| 83 | +// Other owners must approve the proposal |
| 84 | +const txApprove = await multisigController.connect(owner2).approve(proposalId); |
| 85 | +``` |
0 commit comments