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:
- a 2+1 configuration where you form a private group with 2 fusion nodes and your own node.
- a local configuration where you can set any ownership of nodes in your group.
This library contains 2 functions:
- Distributed key generation which returns the public key (dcrm_genPubkey)
- Distributed signing of transactions (dcrm_sign)
- Linux terminal
- Golang ^1.12
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
Next compile the code. Make sure you are in /dcrm-sdk directory.
cd dcrm-sdk && make
cmd/conf.toml (bin/cmd/conf.toml)
Open access to the APIs by running the compiled code.
./bin/cmd/gdcrm
The gdcrm
will provide two RPC APIs:
dcrm_genPubkey
dcrm_sign
The default RPC port is port 5559.
Note:
- If you want to call RPC API, please wait at least 2 minutes after running the node.
- If you want to call RPC API quickly more than once,please wait longer.
This API return a public key which distributed generated by the P2P network's nodes.
None
error
- Error info.
pubkey
- DCRM public key generated by the P2P network's nodes.
// 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"
}
This API return a signature which distributed signed by the P2P network's nodes.
DATA
,pubkey - the pubkey fromdcrm_genPubkey
returned.String
,HexNumber - the message hash to be signed. The format is 32-bit hexadecimal string appended with prifex "0x".
For example: 0x19b6236d2e7eb3e925d0c6e8850502c1f04822eb9aa67cb92e5004f7017e5e41.
error
- Error info.
rsv
- The signature string which distributed signed by the P2P network's nodes.
// 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"
}
The SDK can also be configured to run locally, where the user can control ownership of all nodes in the P2P network.
./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:
- addr: 5550
- group: 0 (group mode)
- nodes: 3 (group's nodes number)
The Default setup parameters are:
- nodekey: node.key
- rpcport: 5559
- port: 5551
- 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.