Skip to main content

banner

Nevermined Secret Store Client

🐳 Python client for Parity Secret Store. nevermined.io

PyPI Python package


Table of Contents


Features

  • Encrypt and publish encrypted documents to the Parity Secret Store.
  • Fetch and decrypt the documents from the Parity Secret Store, if permissions are given.

Prerequisites

  • A URL of a Secret Store node that accepts requests.

  • A supported version of Python. For details, see setup.py.

  • A JSON-RPC URL of the Parity EVM client. It is strongly recommended to run the client locally.

  • A publisher Ethereum account, for publishing documents.

  • A consumer Ethreum account, for consuming documents.

Quickstart

Instantiate a publisher

from secret_store_client import Client

secret_store_url = 'http://localhost:8010'
parity_client_url = 'http://localhost:8545'
publisher_address = '0xc8307e6fbe40e97061a7b9f88b98df9249e4cefd'
publisher_password = 'publisherpwd'

publisher = Client(secret_store_url, parity_client_url,
                   publisher_address, publisher_password)

Publish a document

import hashlib

document = 'mySecretDocument'
# we need a 256 bit hash
document_id = hashlib.sha256(document.encode()).hexdigest()

encrypted = publisher.publish_document(document_id, document)

By default, if there are multiple Secret Store nodes, all nodes are required to participate in the encryption process. You can allow one or more nodes to not participate by passing a custom threshold parameter:

encrypted = publisher.publish_document(document_id, document, threshold=1)

You can find some guidance on how to choose a threshold here.

Instantiate a consumer

from secret_store_client import Client

secret_store_url = 'http://localhost:8010'
parity_client_url = 'http://localhost:8545'
consumer_address = '0xe887f790103a108e9c500cf167bfef019f5f41e0'
consumer_password = 'consumerpwd'

consumer = Client(secret_store_url, parity_client_url,
                  consumer_address, consumer_password)

Decrypt the document

decrypted = consumer.decrypt_document(document_id, encrypted)

assert 'mySecretDocument' == decrypted

Development

The Secret Store setup instructions in this section is a simplification of the instructions presented here.

Download and compile the Parity Ethereum client

Follow these instructions.

Put the ./target/release/parity binary somewhere on your PATH.

Configure a publisher node

Make a copy of the user configuration template.

cp integration_tests/configs/users.template.toml integration_tests/configs/users.toml

Create an account.

parity --config integration_tests/configs/users.toml account new

It asks you for a password and outputs an address.

Now make a copy of the test configuration template.

cp integration_tests/configs/test_setup.template.conf integration_tests/configs/test_setup.conf

Insert your publisher password and address into the corresponding placeholders inside test_setup.conf.

Configure a consumer node

Repeat the steps from the previous section except for this time fill in consumer address and password in the configuration file.

Configure a Secret Store node

Make a copy of the Secret Store configuration template.

cp integration_tests/configs/secret_store.template.toml integration_tests/configs/secret_store.toml

Create an account.

parity --config integration_tests/configs/secret_store.toml account new

It asks you for a password and outputs an address.

Put your password into integration_tests/configs/ss.pwd. Put the account address into the corresponding place inside integration_tests/configs/secret_store.toml and uncomment the password = line.

Run the Secret Store node.

parity --config integration_tests/configs/secret_store.toml

It outputs its public node URL.

...
Public node URL: enode://a67dd8d6ffbf81fdd98fdae6902c527c77de34bc6fc39ffa8767126ee71d73484f8f7f692c02f095682b2578e11af004ab68ba47d8a923a7b868a040d2f6d479@192.168.86.248:30301

Insert this URL into the bootnodes list of your users.toml.

Deploy the test permission contract

Install truffle:

npm -g install truffle@beta

Note the versions the process was tested with.

npm 6.4.1
node v9.11.2
Truffle v5.0.0-beta.1 (core: 5.0.0-beta.1)
Solidity v0.4.25 (solc-js)

Compile the contract.

truffle compile

Deploy the contract.

truffle migrate

It outputs "contract address". Copy it and insert as a value for acl_contract into secret_store.toml.

Relaunch the node for the change to take action.

Run the nodes

The steps above have to only be performed once. Every time you want to develop or test, just run the Secret Store node and the Parity Ethereum client.

Run the Secret Store node:

parity --config integration_tests/configs/secret_store.toml

Run the Parity Ethereum client:

parity --config integration_tests/configs/users.toml

Execute integration tests

Make sure the Secret Store node and the Parity Ethereum client are up and running, then execute:

python3 setup.py test

TLDR

pip install flake8
flake8 secret_store_client integration_tests tests

New Version

The bumpversion.sh script helps to bump the project version. You can execute the script using as first argument {major|minor|patch} to bump accordingly the version.

Attribution

This project is based in the Ocean Protocol Python Secret Store Client. It keeps the same Apache v2 License and adds some improvements. See NOTICE file.

License

Copyright 2020 Keyko GmbH
This product includes software developed at
BigchainDB GmbH and Ocean Protocol (https://www.oceanprotocol.com/)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.


Metadata

Release files for nevermined-secret-store 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nevermined-secret-store 0.1.1
File Size Uploaded Provenance
nevermined-secret-store-0.1.1.tar.gz 10.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for nevermined-secret-store 0.1.1
File Interpreter ABI Platform
nevermined_secret_store-0.1.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 21.2 kB

Release files / nevermined-secret-store-0.1.1.tar.gz

Download URL nevermined-secret-store-0.1.1.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3a9304cbd80f97d0767b5f7d34757b14ab3d924ab8ac9582d8b65186b1f8262e
BLAKE2b-256 checksum
How to use checksums
ac3c7202691f0812c4a0a85055d7a831b94693f8461f9006b86539457e2e0e1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

Release files / nevermined_secret_store-0.1.1-py2.py3-none-any.whl

Download URL nevermined_secret_store-0.1.1-py2.py3-none-any.whl
Size 10.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
7a5d98a399e0f3b499ce37e0ee0bad2066082d63e6fa1e1730d9654cbea1af58
BLAKE2b-256 checksum
How to use checksums
8e34693523e2a359933faf4adec579e7d975dc193160632f65bd84604ec79344
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

Security for nevermined-secret-store 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page