Data Access Patterns
Defined process of accessing data in permission protocol by a consumer utilizing dataRef in a consent record for secure access of supplier provided data according to consent.
DataRef driven Access Pattern
There are two ways to access data from supplier, IPFS encrypted and Signature Gated mode
Chossing Correct Mode
dataRef starts with ipfs:// ⇒ IPFS Encrypted Mode
dataRef starts with http:// or https:// ⇒ API Signature-Gated Mode
1. Public Access Mode (disclosed: true)
Condition: When the consent record contains { disclosed: true, dataRef: "..." }
Behavior:
Data is publicly accessible without any cryptographic protection
No EIP-712 signatures required
No ECDH encryption/decryption needed
Consumer can directly fetch data using the dataRef URI
Suitable for non-sensitive, publicly shareable datasets
Example Consent Record:
2. Restricted Access Mode (disclosed: false)
When disclosed: false (or undefined), the protocol uses secure access based on dataRef scheme:
A. Signature Gated Api Mode
Consumer Flow:
Sign EIP-712 ConsentRecord structure containing:
supplier: Supplier's blockchain address
agreementContract: Agreement contract address
agreementId: The specific agreement identifier
Attach signature to API request headers:
X-Signature: EIP-712 signature
X-Consent-ID: The onchain id of associated consent record
Supplier Flow:
Extract signature and identifiers from request headers
Recover signer from EIP-712 signature
Verify:
Signer matches consent consumer
Serve data if verification passes, otherwise reject
Consumer Code:
Supplier Code:
Api Request Example:
Api Middleware Example
B. IPFS Encrypted Mode
Consumer and Supplier must have DID Documents so public keys can be extracted for encryption
Condition: open: false AND dataRef.startsWith("ipfs://")
Supplier Flow:
Extract consumer's public key from DID Document (keyAgreement section)
Generate ECDH shared secret: secp256k1.getSharedSecret(supplierPrivKey, consumerPubKey)
Encrypt data with AES-256-GCM using SHA256(sharedSecret) as key
Upload envelope JSON to IPFS: { ciphertext, iv, authTag }
Set dataRef to the IPFS CID
Consumer Flow:
Fetch encrypted envelope from IPFS using the CID
Extract supplier's public key from DID Document
Generate same ECDH shared secret: secp256k1.getSharedSecret(consumerPrivKey, supplierPubKey)
Decrypt using AES-256-GCM with authenticated verification
Code for Supplier Encryption:
Code for Consumer Decryption:
Last updated

