keybase-proofs 2.3.33 → 2.3.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/lib/alloc.js +6 -8
- package/lib/base.js +64 -62
- package/lib/main.js +1 -3
- package/lib/parse3.js +21 -6
- package/lib/schema3.js +51 -31
- package/lib/scrapers/twitter.js +13 -13
- package/lib/subkey.js +16 -14
- package/lib/util.js +15 -1
- package/package.json +7 -2
- package/src/alloc.iced +2 -4
- package/src/base.iced +6 -3
- package/src/constants.iced +4 -0
- package/src/main.iced +0 -2
- package/src/parse3.iced +9 -3
- package/src/schema3.iced +20 -7
- package/src/scrapers/twitter.iced +3 -3
- package/src/subkey.iced +6 -4
- package/src/util.iced +11 -0
- package/.travis.yml +0 -10
- package/CONTRIBUTORS.md +0 -5
- package/Makefile +0 -70
- package/lib/wot.js +0 -147
- package/src/wot.iced +0 -96
- package/teams_sample.cson +0 -211
- package/test/files/auth.iced +0 -132
- package/test/files/b64.iced +0 -58
- package/test/files/errsan.iced +0 -13
- package/test/files/expand.iced +0 -128
- package/test/files/generic_social.iced +0 -67
- package/test/files/per_user_key.iced +0 -74
- package/test/files/sibkey.iced +0 -60
- package/test/files/team.iced +0 -118
- package/test/files/team_hidden.iced +0 -321
- package/test/files/util.iced +0 -55
- package/test/files/v2.iced +0 -410
- package/test/files/wallet.iced +0 -110
- package/test/files/wot.iced +0 -99
- package/test/make_esc.iced +0 -48
- package/test/run.iced +0 -1
- package/test_scraper.iced +0 -49
package/test/files/v2.iced
DELETED
|
@@ -1,410 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
{KeyManager} = require('kbpgp').kb
|
|
3
|
-
{prng} = require 'crypto'
|
|
4
|
-
{constants,errors,alloc,Eldest,Cryptocurrency} = require '../../'
|
|
5
|
-
{make_esc} = require 'iced-error'
|
|
6
|
-
{createHash} = require 'crypto'
|
|
7
|
-
{make_ids} = require '../../lib/base'
|
|
8
|
-
{pack,unpack} = require 'purepack'
|
|
9
|
-
pgp_utils = require('pgp-utils')
|
|
10
|
-
{json_stringify_sorted} = pgp_utils.util
|
|
11
|
-
|
|
12
|
-
new_uid = () -> prng(16).toString('hex')
|
|
13
|
-
new_username = () -> "u_" + prng(5).toString('hex')
|
|
14
|
-
new_device = () ->
|
|
15
|
-
sha256 = (x) -> createHash('SHA256').update(x).digest('hex')
|
|
16
|
-
|
|
17
|
-
#-------------
|
|
18
|
-
|
|
19
|
-
class User
|
|
20
|
-
|
|
21
|
-
constructor : ({@uid, @username, @km}) ->
|
|
22
|
-
@generate : (cb) ->
|
|
23
|
-
esc = make_esc cb, "@generate"
|
|
24
|
-
await KeyManager.generate {}, esc defer km
|
|
25
|
-
uid = new_uid()
|
|
26
|
-
username = new_username()
|
|
27
|
-
cb null, new User { uid, username, km }
|
|
28
|
-
to_json : () -> { @uid, @username }
|
|
29
|
-
to_constructor_arg : ({seq_type} = {}) -> {
|
|
30
|
-
user :
|
|
31
|
-
local :
|
|
32
|
-
username : @username
|
|
33
|
-
uid : @uid
|
|
34
|
-
host : 'keybase.io'
|
|
35
|
-
sig_eng : @km.make_sig_eng()
|
|
36
|
-
seq_type : seq_type
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
#-------------
|
|
41
|
-
|
|
42
|
-
class Chain
|
|
43
|
-
constructor : ({@user}) -> @links = []
|
|
44
|
-
prev : () -> @links[-1...][0]
|
|
45
|
-
push : (l) -> @links.push l
|
|
46
|
-
copy : () -> new Chain { @user, links : [].concat(@links) }
|
|
47
|
-
|
|
48
|
-
to_constructor_arg : (opts = {}) ->
|
|
49
|
-
arg = @user.to_constructor_arg(opts)
|
|
50
|
-
if (p = @prev())? then p.populate_next arg
|
|
51
|
-
else
|
|
52
|
-
arg.seqno = 1
|
|
53
|
-
arg.prev = null
|
|
54
|
-
for k, v of opts.extra_params
|
|
55
|
-
arg[k] = v
|
|
56
|
-
arg
|
|
57
|
-
|
|
58
|
-
to_btc_constructor_arg : (opts) ->
|
|
59
|
-
ret = @to_constructor_arg(opts)
|
|
60
|
-
ret.cryptocurrency = {
|
|
61
|
-
address: "1BjgMvwVkpmmJ5HFGZ3L3H1G6fcKLNGT5h"
|
|
62
|
-
type: "bitcoin"
|
|
63
|
-
}
|
|
64
|
-
ret
|
|
65
|
-
|
|
66
|
-
#-------------
|
|
67
|
-
|
|
68
|
-
class LinkV2
|
|
69
|
-
constructor : ({@inner, @armored, @raw, @id, @short_id, @outer}) ->
|
|
70
|
-
populate_next : (arg) ->
|
|
71
|
-
arg.seqno = @inner.obj.seqno+1
|
|
72
|
-
arg.prev = @chain_link_id()
|
|
73
|
-
chain_link_id : () -> sha256 @outer
|
|
74
|
-
full_type : () -> @inner.obj.body.type
|
|
75
|
-
prev : () -> @inner.obj.prev
|
|
76
|
-
|
|
77
|
-
verify : ({chain, opts}, cb) ->
|
|
78
|
-
# Client provides but server doesn't...
|
|
79
|
-
carg = chain.user.to_constructor_arg(opts)
|
|
80
|
-
if (m = opts?.extra_params)?
|
|
81
|
-
for k, v of m
|
|
82
|
-
carg[k] = v
|
|
83
|
-
verifier = alloc @full_type(), carg
|
|
84
|
-
varg = { @armored, skip_ids : true, make_ids : true, inner : @inner.str }
|
|
85
|
-
await verifier.verify_v2 varg, defer err
|
|
86
|
-
cb err
|
|
87
|
-
|
|
88
|
-
verify_v1 : ({chain, opts}, cb) ->
|
|
89
|
-
carg = chain.user.to_constructor_arg(opts)
|
|
90
|
-
verifier = alloc @full_type(), carg
|
|
91
|
-
varg = { @armored, skip_ids : true, make_ids : true, inner : @inner.str }
|
|
92
|
-
await verifier.verify varg, defer err
|
|
93
|
-
cb err
|
|
94
|
-
|
|
95
|
-
#-------------
|
|
96
|
-
|
|
97
|
-
chain = null
|
|
98
|
-
user = null
|
|
99
|
-
|
|
100
|
-
#-------------
|
|
101
|
-
|
|
102
|
-
exports.init = (T,cb) ->
|
|
103
|
-
await User.generate T.esc(defer(u), cb)
|
|
104
|
-
user = u
|
|
105
|
-
chain = new Chain { user : u }
|
|
106
|
-
cb()
|
|
107
|
-
|
|
108
|
-
#-------------
|
|
109
|
-
|
|
110
|
-
exports.gen_1 = (T,cb) ->
|
|
111
|
-
arg = chain.to_constructor_arg()
|
|
112
|
-
eldest = new Eldest arg
|
|
113
|
-
await eldest.generate_v2 T.esc(defer(out), cb)
|
|
114
|
-
link = new LinkV2 out
|
|
115
|
-
chain.push link
|
|
116
|
-
cb()
|
|
117
|
-
|
|
118
|
-
#-------------
|
|
119
|
-
|
|
120
|
-
check_valid_link = ({T, chain, link, i, opts}, cb) ->
|
|
121
|
-
link.verify { chain, opts }, cb
|
|
122
|
-
|
|
123
|
-
check_valid_link_v1 = ({T, chain, link, i}, cb) ->
|
|
124
|
-
link.verify_v1 { chain }, cb
|
|
125
|
-
|
|
126
|
-
check_valid_linkage = ({T, curr, prev}, cb) ->
|
|
127
|
-
err = if not(prev) and not curr.prev() then null
|
|
128
|
-
else if not(prev) or not curr.prev() then new Error "got nil/non-nil clash in checking for linkage"
|
|
129
|
-
else if (a = prev.chain_link_id()) is (b = curr.prev()) then null
|
|
130
|
-
else new Error "bad linkage: #{a} != #{b}"
|
|
131
|
-
cb err
|
|
132
|
-
|
|
133
|
-
#-------------
|
|
134
|
-
|
|
135
|
-
check_valid_chain = ({T, chain}, cb) ->
|
|
136
|
-
esc = make_esc cb, "check_valid_chain"
|
|
137
|
-
for link, i in chain.links
|
|
138
|
-
await check_valid_link {T, chain, link, i}, esc defer()
|
|
139
|
-
await check_valid_linkage { T, curr : link, prev : chain.links[i-1] }, esc defer()
|
|
140
|
-
cb null
|
|
141
|
-
|
|
142
|
-
#-------------
|
|
143
|
-
|
|
144
|
-
exports.check_chain_1 = (T,cb) ->
|
|
145
|
-
check_valid_chain {T, chain}, cb
|
|
146
|
-
|
|
147
|
-
#-------------
|
|
148
|
-
|
|
149
|
-
exports.gen_2 = (T,cb) ->
|
|
150
|
-
arg = chain.to_btc_constructor_arg()
|
|
151
|
-
btc = new Cryptocurrency arg
|
|
152
|
-
await btc.generate_v2 T.esc(defer(out), cb)
|
|
153
|
-
link = new LinkV2 out
|
|
154
|
-
chain.push link
|
|
155
|
-
cb()
|
|
156
|
-
|
|
157
|
-
#-------------
|
|
158
|
-
|
|
159
|
-
exports.check_chain_2 = (T,cb) ->
|
|
160
|
-
check_valid_chain {T, chain}, cb
|
|
161
|
-
|
|
162
|
-
#-------------
|
|
163
|
-
|
|
164
|
-
exports.gen_3 = (T,cb) ->
|
|
165
|
-
arg = chain.to_btc_constructor_arg()
|
|
166
|
-
arg.revoke = { sig_id : "aabb" }
|
|
167
|
-
btc = new Cryptocurrency arg
|
|
168
|
-
await btc.generate_v2 T.esc(defer(out), cb)
|
|
169
|
-
link = new LinkV2 out
|
|
170
|
-
chain.push link
|
|
171
|
-
cb()
|
|
172
|
-
|
|
173
|
-
#-------------
|
|
174
|
-
|
|
175
|
-
exports.check_chain_3 = (T,cb) ->
|
|
176
|
-
check_valid_chain {T, chain}, cb
|
|
177
|
-
|
|
178
|
-
#-------------
|
|
179
|
-
|
|
180
|
-
forge_bad_link = ({link,h1,h2}, cb) ->
|
|
181
|
-
esc = make_esc cb, "forge_bad_link"
|
|
182
|
-
await link._v_generate {}, esc defer()
|
|
183
|
-
await link.generate_json { version : 2}, esc defer s, o
|
|
184
|
-
inner = { str : s, obj : o }
|
|
185
|
-
if h1? then h1 { inner }
|
|
186
|
-
await link.generate_outer {inner }, esc defer outer
|
|
187
|
-
if h2? then outer = h2 { inner, outer }
|
|
188
|
-
await link.sig_eng.box outer, esc defer {pgp, raw, armored}
|
|
189
|
-
{short_id, id} = make_ids raw
|
|
190
|
-
out = { pgp, id, short_id, raw, armored, inner, outer}
|
|
191
|
-
cb null, out
|
|
192
|
-
|
|
193
|
-
#-------------
|
|
194
|
-
|
|
195
|
-
exports.check_bad_type_1 = (T,cb) ->
|
|
196
|
-
arg = chain.to_btc_constructor_arg()
|
|
197
|
-
|
|
198
|
-
btc = new Cryptocurrency arg
|
|
199
|
-
h1 = ({inner}) -> inner.obj.body.type = "eldest"
|
|
200
|
-
await forge_bad_link { link : btc, h1 }, T.esc(defer(out), cb)
|
|
201
|
-
link = new LinkV2 out
|
|
202
|
-
await check_valid_link { T, chain, link }, defer err
|
|
203
|
-
T.assert err?, "should get a verification failure"
|
|
204
|
-
T.equal err.toString(), "Error: Wrong signature type; got 'eldest' but wanted 'cryptocurrency'", "right error text"
|
|
205
|
-
cb()
|
|
206
|
-
|
|
207
|
-
#-------------
|
|
208
|
-
|
|
209
|
-
exports.check_v2_link_with_inner_version_v1 = (T,cb) ->
|
|
210
|
-
arg = chain.to_btc_constructor_arg()
|
|
211
|
-
|
|
212
|
-
btc = new Cryptocurrency arg
|
|
213
|
-
h1 = ({inner}) ->
|
|
214
|
-
inner.obj.body.version = 1
|
|
215
|
-
inner.str = json_stringify_sorted inner.obj
|
|
216
|
-
await forge_bad_link { link : btc, h1 }, T.esc(defer(out), cb)
|
|
217
|
-
link = new LinkV2 out
|
|
218
|
-
await check_valid_link { T, chain, link }, defer err
|
|
219
|
-
T.assert err?, "should get a version failure"
|
|
220
|
-
T.equal err.toString(), "Error: Version mismatch: 2 != 1"
|
|
221
|
-
cb()
|
|
222
|
-
|
|
223
|
-
#-------------
|
|
224
|
-
|
|
225
|
-
exports.check_v1_link_with_inner_version_v2 = (T,cb) ->
|
|
226
|
-
esc = make_esc cb, "check_v1_link_with_inner_version_v2"
|
|
227
|
-
arg = chain.to_btc_constructor_arg()
|
|
228
|
-
btc = new Cryptocurrency arg
|
|
229
|
-
await btc._v_generate {}, esc defer()
|
|
230
|
-
await btc.generate_json { version : 2}, esc defer _, obj
|
|
231
|
-
obj.body.version = 2
|
|
232
|
-
json = json_stringify_sorted obj
|
|
233
|
-
inner = { str : json, obj : obj }
|
|
234
|
-
await btc.sig_eng.box json, esc defer {pgp, raw, armored}
|
|
235
|
-
out = { pgp, json, raw, armored, inner }
|
|
236
|
-
link = new LinkV2 out
|
|
237
|
-
await check_valid_link_v1 { T, chain, link }, defer err
|
|
238
|
-
T.assert err?, "should get a version failure"
|
|
239
|
-
T.equal err.toString(), "Error: Expected inner signature version 1 but got 2"
|
|
240
|
-
cb()
|
|
241
|
-
|
|
242
|
-
#-------------
|
|
243
|
-
|
|
244
|
-
check_bad_link = (T,arg,f,msg,cb) ->
|
|
245
|
-
arg or= chain.to_btc_constructor_arg()
|
|
246
|
-
btc = new Cryptocurrency arg
|
|
247
|
-
out = null
|
|
248
|
-
h2 = ({outer}) ->
|
|
249
|
-
o = unpack outer
|
|
250
|
-
f o
|
|
251
|
-
pack o
|
|
252
|
-
await forge_bad_link { link : btc, h2 }, T.esc(defer(out), cb)
|
|
253
|
-
link = new LinkV2 out
|
|
254
|
-
await check_valid_link { T, chain, link }, defer err
|
|
255
|
-
T.assert err?, "should get a verification failure"
|
|
256
|
-
# Sometimes we need late binding of what the error message will be
|
|
257
|
-
# (as a function of what f does above), so use this hack.
|
|
258
|
-
if typeof(msg) is 'function' then msg = msg()
|
|
259
|
-
T.equal err.toString(), msg, "right error"
|
|
260
|
-
|
|
261
|
-
cb()
|
|
262
|
-
|
|
263
|
-
#-------------
|
|
264
|
-
|
|
265
|
-
exports.check_bad_type_2 = (T,cb) ->
|
|
266
|
-
f = (o) -> o[4] = constants.sig_types_v2.subkey
|
|
267
|
-
check_bad_link T, null, f, "Error: Type mismatch: 12 != 6", cb
|
|
268
|
-
|
|
269
|
-
#-------------
|
|
270
|
-
|
|
271
|
-
exports.check_bad_type_3 = (T,cb) ->
|
|
272
|
-
arg = chain.to_btc_constructor_arg()
|
|
273
|
-
arg.revoke = { sig_id : "aabb" }
|
|
274
|
-
f = (o) -> o[4] = constants.sig_types_v2.cryptocurrency
|
|
275
|
-
check_bad_link T, arg, f, "Error: Type mismatch: 6 != 10", cb
|
|
276
|
-
|
|
277
|
-
#-------------
|
|
278
|
-
|
|
279
|
-
exports.check_bad_version_outer = (T,cb) ->
|
|
280
|
-
f = (o) -> o[0] = 1
|
|
281
|
-
check_bad_link T, null, f, "Error: Bad version: 1 != 2", cb
|
|
282
|
-
|
|
283
|
-
#-------------
|
|
284
|
-
|
|
285
|
-
exports.check_bad_xss = (T,cb) ->
|
|
286
|
-
f = (o) -> o[0] = "<script>alert()</script>"
|
|
287
|
-
check_bad_link T, null, f, "Error: Bad version: <script>alert()</script> != 2", cb
|
|
288
|
-
|
|
289
|
-
#-------------
|
|
290
|
-
|
|
291
|
-
exports.check_bad_hash = (T,cb) ->
|
|
292
|
-
msg = null
|
|
293
|
-
f = (o) ->
|
|
294
|
-
msg = "Error: hash mismatch: #{o[2].toString('hex')} != #{o[3].toString('hex')}"
|
|
295
|
-
o[3] = o[2]
|
|
296
|
-
msg_fn = () -> msg
|
|
297
|
-
check_bad_link T, null, f, msg_fn, cb
|
|
298
|
-
|
|
299
|
-
#-------------
|
|
300
|
-
|
|
301
|
-
exports.check_bad_seqno = (T,cb) ->
|
|
302
|
-
f = (o) -> o[1]++
|
|
303
|
-
msg = "WrongSeqnoError: wrong seqno: 5 != 4"
|
|
304
|
-
check_bad_link T, null, f, msg, cb
|
|
305
|
-
|
|
306
|
-
#-------------
|
|
307
|
-
|
|
308
|
-
exports.check_bad_seq_type = (T,cb) ->
|
|
309
|
-
f = (o) -> o[5] = constants.seq_types.SEMIPRIVATE
|
|
310
|
-
msg = "Error: wrong seq type: 3 != 1"
|
|
311
|
-
check_bad_link T, null, f, msg, cb
|
|
312
|
-
|
|
313
|
-
#-------------
|
|
314
|
-
|
|
315
|
-
exports.check_bad_prev = (T,cb) ->
|
|
316
|
-
msg = null
|
|
317
|
-
f = (o) ->
|
|
318
|
-
msg = "Error: wrong prev: #{o[3].toString('hex')} != #{o[2].toString('hex')}"
|
|
319
|
-
o[2] = o[3]
|
|
320
|
-
msg_fn = () -> msg
|
|
321
|
-
check_bad_link T, null, f, msg_fn, cb
|
|
322
|
-
|
|
323
|
-
#-------------
|
|
324
|
-
|
|
325
|
-
exports.semiprivate_link = (T,cb) ->
|
|
326
|
-
esc = make_esc cb, "semiprivate_link"
|
|
327
|
-
semipriv_chain = new Chain { user }
|
|
328
|
-
arg = semipriv_chain.to_constructor_arg({seq_type : constants.seq_types.SEMIPRIVATE})
|
|
329
|
-
eldest = new Eldest arg
|
|
330
|
-
await eldest.generate_v2 esc defer out
|
|
331
|
-
T.equal out.inner.obj.seq_type, constants.seq_types.SEMIPRIVATE, "right inner seqtype"
|
|
332
|
-
T.equal unpack(out.outer)[5], constants.seq_types.SEMIPRIVATE, "right outer seqtype"
|
|
333
|
-
link = new LinkV2 out
|
|
334
|
-
semipriv_chain.push link
|
|
335
|
-
await check_valid_chain {T, chain: semipriv_chain}, esc defer()
|
|
336
|
-
cb null
|
|
337
|
-
|
|
338
|
-
#-------------
|
|
339
|
-
|
|
340
|
-
exports.high_skip_ingest = (T, cb) ->
|
|
341
|
-
esc = make_esc cb, "high_skip_ingest"
|
|
342
|
-
|
|
343
|
-
await User.generate T.esc(defer(user), cb)
|
|
344
|
-
high_skip_chain = new Chain { user }
|
|
345
|
-
|
|
346
|
-
arg = high_skip_chain.to_constructor_arg({})
|
|
347
|
-
eldest = new Eldest arg
|
|
348
|
-
await eldest.generate_v2 esc defer out
|
|
349
|
-
outer = out.outer
|
|
350
|
-
T.assert not outer.high_skip?, "An older client did include high_skip_seqno; should not be returned."
|
|
351
|
-
|
|
352
|
-
new_eldest_from_params = (extra_params, corruptor, cb) ->
|
|
353
|
-
arg = high_skip_chain.to_constructor_arg({ extra_params })
|
|
354
|
-
eldest = new Eldest arg
|
|
355
|
-
await eldest.generate_v2 defer err, out
|
|
356
|
-
return cb err, null if err?
|
|
357
|
-
link = new LinkV2 out
|
|
358
|
-
if corruptor?
|
|
359
|
-
extra_params = corruptor extra_params
|
|
360
|
-
await check_valid_link {T, chain: high_skip_chain, link, opts: {extra_params}}, defer err
|
|
361
|
-
cb err, link, out
|
|
362
|
-
|
|
363
|
-
gen_params = (seqno, hash, corruptor) -> { high_skip : { seqno, hash } }
|
|
364
|
-
|
|
365
|
-
T.waypoint 'high_skip sanity checking'
|
|
366
|
-
hash_val = "7f1dbeb3db94c01b64948973c1d04a87bf6ff89eec4ae61a593f81c5a0ff1700"
|
|
367
|
-
await new_eldest_from_params (gen_params hash_val, null), null, defer err, link, out
|
|
368
|
-
T.assert err?, 'no high_skip hash without high_skip seqno'
|
|
369
|
-
T.assert err instanceof errors.BadHighSkipError
|
|
370
|
-
await new_eldest_from_params (gen_params 0, hash_val), null, defer err, link, out
|
|
371
|
-
T.assert err?, 'no high_skip hash with zero high_skip seqno'
|
|
372
|
-
T.assert err instanceof errors.BadHighSkipError
|
|
373
|
-
await new_eldest_from_params (gen_params 1, null), null, defer err, link, out
|
|
374
|
-
T.assert err?, 'must provide high_skip_hash with positive high_skip_seqno'
|
|
375
|
-
T.assert err instanceof errors.BadHighSkipError
|
|
376
|
-
await new_eldest_from_params (gen_params 15, null), null, defer err, link, out
|
|
377
|
-
T.assert err?, 'must provide high_skip_hash with positive high_skip_seqno'
|
|
378
|
-
T.assert err instanceof errors.BadHighSkipError
|
|
379
|
-
await new_eldest_from_params (gen_params 1, null), null, defer err, link, out
|
|
380
|
-
T.assert err?, 'if seqno 1, cannot set high_skip seqno, part 1 (no hash).'
|
|
381
|
-
T.assert err instanceof errors.BadHighSkipError
|
|
382
|
-
await new_eldest_from_params (gen_params 1, hash_val), null, defer err, link, out
|
|
383
|
-
T.assert err?, 'if seqno 1, cannot set high_skip seqno, part 2 (with hash).'
|
|
384
|
-
T.assert err instanceof errors.BadHighSkipError
|
|
385
|
-
await new_eldest_from_params (gen_params -4, hash_val), null, defer err, link, out
|
|
386
|
-
T.assert err?, 'no negative seqno'
|
|
387
|
-
T.assert err instanceof errors.BadHighSkipError
|
|
388
|
-
|
|
389
|
-
unhex_hash_val = "qf1dbeb3db94c01b64948973c1d04a87bf6ff89eec4ae61a593f81c5a0ff1700"
|
|
390
|
-
await new_eldest_from_params (gen_params 5, hash_val), null, defer err, link, out
|
|
391
|
-
T.assert err?, 'hash_val must be valid hex'
|
|
392
|
-
|
|
393
|
-
T.waypoint 'high_skip happy path'
|
|
394
|
-
|
|
395
|
-
# Note that the second link is only acceptable because seqno is greater than 1.
|
|
396
|
-
for [seqno, hash] in [[0, null], [1, hash_val], [2, hash_val]]
|
|
397
|
-
await new_eldest_from_params (gen_params seqno, hash), null, esc defer link, out
|
|
398
|
-
high_skip_chain.push link
|
|
399
|
-
|
|
400
|
-
wrong_hash_val = "9e52faf4c08d21b4fa87f0561cfd415fb72ae6962b523e4b5897c3f48c5f2f97"
|
|
401
|
-
corruptor = (extra_params) ->
|
|
402
|
-
extra_params.high_skip.hash = wrong_hash_val
|
|
403
|
-
return extra_params
|
|
404
|
-
await new_eldest_from_params (gen_params 4, hash_val), corruptor, defer err, link, out
|
|
405
|
-
T.assert err?, "client returned unexpected hash"
|
|
406
|
-
T.assert err instanceof errors.BadHighSkipError
|
|
407
|
-
|
|
408
|
-
cb null
|
|
409
|
-
|
|
410
|
-
#------------
|
package/test/files/wallet.iced
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
{alloc,Stellar} = require '../../'
|
|
2
|
-
{EncKeyManager,KeyManager} = require('kbpgp').kb
|
|
3
|
-
{make_esc} = require 'iced-error'
|
|
4
|
-
{new_sig_arg} = require './util'
|
|
5
|
-
pgp_utils = require('pgp-utils')
|
|
6
|
-
{json_stringify_sorted} = pgp_utils.util
|
|
7
|
-
bitcoyne = require 'bitcoyne'
|
|
8
|
-
|
|
9
|
-
exports.test_wallet_key_happy_path = (T,cb) ->
|
|
10
|
-
esc = make_esc cb, "test_sibkey_happy_path"
|
|
11
|
-
await KeyManager.generate {}, esc defer device
|
|
12
|
-
await KeyManager.generate {}, esc defer stellar
|
|
13
|
-
arg = new_sig_arg { km : device }
|
|
14
|
-
arg.wallet =
|
|
15
|
-
km : stellar
|
|
16
|
-
network : "stellar"
|
|
17
|
-
name : "default"
|
|
18
|
-
obj = new Stellar arg
|
|
19
|
-
await obj.generate esc defer out
|
|
20
|
-
typ = out.inner.obj.body.type
|
|
21
|
-
obj2 = alloc typ, arg
|
|
22
|
-
varg = { armored : out.armored, skip_ids : true, make_ids : true, inner : out.inner.str }
|
|
23
|
-
await obj2.verify varg, esc defer()
|
|
24
|
-
cb null
|
|
25
|
-
|
|
26
|
-
round_trip_with_corrupted_reverse_sig = ({T, corrupt}, cb) ->
|
|
27
|
-
esc = make_esc cb, "round_trip_with_corrupted_reverse_sig"
|
|
28
|
-
await KeyManager.generate {}, esc defer device
|
|
29
|
-
await KeyManager.generate {}, esc defer stellar
|
|
30
|
-
arg = new_sig_arg { km : device }
|
|
31
|
-
arg.wallet =
|
|
32
|
-
km : stellar
|
|
33
|
-
network : "stellar"
|
|
34
|
-
name : "foo"
|
|
35
|
-
obj = new Stellar arg
|
|
36
|
-
|
|
37
|
-
obj._v_generate = (opts, cb) ->
|
|
38
|
-
esc = make_esc cb, "_v_generate"
|
|
39
|
-
x = { reverse_sig: null }
|
|
40
|
-
@set_new_key_section x
|
|
41
|
-
x.kid = @get_new_km().get_ekid().toString('hex')
|
|
42
|
-
eng = @get_new_km().make_sig_eng()
|
|
43
|
-
await @generate_json { version : opts.version }, esc defer msg
|
|
44
|
-
msg2 = JSON.parse msg
|
|
45
|
-
msg2.foo = "bar" if corrupt
|
|
46
|
-
msg = json_stringify_sorted(msg2)
|
|
47
|
-
await eng.box msg, esc defer { armored, type }
|
|
48
|
-
x.reverse_sig = armored
|
|
49
|
-
cb null
|
|
50
|
-
|
|
51
|
-
await obj.generate esc defer out
|
|
52
|
-
typ = out.inner.obj.body.type
|
|
53
|
-
obj2 = alloc typ, arg
|
|
54
|
-
varg = { armored : out.armored, skip_ids : true, make_ids : true, inner : out.inner.str }
|
|
55
|
-
await obj2.verify varg, defer err
|
|
56
|
-
if corrupt
|
|
57
|
-
T.assert err?, "got an error back"
|
|
58
|
-
T.assert (err.message.indexOf('Reverse sig json mismatch') >= 0), "found right error message"
|
|
59
|
-
else
|
|
60
|
-
T.no_error err, "in the success case, don't expect an error"
|
|
61
|
-
cb null
|
|
62
|
-
|
|
63
|
-
exports.test_corruption_mechanism = (T,cb) ->
|
|
64
|
-
round_trip_with_corrupted_reverse_sig { T, corrupt : false }, cb
|
|
65
|
-
|
|
66
|
-
exports.test_reverse_sig_failure = (T,cb) ->
|
|
67
|
-
round_trip_with_corrupted_reverse_sig { T, corrupt : true }, cb
|
|
68
|
-
|
|
69
|
-
round_trip_with_dropped_accountID = ({T, corrupt}, cb) ->
|
|
70
|
-
esc = make_esc cb, "round_trip_with_corrupted_reverse_sig"
|
|
71
|
-
await KeyManager.generate {}, esc defer device
|
|
72
|
-
await KeyManager.generate {}, esc defer stellar
|
|
73
|
-
await KeyManager.generate {}, esc defer stellar2
|
|
74
|
-
arg = new_sig_arg { km : device }
|
|
75
|
-
arg.wallet =
|
|
76
|
-
km : stellar
|
|
77
|
-
network : "stellar"
|
|
78
|
-
name : "foo"
|
|
79
|
-
obj = new Stellar arg
|
|
80
|
-
|
|
81
|
-
km_to_base = (k) -> k.get_ekid()[2...-1]
|
|
82
|
-
|
|
83
|
-
obj._v_customize_json = (ret) ->
|
|
84
|
-
ret.body[@get_key_field()] = @get_new_key_section()
|
|
85
|
-
ret.body.device = @device if @device?
|
|
86
|
-
ret.body.wallet =
|
|
87
|
-
network : "stellar"
|
|
88
|
-
name : "foo"
|
|
89
|
-
if corrupt
|
|
90
|
-
ret.body.wallet.address = bitcoyne.stellar.public_key.encode km_to_base stellar2
|
|
91
|
-
else
|
|
92
|
-
ret.body.wallet.address = bitcoyne.stellar.public_key.encode km_to_base stellar
|
|
93
|
-
|
|
94
|
-
await obj.generate esc defer out
|
|
95
|
-
typ = out.inner.obj.body.type
|
|
96
|
-
obj2 = alloc typ, arg
|
|
97
|
-
varg = { armored : out.armored, skip_ids : true, make_ids : true, inner : out.inner.str }
|
|
98
|
-
await obj2.verify varg, defer err
|
|
99
|
-
if corrupt
|
|
100
|
-
T.assert err?, "got an error back"
|
|
101
|
-
T.assert (err.message.indexOf("Stellar Account ID didn't match given KID") >= 0), "found right error message"
|
|
102
|
-
else
|
|
103
|
-
T.no_error err, "in the success case, don't expect an error"
|
|
104
|
-
cb null
|
|
105
|
-
|
|
106
|
-
exports.test_dropped_accountID_mechanism = (T,cb) ->
|
|
107
|
-
round_trip_with_dropped_accountID { T, corrupt : false }, cb
|
|
108
|
-
|
|
109
|
-
exports.test_dropped_account_ID = (T,cb) ->
|
|
110
|
-
round_trip_with_dropped_accountID { T, corrupt : true }, cb
|
package/test/files/wot.iced
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
{alloc,wot,constants} = require '../../'
|
|
2
|
-
{EncKeyManager,KeyManager} = require('kbpgp').kb
|
|
3
|
-
{make_esc} = require 'iced-error'
|
|
4
|
-
{new_uid,new_km_and_sig_arg,new_sig_id,new_payload_hash} = require './util'
|
|
5
|
-
pgp_utils = require('pgp-utils')
|
|
6
|
-
{json_stringify_sorted} = pgp_utils.util
|
|
7
|
-
{unpack} = require 'purepack'
|
|
8
|
-
|
|
9
|
-
exports.wot_vouch_happy = (T,cb) ->
|
|
10
|
-
esc = make_esc cb
|
|
11
|
-
await new_km_and_sig_arg {}, esc defer me
|
|
12
|
-
await new_km_and_sig_arg {}, esc defer them
|
|
13
|
-
proof1 = { proof_type : 4, name : "reddit", username : "betaveros" }
|
|
14
|
-
proof2 = { proof_type : 9, name : "mastodon.social", username : "gammaveros" }
|
|
15
|
-
proof3 = { proof_type : 1000, protocol : "https:", hostname : "beta.veros" }
|
|
16
|
-
proof4 = { proof_type : 1001, protocol : "dns", hostname : "beta.veros" }
|
|
17
|
-
me.wot =
|
|
18
|
-
vouch :
|
|
19
|
-
user :
|
|
20
|
-
username : them.user.local.username
|
|
21
|
-
uid : them.user.local.uid
|
|
22
|
-
eldest:
|
|
23
|
-
kid : them.sig_eng.km.key.ekid().toString('hex')
|
|
24
|
-
seqno : 1
|
|
25
|
-
seq_tail :
|
|
26
|
-
seqno : 20
|
|
27
|
-
sig_id : new_sig_id()
|
|
28
|
-
payload_hash : new_payload_hash()
|
|
29
|
-
confidence :
|
|
30
|
-
username_verified_via : "audio"
|
|
31
|
-
other : "lorem ipsum"
|
|
32
|
-
proofs : [ proof1, proof2]
|
|
33
|
-
vouch_text : "darn rootin tootin"
|
|
34
|
-
obj = new wot.Vouch me
|
|
35
|
-
await obj.generate_v2 esc(defer(out)), {dohash:true}
|
|
36
|
-
hsh = out.inner.obj.body.wot_vouch
|
|
37
|
-
T.assert hsh?, "hash was there"
|
|
38
|
-
T.equal hsh.length, 64, "64-byte hex string"
|
|
39
|
-
T.assert out.expansions[hsh]?.obj?, "expansion was there"
|
|
40
|
-
|
|
41
|
-
verifier = alloc out.inner.obj.body.type, me
|
|
42
|
-
varg = { armored : out.armored, skip_ids : true, make_ids : true, inner : out.inner.str, expansions : out.expansions, require_packet_hash :true}
|
|
43
|
-
await verifier.verify_v2 varg, esc defer()
|
|
44
|
-
|
|
45
|
-
me.wot =
|
|
46
|
-
react :
|
|
47
|
-
sig_id : new_sig_id()
|
|
48
|
-
reaction : "accept"
|
|
49
|
-
obj = new wot.React me
|
|
50
|
-
await obj.generate_v2 esc(defer(out)), {dohash:true}
|
|
51
|
-
verifier = alloc out.inner.obj.body.type, me
|
|
52
|
-
varg = { armored : out.armored, skip_ids : true, make_ids : true, inner : out.inner.str, expansions : out.expansions, require_packet_hash :true}
|
|
53
|
-
await verifier.verify_v2 varg, esc defer()
|
|
54
|
-
|
|
55
|
-
# try to revoke both with and without a replacement...
|
|
56
|
-
me.revoke = { sig_ids : [ new_sig_id() ]}
|
|
57
|
-
obj = new wot.Vouch me
|
|
58
|
-
await obj.generate_v2 esc(defer(out)), {dohash:true}
|
|
59
|
-
outer = unpack out.outer
|
|
60
|
-
T.equal outer[4], constants.sig_types_v2.wot.vouch_with_revoke, "revoke picked up"
|
|
61
|
-
|
|
62
|
-
me.wot = null
|
|
63
|
-
obj = new wot.Vouch me
|
|
64
|
-
await obj.generate_v2 esc(defer(out)), {dohash:true}
|
|
65
|
-
outer = unpack out.outer
|
|
66
|
-
T.equal outer[4], constants.sig_types_v2.wot.vouch_with_revoke, "revoke picked up"
|
|
67
|
-
|
|
68
|
-
cb null
|
|
69
|
-
|
|
70
|
-
exports.wot_vouch_bad = (T,cb) ->
|
|
71
|
-
esc = make_esc cb
|
|
72
|
-
await new_km_and_sig_arg {}, esc defer me
|
|
73
|
-
await new_km_and_sig_arg {}, esc defer them
|
|
74
|
-
me.wot =
|
|
75
|
-
vouch :
|
|
76
|
-
user :
|
|
77
|
-
username : them.user.local.username
|
|
78
|
-
uid : them.user.local.uid
|
|
79
|
-
eldest:
|
|
80
|
-
kid : them.sig_eng.km.key.ekid().toString('hex')
|
|
81
|
-
seqno : 1
|
|
82
|
-
seq_tail :
|
|
83
|
-
seqno : 20
|
|
84
|
-
sig_id : new_sig_id()
|
|
85
|
-
payload_hash : new_payload_hash()
|
|
86
|
-
confidence :
|
|
87
|
-
username_verified_via : "audio"
|
|
88
|
-
other : "this string is longer than 90 char this string is longer than 90 char this string is longer than 90 char this string is longer than 90 char"
|
|
89
|
-
vouch_text : "darn rootin tootin"
|
|
90
|
-
obj = new wot.Vouch me
|
|
91
|
-
await obj.generate_v2 esc(defer(out)), {dohash:true}
|
|
92
|
-
|
|
93
|
-
verifier = alloc out.inner.obj.body.type, me
|
|
94
|
-
varg = { armored : out.armored, skip_ids : true, make_ids : true, inner : out.inner.str, expansions : out.expansions, require_packet_hash :true}
|
|
95
|
-
await verifier.verify_v2 varg, defer err
|
|
96
|
-
T.assert err?, "got an error back"
|
|
97
|
-
T.assert (err.message.indexOf(".confidence.other") >= 0), "found right error message"
|
|
98
|
-
|
|
99
|
-
cb null
|
package/test/make_esc.iced
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
C = require('iced-runtime').const
|
|
2
|
-
|
|
3
|
-
exports.skip = true
|
|
4
|
-
|
|
5
|
-
ipush = (e, msg) ->
|
|
6
|
-
if msg?
|
|
7
|
-
# Note: `e.istack = []` will be a noop if e is a primitive type
|
|
8
|
-
# like number or string. We have to check if `e.istack` exists
|
|
9
|
-
# before pushing so we don't crash.
|
|
10
|
-
e.istack = [] unless e.istack?
|
|
11
|
-
e.istack?.push msg
|
|
12
|
-
|
|
13
|
-
copy_trace = (src, dst) ->
|
|
14
|
-
dst[C.trace] = src[C.trace]
|
|
15
|
-
dst
|
|
16
|
-
|
|
17
|
-
# Error short-circuit connector with more verbose istack.
|
|
18
|
-
|
|
19
|
-
# When resulting `esc` function is called, an istack entry will be constructed
|
|
20
|
-
# based on iced trace object. This way istack will be populated by not only esc
|
|
21
|
-
# identifiers (usually call site function names) but also filenames and line
|
|
22
|
-
# numbers of call sites of individual esc() calls. If an error happens and
|
|
23
|
-
# short-circuited back from deep in some test, it should be easier to identify
|
|
24
|
-
# where exactly it originates from using the new istack.
|
|
25
|
-
|
|
26
|
-
exports.make_esc = make_esc = (gcb, where) ->
|
|
27
|
-
# Create "global where" based on make_esc() call site.
|
|
28
|
-
where = make_esc.caller?.name unless where?
|
|
29
|
-
return (lcb) ->
|
|
30
|
-
# Create "local where" based on esc() call site. So every
|
|
31
|
-
# esc(defer(...)) will have its own istack entry, if iced
|
|
32
|
-
# trace object is available.
|
|
33
|
-
sb = [ where ]
|
|
34
|
-
if (tr = lcb[C.trace])
|
|
35
|
-
sb.push "Trace:"
|
|
36
|
-
sb.push tr[C.funcname]
|
|
37
|
-
sb.push "(#{tr[C.filename]}:#{tr[C.lineno] + 1})"
|
|
38
|
-
local_where = sb.filter((x) -> x).join(' ')
|
|
39
|
-
copy_trace lcb, (err, args...) ->
|
|
40
|
-
if not err? then lcb args...
|
|
41
|
-
else if not gcb.__esc
|
|
42
|
-
gcb.__esc = true
|
|
43
|
-
ipush err, local_where
|
|
44
|
-
gcb err
|
|
45
|
-
|
|
46
|
-
exports.patch_make_esc = () ->
|
|
47
|
-
iced_error = require 'iced-error'
|
|
48
|
-
iced_error.make_esc = make_esc
|
package/test/run.iced
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require('iced-test').main { mainfile : __filename }
|