dcrm-sdk

module
v0.0.0-...-6b48cb7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2020 License: Apache-2.0

README

DCRM SDK BETA

Note : dcrm-sdk is considered beta software. We make no warranties or guarantees of its security or stability.*

Introduction

DCRM SDK is a distributed key generation and distributed signature module that forms the cornerstone of decentralized value exchange. This technology was developed for over a year, with the feedback of 4 leading cryptographers: Rosario Gennaro, Steven Goldfeder, Pascal Paillier, Louis Goubin.

When used in context of blockchain, this module can serve as a non-custodial solution, a keyless wallet, a component to an interoperable solution, and more. Please read the Wiki for more information.

This SDK allows you to connect to DCRM's network directly in either:

  1. a 2+1 configuration where you form a private group with 2 fusion nodes and your own node.
  2. a local configuration where you can set any ownership of nodes in your group.

This library contains 2 functions:

  1. Distributed key generation which returns the public key (dcrm_genPubkey)
  2. Distributed signing of transactions (dcrm_sign)

Prerequisites

  1. Linux terminal
  2. Golang ^1.12

Setting Up

Clone The Repository

To get started, launch your terminal and download the latest version of the SDK.

mkdir -p $GOPATH/src/github.com/fsn-dev

cd $GOPATH/src/github.com/fsn-dev

git clone https://github.com/fsn-dev/dcrm-sdk.git

Build

Next compile the code. Make sure you are in /dcrm-sdk directory.

cd dcrm-sdk && make

config file

cmd/conf.toml (bin/cmd/conf.toml)

Run

Open access to the APIs by running the compiled code.

./bin/cmd/gdcrm

The gdcrm will provide two RPC APIs:

  1. dcrm_genPubkey
  2. dcrm_sign

The default RPC port is port 5559.

Note:

  1. If you want to call RPC API, please wait at least 2 minutes after running the node.
  2. If you want to call RPC API quickly more than once,please wait longer.

JSON RPC API

dcrm_genPubkey

This API return a public key which distributed generated by the P2P network's nodes.

Parameters

None

Return

error - Error info.

pubkey - DCRM public key generated by the P2P network's nodes.

Example
// Request

curl -X POST -H "Content-Type":application/json --data '{"jsonrpc":"2.0","method":"dcrm_genPubkey","params":[],"id":67}' http://127.0.0.1:5559

// Result

{
"pubkey":"049ac626ee0f0f79a49d6ed37f14ff2ad4e4f45fddf6e5293bcaa6a607e5392b49dde27a8f0602e23bc5fa0b847bd28d46e2f2d1d0d8cf59514785e4276b28de9d"
}
dcrm_sign

This API return a signature which distributed signed by the P2P network's nodes.

Parameters
  1. DATA,pubkey - the pubkey from dcrm_genPubkey returned.
  2. String,HexNumber - the message hash to be signed. The format is 32-bit hexadecimal string appended with prifex "0x".
    For example: 0x19b6236d2e7eb3e925d0c6e8850502c1f04822eb9aa67cb92e5004f7017e5e41.
Return

error - Error info.

rsv - The signature string which distributed signed by the P2P network's nodes.

Example
// Request

curl -X POST -H "Content-Type":application/json --data '{"jsonrpc":"2.0","method":"dcrm_sign","params":["049ac626ee0f0f79a49d6ed37f14ff2ad4e4f45fddf6e5293bcaa6a607e5392b49dde27a8f0602e23bc5fa0b847bd28d46e2f2d1d0d8cf59514785e4276b28de9d","0x19b6236d2e7eb3e925d0c6e8850502c1f04822eb9aa67cb92e5004f7017e5e41"],"id":67}' http://127.0.0.1:5559

// Result

{
"rsv":"FFBB398B95ED2ED308B0FE87BC254FFC2C9957742EA05C18A1411C672B74FBDF6FBD6F4915799F2B4186192581D4506039ADEB79C8EB954E779901FDB9575C8301"
}

Run Local

The SDK can also be configured to run locally, where the user can control ownership of all nodes in the P2P network.

Run bootnode
./bin/cmd/bootnode --genkey ./bootnode.key

./bin/cmd/bootnode --nodekey ./bootnode.key --addr :5550 --group 0 --nodes 3

will print bootnode which use for run node with args --bootnodes bootnode key such as enode://16ab118525ec559dde2640b513676b8df7368aac3a80cc5c9d9e8b9c71781c09103fe3e8b5dd17bf245f0c71b891ec4848b142852763ab2146a1e288df15da40@127.0.0.1:5550

The default bootnode parameters are:

  1. addr: 5550
  2. group: 0 (group mode)
  3. nodes: 3 (group's nodes number)
Run nodes (3 nodes at least)

The Default setup parameters are:

  1. nodekey: node.key
  2. rpcport: 5559
  3. port: 5551
  4. bootnodes: "enode://16ab118525ec559dde2640b513676b8df7368aac3a80cc5c9d9e8b9c71781c09103fe3e8b5dd17bf245f0c71b891ec4848b142852763ab2146a1e288df15da40@127.0.0.1:5550"

Note: If you want to reboot a node, please wait 1 minute after closing node before restarting the node.

Setup the node's key:

./bin/cmd/gdcrm
./bin/cmd/gdcrm --genkey node1.key

./bin/cmd/gdcrm --genkey node2.key

./bin/cmd/gdcrm --genkey node3.key

Start three nodes with custom parameters:

./bin/cmd/gdcrm --rpcport 9011 --bootnodes "enode://16ab118525ec559dde2640b513676b8df7368aac3a80cc5c9d9e8b9c71781c09103fe3e8b5dd17bf245f0c71b891ec4848b142852763ab2146a1e288df15da40@127.0.0.1:5550" --port 12341 --nodekey "node1.key"

./bin/cmd/gdcrm --rpcport 9012 --bootnodes "enode://16ab118525ec559dde2640b513676b8df7368aac3a80cc5c9d9e8b9c71781c09103fe3e8b5dd17bf245f0c71b891ec4848b142852763ab2146a1e288df15da40@127.0.0.1:5550" --port 12342 --nodekey "node2.key"

./bin/cmd/gdcrm --rpcport 9013 --bootnodes "enode://16ab118525ec559dde2640b513676b8df7368aac3a80cc5c9d9e8b9c71781c09103fe3e8b5dd17bf245f0c71b891ec4848b142852763ab2146a1e288df15da40@127.0.0.1:5550" --port 12343 --nodekey "node3.key"

After bootnode and three nodes started, use curl connect to the node's rpc port, test dcrm_genPubkey and dcrm_sign APIs.

Directories

Path Synopsis
cmd
bootnode
bootnode runs a bootstrap node for the Ethereum Discovery Protocol.
bootnode runs a bootstrap node for the Ethereum Discovery Protocol.
secp256k1
Package secp256k1 wraps the bitcoin secp256k1 C library.
Package secp256k1 wraps the bitcoin secp256k1 C library.
sha3
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
internal
common
Package common contains various helper functions.
Package common contains various helper functions.
common/hexutil
Package hexutil implements hex encoding with 0x prefix.
Package hexutil implements hex encoding with 0x prefix.
common/math
Package math provides integer math utilities.
Package math provides integer math utilities.
common/mclock
Package mclock is a wrapper for a monotonic clock source
Package mclock is a wrapper for a monotonic clock source
Package node sets up multi-protocol Ethereum nodes.
Package node sets up multi-protocol Ethereum nodes.
p2p
Package p2p implements the Ethereum p2p network protocols.
Package p2p implements the Ethereum p2p network protocols.
discover
Package discover implements the Node Discovery Protocol.
Package discover implements the Node Discovery Protocol.
discv5
Package discv5 implements the RLPx v5 Topic Discovery Protocol.
Package discv5 implements the RLPx v5 Topic Discovery Protocol.
event
Package event deals with subscriptions to real-time events.
Package event deals with subscriptions to real-time events.
metrics
Go port of Coda Hale's Metrics library <https://github.com/rcrowley/go-metrics> Coda Hale's original work: <https://github.com/codahale/metrics>
Go port of Coda Hale's Metrics library <https://github.com/rcrowley/go-metrics> Coda Hale's original work: <https://github.com/codahale/metrics>
nat
Package nat provides access to common network port mapping protocols.
Package nat provides access to common network port mapping protocols.
netutil
Package netutil contains extensions to the net package.
Package netutil contains extensions to the net package.
protocols
Package protocols is an extension to p2p.
Package protocols is an extension to p2p.
rlp
Package rlp implements the RLP serialization format.
Package rlp implements the RLP serialization format.
rpc
Package rpc provides access to the exported methods of an object across a network or other I/O connection.
Package rpc provides access to the exported methods of an object across a network or other I/O connection.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL