git ssb

1+

Dominic / ssb-keys



Commit 21deb97a3ee7ca191aa07a8ae90da508fd57388b

remove legacy tests, test signObj, verifyObj with hmac

Dominic Tarr committed on 10/3/2016, 8:47:24 PM
Parent: 433b030af5cc6d76e4737696333b01cfb6b58731

Files changed

test/index.jschanged
test/index.jsView
@@ -26,38 +26,35 @@
2626 t.equal(k1.public.toString('hex'), k2.public.toString('hex'))
2727 t.end()
2828 })
2929
30-tape('sign and verify', function (t) {
31- var keys = ssbkeys.generate()
32- var msg = ssbkeys.hash("HELLO THERE?")
33- var sig = ssbkeys.sign(keys, msg)
34- console.log('public', keys.public)
35- console.log('sig', sig)
36- t.ok(sig)
37- t.equal(ssbkeys.getTag(sig), 'sig.ed25519')
38- t.ok(ssbkeys.verify(keys, sig, msg))
30 +tape('sign and verify a javascript object', function (t) {
3931
40- t.end()
32 + var obj = require('../package.json')
33 + var hmac_key = crypto.randomBytes(32)
34 + var hmac_key2 = crypto.randomBytes(32)
35 + console.log(obj)
4136
42-})
43-
44-tape('sign and verify, call with keys directly', function (t) {
45-
4637 var keys = ssbkeys.generate()
47- var msg = ssbkeys.hash("HELLO THERE?")
48- var sig = ssbkeys.sign(keys.private, msg)
49- console.log('public', keys.public)
50- console.log('sig', sig)
38 + var sig = ssbkeys.signObj(keys.private, hmac_key, obj)
39 + console.log(sig)
5140 t.ok(sig)
52- t.equal(ssbkeys.getTag(sig), 'sig.ed25519')
53- t.ok(ssbkeys.verify(keys.public, sig, msg))
54-
41 + //verify must be passed the key to correctly verify
42 + t.notOk(ssbkeys.verifyObj(keys, sig))
43 + t.notOk(ssbkeys.verifyObj({public: keys.public}, sig))
44 + t.ok(ssbkeys.verifyObj(keys, hmac_key, sig))
45 + t.ok(ssbkeys.verifyObj({public: keys.public}, hmac_key, sig))
46 + //a different hmac_key fails to verify
47 + t.notOk(ssbkeys.verifyObj(keys, hmac_key2, sig))
48 + t.notOk(ssbkeys.verifyObj({public: keys.public}, hmac_key2, sig))
5549 t.end()
5650
5751 })
5852
59-tape('sign and verify a javascript object', function (t) {
53 +//allow sign and verify to also take a separate key
54 +//so that we can create signatures that cannot be used in other places.
55 +//(i.e. testnet) avoiding chosen protocol attacks.
56 +tape('sign and verify a hmaced object javascript object', function (t) {
6057
6158 var obj = require('../package.json')
6259
6360 console.log(obj)
@@ -65,61 +62,14 @@
6562 var keys = ssbkeys.generate()
6663 var sig = ssbkeys.signObj(keys.private, obj)
6764 console.log(sig)
6865 t.ok(sig)
69- t.ok(ssbkeys.verifyObj(keys, sig, obj))
66 + t.ok(ssbkeys.verifyObj(keys, sig))
67 + t.ok(ssbkeys.verifyObj({public: keys.public}, sig))
7068 t.end()
7169
7270 })
7371
74-//tape('test legacy curve: k256', function (t) {
75-// var keys = ssbkeys.generate('k256')
76-//
77-// var msg = ssbkeys.hash("LEGACY SYSTEMS")
78-// var sig = ssbkeys.sign(keys, msg)
79-//
80-// console.log('public', keys.public)
81-// console.log('sig', sig)
82-//
83-// t.ok(sig)
84-// t.equal(ssbkeys.getTag(sig), 'sig.k256')
85-// t.ok(ssbkeys.verify(keys, sig, msg))
86-//
87-// t.end()
88-//})
89-//
90-//tape('create and load async, legacy', function (t) {
91-//
92-// ssbkeys.create(path, 'k256', function(err, k1) {
93-// if (err) throw err
94-// ssbkeys.load(path, function(err, k2) {
95-// if (err) throw err
96-//
97-// t.equal(k2.curve, 'k256')
98-// t.equal(k1.id, k2.id)
99-// t.equal(k1.private, k2.private)
100-// t.equal(k1.public, k2.public)
101-//
102-// t.end()
103-// })
104-// })
105-//})
106-
107-//tape('create and load sync, legacy', function (t) {
108-//
109-// var k1 = ssbkeys.createSync(path, 'k256', true)
110-// var k2 = ssbkeys.loadSync(path)
111-//
112-// console.log(k2)
113-//
114-// t.equal(k2.curve, 'k256')
115-// t.equal(k1.id, k2.id)
116-// t.equal(k1.private, k2.private)
117-// t.equal(k1.public, k2.public)
118-//
119-// t.end()
120-//})
121-//
12272 tape('seeded keys, ed25519', function (t) {
12373
12474 var seed = crypto.randomBytes(32)
12575 var k1 = ssbkeys.generate('ed25519', seed)
@@ -130,20 +80,8 @@
13080 t.end()
13181
13282 })
13383
134-//tape('seeded keys, k256', function (t) {
135-//
136-// var seed = crypto.randomBytes(32)
137-// var k1 = ssbkeys.generate('k256', seed)
138-// var k2 = ssbkeys.generate('k256', seed)
139-//
140-// t.deepEqual(k1, k2)
141-//
142-// t.end()
143-//
144-//})
145-//
14684 tape('ed25519 id === "@" ++ pubkey', function (t) {
14785
14886 var keys = ssbkeys.generate('ed25519')
14987 t.equal(keys.id, '@' + keys.public)
@@ -151,4 +89,12 @@
15189 t.end()
15290
15391 })
15492
93 +
94 +
95 +
96 +
97 +
98 +
99 +
100 +

Built with git-ssb-web