Skip to content

Commit

Permalink
Initial Hyperledger Private Data Objects implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Byron Marohn <[email protected]>
Signed-off-by: Abdulkareem Adesokan <[email protected]>
Signed-off-by: Tom Barnes <[email protected]>
Signed-off-by: Mic Bowman <[email protected]>
Signed-off-by: Holly Harmon <[email protected]>
Signed-off-by: Andrea Miele <[email protected]>
Signed-off-by: Bruno Vavala <[email protected]>
Signed-off-by: Eugene Yarmosh <[email protected]>
  • Loading branch information
byron-marohn committed May 1, 2018
1 parent 00b113b commit d96033b
Show file tree
Hide file tree
Showing 349 changed files with 47,350 additions and 52 deletions.
185 changes: 185 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
<!---
Licensed under Creative Commons Attribution 4.0 International License
https://creativecommons.org/licenses/by/4.0/
--->
# BUILD

In order to build, install, and run Hyperledger Private Data Objects, a number
of additional components must be installed and configured. The following
instructions will guide you through the installation and build process for
Hyperledger Private Data Objects.

## Table of Contents

- [Prerequisites](#prerequisites)
- [Installing Sawtooth Distributed Ledger](#sawtooth)
- [Quickstart: Installing PDO Using Scripts](#quickstart)
- [Building and installing PDO manually](#manual-install)
- [Setting up a Python Virtual Environment](#virtualenv)
- [Compiling the Common C++ Libraries](#common)
- [Compiling the Python shared libraries](#python)
- [Building the Enclave Service](#eservice)
- [Building the Provisioning Service](#pservice)
- [Building the Client](#client)
- [Using Private Data Objects](#using)

# <a name="prerequisites"></a>Prerequisites
Follow the instructions [here](PREREQUISITES.md) to install and configure
components on which PDO depends.

# <a name="sawtooth"></a>Installing Sawtooth Distributed Ledger
Hyperledger Private Data Objects uses the Hyperledger Sawtooth distributed
ledger to store data object instances and state, and to guarantee update
atomicity.

Application logic is implemented in Sawtooth through the use of Transaction
Processors; transaction processors enable the distributed ledger to handle
application requests. This repository contains the code required to build
Transaction Processors that handle PDO requests.

Follow the setup document [here](sawtooth/docs/SETUP.md) to install both
Sawtooth and the custom Sawtooth Transaction Processors.

Note that the Sawtooth components do not depend on any other components of the
PDO project, and can be set up on an entirely separate machine from the one
running Private Data Objects. It is recommended that Sawtooth be run on Ubuntu
16.04 as it is the only operating system version on which Sawtooth is actively
supported.

# <a name="quickstart"></a>Quickstart: Installing PDO Using Scripts
The following section of this document describes manual compilation and
installation instructions for Private Data Objects components. Following those
steps is a good way to learn about the components of the project as you become
an advanced user.

This section describes how to get started with PDO quickly using provided
scripts to compile and install PDO.

First, make sure environment variables are set as described in the
[prerequisites](#prerequisites) section.

The quickstart build will set up a python virtual environment to install things
into. Set `CONTRACTHOME` to point to the target install directory for PDO
components. You will need this environment variable set in every shell session
where you interact with PDO.
```
export CONTRACTHOME=`pwd`/__tools__/build/_dev/opt/pdo
```

Change to the quickstart build directory:
```
cd __tools__/build
```

Edit `opt/pdo/etc/template/eservice.toml` and
`opt/pdo/etc/template/pservice.toml` to have the correct ledger URL for your
sawtooth installation.

Build the virtual environment and install PDO components into it:
```
make
```

Activate the new virtual environment for the current shell session. You will
need to do this in each new shell session (in addition to exporting environment
variables).
```
source _dev/bin/activate
```

Run the test suite to check that the installation is working correctly. Replace
the URL with the URL for the rest-api of your Sawtooth installation.
```
cd ..
LEDGER_URL=http://127.0.0.1:8008 ./run-tests.sh
```

# <a name="manual-install"></a>Building and installing PDO manually
## <a name="virtualenv"></a>Setting up a Python Virtual Environment
The directories containing python code (`python`, `eservice`, `pservice`, and
`client`) all create installable Python modules. You can install these to the
root system's python if you want; however, the recommended approach is to
create a new python "virtual environment" where they can be installed without
affecting the root system.

Create a python virtual environment in the folder `venv` by running:
```
python3 -m venv venv
```

Now activate that virtual environment for your current shell session. You will
need to do this every time you start a new shell session:
```
source venv/bin/activate
```

Now that the virtual environment is active, install the python libraries that
Private Data Objects depends upon. NOTE: On Ubuntu 17.10 (and probably others)
secp256k1 may not install correctly with pip. If this happens to you, try first
installing your distribution's libsecp256k1-dev package via something like
`sudo apt-get install libsecp256k1-dev` and then re-run the pip installation.
```
pip install --upgrade pip
pip install --upgrade setuptools
pip install --upgrade toml
pip install --upgrade requests
pip install --upgrade colorlog
pip install --upgrade twisted
pip install --upgrade pyyaml
pip install --upgrade google
pip install --upgrade protobuf
pip install --upgrade secp256k1
pip install --upgrade cryptography
pip install --upgrade pyparsing
```

If you are using this recommended virtual environment setup, you will also need
to export the environment variable `CONTRACTHOME`. This is used by PDO to find
configuration files and encryption keys. Set this variable in your current
shell session with:
```
export CONTRACTHOME=`pwd`/venv/opt/pdo
```

## <a name="common"></a>Compiling the Common C++ Libraries
The `common` directory contains cryptography, encoding, and other miscellaneous
routines used by many other components. Follow the build instructions
[here](common/BUILD.md) to compile the common libraries.

## <a name="python"></a>Compiling the Python shared libraries
The `python` directory contains shared python libraries/imports used by many
other components. Much of the higher-level user logic of Private Data Objects
is implemented in Python. The python directory includes a python SWIG wrapper
of the common libraries, so common must be compiled prior to compiling the
`python` directory.

Instructions for compiling and installing the python directory are available
[here](python/BUILD.md).

## <a name="eservice"></a>Building the Enclave Service
The Enclave Service (eservice for short) consists of two components:
- A Software Guard Extensions "enclave" which runs the actual contract code
- A python service wrapper (the eservice) which passes messages to and from the enclave

More information about the eservice is available
[here](eservice/docs/eservice.md), and instructions for how to build it are
[here](eservice/docs/BUILD.md).

## <a name="pservice"></a>Building the Provisioning Service
The Provisioning Service (pservice for short) is a simple key/value store used
to generate "secrets" which provision specific enclaves for use with specific
contracts.

Instructions for how to build the provisioning service are available
[here](pservice/docs/BUILD.md).

## <a name="client"></a>Building the Client
The client directory contains several utilities for creating and executing
contracts.

Instructions for how to build the client utilities service are available
[here](client/docs/BUILD.md).

# <a name="using"></a>Using Private Data Objects
See the main [USAGE](USAGE.md) document for information on how to test and
use your Private Data Objects installation.
116 changes: 115 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Apache License
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

Expand Down Expand Up @@ -199,3 +199,117 @@
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.

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

The Hyperledger Private Data Object project contains open source components with
separate copyright notices and license terms. Your use of the source code for
the these components is subject to the terms and conditions of the following
licenses.

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
parson

For project details see: https://github.com/kgabis/parson

MIT License

Copyright (c) 2012 - 2017 Krzysztof Gabis

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
René Nyffenegger cpp-base64

For project details see: https://github.com/ReneNyffenegger/cpp-base64

Copyright © 2004-2017 by René Nyffenegger

This source code is provided 'as-is', without any express or implied
warranty. In no event will the author be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

1. The origin of this source code must not be misrepresented; you must not
claim that you wrote the original source code. If you use this source code
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.

2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original source code.

3. This notice may not be removed or altered from any source distribution.


/*
The original source code has been modified to be used with Private Data
Objects (PDOs).
*/

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
ELK

Copyright 1990, 1991, 1992, 1993, 1994, 1995, Oliver Laumann, Berlin(except for
the contents of the directory `doc / usenix'). This software was derived from
Elk 1.2, which was Copyright 1987, 1988, 1989, Nixdorf Computer AG and TELES
GmbH, Berlin (Elk 1.2 has been written by Oliver Laumann (me) for TELES
Telematic Services, Berlin, in a joint project between TELES and Nixdorf
Microprocessor Engineering, Berlin). Oliver Laumann, TELES GmbH, and Nixdorf
Computer AG, as co-owners or individual owners of copyright in this software,
grant to any person or company a worldwide, royalty free, license to i) copy
this software, ii) prepare derivative works based on this software, iii)
distribute copies of this software or derivative works, iv) perform this
software, or v) display this software, provided that this notice is not removed
and that neither Oliver Laumann nor Teles nor Nixdorf are deemed to have made
any representations as to the suitability of this software for any purpose nor
are held responsible for any defects of this software. THERE IS ABSOLUTELY NO
WARRANTY FOR THIS SOFTWARE. Berlin, June 20, 1995 Oliver Laumann

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
SLIB

SLIB LICENSE Each file in SLIB (over a dozen lines in length) is either in the
public domain, or comes with a statement of terms permitting users to copy,
modify, and redistribute it. The comments at the beginning each file (containing
over a dozen lines) must specify its terms. For instance, the comments at the
beginning of "Template.scm" declare that it is in the public domain: ;;;
"Template.scm" configuration template of *features* for Scheme ;;; Author:
Aubrey Jaffer ;;; ;;; This code is in the public domain. Each copyrighted file
lists the names of the copyright holders and gives permissions to copy, modify,
and redistribute the file. For instance, the beginning of "require.scm" states:
;;;; Implementation of VICINITY and MODULES for Scheme ;Copyright (C) 1991,
1992, 1993, 1994, 1997 Aubrey Jaffer ; ;Permission to copy this software, to
modify it, to redistribute it, ;to distribute modified versions, and to use it
for any purpose is ;granted, subject to the following restrictions and
understandings. ; ;1. Any copy made of this software must include this copyright
notice ;in full. ; ;2. I have made no warranty or representation that the
operation of ;this software will be error-free, and I am under no obligation to
;provide any services, by way of maintenance, update, or otherwise. ; ;3. In
conjunction with products arising from the use of this ;material, there shall be
no use of my name in any advertising, ;promotional, or sales literature without
prior written consent in ;each case.

Loading

0 comments on commit d96033b

Please sign in to comment.