From d01042842649ea62504363626d3803ac2ee01b35 Mon Sep 17 00:00:00 2001 From: Yemel Jardi Date: Wed, 17 Dec 2014 18:00:34 -0300 Subject: [PATCH 1/2] Add ECIES and JSON RPC docs --- docs/helpers/ECIES.md | 43 ++++++++++++++++++++++++++++++++++++++ docs/networking/JSONRPC.md | 41 ++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 docs/helpers/ECIES.md create mode 100644 docs/networking/JSONRPC.md diff --git a/docs/helpers/ECIES.md b/docs/helpers/ECIES.md new file mode 100644 index 0000000..ac0d497 --- /dev/null +++ b/docs/helpers/ECIES.md @@ -0,0 +1,43 @@ +# > `bitcore-ecies` + +## Description + +Bitcore implements [Elliptic Curve Integrated Encryption Scheme (ECIES)](http://en.wikipedia.org/wiki/Integrated_Encryption_Scheme), which is a public key encryption system that performs bulk encryption on data usinc a symmetric cipher and a random key. + +For more information refer to the [bitcore-ecies](https://github.com/bitpay/bitcore-ecies) github repo. + +## Instalation + +ECIES is implemented as a separate module and you must add it to your dependencies: + +For node projects: +``` +npm install bitcore-ecies --save +``` + +For client-side projects: +``` +bower install bitcore-ecies --save +``` + +## Example + +``` +var bitcore = require('bitcore'); +var ECIES = require('bitcore-ecies'); + +var alicePrivateKey = new bitcore.PrivateKey(); +var bobPrivateKey = new bitcore.PrivateKey(); + +var data = new Buffer('The is a raw data example'); + +// Encrypt data +var cypher1 = ECIES.privateKey(alicePrivateKey).publicKey(bobPrivateKey.publicKey); +var encrypted = cypher.encrypt(data); + +// Decrypt data +var cypher2 = ECIES.privateKey(bobPrivateKey).publicKey(alicePrivateKey.publicKey); +var decrypted = cypher.decrypt(encrypted); + +assert(data.toString(), decrypted.toString()); +``` diff --git a/docs/networking/JSONRPC.md b/docs/networking/JSONRPC.md new file mode 100644 index 0000000..5359df6 --- /dev/null +++ b/docs/networking/JSONRPC.md @@ -0,0 +1,41 @@ +# > `bitcore.transport.RPC` + +## Description + +Bitcoind provides a solid integration with the bitcoin network and it also exposes a `JSON-RPC` API. This class allows to connect to a local instance of a bitcoind server and make simple or batch RPC calls to it. + +## Connection to bitcoind + +First you will need a running instance of bitcoind, setting up a username and password to connect with it. For more information about running bitcoind please refer to the official documentation. + +The code for creating and configuring an instance of the RPC client looks like this: + +``` +var bitcore = require('bitcore'); +var RPC = bitcore.transport.RPC; + +var client = new RPC('username', 'password', { + host: 'localhost', + port: 18332, + secure: false, + disableAgent: true, + rejectUnauthorized: true +}); +``` + + +## Examples + +For more information please refer to the [API reference](https://en.bitcoin.it/wiki/API_reference_%28JSON-RPC%29). + +``` +var bitcore = require('bitcore'); +var blockHash = '0000000000000000045d581af7fa3b6110266ece8131424d95bf490af828be1c'; + +var client = new bitcore.transport.RPC('username', 'password'); + +client.getBlock(blockHash, function(err, block) { + // do something with the block +}); + +``` From 2c8813546c5e5fb120078a2cbdc7dfd358b86f15 Mon Sep 17 00:00:00 2001 From: Yemel Jardi Date: Wed, 17 Dec 2014 18:32:56 -0300 Subject: [PATCH 2/2] update official doc reference --- docs/networking/JSONRPC.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/networking/JSONRPC.md b/docs/networking/JSONRPC.md index 5359df6..33a87d0 100644 --- a/docs/networking/JSONRPC.md +++ b/docs/networking/JSONRPC.md @@ -2,11 +2,11 @@ ## Description -Bitcoind provides a solid integration with the bitcoin network and it also exposes a `JSON-RPC` API. This class allows to connect to a local instance of a bitcoind server and make simple or batch RPC calls to it. +Bitcoind provides a direct interface to the bitcoin network and it also exposes a `JSON-RPC` API. This class allows to connect to a local instance of a bitcoind server and make simple or batch RPC calls to it. ## Connection to bitcoind -First you will need a running instance of bitcoind, setting up a username and password to connect with it. For more information about running bitcoind please refer to the official documentation. +First you will need a running instance of bitcoind, setting up a username and password to connect with it. For more information about running bitcoind please refer to the [official documentation](https://en.bitcoin.it/wiki/Running_Bitcoin). The code for creating and configuring an instance of the RPC client looks like this: