Commit d5061208288fe0b3090a797ef7157812f835d6bf
Merge pull request #5 from dfinity/returnBool
make some funcs return boolwanderer authored on 11/27/2017, 4:32:12 PM
GitHub committed on 11/27/2017, 4:32:12 PM
Parent: 0dd1b30801413a39f947d8cb8f38d0f2917f252f
Parent: 3c457e85e4c76d79aaf2696a662063e81744a3e7
Files changed
docs/index.md | changed |
index.js | changed |
package-lock.json | changed |
package.json | changed |
tests/index.js | changed |
docs/index.md | ||
---|---|---|
@@ -13,8 +13,9 @@ | ||
13 | 13 … | - [free](#free) |
14 | 14 … | - [freeArray](#freearray) |
15 | 15 … | - [idSetInt](#idsetint) |
16 | 16 … | - [idImportFromInt](#idimportfromint) |
17 … | +- [idImport](#idimport) | |
17 | 18 … | - [sign](#sign) |
18 | 19 … | - [verify](#verify) |
19 | 20 … | - [publicKeyExport](#publickeyexport) |
20 | 21 … | - [secretKeyExport](#secretkeyexport) |
@@ -25,17 +26,23 @@ | ||
25 | 26 … | - [publicKeyDeserialize](#publickeydeserialize) |
26 | 27 … | - [publicKeyImport](#publickeyimport) |
27 | 28 … | - [signatureDeserialize](#signaturedeserialize) |
28 | 29 … | - [signatureImport](#signatureimport) |
30 … | +- [secretKeySetByCSPRNG](#secretkeysetbycsprng) | |
31 … | +- [getPublicKey](#getpublickey) | |
29 | 32 … | - [secretKeyRecover](#secretkeyrecover) |
30 | 33 … | - [publicKeyRecover](#publickeyrecover) |
31 | 34 … | - [signatureRecover](#signaturerecover) |
32 | 35 … | - [secretKeyShare](#secretkeyshare) |
33 | 36 … | - [publicKeyShare](#publickeyshare) |
37 … | +- [publicKeyAdd](#publickeyadd) | |
38 … | +- [secretKeyAdd](#secretkeyadd) | |
39 … | +- [publicKeyIsEqual](#publickeyisequal) | |
40 … | +- [dhKeyExchange](#dhkeyexchange) | |
34 | 41 … | |
35 | 42 … | ## onModuleInit |
36 | 43 … | |
37 | -[index.js:14-21](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L14-L21 "Source code on GitHub") | |
44 … | +[index.js:14-21](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L14-L21 "Source code on GitHub") | |
38 | 45 … | |
39 | 46 … | takes a callback that is called once the module is setup |
40 | 47 … | |
41 | 48 … | **Parameters** |
@@ -43,27 +50,27 @@ | ||
43 | 50 … | - `cb` |
44 | 51 … | |
45 | 52 … | ## MCLBN_CURVE_FP254BNB |
46 | 53 … | |
47 | -[index.js:26-26](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L26-L26 "Source code on GitHub") | |
54 … | +[index.js:26-26](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L26-L26 "Source code on GitHub") | |
48 | 55 … | |
49 | 56 … | the FP254BNB curve |
50 | 57 … | |
51 | 58 … | ## MCLBN_CURVE_FP382_1 |
52 | 59 … | |
53 | -[index.js:31-31](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L31-L31 "Source code on GitHub") | |
60 … | +[index.js:31-31](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L31-L31 "Source code on GitHub") | |
54 | 61 … | |
55 | 62 … | the FP382_1 curve |
56 | 63 … | |
57 | 64 … | ## MCLBN_CURVE_FP382_2 |
58 | 65 … | |
59 | -[index.js:36-36](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L36-L36 "Source code on GitHub") | |
66 … | +[index.js:36-36](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L36-L36 "Source code on GitHub") | |
60 | 67 … | |
61 | 68 … | the FP382_2 curve |
62 | 69 … | |
63 | 70 … | ## init |
64 | 71 … | |
65 | -[index.js:53-55](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L53-L55 "Source code on GitHub") | |
72 … | +[index.js:49-51](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L49-L51 "Source code on GitHub") | |
66 | 73 … | |
67 | 74 … | intailizes the libary to use a given curve |
68 | 75 … | |
69 | 76 … | **Parameters** |
@@ -71,33 +78,33 @@ | ||
71 | 78 … | - `curve` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the curves that can be used are MCLBN_CURVE_FP254BNB, MCLBN_CURVE_FP382_1 or MCLBN_CURVE_FP382_2 (optional, default `exports.MCLBN_CURVE_FP254BNB`) |
72 | 79 … | |
73 | 80 … | ## secretKey |
74 | 81 … | |
75 | -[index.js:61-63](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L61-L63 "Source code on GitHub") | |
82 … | +[index.js:57-59](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L57-L59 "Source code on GitHub") | |
76 | 83 … | |
77 | 84 … | allocates a secret key |
78 | 85 … | |
79 | 86 … | Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the pointer to the key |
80 | 87 … | |
81 | 88 … | ## publicKey |
82 | 89 … | |
83 | -[index.js:69-71](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L69-L71 "Source code on GitHub") | |
90 … | +[index.js:65-67](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L65-L67 "Source code on GitHub") | |
84 | 91 … | |
85 | 92 … | allocates a secret key |
86 | 93 … | |
87 | 94 … | Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the pointer to the key |
88 | 95 … | |
89 | 96 … | ## signature |
90 | 97 … | |
91 | -[index.js:77-79](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L77-L79 "Source code on GitHub") | |
98 … | +[index.js:73-75](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L73-L75 "Source code on GitHub") | |
92 | 99 … | |
93 | 100 … | allocates a signature |
94 | 101 … | |
95 | 102 … | Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the pointer to the signture |
96 | 103 … | |
97 | 104 … | ## free |
98 | 105 … | |
99 | -[index.js:84-86](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L84-L86 "Source code on GitHub") | |
106 … | +[index.js:80-82](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L80-L82 "Source code on GitHub") | |
100 | 107 … | |
101 | 108 … | frees a pointer |
102 | 109 … | |
103 | 110 … | **Parameters** |
@@ -105,9 +112,9 @@ | ||
105 | 112 … | - `x` |
106 | 113 … | |
107 | 114 … | ## freeArray |
108 | 115 … | |
109 | -[index.js:91-93](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L91-L93 "Source code on GitHub") | |
116 … | +[index.js:87-89](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L87-L89 "Source code on GitHub") | |
110 | 117 … | |
111 | 118 … | frees an array of pointers |
112 | 119 … | |
113 | 120 … | **Parameters** |
@@ -115,9 +122,9 @@ | ||
115 | 122 … | - `a` |
116 | 123 … | |
117 | 124 … | ## idSetInt |
118 | 125 … | |
119 | -[index.js:100-105](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L100-L105 "Source code on GitHub") | |
126 … | +[index.js:96-101](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L96-L101 "Source code on GitHub") | |
120 | 127 … | |
121 | 128 … | creates an ID from an int to use in with threshold groups |
122 | 129 … | |
123 | 130 … | **Parameters** |
@@ -126,9 +133,9 @@ | ||
126 | 133 … | - `n` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a int repsenting the ID. n cannot be zero. |
127 | 134 … | |
128 | 135 … | ## idImportFromInt |
129 | 136 … | |
130 | -[index.js:112-116](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L112-L116 "Source code on GitHub") | |
137 … | +[index.js:108-112](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L108-L112 "Source code on GitHub") | |
131 | 138 … | |
132 | 139 … | creates an ID from an int and returns a pointer to it |
133 | 140 … | |
134 | 141 … | **Parameters** |
@@ -136,11 +143,23 @@ | ||
136 | 143 … | - `n` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a int repsenting the ID. n cannot be zero. |
137 | 144 … | |
138 | 145 … | Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** |
139 | 146 … | |
147 … | +## idImport | |
148 … | + | |
149 … | +[index.js:119-127](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L119-L127 "Source code on GitHub") | |
150 … | + | |
151 … | +creates an ID from an int and returns a pointer to it | |
152 … | + | |
153 … | +**Parameters** | |
154 … | + | |
155 … | +- `n` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a int repsenting the ID. n cannot be zero. | |
156 … | + | |
157 … | +Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** | |
158 … | + | |
140 | 159 … | ## sign |
141 | 160 … | |
142 | -[index.js:124-124](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L124-L124 "Source code on GitHub") | |
161 … | +[index.js:135-135](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L135-L135 "Source code on GitHub") | |
143 | 162 … | |
144 | 163 … | signs a message |
145 | 164 … | |
146 | 165 … | **Parameters** |
@@ -150,9 +169,9 @@ | ||
150 | 169 … | - `msg` **([TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) \| [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String))** the message to sign |
151 | 170 … | |
152 | 171 … | ## verify |
153 | 172 … | |
154 | -[index.js:132-132](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L132-L132 "Source code on GitHub") | |
173 … | +[index.js:144-144](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L144-L144 "Source code on GitHub") | |
155 | 174 … | |
156 | 175 … | verifies a signature |
157 | 176 … | |
158 | 177 … | **Parameters** |
@@ -160,11 +179,13 @@ | ||
160 | 179 … | - `sig` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to the a signature |
161 | 180 … | - `pk` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to the secret key |
162 | 181 … | - `msg` **([TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) \| [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String))** the message that was signed |
163 | 182 … | |
183 … | +Returns **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** | |
184 … | + | |
164 | 185 … | ## publicKeyExport |
165 | 186 … | |
166 | -[index.js:139-139](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L139-L139 "Source code on GitHub") | |
187 … | +[index.js:151-151](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L151-L151 "Source code on GitHub") | |
167 | 188 … | |
168 | 189 … | given a pointer to a public key this returns 64 byte Int8Array containing the key |
169 | 190 … | |
170 | 191 … | **Parameters** |
@@ -174,9 +195,9 @@ | ||
174 | 195 … | Returns **[TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)** |
175 | 196 … | |
176 | 197 … | ## secretKeyExport |
177 | 198 … | |
178 | -[index.js:146-146](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L146-L146 "Source code on GitHub") | |
199 … | +[index.js:158-158](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L158-L158 "Source code on GitHub") | |
179 | 200 … | |
180 | 201 … | given a pointer to a secret key this returns 32 byte Int8Array containing the key |
181 | 202 … | |
182 | 203 … | **Parameters** |
@@ -186,9 +207,9 @@ | ||
186 | 207 … | Returns **[TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)** |
187 | 208 … | |
188 | 209 … | ## signatureExport |
189 | 210 … | |
190 | -[index.js:153-153](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L153-L153 "Source code on GitHub") | |
211 … | +[index.js:165-165](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L165-L165 "Source code on GitHub") | |
191 | 212 … | |
192 | 213 … | given a pointer to a signature this returns 32 byte Int8Array containing the signature |
193 | 214 … | |
194 | 215 … | **Parameters** |
@@ -198,9 +219,9 @@ | ||
198 | 219 … | Returns **[TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)** |
199 | 220 … | |
200 | 221 … | ## hashToSecretKey |
201 | 222 … | |
202 | -[index.js:160-160](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L160-L160 "Source code on GitHub") | |
223 … | +[index.js:172-172](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L172-L172 "Source code on GitHub") | |
203 | 224 … | |
204 | 225 … | generates a secret key given a seed phrase. |
205 | 226 … | |
206 | 227 … | **Parameters** |
@@ -209,9 +230,9 @@ | ||
209 | 230 … | - `seed` **([String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray))** the seed phrase |
210 | 231 … | |
211 | 232 … | ## secretKeyDeserialize |
212 | 233 … | |
213 | -[index.js:167-167](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L167-L167 "Source code on GitHub") | |
234 … | +[index.js:179-179](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L179-L179 "Source code on GitHub") | |
214 | 235 … | |
215 | 236 … | write a secretKey to memory |
216 | 237 … | |
217 | 238 … | **Parameters** |
@@ -220,9 +241,9 @@ | ||
220 | 241 … | - `array` **[TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)** the secret key as a 32 byte TypedArray |
221 | 242 … | |
222 | 243 … | ## secretKeyImport |
223 | 244 … | |
224 | -[index.js:175-179](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L175-L179 "Source code on GitHub") | |
245 … | +[index.js:187-191](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L187-L191 "Source code on GitHub") | |
225 | 246 … | |
226 | 247 … | write a secretKey to memory and returns a pointer to it |
227 | 248 … | |
228 | 249 … | **Parameters** |
@@ -234,9 +255,9 @@ | ||
234 | 255 … | Returns **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** |
235 | 256 … | |
236 | 257 … | ## publicKeyDeserialize |
237 | 258 … | |
238 | -[index.js:186-186](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L186-L186 "Source code on GitHub") | |
259 … | +[index.js:198-198](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L198-L198 "Source code on GitHub") | |
239 | 260 … | |
240 | 261 … | write a publicKey to memory |
241 | 262 … | |
242 | 263 … | **Parameters** |
@@ -245,9 +266,9 @@ | ||
245 | 266 … | - `array` **[TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)** the secret key as a 64 byte TypedArray |
246 | 267 … | |
247 | 268 … | ## publicKeyImport |
248 | 269 … | |
249 | -[index.js:193-197](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L193-L197 "Source code on GitHub") | |
270 … | +[index.js:205-209](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L205-L209 "Source code on GitHub") | |
250 | 271 … | |
251 | 272 … | write a publicKey to memory and returns a pointer to it |
252 | 273 … | |
253 | 274 … | **Parameters** |
@@ -258,9 +279,9 @@ | ||
258 | 279 … | Returns **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** |
259 | 280 … | |
260 | 281 … | ## signatureDeserialize |
261 | 282 … | |
262 | -[index.js:204-204](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L204-L204 "Source code on GitHub") | |
283 … | +[index.js:216-216](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L216-L216 "Source code on GitHub") | |
263 | 284 … | |
264 | 285 … | write a signature to memory |
265 | 286 … | |
266 | 287 … | **Parameters** |
@@ -269,9 +290,9 @@ | ||
269 | 290 … | - `array` **[TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)** the signature as a 32 byte TypedArray |
270 | 291 … | |
271 | 292 … | ## signatureImport |
272 | 293 … | |
273 | -[index.js:211-215](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L211-L215 "Source code on GitHub") | |
294 … | +[index.js:223-227](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L223-L227 "Source code on GitHub") | |
274 | 295 … | |
275 | 296 … | write a signature to memory and returns a pointer to it |
276 | 297 … | |
277 | 298 … | **Parameters** |
@@ -280,11 +301,32 @@ | ||
280 | 301 … | - `array` **[TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)** the signature as a 32 byte TypedArray |
281 | 302 … | |
282 | 303 … | Returns **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** |
283 | 304 … | |
305 … | +## secretKeySetByCSPRNG | |
306 … | + | |
307 … | +[index.js:233-233](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L233-L233 "Source code on GitHub") | |
308 … | + | |
309 … | +Initialize a secret key by a Cryptographically Secure Pseudo Random Number Generator | |
310 … | + | |
311 … | +**Parameters** | |
312 … | + | |
313 … | +- `array` **[TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)** the secret key as a TypedArray | |
314 … | + | |
315 … | +## getPublicKey | |
316 … | + | |
317 … | +[index.js:240-240](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L240-L240 "Source code on GitHub") | |
318 … | + | |
319 … | +Create a public key from the secret key | |
320 … | + | |
321 … | +**Parameters** | |
322 … | + | |
323 … | +- `array` **[TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)** the public key as a TypedArray | |
324 … | +- `array` **[TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)** the secret key as a TypedArray | |
325 … | + | |
284 | 326 … | ## secretKeyRecover |
285 | 327 … | |
286 | -[index.js:223-223](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L223-L223 "Source code on GitHub") | |
328 … | +[index.js:248-248](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L248-L248 "Source code on GitHub") | |
287 | 329 … | |
288 | 330 … | Recovers a secret key for a group given the groups secret keys shares and the groups ids |
289 | 331 … | |
290 | 332 … | **Parameters** |
@@ -294,21 +336,21 @@ | ||
294 | 336 … | - `idArrah` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<numbers>** an array of pointers to ids in the groups. The length of the array should be the threshold number for the group |
295 | 337 … | |
296 | 338 … | ## publicKeyRecover |
297 | 339 … | |
298 | -[index.js:231-231](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L231-L231 "Source code on GitHub") | |
340 … | +[index.js:256-256](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L256-L256 "Source code on GitHub") | |
299 | 341 … | |
300 | 342 … | Recovers a public key for a group given the groups public keys shares and the groups ids |
301 | 343 … | |
302 | 344 … | **Parameters** |
303 | 345 … | |
304 | -- `pk` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to a secret key that will be generated | |
346 … | +- `pk` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to a public key that will be generated | |
305 | 347 … | - `pksArray` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>** an array of pointers to the groups public key shares. The length of the array should be the threshold number for the group |
306 | 348 … | - `idArrah` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<numbers>** an array of pointers to ids in the groups. The length of the array should be the threshold number for the group |
307 | 349 … | |
308 | 350 … | ## signatureRecover |
309 | 351 … | |
310 | -[index.js:239-239](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L239-L239 "Source code on GitHub") | |
352 … | +[index.js:264-264](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L264-L264 "Source code on GitHub") | |
311 | 353 … | |
312 | 354 … | Recovers a signature for a group given the groups public keys shares and the groups ids |
313 | 355 … | |
314 | 356 … | **Parameters** |
@@ -318,9 +360,9 @@ | ||
318 | 360 … | - `idArrah` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<numbers>** an array of pointers to ids in the groups. The length of the array should be the threshold number for the group |
319 | 361 … | |
320 | 362 … | ## secretKeyShare |
321 | 363 … | |
322 | -[index.js:247-247](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L247-L247 "Source code on GitHub") | |
364 … | +[index.js:272-272](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L272-L272 "Source code on GitHub") | |
323 | 365 … | |
324 | 366 … | Creates a secket key share for a group member given the groups members id (which is a the secret key) and array of master secret keys |
325 | 367 … | |
326 | 368 … | **Parameters** |
@@ -330,13 +372,59 @@ | ||
330 | 372 … | - `id` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the id of the member |
331 | 373 … | |
332 | 374 … | ## publicKeyShare |
333 | 375 … | |
334 | -[index.js:255-255](https://github.com/wanderer/bls-lib/blob/63a2cdafe199f883855c63bd361a125a6b8b464a/index.js#L255-L255 "Source code on GitHub") | |
376 … | +[index.js:280-280](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L280-L280 "Source code on GitHub") | |
335 | 377 … | |
336 | 378 … | Creates a public key share for a group member given the groups members id (which is a the secret key) and array of master public keys |
337 | 379 … | |
338 | 380 … | **Parameters** |
339 | 381 … | |
340 | 382 … | - `pkshare` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to a secret key that will be generated |
341 | 383 … | - `mpk` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>** an array of master public keys. The number of keys is the threshould of the group. |
342 | 384 … | - `id` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the id of the member |
385 … | + | |
386 … | +## publicKeyAdd | |
387 … | + | |
388 … | +[index.js:287-287](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L287-L287 "Source code on GitHub") | |
389 … | + | |
390 … | +Take two publicKeys and adds them together. pubkey1 = pubkey1 + pubkey2 | |
391 … | + | |
392 … | +**Parameters** | |
393 … | + | |
394 … | +- `pubkey1` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to a public key | |
395 … | +- `pubkey2` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to a public key | |
396 … | + | |
397 … | +## secretKeyAdd | |
398 … | + | |
399 … | +[index.js:294-294](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L294-L294 "Source code on GitHub") | |
400 … | + | |
401 … | +Take two secretKeys and adds them together. seckey1 = seckey1 + seckey2 | |
402 … | + | |
403 … | +**Parameters** | |
404 … | + | |
405 … | +- `seckey1` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to a secret key | |
406 … | +- `seckey2` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to a secret key | |
407 … | + | |
408 … | +## publicKeyIsEqual | |
409 … | + | |
410 … | +[index.js:302-302](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L302-L302 "Source code on GitHub") | |
411 … | + | |
412 … | +Take two publicKeys and tests thier equality | |
413 … | + | |
414 … | +**Parameters** | |
415 … | + | |
416 … | +- `pubkey1` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to a public key | |
417 … | +- `pubkey2` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to a public key | |
418 … | + return {Boolean} | |
419 … | + | |
420 … | +## dhKeyExchange | |
421 … | + | |
422 … | +[index.js:310-310](https://github.com/dfinity/bls-lib/blob/2b6104bd4d6a111c264a5b60ec590f39c84b3da0/index.js#L310-L310 "Source code on GitHub") | |
423 … | + | |
424 … | +Does Diffie–Hellman key exchange | |
425 … | + | |
426 … | +**Parameters** | |
427 … | + | |
428 … | +- `sharedSecretKey` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to a secretKey that will be populated with the shared secret | |
429 … | +- `secretKey` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to a secret key | |
430 … | +- `pubkey` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to a public key |
index.js | ||
---|---|---|
@@ -1,12 +1,13 @@ | ||
1 | 1 … | const nop = require('nop') |
2 … | +const Buffer = require('safe-buffer').Buffer | |
2 | 3 … | const mod = require('./build/bls_lib.js') |
3 | 4 … | |
4 | -exports.mod = mod | |
5 | - | |
6 | 5 … | let init = false |
7 | 6 … | let initCb = nop |
8 | 7 … | |
8 … | +exports.mod = mod | |
9 … | + | |
9 | 10 … | /** |
10 | 11 … | * takes a callback that is called once the module is setup |
11 | 12 … | * @params {Function} cb - the callback tobe called once the module is intailized |
12 | 13 … | */ |
@@ -137,10 +138,11 @@ | ||
137 | 138 … | * verifies a signature |
138 | 139 … | * @param {number} sig - a pointer to the a signature |
139 | 140 … | * @param {number} pk - a pointer to the secret key |
140 | 141 … | * @param {TypedArray|String} msg - the message that was signed |
142 … | + * @returns {Boolean} | |
141 | 143 … | */ |
142 | - exports.verify = wrapInput(mod._blsVerify, true) | |
144 … | + exports.verify = returnBool(wrapInput(mod._blsVerify)) | |
143 | 145 … | |
144 | 146 … | /** |
145 | 147 … | * given a pointer to a public key this returns 64 byte Int8Array containing the key |
146 | 148 … | * @param {number} pk - a pointer to the secret key |
@@ -166,16 +168,16 @@ | ||
166 | 168 … | * generates a secret key given a seed phrase. |
167 | 169 … | * @param {number} sk - a pointer to a secret key |
168 | 170 … | * @param {String|TypedArray} seed - the seed phrase |
169 | 171 … | */ |
170 | - exports.hashToSecretKey = wrapInput(mod._blsHashToSecretKey, true) | |
172 … | + exports.hashToSecretKey = wrapInput(mod._blsHashToSecretKey) | |
171 | 173 … | |
172 | 174 … | /** |
173 | 175 … | * write a secretKey to memory |
174 | 176 … | * @param {number} sk - a pointer to a secret key |
175 | 177 … | * @param {TypedArray} array - the secret key as a 32 byte TypedArray |
176 | 178 … | */ |
177 | - exports.secretKeyDeserialize = wrapInput(mod._blsSecretKeyDeserialize, true) | |
179 … | + exports.secretKeyDeserialize = wrapInput(mod._blsSecretKeyDeserialize) | |
178 | 180 … | |
179 | 181 … | /** |
180 | 182 … | * write a secretKey to memory and returns a pointer to it |
181 | 183 … | * @param {number} sk - a pointer to a secret key |
@@ -192,9 +194,9 @@ | ||
192 | 194 … | * write a publicKey to memory |
193 | 195 … | * @param {number} sk - a pointer to a public key |
194 | 196 … | * @param {TypedArray} array - the secret key as a 64 byte TypedArray |
195 | 197 … | */ |
196 | - exports.publicKeyDeserialize = wrapInput(mod._blsPublicKeyDeserialize, true) | |
198 … | + exports.publicKeyDeserialize = wrapInput(mod._blsPublicKeyDeserialize) | |
197 | 199 … | |
198 | 200 … | /** |
199 | 201 … | * write a publicKey to memory and returns a pointer to it |
200 | 202 … | * @param {TypedArray} array - the secret key as a 64 byte TypedArray |
@@ -276,11 +278,47 @@ | ||
276 | 278 … | * @param {number} id - the id of the member |
277 | 279 … | */ |
278 | 280 … | exports.publicKeyShare = wrapKeyShare(mod._blsPublicKeyShare, G2_SIZE) |
279 | 281 … | |
282 … | + /** | |
283 … | + * Take two publicKeys and adds them together. pubkey1 = pubkey1 + pubkey2 | |
284 … | + * @param {number} pubkey1 - a pointer to a public key | |
285 … | + * @param {number} pubkey2 - a pointer to a public key | |
286 … | + */ | |
287 … | + exports.publicKeyAdd = mod._blsPublicKeyAdd | |
288 … | + | |
289 … | + /** | |
290 … | + * Take two secretKeys and adds them together. seckey1 = seckey1 + seckey2 | |
291 … | + * @param {number} seckey1 - a pointer to a secret key | |
292 … | + * @param {number} seckey2 - a pointer to a secret key | |
293 … | + */ | |
294 … | + exports.secretKeyAdd = mod._blsSecretKeyAdd | |
295 … | + | |
296 … | + /** | |
297 … | + * Take two publicKeys and tests thier equality | |
298 … | + * @param {number} pubkey1 - a pointer to a public key | |
299 … | + * @param {number} pubkey2 - a pointer to a public key | |
300 … | + * return {Boolean} | |
301 … | + */ | |
302 … | + exports.publicKeyIsEqual = returnBool(mod._blsPublicKeyIsEqual) | |
303 … | + | |
304 … | + /** | |
305 … | + * Does Diffie–Hellman key exchange | |
306 … | + * @param {number} sharedSecretKey - a pointer to a secretKey that will be populated with the shared secret | |
307 … | + * @param {number} secretKey - a pointer to a secret key | |
308 … | + * @param {number} pubkey - a pointer to a public key | |
309 … | + */ | |
310 … | + exports.dhKeyExchange = mod._blsDHKeyExchange | |
311 … | + | |
280 | 312 … | initCb() |
281 | 313 … | } |
282 | 314 … | |
315 … | +function returnBool (func) { | |
316 … | + return function () { | |
317 … | + return func.apply(null, arguments) === 1 | |
318 … | + } | |
319 … | +} | |
320 … | + | |
283 | 321 … | function wrapInput (func) { |
284 | 322 … | return function () { |
285 | 323 … | const args = [...arguments] |
286 | 324 … | let buf = args.pop() |
package-lock.json | ||
---|---|---|
The diff is too large to show. Use a local git client to view these changes. Old file size: 320311 bytes New file size: 296056 bytes |
package.json | ||
---|---|---|
@@ -14,26 +14,29 @@ | ||
14 | 14 … | "bls", |
15 | 15 … | "wasm", |
16 | 16 … | "crypto" |
17 | 17 … | ], |
18 | - "author": "mjbecze <mjbecze@gmail.com>", | |
18 … | + "contributors": [ | |
19 … | + "MITSUNARI Shigeo <herumi@nifty.com>", | |
20 … | + "mjbecze <mjbecze@gmail.com>" | |
21 … | + ], | |
19 | 22 … | "license": "MPL-2.0", |
20 | 23 … | "devDependencies": { |
21 | 24 … | "array-shuffle": "^1.0.1", |
22 | 25 … | "coveralls": "^3.0.0", |
23 | - "documentation": "^5.2.0", | |
24 | - "nyc": "^11.2.1", | |
26 … | + "documentation": "^5.3.3", | |
27 … | + "nyc": "^11.3.0", | |
25 | 28 … | "standard": "^10.0.0", |
26 | 29 … | "tape": "^4.0.3" |
27 | 30 … | }, |
28 | 31 … | "repository": { |
29 | 32 … | "type": "git", |
30 | - "url": "git@github.com:wanderer/bls-lib.git" | |
33 … | + "url": "git@github.com:dfinity/js-bls-lib.git" | |
31 | 34 … | }, |
32 | 35 … | "bugs": { |
33 | - "url": "https://github.com/wanderer/bls-lib/issues" | |
36 … | + "url": "https://github.com/dfinity/js-bls-lib/issues" | |
34 | 37 … | }, |
35 | - "homepage": "https://github.com/wanderer/bls-lib", | |
38 … | + "homepage": "https://github.com/dfinity/js-bls-lib", | |
36 | 39 … | "standard": { |
37 | 40 … | "ignore": [ |
38 | 41 … | "/mcl/", |
39 | 42 … | "/build/", |
@@ -46,7 +49,8 @@ | ||
46 | 49 … | "build" |
47 | 50 … | ] |
48 | 51 … | }, |
49 | 52 … | "dependencies": { |
50 | - "nop": "^1.0.0" | |
53 … | + "nop": "^1.0.0", | |
54 … | + "safe-buffer": "^5.1.1" | |
51 | 55 … | } |
52 | 56 … | } |
tests/index.js | ||
---|---|---|
@@ -21,9 +21,9 @@ | ||
21 | 21 … | const msg = 'test' |
22 | 22 … | bls.sign(sig, sec, msg) |
23 | 23 … | |
24 | 24 … | const v = bls.verify(sig, pub, msg) |
25 | - t.equals(v, 1) | |
25 … | + t.equals(v, true) | |
26 | 26 … | }) |
27 | 27 … | }) |
28 | 28 … | |
29 | 29 … | tape('verify', t => { |
@@ -38,9 +38,9 @@ | ||
38 | 38 … | |
39 | 39 … | bls.getPublicKey(pub, sec) |
40 | 40 … | |
41 | 41 … | const v = bls.verify(sig, pub, msg) |
42 | - t.equals(v, 1) | |
42 … | + t.equals(v, true) | |
43 | 43 … | |
44 | 44 … | bls.free(sec) |
45 | 45 … | bls.free(sig) |
46 | 46 … | bls.free(pub) |
@@ -78,9 +78,9 @@ | ||
78 | 78 … | sig = bls.signatureImport(sigArray) |
79 | 79 … | pub = bls.publicKeyImport(pubArray) |
80 | 80 … | |
81 | 81 … | const v = bls.verify(sig, pub, msg) |
82 | - t.equals(v, 1) | |
82 … | + t.equals(v, true) | |
83 | 83 … | |
84 | 84 … | bls.free(sec) |
85 | 85 … | bls.free(sig) |
86 | 86 … | bls.free(pub) |
@@ -144,9 +144,9 @@ | ||
144 | 144 … | |
145 | 145 … | sigs.push(sig) |
146 | 146 … | const r = bls.verify(sig, pk, msg) |
147 | 147 … | |
148 | - t.equals(r, 1, 'should verify') | |
148 … | + t.equals(r, true, 'should verify') | |
149 | 149 … | } |
150 | 150 … | |
151 | 151 … | // recover |
152 | 152 … | const subIds = [] |
Built with git-ssb-web