This repository contains the Go implementation of the Sri Lanka Unique Digital Identity (SLUDI) chaincode for Hyperledger Fabric networks. The chaincode manages Decentralized Identifiers (DIDs), Verifiable Credentials, Organization Users, and Authentication Logs.
- DID Management: Create, update, deactivate, and query Decentralized Identifiers
- Verifiable Credentials: Issue, revoke, verify, and query credentials
- Organization Users: Register, update, revoke, and restore organization users
- Authentication Logging: Log and query authentication events
- System Statistics: Track system-wide metrics
| Component | Version | Installation Guide |
|---|---|---|
| Go | 1.21+ | Go Installation |
| Docker | 20.10+ | Docker Docs |
| Fabric Samples | 2.5+ | Fabric Docs |
To download Hyperledger Fabric CLI tools and Docker images:
curl -sSL https://bit.ly/2ysbOFE | bash -s -- 2.5.0 1.5.6- test-network directory should be at the same level of the project directory
SLUDI-Chaincode-Go/
βββ entities/ # Data structures
β βββ did_document.go
β βββ verifiable_credential.go
β βββ authentication_log.go
β βββ organization_user.go
β βββ supporting_types.go
βββ contract/ # Smart contract functions
β βββ sludi_contract.go
β βββ org_auth_functions.go
βββ main.go # Entry point
βββ go.mod # Go module definition
βββ Dockerfile # Container build file
βββ README.md # This file
cd SLUDI-Chaincode-Go
go mod tidygo buildgo test ./... -vThe scripts/ directory contains deployment and testing utilities:
- deploy.sh - Main deployment script (start/update modes)
- test-chaincode.sh - Comprehensive testing with 12 test cases
- package.sh - Build and package chaincode
See scripts/README.md for detailed usage instructions.
# Navigate to test-network
cd /path/to/fabric-samples/test-network
# Deploy chaincode
../SLUDI-Chaincode/SLUDI-Chaincode-Go/scripts/deploy.sh start 1.0
# Run all tests
../SLUDI-Chaincode/SLUDI-Chaincode-Go/scripts/test-chaincode.sh allThe deployment script simplifies the deployment process during development in the test network.
scripts/deploy.sh| Mode | Description |
|---|---|
start |
Brings down any existing network, starts a new one, creates the channel, and deploys the chaincode. Use this for initial setup or network resets. |
update |
Skips network operations and only deploys the updated chaincode. Use this during development when updating the chaincode logic frequently. |
From test-network directory:
# Full network reset + deploy chaincode version 1.0
../SLUDI-Chaincode/scripts/deploy.sh start 1.0
# Only re-deploy updated chaincode as version 1.1 (no network restart)
../SLUDI-Chaincode/scripts/deploy.sh update 1.1 2If you prefer manual deployment:
# Package the chaincode
peer lifecycle chaincode package sludi-chaincode.tar.gz \
--path ./SLUDI-Chaincode-Go \
--lang golang \
--label sludi-chaincode_1.0
# Install on peer
peer lifecycle chaincode install sludi-chaincode.tar.gz
# Approve and commit (follow standard Fabric lifecycle)CreateDID- Create a new DID documentGetDID- Retrieve a DID documentUpdateDID- Update DID public keys and servicesDeactivateDID- Deactivate a DIDGetDIDHistory- Get DID modification history
IssueCredential- Issue a new credentialGetCredential- Retrieve a credentialRevokeCredential- Revoke a credentialGetCredentialsBySubject- Query credentials by subject DIDGetCredentialsByIssuer- Query credentials by issuerVerifyCredential- Verify credential validity
RegisterOrganizationUser- Register a new userGetOrganizationUser- Retrieve user detailsUpdateOrganizationUser- Update user informationRevokeOrganizationUser- Revoke user accessRestoreOrganizationUser- Restore revoked user
LogAuthentication- Log an authentication eventGetAuthenticationLog- Retrieve authentication logGetAuthenticationLogsByUser- Query logs by user DID
InitLedger- Initialize the ledgerGetSystemStats- Get system statistics
peer chaincode invoke -C sludi-channel -n sludi-chaincode \
-c '{"function":"CreateDID","Args":["did:sludi:123","1.0","[]","[]","[]","{\"proofType\":\"Ed25519Signature2018\",\"created\":\"2025-12-03T12:00:00Z\",\"creator\":\"did:sludi:issuer\",\"issuerDid\":\"did:sludi:issuer\",\"signatureValue\":\"abc123\"}"]}'peer chaincode query -C sludi-channel -n sludi-chaincode \
-c '{"function":"GetDID","Args":["did:sludi:123"]}'peer chaincode query -C sludi-channel -n sludi-chaincode \
-c '{"function":"GetSystemStats","Args":[]}'This is a complete rewrite of the Java chaincode in Go. Key differences:
- Language: Go instead of Java
- Build System: Go modules instead of Gradle
- Deployment: Golang chaincode type instead of Java
- Performance: Generally faster execution and lower memory footprint
The data structures and functionality remain the same, ensuring compatibility with existing applications.
Apache-2.0