forked from zookos/jscrypto
-
Notifications
You must be signed in to change notification settings - Fork 2
/
cpk.js
63 lines (44 loc) · 1.08 KB
/
cpk.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
/* jscrypto library, cpk cryptosystem
* by GUAN Zhi <guanzhi at guanzhi dot org>
*/
/*
ecies_ciphertext_value = {
'ephem_public_key': { 'x':'319038102389',
'y':'2u20348909'
},
'ciphertext': 'base64 encoded value'
}
ciphertext = {
'ecies_ciphertext_value': {},
'symmetric_algor':{},
*/
/*
function cpk_gen_public_key(params, id) {
var index = cpk_str2index(id);
var pubkey = ecpoint_from_json();
for (var i = 0; i < index.length; i++) {
var factor = ecpoint_from_json(param[index[i]]);
pubkey = ecpoint_add(pubkey, factor);
}
return pubkey;
}
function str2index(str) {
var index = new Array(32);
var binb = core_sha1(str2binb(str),str.length * chrsz);
for (var i = 0; i < 32; i++) {
var a = 1 << i;
index[i] = 32 * i +
((binb[0] & a) ? 1 : 0) +
((binb[1] & a) ? 2 : 0) +
((binb[2] & a) ? 4 : 0) +
((binb[3] & a) ? 8 : 0) +
((binb[4] & a) ? 16 : 0);
}
return index;
}
*/
function cpk_gen_private_key2(id) {
// var index = cpk_str2index(id);
var key = "FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22830";
return key;
}