/blockchain

Explore extensions and applicability of Blockchain technology to guarantee integrity and traceability of private data.

Primary LanguagePythonMIT LicenseMIT

User-Data Consents Management Blockchain

User consents management using Blockchain technology to guarantee integrity and traceability of private data.

Confluence Page: MODL - EvalBlockchain

Évaluer l’utilisation de la technologie blockchain pour garantir l’intégrité et la traçabilité des données privées.

version badge MIT

Table of Contents

Blockchain Contents

The blockchains are intended to contain tracking of Consent changes and resolution. Each blockchain UUID (multiple chains per nodes) represent a potential distinct user for management their Consents.

Starting with version 2.0.1, Consent Subsystems metadata can also be stored in the blockchains to better represented the consented data, and maintain references to any applicable data provider, data source or other policies using customizable metadata.

Following is a visual representation of such Consents using UI endpoints.

blockchain-consents

Similar details can be retrieved from the API endpoints, as well as further operations on the blockchains and nodes for which process consensus resolution must be executed against in a network of blockchain nodes.

The Consents are generated with a set of demonstration Actions, which can be extended as needed by modifying the ConsentsAction enumeration.

Please refer to Updating Consents section for more details regarding applicable consents metadata that can be pushed to a blockchain.

Installation

  1. Make sure Python 3.6+ is installed.
  2. Install the dependencies in your preferred virtual environment manager (pipenv, conda, etc.)
pip install -e <blockchain-repo-root> 
  1. Generate one or more blockchains:
python blockchain/app.py --port 5002 --db file://<custom-directory> --new
  1. Run one or more server nodes:
python blockchain/app.py -s secret -p 5001 --db file://<custom-directory>  # loads all "<blockchain-id>/chain.json" in directory
python blockchain/app.py -s secret -p 5002 --db file://<custom-directory>/<id>/chain.json  # loads only that blockchain
python blockchain/app.py -s secret -p 5003 --db file://<custom-directory>/chains.txt  # loads only listed blockchains IDs
python blockchain/app.py -s secret --port 5004 --db <db-impl>://<db-connector>  # use an alternate database implementation

When running server nodes, any predefined set of nodes within a shared network should be provided directly with the --nodes='<node1-url>,<node2-url>,...' option to allow consensus resolution between nodes. Otherwise, nodes can be registered after startup using the relevant API endpoints.

When running the above commands to start a server node, uvicorn ASGI runner is automatically called to serve the Web Application. Any additional parameters supported by uvicorn can be specified on the command line. For example, timeout controls and workers can be configured as follows.

python blockchain/app.py \
  --db "file://<custom-directory>" \
  --secret 'blockchain-1' \
  -N "0.0.0.0:5002" -N "0.0.0.0:5003" -N "0.0.0.0:5004" \
  --host "0.0.0.0" \
  --port 5001 \ 
  --workers 20 \ 
  --timeout-keep-alive 10

The CLI will automatically handle and redirect relevant parameters for the blockchain and the ASGI runner respectively.

  1. Once started, refer to the following endpoints for OpenAPI requests and details:

Details about the current blockchain node:

GET localhost:<port>/

OpenAPI description:

GET localhost:<port>/api
  1. Refer to usage help for further customization options:
python blockchain/app.py --help

Docker

Another option for running this blockchain program is to use Docker.
Follow the instructions below to create a local Docker container:

  1. Clone this repository
  2. Build the docker container
docker build -t blockchain:2.0.1 .
  1. Run the container
docker run --rm -p 80:5000 blockchain:2.0.1 <blockchain-parameters>
  1. To add more instances, vary the public port number before the colon:
docker run --rm -p "81:5000" blockchain:2.0.1 <blockchain-parameters>
docker run --rm -p "82:5000" blockchain:2.0.1 <blockchain-parameters>
docker run --rm -p "83:5000" blockchain:2.0.1 <blockchain-parameters>

Citation

Versions 1.1.0 and prior providing the initial Consents multi-blockchain application correspond to the following publication:

Darine Ameyed, Fehmi Jaafar, Francis Charette-Migneault, and Mohamed Cheriet. " Blockchain Based Model for Consent Management and Data Transparency Assurance." In 2021 IEEE 21th International Conference on Software Quality, Reliability and Security Companion (QRS-C). IEEE, 2019.

@article{ Ameyed2021QRS,
  title={Blockchain Based Model for Consent Management and Data Transparency Assurance},
  author={Ameyed, Darine and Jaafar, Fehmi and Charette-Migneault, Francis and Cheriet, Mohamed},
  journal={2021 IEEE 21th International Conference on Software Quality, Reliability and Security Companion (QRS-C)},
  year={2021}
}

Version 2.0.1 and any following minor releases correspond to the extension of the previous work with Consents Subsystems. This is associated with the following publication.

contents-shield

License

This work is licensed under MIT License.

The original implementation is based on dvf/blockchain with the following MIT License. See its corresponding README for more details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Resources

Following are the reference resources and source code employed to start development of this project.