Package: nevermined-secret-store
Nevermined Secret Store Client🐳  Python client for Parity Secret Store.nevermined.ioTable of ContentsNevermined Secret Store ClientTable of ContentsFeaturesPrerequisitesQuickstartInstantiate a publisherPublish a documentInstantiate a consumerDecrypt the documentDevelopmentDownload and compile the Parity Ethereum clientConfigure a publisher nodeConfigure a consumer nodeConfigure a Secret Store nodeDeploy the test permission contractRun the nodesExecute integration testsTLDRNew VersionAttributionLicenseFeaturesEncrypt and publish encrypted documents to the Parity Secret Store.Fetch and decrypt the documents from the Parity Secret Store, if permissions are given.PrerequisitesA URL of a Secret Store node that accepts requests.A supported version of Python. For details, seesetup.py.A JSON-RPC URL of theParity 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.QuickstartInstantiate a publisherfrom 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 documentimport 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 customthresholdparameter:encrypted = publisher.publish_document(document_id, document, threshold=1)You can find some guidance on how to choose a thresholdhere.Instantiate a consumerfrom 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 documentdecrypted = consumer.decrypt_document(document_id, encrypted)

assert 'mySecretDocument' == decryptedDevelopmentThe Secret Store setup instructions in this section is a simplification of the instructions presentedhere.Download and compile the Parity Ethereum clientFollow theseinstructions.Put the./target/release/paritybinary somewhere on your PATH.Configure a publisher nodeMake a copy of the user configuration template.cp integration_tests/configs/users.template.toml integration_tests/configs/users.tomlCreate an account.parity --config integration_tests/configs/users.toml account newIt 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.confInsert your publisher password and address into the corresponding placeholders insidetest_setup.conf.Configure a consumer nodeRepeat the steps from the previous section except for this time fill in consumer address and password in the configuration file.Configure a Secret Store nodeMake a copy of the Secret Store configuration template.cp integration_tests/configs/secret_store.template.toml integration_tests/configs/secret_store.tomlCreate an account.parity --config integration_tests/configs/secret_store.toml account newIt asks you for a password and outputs an address.Put your password intointegration_tests/configs/ss.pwd. Put the account address into the corresponding place
insideintegration_tests/configs/secret_store.tomland uncomment thepassword =line.Run the Secret Store node.parity --config integration_tests/configs/secret_store.tomlIt outputs its public node URL....
Public node URL: enode://a67dd8d6ffbf81fdd98fdae6902c527c77de34bc6fc39ffa8767126ee71d73484f8f7f692c02f095682b2578e11af004ab68ba47d8a923a7b868a040d2f6d479@192.168.86.248:30301Insert this URL into thebootnodeslist of yourusers.toml.Deploy the test permission contractInstalltruffle:npm -g install truffle@betaNote 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 compileDeploy the contract.truffle migrateIt outputs "contract address". Copy it and insert as a value foracl_contractintosecret_store.toml.Relaunch the node for the change to take action.Run the nodesThe 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.tomlRun the Parity Ethereum client:parity --config integration_tests/configs/users.tomlExecute integration testsMake sure the Secret Store node and the Parity Ethereum client are up and running, then execute:python3 setup.py testTLDRpip install flake8
flake8 secret_store_client integration_tests testsNew VersionThebumpversion.shscript helps to bump the project version. You can execute the script using as first argument {major|minor|patch} to bump accordingly the version.AttributionThis project is based in the Ocean ProtocolPython Secret Store Client.
It keeps the same Apache v2 License and adds some improvements. SeeNOTICE file.LicenseCopyright 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.