Commit d8d5c4d9978b3679c72ff01450bdf7da233a8b60
rebuild
Signed-off-by: wanderer <mjbecze@gmail.com>wanderer committed on 9/22/2017, 7:51:25 PM
Parent: 214afb1ac2694681c1cbd4fcb01145f491f3ca42
Files changed
build/bls_lib.js | changed |
build/bls_lib.wasm | changed |
build/build.ninja | changed |
exportedFuncs.json | changed |
index.js | changed |
build/bls_lib.js | ||
---|---|---|
The diff is too large to show. Use a local git client to view these changes. Old file size: 144098 bytes New file size: 144367 bytes |
build/bls_lib.wasm | ||
---|---|---|
The diff is too large to show. Use a local git client to view these changes. Old file size: 429653 bytes New file size: 429834 bytes |
build/build.ninja | ||
---|---|---|
@@ -1,7 +1,7 @@ | ||
1 | 1 … | cflags = -I../mcl/include/ -I../cybozulib/include -I../bls/include -I../bls |
2 | 2 … | |
3 | -EXPORTED_BLS= "'_blsInit', '_blsIdSerialize' ,'_blsSecretKeySerialize' ,'_blsPublicKeySerialize' ,'_blsSignatureSerialize' ,'_blsIdDeserialize' ,'_blsSecretKeyDeserialize' ,'_blsPublicKeyDeserialize' ,'_blsSignatureDeserialize','_blsSecretKeyIsEqual' ,'_blsPublicKeyIsEqual' ,'_blsSignatureIsEqual' ,'_blsSecretKeySetByCSPRNG' ,'_blsGetPublicKey', '_blsSecretKeyShare' ,'_blsPublicKeyShare' ,'_blsSecretKeyRecover' ,'_blsPublicKeyRecover' ,'_blsSignatureRecover' ,'_blsSign' ,'_blsVerify', '_blsIdSetInt'" | |
3 … | +EXPORTED_BLS= "'_blsInit', '_blsIdSerialize' ,'_blsSecretKeySerialize' ,'_blsPublicKeySerialize' ,'_blsSignatureSerialize' ,'_blsIdDeserialize' ,'_blsSecretKeyDeserialize' ,'_blsPublicKeyDeserialize' ,'_blsSignatureDeserialize','_blsSecretKeyIsEqual' ,'_blsPublicKeyIsEqual' ,'_blsSignatureIsEqual' ,'_blsSecretKeySetByCSPRNG' ,'_blsGetPublicKey', '_blsSecretKeyShare' ,'_blsPublicKeyShare' ,'_blsSecretKeyRecover' ,'_blsPublicKeyRecover' ,'_blsSignatureRecover' ,'_blsSign' ,'_blsVerify', '_blsIdSetInt', '_blsHashToSecretKey'" | |
4 | 4 … | |
5 | 5 … | rule buildExLib |
6 | 6 … | command = emcc -O3 -o $out ../bls/src/bls_c.cpp ../mcl/src/fp.cpp -s EXPORTED_FUNCTIONS=[$EXPORTED_BLS] --pre-js ../pre.js $cflags -s WASM=1 -DNDEBUG -DMCLBN_FP_UNIT_SIZE=6 -DMCL_MAX_BIT_SIZE=384 -DDISABLE_EXCEPTION_CATCHING=1 |
7 | 7 … |
exportedFuncs.json | ||
---|---|---|
@@ -80,5 +80,10 @@ | ||
80 | 80 … | "name": "blsIdSetInt", |
81 | 81 … | "exportName": "idSetInt", |
82 | 82 … | "returns": "number", |
83 | 83 … | "args": ["number", "number"] |
84 … | +}, { | |
85 … | + "name": "blsHashToSecretKey", | |
86 … | + "exportName": "_hashToSecretKey", | |
87 … | + "returns": "number", | |
88 … | + "args": ["number", "number", "number"] | |
84 | 89 … | }] |
index.js | |||
---|---|---|---|
@@ -1,7 +1,9 @@ | |||
1 | 1 … | const mod = require('./build/bls_lib.js') | |
2 | 2 … | const exportedFuncs = require('./exportedFuncs.json') | |
3 | 3 … | ||
4 … | +exports.mod = mod | ||
5 … | + | ||
4 | 6 … | let init = false | |
5 | 7 … | let initCb = () => {} | |
6 | 8 … | ||
7 | 9 … | /** | |
@@ -118,8 +120,10 @@ | |||
118 | 120 … | * @return {TypedArray} | |
119 | 121 … | */ | |
120 | 122 … | exports.signatureSerialize = wrapOutput(exports._signatureSerialize, 32) | |
121 | 123 … | ||
124 … | + exports.hashToSecretKey = wrapInput(exports._hashToSecretKey, true) | ||
125 … | + | ||
122 | 126 … | /** | |
123 | 127 … | * write a secretKey to memory | |
124 | 128 … | * @param {number} sk - a pointer to a secret key | |
125 | 129 … | * @param {TypedArray} array - the secret key as a 32 byte TypedArray | |
@@ -137,9 +141,9 @@ | |||
137 | 141 … | * write a signature to memory | |
138 | 142 … | * @param {number} sig - a pointer to a signature | |
139 | 143 … | * @param {TypedArray} array - the signature as a 32 byte TypedArray | |
140 | 144 … | */ | |
141 | - exports.signatureDeserialize = wrapInput(exports._signatureDeserialize, true) | ||
145 … | + exports.signatureDeserialize = wrapInput(exports._signatureDeserialize) | ||
142 | 146 … | ||
143 | 147 … | /** | |
144 | 148 … | * Recovers a secret key for a group given the groups secret keys shares and the groups ids | |
145 | 149 … | * @param {number} sk - a pointer to a secret key that will be generated | |
@@ -182,29 +186,28 @@ | |||
182 | 186 … | ||
183 | 187 … | initCb() | |
184 | 188 … | } | |
185 | 189 … | ||
186 | -function wrapInput (func, returnValue = false) { | ||
190 … | +function wrapInput (func) { | ||
187 | 191 … | return function () { | |
188 | 192 … | const args = [...arguments] | |
189 | 193 … | let buf = args.pop() | |
190 | - const ioMode = 0 | ||
191 | - const pos = mod._malloc(buf.length) | ||
192 | 194 … | if (typeof buf === 'string') { | |
193 | 195 … | buf = Buffer.from(buf) | |
194 | 196 … | } | |
197 … | + const pos = mod._malloc(buf.length) | ||
195 | 198 … | ||
196 | 199 … | mod.HEAP8.set(buf, pos) | |
197 | - let r = func(...args, pos, buf.length, ioMode) | ||
200 … | + let r = func(...args, pos, buf.length) | ||
198 | 201 … | mod._free(pos) | |
199 | - if (returnValue) return r | ||
202 … | + return r | ||
200 | 203 … | } | |
201 | 204 … | } | |
202 | 205 … | ||
203 | 206 … | function wrapOutput (func, size) { | |
204 | - return function (x, ioMode = 0) { | ||
207 … | + return function (x) { | ||
205 | 208 … | const pos = mod._malloc(size) | |
206 | - const n = func(pos, size, x, ioMode) | ||
209 … | + const n = func(pos, size, x) | ||
207 | 210 … | const a = mod.HEAP8.slice(pos, pos + n) | |
208 | 211 … | mod._free(pos) | |
209 | 212 … | return a | |
210 | 213 … | } |
Built with git-ssb-web