Skip to content

Commit 0b54ee7

Browse files
feat: introduce comprehensive GitBook documentation structure with build instructions, feature guides, a validation workflow, and updated README links.
1 parent ee6db2c commit 0b54ee7

9 files changed

Lines changed: 405 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Docs Validation
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
paths:
7+
- 'docs/**'
8+
pull_request:
9+
branches: [ "main" ]
10+
paths:
11+
- 'docs/**'
12+
13+
jobs:
14+
lint-docs:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout Repository
18+
uses: actions/checkout@v4
19+
20+
- name: Lint markdown files
21+
uses: davidanson/markdownlint-cli2-action@v15
22+
with:
23+
globs: |
24+
docs/**/*.md

.markdownlint.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"default": true,
3+
"MD013": false,
4+
"MD033": false,
5+
"MD041": false
6+
}

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# on-chain-ssi
22

3+
[![GitBook Documentation](https://img.shields.io/badge/GitBook-Documentation-blue?logo=gitbook)](docs/getting-started.md)
4+
35
## About
46

57
On-Chain Self-Sovereign Identity (SSI) architecture migrating CRSet from Ethereum Blobs to Tezos Etherlink. This project enables organizations to issue and verify decentralized digital identities anchored on blockchain, providing cryptographic proof of identity without relying on centralized authorities.
@@ -125,11 +127,16 @@ Open http://localhost:5173/ in your browser.
125127

126128
## Documentation
127129

130+
The comprehensive project features and setup information are part of the GitBook documentation. You can find the source in the [`docs/`](docs/) directory.
131+
132+
- **[📖 GitBook Documentation](docs/getting-started.md)** - Main entry point
128133
- **[BUILD.md](BUILD.md)** - Comprehensive build instructions, testing, troubleshooting, and deployment guides
129134
- **[CI_CD.md](CI_CD.md)** - CI/CD pipeline documentation with workflow details and troubleshooting
130135
- **[Smart Contracts](packages/trust-anchor-did-ethr/README.md)** - Detailed smart contract documentation
131136
- **[Demo Application](packages/demo-app-frontend/README.md)** - Frontend application guide
132137

138+
To contribute to the documentation, simply modify the Markdown files in the `docs/` directory and create a Pull Request. GitBook will automatically synchronize the changes via its native GitHub App.
139+
133140
## License
134141

135142
This project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.

docs/SUMMARY.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Table of contents
2+
3+
* [Getting Started](getting-started.md)
4+
* [Build & Setup Instructions](build-instructions.md)
5+
6+
## Features
7+
8+
* [Registry Contracts](features/registry-contracts.md)
9+
* [Issuer Service](features/issuer-service.md)
10+
* [Verifier Service](features/verifier-service.md)

docs/build-instructions.md

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Build & Setup Instructions
2+
3+
## Prerequisites
4+
5+
Before starting, ensure you have the following installed on your system:
6+
7+
- **Node.js**: ≥ 22.12.0 (Required for Hardhat 3 and Vite 7)
8+
- **NPM**: ≥ 10.0.0
9+
- **MetaMask**: Browser extension for managing Ethereum accounts
10+
11+
> [!WARNING]
12+
> Do not use Node.js 20.x, as it will cause Hardhat runtime errors. Use a version manager like `nvm` to ensure you are on `22.12.0` or higher:
13+
>
14+
> ```bash
15+
> nvm install 22
16+
> nvm use 22
17+
> ```
18+
19+
## 1. Installation
20+
21+
Start by cloning the repository and installing both the root and package-specific dependencies.
22+
23+
```bash
24+
# Install root dependencies (including Husky pre-commit hooks)
25+
npm install
26+
27+
# Install smart contract dependencies
28+
cd packages/trust-anchor-did-ethr
29+
npm install
30+
31+
# Install frontend dependencies
32+
cd ../demo-app-frontend
33+
npm install
34+
35+
# Return to root directory
36+
cd ../..
37+
```
38+
39+
## 2. Compile and Run the Blockchain (Hardhat)
40+
41+
You'll need a local Ethereum network to deploy the registry contracts. Ensure you run this in a **dedicated terminal** and leave it open.
42+
43+
```bash
44+
cd packages/trust-anchor-did-ethr
45+
46+
# Start Hardhat local node
47+
npx hardhat node
48+
```
49+
50+
Once running, Hardhat will output a list of test accounts and private keys. Keep this window open.
51+
52+
## 3. Deploy Smart Contracts
53+
54+
Open a **new terminal** and deploy the initial Trust Anchor and Registry contracts to the local network:
55+
56+
```bash
57+
cd packages/trust-anchor-did-ethr
58+
59+
# Deploy the modules using Hardhat Ignition
60+
npx hardhat ignition deploy ignition/modules/CompanyCRSet.ts --network localhost
61+
```
62+
63+
**Important**: The deployment process will output the contract addresses. **Copy these addresses**, as you will need them for the frontend configuration.
64+
65+
Example output:
66+
67+
```text
68+
CompanyCRSetModule#EthereumDIDRegistry - 0xabcd...1234
69+
CompanyCRSetModule#DIDMultisigController - 0xef01...5678
70+
CompanyCRSetModule#CompanyCRSetRegistry - 0x9abc...def0
71+
```
72+
73+
## 4. Frontend Configuration
74+
75+
Navigate to the frontend package and configure the environment variables:
76+
77+
```bash
78+
cd packages/demo-app-frontend
79+
80+
# Copy the example environment file
81+
cp .env.example .env
82+
```
83+
84+
Open the `.env` file and replace the placeholder addresses with the addresses you received from the contract deployment step:
85+
86+
| Variable | Description | Value from Deployment |
87+
| :--- | :--- | :--- |
88+
| `VITE_TRUST_ANCHOR_ADDRESS` | Address of the Trust Anchor multisig | `CompanyCRSetModule#DIDMultisigController` |
89+
| `VITE_REGISTRY_ADDRESS` | Address of the baseline DID registry | `CompanyCRSetModule#EthereumDIDRegistry` |
90+
| `VITE_CRSET_REGISTRY_ADDRESS` | Address of the revocation registry | `CompanyCRSetModule#CompanyCRSetRegistry` |
91+
| `VITE_PINATA_JWT` | JWT for Pinata IPFS access (Optional for local testing) | *Your Pinata Token* |
92+
| `VITE_HARDHAT_RPC_URL` | Local RPC endpoint | `http://127.0.0.1:8545` |
93+
94+
## 5. Configure MetaMask
95+
96+
To interact with the local development environment:
97+
98+
1. Add a **Custom Network** to MetaMask:
99+
- **Network Name**: Hardhat Local
100+
- **RPC URL**: `http://127.0.0.1:8545`
101+
- **Chain ID**: `31337`
102+
- **Currency Symbol**: `ETH`
103+
2. **Import Accounts**: Import the first few (1-5) private keys provided by the Hardhat node terminal into MetaMask to act as the Trust Anchor admins.
104+
105+
## 6. Run the Application
106+
107+
Start the local Vite development server for the frontend application:
108+
109+
```bash
110+
cd packages/demo-app-frontend
111+
npm run dev
112+
```
113+
114+
The application will be accessible at [http://localhost:5173/](http://localhost:5173/).
115+
116+
## Additional Commands
117+
118+
### Testing Contracts
119+
120+
```bash
121+
cd packages/trust-anchor-did-ethr
122+
npx hardhat test
123+
```
124+
125+
### Production Build (Frontend)
126+
127+
```bash
128+
cd packages/demo-app-frontend
129+
npm run build
130+
```
131+
132+
This generates the optimized `dist/` artifacts required if you intend to serve the application via Docker or static hosting.

docs/features/issuer-service.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Issuer Service
2+
3+
> [!NOTE]
4+
> The `issuer-service` is currently a placeholder package within the `on-chain-ssi` monorepo. The core verifiable credential issuance logic is expected to be implemented here in the future.
5+
6+
## Overview and Purpose
7+
8+
The Issuer Service is responsible for generating and signing Verifiable Credentials (VCs) for users or organizations within the On-Chain SSI ecosystem. It acts as the authority that attests to specific claims about a subject.
9+
10+
While the dedicated backend service is pending implementation, some issuance flows (such as registering companies and adding test credentials) are currently demonstrated via the `demo-app-frontend`, which interacts directly with the smart contracts using the test accounts.
11+
12+
## Technical Details
13+
14+
Currently, the `packages/issuer-service/` directory contains placeholder files. Once implemented, this service is expected to:
15+
16+
- **DID Method**: Utilize `did:ethr` for resolving and anchoring identities.
17+
- **Credential Format**: Issue W3C standard Verifiable Credentials (typically JWT or JSON-LD format).
18+
- **Architecture**: Likely a Node.js/TypeScript backend service or an Express/NestJS API that holds the private key of the issuer.
19+
20+
## Usage Examples
21+
22+
> Note: These are illustrative examples based on the planned architecture. Actual implementation may vary once the service is fully developed in the repository.
23+
24+
### Planned API Endpoint (Illustrative)
25+
26+
```http
27+
POST /api/v1/issue-credential
28+
Content-Type: application/json
29+
30+
{
31+
"subjectDid": "did:ethr:sepolia:0x1234567890abcdef1234567890abcdef12345678",
32+
"claims": {
33+
"organizationName": "Acme Corp",
34+
"role": "Verified Partner"
35+
}
36+
}
37+
```
38+
39+
### Current Frontend Issuance (Workaround)
40+
41+
In the current demo, the Trust Anchor (using a Hardhat test account) directly registers a company on-chain, effectively "issuing" them the right to act within the ecosystem:
42+
43+
```javascript
44+
// Example from frontend hooks (useTrustAnchor.ts context)
45+
const addCompanyAdmin = async (companyDID, adminAddress) => {
46+
// Trust Anchor multisig executes transaction to authorize a company admin
47+
const tx = await registryContract.addCompanyAdmin(companyDID, adminAddress);
48+
await tx.wait();
49+
};
50+
```
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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+
```

docs/features/verifier-service.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Verifier Service
2+
3+
> [!NOTE]
4+
> The `verifier-service` is currently a placeholder package within the `on-chain-ssi` monorepo. The verification logic is part of the future implementation roadmap.
5+
6+
## Overview and Purpose
7+
8+
The Verifier Service's role is to receive Verifiable Presentations (VPs) or Verifiable Credentials (VCs) from users (Holders) and cryptographically verify their authenticity, integrity, and validity against the on-chain registry.
9+
10+
Currently, validation of identity statuses (like checking if an address is an authorized company admin) is performed directly by the smart contracts and the frontend application.
11+
12+
## Technical Details
13+
14+
The `packages/verifier-service/` directory holds placeholder files. The completed service is designed to handle:
15+
16+
- **DID Resolution**: Resolving `did:ethr` documents from the `EthereumDIDRegistry`.
17+
- **Revocation Checking**: Checking the `CompanyCRSetRegistry` for a company's current Credential Revocation Set (CRSet) via IPFS/Bloom Filters to ensure credentials haven't been revoked.
18+
- **Signature Verification**: Verifying the issuer's cryptographic signature on the VC/VP.
19+
20+
## Usage Examples
21+
22+
> Note: These are illustrative examples based on the system's architecture. The verifiable logic shown here represents the planned flow.
23+
24+
### Checking Revocation Status (Current On-Chain Flow)
25+
26+
The verification process relies on the `CompanyCRSetRegistry` to find the latest revocation list (CRSet) for an issuer:
27+
28+
```solidity
29+
// CompanyCRSetRegistry.sol
30+
// Verifiers call this to get the IPFS CID of the company's revocation set
31+
function getRevocationCID(address companyDID) external view returns (string memory) {
32+
return revocationCIDs[companyDID];
33+
}
34+
```
35+
36+
### Planned API Endpoint (Illustrative)
37+
38+
```http
39+
POST /api/v1/verify
40+
Content-Type: application/json
41+
42+
{
43+
"verifiablePresentation": "eyJhbGciOiJFUzI1Nksi...[VP Token]..."
44+
}
45+
```
46+
47+
### Verifying an Identity (Frontend/Smart Contract Context)
48+
49+
To verify if an address is authorized to manage a company's identity before accepting their credentials:
50+
51+
```javascript
52+
// Call to CompanyCRSetRegistry
53+
const isAuthorized = await crsetRegistry.isCompanyAdmin(companyDid, userAddress);
54+
55+
if (!isAuthorized) {
56+
throw new Error("This user is not an authorized administrator for the company.");
57+
}
58+
```

0 commit comments

Comments
 (0)