git ssb

0+

wanderer🌟 / bls-lib



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.jschanged
build/bls_lib.wasmchanged
build/build.ninjachanged
exportedFuncs.jsonchanged
index.jschanged
build/bls_lib.jsView
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.wasmView
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.ninjaView
@@ -1,7 +1,7 @@
11 cflags = -I../mcl/include/ -I../cybozulib/include -I../bls/include -I../bls
22
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'"
44
55 rule buildExLib
66 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
77
exportedFuncs.jsonView
@@ -80,5 +80,10 @@
8080 "name": "blsIdSetInt",
8181 "exportName": "idSetInt",
8282 "returns": "number",
8383 "args": ["number", "number"]
84 +}, {
85 + "name": "blsHashToSecretKey",
86 + "exportName": "_hashToSecretKey",
87 + "returns": "number",
88 + "args": ["number", "number", "number"]
8489 }]
index.jsView
@@ -1,7 +1,9 @@
11 const mod = require('./build/bls_lib.js')
22 const exportedFuncs = require('./exportedFuncs.json')
33
4 +exports.mod = mod
5 +
46 let init = false
57 let initCb = () => {}
68
79 /**
@@ -118,8 +120,10 @@
118120 * @return {TypedArray}
119121 */
120122 exports.signatureSerialize = wrapOutput(exports._signatureSerialize, 32)
121123
124 + exports.hashToSecretKey = wrapInput(exports._hashToSecretKey, true)
125 +
122126 /**
123127 * write a secretKey to memory
124128 * @param {number} sk - a pointer to a secret key
125129 * @param {TypedArray} array - the secret key as a 32 byte TypedArray
@@ -137,9 +141,9 @@
137141 * write a signature to memory
138142 * @param {number} sig - a pointer to a signature
139143 * @param {TypedArray} array - the signature as a 32 byte TypedArray
140144 */
141- exports.signatureDeserialize = wrapInput(exports._signatureDeserialize, true)
145 + exports.signatureDeserialize = wrapInput(exports._signatureDeserialize)
142146
143147 /**
144148 * Recovers a secret key for a group given the groups secret keys shares and the groups ids
145149 * @param {number} sk - a pointer to a secret key that will be generated
@@ -182,29 +186,28 @@
182186
183187 initCb()
184188 }
185189
186-function wrapInput (func, returnValue = false) {
190 +function wrapInput (func) {
187191 return function () {
188192 const args = [...arguments]
189193 let buf = args.pop()
190- const ioMode = 0
191- const pos = mod._malloc(buf.length)
192194 if (typeof buf === 'string') {
193195 buf = Buffer.from(buf)
194196 }
197 + const pos = mod._malloc(buf.length)
195198
196199 mod.HEAP8.set(buf, pos)
197- let r = func(...args, pos, buf.length, ioMode)
200 + let r = func(...args, pos, buf.length)
198201 mod._free(pos)
199- if (returnValue) return r
202 + return r
200203 }
201204 }
202205
203206 function wrapOutput (func, size) {
204- return function (x, ioMode = 0) {
207 + return function (x) {
205208 const pos = mod._malloc(size)
206- const n = func(pos, size, x, ioMode)
209 + const n = func(pos, size, x)
207210 const a = mod.HEAP8.slice(pos, pos + n)
208211 mod._free(pos)
209212 return a
210213 }

Built with git-ssb-web