-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_side.js
98 lines (66 loc) · 3 KB
/
client_side.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
const fs = require('fs');
// Ring Signature Generation
function ring_sig_gen_for_view_resource(index) {
//console.log(index);
fs.writeFile('/home/rimjhim/front_end/JWT_token/token_simplify/Ring/Ring_Client/resource_index.txt', index, function (err) {
if (err) return console.log(err);
console.log('written in the resource_index.txt file - > index');
})
const { spawn } = require('child_process');
const pyProg = spawn('python', ['/home/rimjhim/front_end/JWT_token/token_simplify/Ring/Ring_Client/ring_sig_client.py']);
pyProg.stdout.on('data', function (data) {
//console.log('Pipe data from python script ...');
dataToSend = data.toString();
console.log(data.toString());
fs.writeFile('/home/rimjhim/front_end/JWT_token/token_simplify/Ring/Ring_Client/signature.txt', data.toString(), (err) => {
if (err) throw err;
});
});
// in close event we are sure that stream from child process is closed
pyProg.on('close', (code) => {
//console.log(`child process close all stdio with code ${code}`);
// send data to browser
//console.log(dataToSend);
});
}
// Ring Signature Generation
function ring_sig_gen_for_view_specific_resource(Rid) {
console.log(Rid);
fs.writeFile('/home/rimjhim/front_end/JWT_token/token_simplify/Ring/Ring_Client/resource_id.txt', Rid, function (err) {
if (err) return console.log(err);
console.log('written in the resource_id.txt file - > index');
})
const { spawn } = require('child_process');
const pyProg = spawn('python', ['/home/rimjhim/front_end/JWT_token/token_simplify/Ring/Ring_Client/ring_sig_client_rid.py']);
pyProg.stdout.on('data', function (data) {
//console.log('Pipe data from python script ...');
dataToSend = data.toString();
console.log(data.toString());
fs.writeFile('/home/rimjhim/front_end/JWT_token/token_simplify/Ring/Ring_Client/signature.txt', data.toString(), (err) => {
if (err) throw err;
});
});
// in close event we are sure that stream from child process is closed
pyProg.on('close', (code) => {
//console.log(`child process close all stdio with code ${code}`);
// send data to browser
//console.log(dataToSend);
});
}
// EC Signature Generation
function ec_sig_gen_for_add_resource(info, cert, desc, policy, metadata) {
const { spawn } = require('child_process');
const pyProg = spawn('python', ['/home/rimjhim/front_end/JWT_token/token_simplify/EC/EC_Client/ec_sign_gen_client.py']);
pyProg.stdout.on('data', function (data) {
//console.log('Pipe data from python script ...');
dataToSend = data.toString();
console.log(data.toString());
});
// in close event we are sure that stream from child process is closed
pyProg.on('close', (code) => {
//console.log(`child process close all stdio with code ${code}`);
// send data to browser
//console.log(dataToSend);
});
}
module.exports = { ring_sig_gen_for_view_resource, ec_sig_gen_for_add_resource, ring_sig_gen_for_view_specific_resource };