Skip to content

Commit

Permalink
Random funcion added
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpuig committed Mar 20, 2020
1 parent f62de2c commit fb57c0c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@lorena-ssi/zenroom-lib",
"version": "1.3.3",
"version": "1.4.0",
"description": "zenroom-lib is a javascript library to interact with the Zenroom Virtual Machine",
"main": "src/index.js",
"author": "Alex Puig",
Expand Down
21 changes: 21 additions & 0 deletions src/index.js
Expand Up @@ -337,6 +337,27 @@ module.exports = class Zen {
return zprocess()
}

/**
* Create a Hash
*
* @param {string} source to be hashed
* @returns {Promise} Return a promise with the execution of the creation.
*/
async random () {
return new Promise((resolve) => {
const zprocess = () => this.execute(false,
`rule check version 1.0.0
Scenario simple: Generate a random password
Given nothing
When I create the array of '1' random objects of '256' bits
Then print the 'array'`)
zprocess().then((rnd) => {
resolve(rnd.array[0])
})

})
}

/**
* Create a Hash
*
Expand Down
9 changes: 9 additions & 0 deletions test/zenroom.js
Expand Up @@ -11,6 +11,7 @@ const z = new Zen()
describe('Zenroom', function () {
// Keypairs.
describe('KeyPair generation: ', () => {

it('Should create a new KeyPair: ', async () => {
aliceKeypair = await z.newKeyPair('Alice')
assert.isNotEmpty(aliceKeypair.Alice.keypair)
Expand Down Expand Up @@ -161,4 +162,12 @@ describe('Zenroom', function () {
assert.isNotEmpty(result.hash)
})
})

describe('Random: ', () => {
it('10. Should create a random Number: ', async () => {
let rnd = await z.random()
assert.isNotEmpty(rnd)
})
})

})

0 comments on commit fb57c0c

Please sign in to comment.