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:

  1. Sign EIP-712 ConsentRecord structure containing:

    • supplier: Supplier's blockchain address

    • agreementContract: Agreement contract address

    • agreementId: The specific agreement identifier

  2. Attach signature to API request headers:

    • X-Signature: EIP-712 signature

    • X-Consent-ID: The onchain id of associated consent record

Supplier Flow:

  1. Extract signature and identifiers from request headers

  2. Recover signer from EIP-712 signature

  3. Verify:

    • Signer matches consent consumer

  4. Serve data if verification passes, otherwise reject

Supplier and Consumer doesn't need to have a DID Document when using signature based verification

Consumer Code:

Supplier Code:

Api Request Example:

Api Middleware Example

B. IPFS Encrypted Mode

Condition: open: false AND dataRef.startsWith("ipfs://")

Supplier Flow:

  1. Extract consumer's public key from DID Document (keyAgreement section)

  2. Generate ECDH shared secret: secp256k1.getSharedSecret(supplierPrivKey, consumerPubKey)

  3. Encrypt data with AES-256-GCM using SHA256(sharedSecret) as key

  4. Upload envelope JSON to IPFS: { ciphertext, iv, authTag }

  5. Set dataRef to the IPFS CID

Consumer Flow:

  1. Fetch encrypted envelope from IPFS using the CID

  2. Extract supplier's public key from DID Document

  3. Generate same ECDH shared secret: secp256k1.getSharedSecret(consumerPrivKey, supplierPubKey)

  4. Decrypt using AES-256-GCM with authenticated verification

Public key of the DID subject can be found in DID document under keyAgreement

Code for Supplier Encryption:

Code for Consumer Decryption:

Last updated