Secret Store Java Client

Parity secret store java client

License

License

Categories

Categories

CLI User Interface KeY Data Data Formats Formal Verification
GroupId

GroupId

io.keyko
ArtifactId

ArtifactId

secret-store-client
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

Secret Store Java Client
Parity secret store java client
Project URL

Project URL

https://github.com/nevermined-io/secret-store-client-java
Source Code Management

Source Code Management

https://github.com/nevermined-io/secret-store-client-java/tree/master

Download secret-store-client

How to add to project

<!-- https://jarcasting.com/artifacts/io.keyko/secret-store-client/ -->
<dependency>
    <groupId>io.keyko</groupId>
    <artifactId>secret-store-client</artifactId>
    <version>0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.keyko/secret-store-client/
implementation 'io.keyko:secret-store-client:0.1.0'
// https://jarcasting.com/artifacts/io.keyko/secret-store-client/
implementation ("io.keyko:secret-store-client:0.1.0")
'io.keyko:secret-store-client:jar:0.1.0'
<dependency org="io.keyko" name="secret-store-client" rev="0.1.0">
  <artifact name="secret-store-client" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.keyko', module='secret-store-client', version='0.1.0')
)
libraryDependencies += "io.keyko" % "secret-store-client" % "0.1.0"
[io.keyko/secret-store-client "0.1.0"]

Dependencies

compile (10)

Group / Artifact Type Version
org.web3j : core jar 4.0.1
org.web3j : parity jar 4.0.1
org.web3j : utils jar 4.0.1
com.fasterxml.jackson.core : jackson-core jar 2.11.3
com.fasterxml.jackson.core : jackson-annotations jar 2.11.3
com.fasterxml.jackson.core : jackson-databind jar 2.11.3
javax.xml.bind : jaxb-api jar 2.3.0
org.apache.logging.log4j : log4j-core jar 2.13.3
org.apache.logging.log4j : log4j-api jar 2.13.3
org.apache.logging.log4j : log4j-slf4j18-impl jar 2.13.3

test (1)

Group / Artifact Type Version
junit : junit jar 4.13.1

Project Modules

There are no modules declared in this project.

banner

Java Parity Secret Store Library

Secret Store client Library (Java) nevermined.io

Java Maven CI Release javadoc


Table of Contents


Features

This library allows to encrypt & decrypt secrets using the Parity EVM and Secret Store components. The library exposes 2 main objects to do that (PublisherWorker & ConsumerWorker).

The PublisherWorker class, given a document id and the content of a document, encrypts the document, store the decryption keys in the distributed vault (Secret Store) and return the encrypted document.

The ConsumerWorker class, given a document id and the encrypted document, decrypt the document using the keys stored in the secret store.

Technical Details

From the Parity Secret Store documentation page:

The Parity Secret Store is core technology that enables:

  • distributed elliptic curve (EC) key pair generation - key is generated by several parties using special cryptographic protocol, so that:
    • private key portion remains unknown to every single party;
    • public key portion could be computed on every party and could be safely exposed to external entities;
    • every party hold the ‘share’ of the private key;
    • any subset of t+1 parties could unite to restore the private portion of the key;
    • any subset of less than t+1 parties could not restore the private portion of the key;
  • distributed key storage - private key shares are stored separately by every party and are never exposed neither to another parties, nor to external entities;
  • threshold retrieval according to blockchain permissions - all operations that are requiring private key, require at least t+1 parties to agree on ‘Permissioning contract’ state.

Pre-requisites

If you want to run this locally you need the following:

  • A URL to a Secret Store node (you can run it locally too)
  • A URL to an instance of the Parity EVM client (you should run it locally)
  • Consumer and Publisher ethereum accounts
  • JVM >= 8

API

Installing the library

Typically in Maven you could add the dependency:

<dependency>
  <groupId>io.nevermined</groupId>
  <artifactId>secretstore-client</artifactId>
  <version>0.1.0</version>
</dependency>

Encrypting Documents

Encrypt or decrypt documents require interaction with the Parity blockchain client (for security reasons it's better to have this running locally) and one of the nodes of the Secret Store cluster. You can initialize the PublisherWorker object passing the URL's to both components, the ethereum address of the user encrypting documents and the password of that ethereum account.

// Initializing the Publisher
publisher= new PublisherWorker(
    "http://localhost:8010",
    "http://localhost:8545",
    "0x123..",
    "password"
);

Publishing a document only require an API call:

String docEncrypted= publisher.encryptDocument("my-document-id", contentOfTheDocument);

Decrypting Documents

You can initialize the ConsumerWorker object passing the URL's of the Secret Store and Parity EVM client, the ethereum address of the user consuming documents and the password of that ethereum account.

// Initializing the Consumer
consumer= new ConsumerWorker(
    "http://localhost:8010",
    "http://localhost:8545",
    "0xabc..",
    "password"
);

It's possible to decrypt a document using the decrypt method:

String document= consumer.decryptDocument("my-document-id", docEncrypted);

You can find a complete integration test in the PublishConsumeIT file.

On-chain Permissions

Secret Store incorporate the mechanisms to query a Smart Contract to authorize a Consumer to decrypt a secret. This library was tested in a Secret Store setup using this feature.

In order to test the integration with last version of Nevermined Service Agreements, you can integrate the SLA Smart Contracts of the contracts.

For testing purposes, this library includes the web3j bindings of a testing Smart Contract implementing the authorization phase integrated with the Secret Store.

To build the java bindings we use the following command:

$ web3j truffle generate --javaTypes contracts/contracts/AccessServiceAgreement.json -o src/main/java -p com.nevermined.secretstore.contracts

Links

You can find further information about the Secret Store in the following links:

Attribution

This library is based in the Ocean Protocol Secret Store Java library (source code not existing anymore in ocean protocol). 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.
io.keyko

Nevermined

The world's first enterprise-grade unstoppable data sharing ecosystem

Versions

Version
0.1.0