From 8593358ebf5adab6731dbda5490891dc9c36b787 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 29 Aug 2018 12:43:10 +0200 Subject: [PATCH 1/3] add Python examples to setup --- _src/_guide/_setup.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/_src/_guide/_setup.md b/_src/_guide/_setup.md index bdbb230..de12164 100644 --- a/_src/_guide/_setup.md +++ b/_src/_guide/_setup.md @@ -1,11 +1,15 @@ # Setup -Start by installing the official [BigchainDB JavaScript driver](https://github.com/bigchaindb/js-bigchaindb-driver): +Start by installing the official BigchainDB [JavaScript driver](https://github.com/bigchaindb/js-bigchaindb-driver) or [Python driver](https://github.com/bigchaindb/bigchaindb-driver): ```bash npm i bigchaindb-driver ``` +```bash +pip install -U bigchaindb-driver +``` + Then, include that as a module and connect to any BigchainDB node. You can create your own `app_id` and `app_key` on [BigchainDB Testnet](https://testnet.bigchaindb.com). ```js @@ -18,3 +22,22 @@ const conn = new BigchainDB.Connection(API_PATH, { app_key: 'Get one from testnet.bigchaindb.com' }) ``` + +```python +from bigchaindb_driver import BigchainDB +from bigchaindb_driver.crypto import generate_keypair + +bdb = BigchainDB( + 'https://test.bigchaindb.com', + headers={'app_id': 'Get one from testnet.bigchaindb.com', + 'app_key': 'Get one from testnet.bigchaindb.com'}) +alice = generate_keypair() +tx = bdb.transactions.prepare( + operation='CREATE', + signers=alice.public_key, + asset={'data': {'message': ''}}) +signed_tx = bdb.transactions.fulfill( + tx, + private_keys=alice.private_key) +bdb.transactions.send(signed_tx) +``` From 7a800ffb020c00dd8bfac50ada50eaf21d582a48 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 29 Aug 2018 12:52:10 +0200 Subject: [PATCH 2/3] add java setup example --- _src/_guide/_setup.md | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/_src/_guide/_setup.md b/_src/_guide/_setup.md index de12164..d4d2804 100644 --- a/_src/_guide/_setup.md +++ b/_src/_guide/_setup.md @@ -1,15 +1,26 @@ # Setup -Start by installing the official BigchainDB [JavaScript driver](https://github.com/bigchaindb/js-bigchaindb-driver) or [Python driver](https://github.com/bigchaindb/bigchaindb-driver): +Start by installing the official BigchainDB [JavaScript driver](https://github.com/bigchaindb/js-bigchaindb-driver), [Python driver](https://github.com/bigchaindb/bigchaindb-driver) or [Java driver](https://github.com/bigchaindb/java-bigchaindb-driver): ```bash +# JavaScript driver npm i bigchaindb-driver ``` ```bash +# Python driver pip install -U bigchaindb-driver ``` +```xml + + + com.bigchaindb + bigchaindb-driver + 1.0 + +``` + Then, include that as a module and connect to any BigchainDB node. You can create your own `app_id` and `app_key` on [BigchainDB Testnet](https://testnet.bigchaindb.com). ```js @@ -25,19 +36,16 @@ const conn = new BigchainDB.Connection(API_PATH, { ```python from bigchaindb_driver import BigchainDB -from bigchaindb_driver.crypto import generate_keypair -bdb = BigchainDB( +conn = BigchainDB( 'https://test.bigchaindb.com', headers={'app_id': 'Get one from testnet.bigchaindb.com', 'app_key': 'Get one from testnet.bigchaindb.com'}) -alice = generate_keypair() -tx = bdb.transactions.prepare( - operation='CREATE', - signers=alice.public_key, - asset={'data': {'message': ''}}) -signed_tx = bdb.transactions.fulfill( - tx, - private_keys=alice.private_key) -bdb.transactions.send(signed_tx) +``` + +```java +BigchainDbConfigBuilder + .baseUrl("https://test.bigchaindb.com/") + .addToken("app_id", "Get one from testnet.bigchaindb.com") + .addToken("app_key","Get one from testnet.bigchaindb.com").setup(); ``` From 290f29d8304aa896cd59c69ce6da331829ec52cb Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 29 Aug 2018 13:01:40 +0200 Subject: [PATCH 3/3] add python & java examples for keypair creation --- _src/_guide/_setup.md | 1 - _src/_guide/tutorial-car-telemetry-app.md | 17 ++++++++++++++++- _src/_guide/tutorial-piece-of-art.md | 17 ++++++++++++++++- _src/_guide/tutorial-rbac.md | 5 +++-- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/_src/_guide/_setup.md b/_src/_guide/_setup.md index d4d2804..f2bb5a3 100644 --- a/_src/_guide/_setup.md +++ b/_src/_guide/_setup.md @@ -25,7 +25,6 @@ Then, include that as a module and connect to any BigchainDB node. You can creat ```js const BigchainDB = require('bigchaindb-driver') -const bip39 = require('bip39') const API_PATH = 'https://test.bigchaindb.com/api/v1/' const conn = new BigchainDB.Connection(API_PATH, { diff --git a/_src/_guide/tutorial-car-telemetry-app.md b/_src/_guide/tutorial-car-telemetry-app.md index 707223c..fe8d8ae 100644 --- a/_src/_guide/tutorial-car-telemetry-app.md +++ b/_src/_guide/tutorial-car-telemetry-app.md @@ -33,7 +33,22 @@ In BigchainDB, users are represented as a private and public key pair. In our ca For Alice, you can generate a key pair from a seed phrase using the BIP39 library, so you will just need to remember this particular seed phrase. The code below illustrates that. ```js -const alice = new BigchainDB.Ed25519Keypair(bip39.mnemonicToSeed('seedPhrase').slice(0,32)) +const bip39 = require('bip39') + +const seed = bip39.mnemonicToSeed('seedPhrase').slice(0,32) +const alice = new BigchainDB.Ed25519Keypair(seed) +``` + +```python +from bigchaindb_driver.crypto import generate_keypair + +alice = generate_keypair() +``` + +```java +net.i2p.crypto.eddsa.KeyPairGenerator edDsaKpg = new net.i2p.crypto.eddsa.KeyPairGenerator(); + +KeyPair alice = edDsaKpg.generateKeyPair(); ``` # Decentralized Identifier Class diff --git a/_src/_guide/tutorial-piece-of-art.md b/_src/_guide/tutorial-piece-of-art.md index 724a40e..1132dd7 100644 --- a/_src/_guide/tutorial-piece-of-art.md +++ b/_src/_guide/tutorial-piece-of-art.md @@ -36,7 +36,22 @@ Before starting, you need to create a user in BigchainDB. In BigchainDB, users a You can generate a key pair from a seed phrase using the BIP39 library, so you will just need to remember this particular seed phrase. The code below illustrates that. ```js -const alice = new BigchainDB.Ed25519Keypair(bip39.mnemonicToSeed('seedPhrase').slice(0,32)) +const bip39 = require('bip39') + +const seed = bip39.mnemonicToSeed('seedPhrase').slice(0,32) +const alice = new BigchainDB.Ed25519Keypair(seed) +``` + +```python +from bigchaindb_driver.crypto import generate_keypair + +alice = generate_keypair() +``` + +```java +net.i2p.crypto.eddsa.KeyPairGenerator edDsaKpg = new net.i2p.crypto.eddsa.KeyPairGenerator(); + +KeyPair alice = edDsaKpg.generateKeyPair(); ``` # Digital registration of an asset on BigchainDB diff --git a/_src/_guide/tutorial-rbac.md b/_src/_guide/tutorial-rbac.md index b3697ac..fab6e8c 100644 --- a/_src/_guide/tutorial-rbac.md +++ b/_src/_guide/tutorial-rbac.md @@ -14,6 +14,7 @@ learn: > Hi there! Welcome to our next tutorial about Role-based access controls (RBAC) in BigchainDB. For this tutorial, we assume that you are familiar with the BigchainDB primitives (assets, inputs, outputs, transactions etc.). If you are not, familiarize yourself with the [Key concepts of BigchainDB](../key-concepts-of-bigchaindb/). We also assume that you have completed our [first tutorial](../tutorial-car-telemetry-app/). # About RBAC + Role based access control is a way to restrict the system access to certain users. In BigchainDB this function enables the creation of hierarchies of role and permissions as assets. Furthermore, users can be assigned roles to “act on behalf of” or “represent” other users or groups. In our example use-case scenario for this guide, we have different tribes or groups of users where they have different roles, users belonging to one tribe can create proposal assets and others can create vote assets on the BigchainDB blockchain. @@ -25,7 +26,6 @@ In our example use-case scenario for this guide, we have different tribes or gro Let's create the app. You will create an asset for Admin type which will act as the admin group for the app. Async/await functions will be used in this tutorial ```js - const nameSpace = 'rbac-bdb-tutorial' async function createApp(){ // Generate keypair for admin instance @@ -63,7 +63,8 @@ async function createApp(){ } ``` -The `createNewAsset` function looks like this +The `createNewAsset` function looks like this: + ```js async function createNewAsset(keypair, asset, metadata) {