Code Monkey home page Code Monkey logo

incubator-milagro-dta's Introduction

Apache Milagro (Incubating) Decentralized Trust Authority


Maintenance

The Apache Milagro (Incubating) Decentralized Trust Authority (D-TA) is a collaborative key management server.

The D-TA facilitates secure and auditable communication between people who to use key pairs (Principal) and service providers who can keep the secret keys safe (Master Fiduciary). It is written in Go and uses REST services based on the GoKit microservices framework, it uses IPFS to create a shared immutable log of transactions and relies on Milagro-Crypto-C for it's crypto.

Plugins

The Milagro D-TA provides a basic set of services for creating identities for actors in the system, and passing encrypted communication between them but it assumes that different service providers will have their own "special sauce" for securely storing secret keys, so the vanilla services can be extended using a plugin framework. Two basic plugins are included in this release to give you an idea of how this can be done.

  1. BitcoinPlugin Generates a Bitcoin address and reveals the corresponding secret key
  2. SafeGuardSecret Encrypts a string and decrypts it again

Installation

Below are instructions on how to build and run the Milagro D-TA either using Docker or as developments builds for Linux and Mac.

These instructions will build the service with default settings including an embeded IPFS node connected to a private IPFS network and an embedded "Bolt" database. This will get you up and running quickly but is not recommended for production use!

Docker

To see the Milagro D-TA in action you can run the Milagro D-TA in a docker container. This is currently the preferred method to build and run the D-TA. Tested on Ubuntu 19.04 and MacOS but should run in any Docker environment.

Prerequisites

Docker

Build & Run on Docker

git clone https://github.com/apache/incubator-milagro-dta.git

cd incubator-milagro-dta

docker build -t mydta .

docker run -p5556:5556 mydta

Build and run on development machine

Tested on Ubuntu 19, MacOS 10.14 Mojave & Debian 10

Install development Tools on Ubuntu/Debian

sudo apt-get update
sudo apt-get install \
     ca-certificates \
     cmake \
     g++ \
     gcc \
     git \
     make \
     libtool \
     automake \
     libssl-dev \
     jq \
     curl

Install development Tools on MacOS

brew install \
     cmake \
     autoconf \
     automake \
     libtool 

golang

Download and install Golang

liboqs

liboqs is a C library for quantum-resistant cryptographic algorithms. It is a API level on top of the NIST round two submissions.

git clone https://github.com/open-quantum-safe/liboqs.git
cd liboqs
git checkout 7cb03c3ce9182790c77e69cd21a6901e270781d6 
autoreconf -i
./configure --disable-shared --disable-aes-ni --disable-kem-bike --disable-kem-frodokem --disable-kem-newhope --disable-kem-kyber --disable-sig-qtesla 
make clean
make -j
sudo make install

AMCL

AMCL is required

Build and install the AMCL library

git clone https://github.com/apache/incubator-milagro-crypto-c.git
cd incubator-milagro-crypto-c
git checkout feecb27e7cc24ba5809405cc3efe74b0f7ac69ef
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=ON -D AMCL_CHUNK=64 -D AMCL_CURVE="BLS381,SECP256K1" -D AMCL_RSA="" -D BUILD_PYTHON=OFF -D BUILD_BLS=ON -D BUILD_WCC=OFF -D BUILD_MPIN=OFF -D BUILD_X509=OFF -D CMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_C_FLAGS="-fPIC" ..
make
make test
sudo make install

pqnist

git clone https://github.com/apache/incubator-milagro-dta.git
cd incubator-milagro-dta/libs/crypto/libpqnist
mkdir build
cd build
cmake -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_SHARED_LIBS=ON ..
make
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
make test
sudo make install

Set the library path

export C_INCLUDE_PATH=$C_INCLUDE_PATH:/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

Build & Run Instructions

./build.sh

To run the service with default settings:

./target/milagro init
./target/milagro daemon 

Documentation

You can find documentation for Milagro D-TA in the main Milagro docs site

This includes a quick start guide that will show you how to get Milagro D-TA to "do stuff"

Contributing

Key pairs are becoming central to our online lives, and keeping secret keys safe is a growing industry, we hope to create an ecosystem of custodial service providers who collaborate to make the Internet a safer place for everyone. We are keen to get contributions and feedback from anyone in this space. This is a brand new project so our development processes are still being figured out, but if you have suggestions, questions or wish to make contributions please go ahead raise an issue and someone on the team will get right on it.

Crypto Notice

This distribution includes cryptographic software. The country in which you currently reside may have restrictions on the import, possession, use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check your country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted. See http://www.wassenaar.org/ for more information.

The Apache Software Foundation has classified this software as Export Commodity Control Number (ECCN) 5D002, which includes information security software using or performing cryptographic functions with asymmetric algorithms. The form and manner of this Apache Software Foundation distribution makes it eligible for export under the "publicly available" Section 742.15(b) exemption (see the BIS Export Administration Regulations, Section 742.15(b)) for both object code and source code.

Disclaimer

Apache Milagro is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.

Credits

incubator-milagro-dta's People

Contributors

fluidjax avatar howardkitto avatar johnmcw avatar kealan avatar smihaylov avatar spector-in-london avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

incubator-milagro-dta's Issues

Refactor CreateIdentity Method

I want to be able to create an identity document from another Go application. Ideally I would simply import the the defaultService package and call the CreateIdentity method.

Unfortunately this is not possible because:

  1. I have to create a new service which involves lots of unnecessary coding.
  2. It depends on the "common" package which has a dependency on IPFS, publishing the document to IPFs should be a separate call e.g.
import (
"github.com/apache/incubator-milagro-dta/pkg/identity"
"github.com/apache/incubator-milagro-dta/pkg/ipfs"
"someStorageThing"
)

myFunc() hashddress {
identityDoc, identitySecrets  := identity.CrateIdentity("name")
hashAddress := ipfs.Put(identityDoc)
store.Put(identitySecrets)
return hashAddress
}

The end result is that I have rewrite all the business logic for creating an identity document.

External Master Fiduciary returns "Failed to Decode" error

If I configure a D-TA to use an external fiduciary, and request an order, e.g.:

curl -X POST "http://localhost:5556/v1/order" -H "accept: application/json" -H "Content-Type: application/json" -d "{"BeneficiaryIDDocumentCID":"QmVnGYu4t9nZGPDweSDQnLxnNead1WEnggtLZSJp2ZZ3su"}"

No response is returned. The following error is returned by the D-TA:

2019-09-05T09:49:13.005 [REQ] 1afbb04d-b2e1-4994-80ac-782332a6b02b POST /v1/order
2019-09-05T09:49:14.413 [ERR] reqID: 1afbb04d-b2e1-4994-80ac-782332a6b02b, err: Fail to retrieve Order from IPFS: DecodeIDDocument Failed to Decode: Failed to Decapsulate Encrypted Text in Envelope Decode: Recipient not found
2019-09-05T09:49:14.413 [RES] 1afbb04d-b2e1-4994-80ac-782332a6b02b POST /v1/order 500 Internal Server Error (1.407253379s)

Config/Install Script

As a user, I want to have a configuration/install method that sets up the instance of the Milagro Server for my intended use.

Register AccountID of Beneficiaries

The DTA should maintain a list of "trusted" account ids. This list will be used to nominate beneficiaries and other actors that may participate in order fulfilment.

We should remove the identity endpoints completely and instead have. something like.

POST /trustedAccount - creates a new entry in the list of trusted accounts
Get /trustedaccount - returns a list of trusted accounts with pagination
Get /trustedaccount{accountID} - gets the details of a trusted account

Distributed Trust Authorities

Trusted Authority will be in possession of a master secret
They will be required to issue cryptographic part-secrets (shares of Milagro Tokens), and to protect their own part-secrets. They will be completely law abiding within their own individual jurisdictions. They will be expected to be open and transparent, and to have a reputation for honesty.
Distributed Trust Authorities (D-TAs) - Distributed Trust Authorities are services run by the stakeholders in a Milagro partition which issue Milagro Tokens to People, Apps or Things who petition to obtain them. Distributed Trust Authorities may run their own IdPs, or outsource entirely this function.

The initial version of the D-TA should be derived from the code used in Milagro
The D-TA should be written in Golang in order to utilize this technology's strengths
The D-TA should have the following functionalities:
Generate Server Keys
Generate Client Keys
Generate Time Permits

Counterparty Endpoint

I propose that we create a new feature that enables a DTA to store a list of "approved counterparties".

A counterparty is any actor (represented by an account ID) who the pricipal nominates to participate in creating, storing, or revealing a secretkey. Such as the masterFiduciary, beneficiary, or any entity that is required to give approval.

The default service should simply accept a post that a new id is added to a DTA counterparty list. (Plugins may add additional approval criteria)

The list is stored locally (in bolt by default)

The default service should implement the following endpoints:

POST /counterparty
{accountID string,
timeStamp int,
reference string} <- unique string to provide user friendly lookup eg "Name"

RETURNS 200

Get /counterparty?perPage=n&page=n&sortBy=dateAsc||dateDesc
RETURNS {...IDDoc}

Get /counterparty/accountID/{accountID}||/reference/{reference}
RETURNS {...IDDoc}

In this version the DTA should simply check that the accountid exists (ie just looik it up on IPFS / Tendermint) In future we may add additional verification steps (such as verifying a signature posted with the request)

Ensure all source files have Apache Headers

The following files have been reported as not having the Apache licence header:

./.travis.yml
./.gitignore
./Dockerfile
./Dockerfile-alpine
./build-static.sh
./build.sh
./go.mod
./go.sum
./lint.sh
./report
./test.sh
./cmd/servicetester/e2e_test.sh
./cmd/servicetester/fulltest.sh
./cmd/servicetester/id_test.sh
./libs/crypto/libpqnist/CMakeLists.txt
./libs/crypto/libpqnist/CPackConfig.cmake
./libs/crypto/libpqnist/VERSION
./libs/crypto/libpqnist/cmake_uninstall.cmake.in
./libs/crypto/libpqnist/examples/CMakeLists.txt
./libs/crypto/libpqnist/include/CMakeLists.txt
./libs/crypto/libpqnist/src/CMakeLists.txt
./libs/crypto/libpqnist/test/smoke/CMakeLists.txt
./libs/crypto/libpqnist/testVectors/aes/CBCMMT256.rsp
./libs/documents/docs.pb.go
./libs/documents/docs.proto
./libs/documents/docs.validator.pb.go
./pkg/safeguardsecret/README.md
./pkg/safeguardsecret/open-api.yaml

Please add the header where possible/appropriate. Any files that can't or should not have header files should be listed here so we can document why.

CreateIdentity() should only be run once

A DTA should only store its own identity secrets. We should remove the public endpoint for creating Identities.

The logic for creating identities should be something like this...

  1. When the daemon starts up check if the config has an identity AND the secret keys are present (If there is an identity in config but no secret keys in the local store then they will have to be restored from back up)
  2. If there is no id in config (e.g. the DTA is running for the first time) then run createIdentity()

Sample Docker Build is Not Working

In README, a sample code for docker build is provided. However, seems it is not working.

I tried to run docker build in different environment, and got "exit status 2" at step $GOPATH/bin/milagro init.

In CI process, it is Dockerfile-alpine being used, rather than Dockerfile which is used in the sample Docker build command.

Decentralized Custody

As a user, I would like to configure my Milagro Server as both a principal and beneficiary, and to use another Milagro Server as the fiduciary.
Milagro%20Node

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.