Skip to content

feat(storage): Implement AES-256 Encryption and IPFS Pinning for RWA Documentation #145

Description

@grantfox-oss

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

  1. File Upload Middleware: Implement multer to handle multipart/form-data uploads securely, with strict file type validation (PDF, JPG, PNG) and size limits.
  2. 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).
  3. IPFS Pinning: Integrate a pinning service SDK (like Pinata or Web3.Storage) to upload the encrypted buffer to IPFS.
  4. 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

  • /api/v1/documents/upload endpoint successfully handles, encrypts, and pins documents to IPFS without touching the server's local disk space.
  • /api/v1/documents/:cid endpoint fetches the encrypted blob from IPFS, decrypts it in memory, and pipes the readable stream back to the authenticated client.
  • Absolute isolation of encryption keys (must be read strictly from environment variables, never hardcoded).
  • Integration tests verifying full round-trip encryption/decryption integrity.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaign

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions