GithubHelp home page GithubHelp logo

vonwenm / hyperledger-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from martindale/hyperledger-server

1.0 2.0 0.0 620 KB

A beta reference server for the Hyperledger protocol.

Home Page: http://www.hyperledger.com

License: Apache License 2.0

Elixir 100.00%

hyperledger-server's Introduction

Hyperledger Reference Implementation

This is the reference implementation of Hyperledger. Hyperledger is a protocol for creating and transferring assets on decentralised ledgers. It's designed to be run in environments where the set of replicating nodes is known. All the resources in the system are exposed through a hypermedia interface to allow for loose coupling between parties, especially the clients.

This software is currently in beta so run at your own risk.

Installation

Prerequisites; Elixir v1.0.4, PostgreSQL

  1. Install dependencies with mix deps.get
  2. Modify the DATABASE_URL environment variable in the .env file to reference your Postgres user
  3. Create a database with mix ecto.create
  4. Run the migrations with mix ecto.migrate
  5. Create a database entry for the local node; run iex -S mix and then run > Hyperledger.Node.create(1, System.get_env("NODE_URL"), System.get_env("PUBLIC_KEY"))
  6. Start the server with mix phoenix.server

The server should now be running at localhost:4000.

Domain Model

There are four core concepts behind the Hyperledger domain model:

  1. Assets — assets are defined by a contract document. The document is hashed with SHA256 and this has is used as the asset identifier. Contract documents can be any type of file, but the preferred type is a JSON document which is easily parseable by machines and people. Hyperledger does not store the document itself, only the hash. This enables you to keep the details of the asset private by handing out the contract to specific parties. When an asset is first registered it is associated with a public key; only that key is authorised to create new units of that asset. For more information see [Ian Grigg's paper on Ricardian Contracts] (http://iang.org/papers/ricardian_contract.html).
  2. Accounts — accounts are identified by a public key and are tied to a specific asset; if you want to hold multiple assets you need to create one account per asset. Account balances must always be positive. When you register an asset you create an account at the same time. This is known as the 'primary' account for that asset, and is the only account that can receive new units of an asset. Transfers out of an account must be authorised by the associated key.
  3. Issues — issuing units is the process of introducing new units into the system. Issuing must be authorised by the key associated with the asset and can only be received by the primary account for that asset.
  4. Transfers — units can be transferred from one account to another. The key of the source account must be used to authorise transfers and the account balance can not fall below zero.

All keys used in Hyperledger are EC keys on the curve 'secp256k1'.

API

The API is a standard hypermedia interface exposed over HTTP. The hypermedia format used is UBER. Authors of client libraries are encouraged to use (or create, if none exist) an intermediate library that deals with the UBER representation, rather than assume a fixed structure for requests or responses. However, as the API is not yet fully self-descriptive it is worth looking at the [Hyperledger CLI] (https://github.com/hyperledger/hyperledger-cli) for more information.

When POSTing new resources, the key for the new resource must be used to sign the message to ensure authenticity. The key and the signature should be encoded as uppercase hex, and used to generate an 'authorisation' (case sensitive) header as follows:

authorisation: Hyper Key=<public key>, Signature=<signature>

New resources are created by POSTing authenticated JSON resources. All binary strings (hashes and keys) should be encoded as hex strings. The resources should be structured as follows:

POST /assets
{
  "asset": {
    "hash": <SHA256 hash of contract document>,
    "publicKey": <asset public key>,
    "primaryAccountPublicKey": <primary account public key>
  }  
}

POST /accounts
{
  "account": {
    "assetHash": <asset hash>,
    "publicKey": <account public key>
  }
}

POST /asset/<asset hash>/issues
{
  "issue": {
    "uuid": <UUID version 4>,
    "assetHash": <asset hash>,
    "amount": <integer amount>
  }
}

POST /transfers
{
  "transfer": {
    "uuid": <UUID version 4>,
    "sourcePublicKey": <source account public key>,
    "destinationPublicKey": <destination account public key>,
    "amount": <integer amount>
}

Replication

An Hyperledger pool is a set of servers which replicate an ordered list of write operations. Read operations are not ordered, and it is the responsibility of clients to check the status of operations against the other servers in the pool.

hyperledger-server's People

Contributors

danielfeichtinger avatar danoprey avatar sebastianszturo avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.