Context and Motivation
TradeFlow handles sensitive Real World Assets. Off-chain documentation, such as PDF invoices, business registries, and KYC forms, cannot be stored in plain text on centralized cloud buckets due to compliance and centralization risks. However, storing them raw on IPFS exposes private financial data to the public.
We require an implementation that encrypts these documents server-side before pinning them to a decentralized storage network.
Technical Specification
- File Upload Middleware: Implement
multer to handle multipart/form-data uploads securely, with strict file type validation (PDF, JPG, PNG) and size limits.
- Server-Side Encryption: Implement a crypto utility using Node's native
crypto module (AES-256-GCM) to encrypt the file buffer in memory using a protocol-managed master key (or derived KMS keys).
- IPFS Pinning: Integrate a pinning service SDK (like Pinata or Web3.Storage) to upload the encrypted buffer to IPFS.
- Database Mapping: Save the returned IPFS CID (Content Identifier), the initialization vector (IV), and the auth tag securely in the Prisma database, linked to the respective
Invoice or User record.
Acceptance Criteria
Context and Motivation
TradeFlow handles sensitive Real World Assets. Off-chain documentation, such as PDF invoices, business registries, and KYC forms, cannot be stored in plain text on centralized cloud buckets due to compliance and centralization risks. However, storing them raw on IPFS exposes private financial data to the public.
We require an implementation that encrypts these documents server-side before pinning them to a decentralized storage network.
Technical Specification
multerto handlemultipart/form-datauploads securely, with strict file type validation (PDF, JPG, PNG) and size limits.cryptomodule (AES-256-GCM) to encrypt the file buffer in memory using a protocol-managed master key (or derived KMS keys).InvoiceorUserrecord.Acceptance Criteria
/api/v1/documents/uploadendpoint successfully handles, encrypts, and pins documents to IPFS without touching the server's local disk space./api/v1/documents/:cidendpoint fetches the encrypted blob from IPFS, decrypts it in memory, and pipes the readable stream back to the authenticated client.