This repository contains the Chaincode (Smart Contracts) and Express.js API Gateway for a blockchain-based land certificate system. The project focuses on securing land records using document hashing and multi-party digital signature consensus.
The system operates through three primary layers:
- Chaincode (Hyperledger Fabric): Manages the immutable ledger and validates cryptographic signatures.
- Middleware (Express.js): Acts as the gRPC bridge, handling identity management and transaction routing.
- Client (Laravel): The user interface for uploading certificates and initiating verification (repository separate).
Unlike standard automated consensus, this system requires the agreement of all parties involved in a transaction.
- Each participant signs the
transactionDatausing their Google Cloud KMS-managed keys. - The chaincode's
CreateAssetfunction verifies every signature against the providedpublic_key_pembefore committing the data. - If a single signature is invalid or a previous owner's ID does not match, the transaction is rejected.
- Sensitive land certificate data is not stored on the blockchain. Instead, a SHA-256 hash of the document is stored.
- This ensures data privacy while allowing anyone with the original document to verify its authenticity by comparing hashes.
- The system is optimized for high-throughput peer environments.
- Empirical results show a 0.62s performance gain when scaling from 2 to 6 peers, demonstrating the efficiency of the signature-based consensus model.
- Hyperledger Fabric (v2.x or later)
- Node.js (v18+)
- Docker & Docker Compose
- Clone the repository:
git clone https://github.com/Cupcake-Legend/landchain-chaincode.git
cd landchain-chaincode
- Install Dependencies:
npm install
The Express.js server facilitates communication with the Fabric test-network. Ensure your network is running and the chaincode is deployed.
node server.js
The REST API will be available at http://localhost:3000.
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/init |
Initializes the ledger with dummy data. |
| GET | /api/certificates |
Retrieves all certificate records from the ledger. |
| POST | /api/insert-certificate |
Validates signatures and records a new certificate edition. |
| POST | /api/verify-certificate |
Checks if a specific hash exists and if it is the latest edition. |
{
"certificateHash": "hash_of_original_document",
"certificateEditionFileHash": "hash_of_current_file_edition",
"transactionData": "metadata_string",
"participantKeys": "[{\"kms_key_id\": \"id1\", \"signature\": \"...\", \"public_key_pem\": \"...\", \"type\": \"buyer\"}]"
}
The core security is handled by the verifySignature function using the crypto module:
async verifySignature(signatureBase64, publicKeyPem, transactionData) {
const signatureBuffer = Buffer.from(signatureBase64, 'base64');
const verifier = crypto.createVerify('sha256');
verifier.update(transactionData);
verifier.end();
return verifier.verify(publicKeyPem, signatureBuffer);
}