-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
55 lines (47 loc) · 1.36 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*jslint node: true*/
"use strict";
const inquirer = require('inquirer'),
nacl = require('ed25519'),
ed25519_basic = require('./cases/ed25519'),
ed25519_subcondition = require('./cases/prefixSha256')
var questions = [
{
type: 'list',
name: 'type',
choices: ['1 - Ed25519', '2 - PrefixSha256'],
message: 'Crypto condition simulation type',
default: 0,
filter: function (val) {
return val.substring(0,1);
},
},
{
type: 'input',
name: 'receiverSeed',
message: 'Receiver Seed (to generate PubKey)',
default: '833fe62409237b9d62ec77587520911e9a759cec1d19755b7da901b96dca3d42'
},
{
type: 'input',
name: 'message',
message: 'Message',
default: '{ "value": 12.99 }',
when: function (answers) {
return (answers.type === '2');
}
}
];
inquirer.prompt(questions).then(function (answers) {
const receiverSeedBuffer = new Buffer(answers.receiverSeed, 'hex'),
receiverKeypair = nacl.MakeKeypair(receiverSeedBuffer),
message = new Buffer((answers.message ? answers.message : ''))
console.log('\n');
switch (answers.type) {
case '1':
ed25519_basic.start(receiverKeypair.publicKey, receiverSeedBuffer, message)
break;
case '2':
ed25519_subcondition.start(receiverKeypair.publicKey, receiverSeedBuffer, new Buffer(message))
break;
}
});