Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Chapter 2 — Consumer: request access and decrypt

This notebook walks through the consumer side of the FAIR2Adapt access control workflow. You will:

  1. Unwrap the dataset key using your private key

  2. Decrypt the dataset

  3. Verify the access grant

Step 1 — Load your private key

Your private key was generated in Chapter 0 and saved to keys/example-consumer-private.pem. It never leaves your machine.

Step 2 — Download the wrapped key

The provider published a wrapped dataset key specifically for your DID. In production, this would be at a URL like:

https://fair2adapt.github.io/fair-data-access/keys/<hash-of-your-did>/dataset.key

Here we load it from the local file created by Chapter 1.

Step 3 — Unwrap the dataset key

Using ECDH key agreement: the wrapped envelope contains an ephemeral public key from the provider. Your private key + that ephemeral public key produce a shared secret, which decrypts the dataset key.

Step 4 — Decrypt the dataset

With the recovered dataset key, decrypt the .enc file to get back the original CSV.

Step 5 — Verify the data

Load the decrypted CSV and confirm it matches the original synthetic dataset.

Step 6 — Verify the access grant (audit trail)

In production, the access grant is a signed nanopublication on the decentralised nanopub network. Anyone can independently verify:

  1. The grant exists — query the nanopub network by dataset URI + consumer DID

  2. The signature is valid — the grant was signed by the same ORCID that published the policy

  3. The policy was followed — the grant references the policy nanopub

ODRL Access Grant rendered in Science Live

The access grant as rendered by the Science Live platform.

Summary

The consumer has:

StepWhat happenedTrust guarantee
Unwrap keyRecovered the dataset key from the wrapped envelopeOnly your private key could do this
DecryptGot back the original dataset from the .enc fileAES-GCM integrity check passed
Verify grantConfirmed the grant nanopub exists and is properly signedCryptographic signature verification

The complete chain of trust:

ODRL Policy (signed nanopub)
  ↓ evaluated against
Access Request (consumer DID + purpose)
  ↓ results in
Access Grant (signed nanopub + wrapped key)
  ↓ unwrapped by consumer
Dataset Key
  ↓ decrypts
Original Dataset ✓

Every link in this chain is cryptographically verifiable and publicly auditable, while the dataset itself remains protected.


What’s next?

  • Adapt to your data: Replace data/hamburg-buildings-example.gpkg with your own file and re-run 01_provider.ipynb. No code changes needed.

  • Publish for real: Use the Science Live platform to create the ODRL policy and access grant as signed nanopublications.

  • Set up your own DID: Follow Chapter 0 to publish your identity via GitHub Pages.

  • Automate: See the GitHub Actions workflow for fully automated policy evaluation and key wrapping.