1
0
mirror of https://github.com/bigchaindb/site.git synced 2024-11-22 01:36:55 +01:00

add python & java examples for keypair creation

This commit is contained in:
Matthias Kretschmann 2018-08-29 13:01:40 +02:00
parent 7a800ffb02
commit 290f29d830
Signed by: m
GPG Key ID: 606EEEF3C479A91F
4 changed files with 35 additions and 5 deletions

View File

@ -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, {

View File

@ -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

View File

@ -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

View File

@ -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) {