Giter Site home page Giter Site logo

sidetree-ethereum's Introduction

Repo is inactive

See these repos instead:

Sidetree Ethereum

Build Status

Sidetree Ethereum is a REST API that supports anchoring of Sidetree Transactions to the Ethereum Blockchain.

Sidetree Ethereum is meant to be used with sidetree-core and sidetree-ipfs.

See the mono repo for integration tests... COMING SOON.

A Sidetree Transaction is a JSON Document of the following format:

{
  "transactionTime": 53,
  "transactionTimeHash": "0xa6dd7120730ddccf4788a082b0b5607fd1f39dbb80ebc170678551878b90b835",
  "transactionNumber": 15,
  "anchorFileHash": "QmcModh3cTgSpr8A6m7jNHnwVZRGZsepWv3uaFtD5KhL2U"
}

The anchorFileHash is a multihash content address for an anchor file of the following format:

{
  "batchFileHash": "QmcModh3cTgSpr8A6m7jNHnwVZRGZsepWv3uaFtD5KhL3U",
  "merkleRoot": "b6dd7120730ddccf4788a082b0b5607fd1f39dbb80ebc170678551878b90b836"
}

The batchFileHash is a multihash content address for a batch file of the following format:

{
  "operations": [
    "eyJzaWduaW5nS2V5SWQiOiJrZXkxIiwiY3JlYXRlUGF5bG9hZCI6ImV5SkFZMjl1ZEdWNGRDSTZJbWgwZEhCek9pOHZkek5wWkM1dmNtY3ZaR2xrTDNZeElpd2lhV1FpT2lKa2FXUTZjMmxrWlhSeVpXVTZhV2R1YjNKbFpDSXNJbkIxWW14cFkwdGxlU0k2VzNzaWFXUWlPaUpyWlhreElpd2lkSGx3WlNJNklsTmxZM0F5TlRack1WWmxjbWxtYVdOaGRHbHZia3RsZVRJd01UZ2lMQ0p3ZFdKc2FXTkxaWGxJWlhnaU9pSXdNamMyWXpJek5EZ3dNelU0TWpJeE9EZ3dPVFkwTlRWaU4yWXpaakprTlRaaE5HSmhZbVU0WkRka09UZGpZMlF5TmpnMVl6VXdZbVJpTXpVNFpHUmlOekVpZlN4N0ltbGtJam9pWkdsa09uTnBaR1YwY21WbE9tUnBaRkJ2Y25ScGIyNUpaMjV2Y21Wa0kydGxlVElpTENKMGVYQmxJam9pVW5OaFZtVnlhV1pwWTJGMGFXOXVTMlY1TWpBeE9DSXNJbTkzYm1WeUlqb2laR2xrT25OcFpHVjBjbVZsT21sbmJtOXlaV1JWYm14bGMzTlNaWE52YkhaaFlteGxJaXdpY0hWaWJHbGpTMlY1VUdWdElqb2lMUzB0TFMxQ1JVZEpUaUJRVlVKTVNVTWdTMFZaTGpJdVJVNUVJRkJWUWt4SlF5QkxSVmt0TFMwdExTSjlYU3dpYzJWeWRtbGpaU0k2VzNzaWRIbHdaU0k2SWtsa1pXNTBhWFI1U0hWaUlpd2ljSFZpYkdsalMyVjVJam9pWkdsa09uTnBaR1YwY21WbE9tbG5ibTl5WldRamEyVjVMVEVpTENKelpYSjJhV05sUlc1a2NHOXBiblFpT25zaVFHTnZiblJsZUhRaU9pSnpZMmhsYldFdWFXUmxiblJwZEhrdVptOTFibVJoZEdsdmJpOW9kV0lpTENKQWRIbHdaU0k2SWxWelpYSlRaWEoyYVdObFJXNWtjRzlwYm5RaUxDSnBibk4wWVc1alpYTWlPbHNpWkdsa09tSmhjam8wTlRZaUxDSmthV1E2ZW1GNk9qYzRPU0pkZlgxZGZRIiwic2lnbmF0dXJlIjoibnFTNDNLeTNYUjBmanRQTHFVaHpTRWhKLWlUbEJ0ZXdGdDl1dDN3YVhyMWhaRTRQSy1VcXZEYzlzVUtscTZNX0hDdHkxVkM1U1Fpa0FPVlRPN3JnRkEiLCJwcm9vZk9mV29yayI6InByb29mIG9mIHdvcmsifQ"
  ]
}

The merkleRoot is used prove that a given operation is included in a batch. See here

Development Commands

. ./env
npm run start-ganache
npm run contracts:test
npm run contracts:migrate:dev
npm run test

sidetree-ethereum's People

Contributors

ebaizel avatar jguyton avatar or13 avatar csuwildcat avatar

Stargazers

Guoyi avatar  avatar mjolk avatar Kevin avatar  avatar Partido Digital Português avatar Nuno Amiar avatar Robin Wen avatar Ming-der Wang avatar Tomisin Jenrola avatar SinTan1071 avatar Aditya Singh avatar Jan Christoph Ebersbach avatar John Hopkins avatar Doug King avatar Akhil Shaji avatar  avatar  avatar Will Pankiewicz avatar  avatar Somer B. avatar zhou avatar  avatar Dashon 'DJ' Hawkins avatar Tiziano Rocca avatar nolan avatar Haard avatar Kevin Leffew avatar  avatar

Watchers

James Cloos avatar Tiziano Rocca avatar  avatar Nathan Aw avatar Tobias Looker avatar Andreas Freund avatar  avatar  avatar

sidetree-ethereum's Issues

Review of the EthDIDAnchor contract

Review of the EthDIDAnchor contract

Issues

Here are some issues I found with the EthDIDAnchor contract:

Use of both anchorHash and ipfsHash

It's not clear why we need both anchorHash and ipfsHash and what the relationship between them are. The implementation spec in the sidetree-core repo specifies the use of an "anchor file hash" that represents the hash of the file containing the batch of sidetree operations. It seems that we can just use one anchorFileHash in the transactions array.

Anyone can reset the mapping from anchor hash to ipfs hash

Anyone can call the function newAnchorHash with an existing _anchorHash and an arbitrary _ipfsHash. This overwrites the previous mapping in the anchors map. I'm not sure about the functionality of the two hashes (see above) but this is probably not the intended functionality.

Blocknumber should be recorded along with anchor file hash

The sidetree-core spec requires that the anchor file hash be recorded together with a transaction number (which is included here) as well as a transactionTime, which can be a block number. To remedy this another array blocknumber can be introduced where the blocknumber can be stored indexed by the transaction number.

Possible optimization: use only Events and not on-chain storage

Since we are not expecting that the data here should be readable by smart contracts on-chain we could log the data only as an Event (like what is done with AnchorHashCreated). This will avoid some unneccessary on-chain state but will still give strong guarantees about the data.

A downside of this optimization is that it is more cumbersome to read the data since it's not all available in the latest state database. The whole blockchain will need to be traversed sequentially.

Recommendations

Remove ipfsHash and the anchors mapping

This is not needed in order to be compliant with the sidetree-core spec. Only one hash is needed.

Add an array to keep track of blocknumbers

Add an array blocknumbers to map transaction numbers to block numbers in order to be able to get block numbers along with anchor file hashes.

For event-based optimization: use only transactionNumber and Events

If we want to do this optimization we may remove all on-chain data except transactionNumber and use an Event to store the following data: anchor file hash, transaction number, block number (block number may be reconstructed later so may can probably be omitted).

Limit who can execute the smart contract

The smart contract containing all the anchors will live on the Ethereum main net. We want to ensure only valid actors are able to update the state of the contract. This could involve staking ether that releases back to the owner over time, to insure good behavior. There are other options too.

The purpose of this ticket is to discuss the implementation, and we can then create an issue for the implementation work required.

Add Pagination Support

Related to decentralized-identity/sidetree#37

We want to be able to fetch batches by their corresponding transaction numbers. Each batch added to the smart contract will have a transaction number, starting at 1 and incrementing by 1 for each added batch.

Sample response: https://github.com/decentralized-identity/sidetree-core/blob/master/docs/implementation.md#response-body-example

An open question is how many transactions in addition to this one do we want to return? The spec keeps this open. It would help to understand how this is intended to be used. If it's for paginating through all transactions, then returning 10 (or more) makes sense, or having that be another request parameter.

@thehenrytsai thoughts?

Create a service method that updates a DID

Given a passed in request body for an existing DID, update the DID's document. Example update would be to add an additional key.

The tests should cover the case where the passed in DID can not be found.

This ticket is for the service function, not the API route.

Init the project

Create a truffle project, add the .gitignore, basic README and get the project going

ERC725 and ERC735

Specifically, how does sidetree-based DID method differ from ERC-725 and ERC-735 implementation? I am working on ERC725 and ERC 735 and am exploring how DID identifiers can be related vis-a-vis Ethereum.

Add ipfs module

We should encapsulate the IPFS interface within a module. The interface should expose methods that allow a caller to:

  • fetch data for a passed in ipfs address

Create a service method that creates a new DID

Given a passed in request body, generate a DID of the form did:side-eth:xyz where xyz is the hash of the passed in request body. This function should return the generated DID

This ticket is for the service function, not the API route.

Add API infrastructure

Look into adding Koa or Express for the API route handling. Koa is used in sidetree-core so it may be helpful to keep in sync with that.

is this repo still active ?

I am trying to run sidetree on top of ethereum,but seems this repo is no longer used.
Where should I start for sidetree + ethereum?

which npm version

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(__builtin_expect(!(e), 0) ? __assert_rtn(func, FILE, LINE, #e) : (void)0)
^
2 warnings and 5 errors generated.
make: *** [Release/obj.target/scrypt/src/node-boilerplate/scrypt_common.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)

Create the Smart Contract that will hold the anchor file hashes

  • hold an array of the anchor file hashes (AFH)
  • keep a field nextIndex that indicates where in the array to write the next AFH
  • keep a mapping of bytes32 (the AFH) to uint (the index) to be able to lookup/verify an AFH has been written

Not doing yet:

  • limiting who can execute these functions. We'll want to prevent just anyone from doing that, but that's out of the scope of this ticket.

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.