git ssb

1+

Dominic / ssb-keys



Commit 190fcd1306706e588f1d8dcb1be4522b281a5e77

test legacy functionality

Dominic Tarr committed on 5/29/2015, 2:50:27 PM
Parent: 846e0d32e32e26a7f44d1af8f6315b457b5070a1

Files changed

test/index.jschanged
test/index.jsView
@@ -71,4 +71,54 @@
7171 t.ok(ssbkeys.verifyObj(keys, sig, obj))
7272 t.end()
7373
7474 })
75+
76+tape('test legacy curve: k256', function (t) {
77+ var keys = ssbkeys.generate('k256')
78+
79+ var msg = ssbkeys.hash("LEGACY SYSTEMS")
80+ var sig = ssbkeys.sign(keys, msg)
81+
82+ console.log('public', keys.public)
83+ console.log('sig', sig)
84+
85+ t.ok(sig)
86+ t.equal(ssbkeys.getTag(sig), 'blake2s.k256')
87+ t.ok(ssbkeys.verify(keys, sig, msg))
88+
89+ t.end()
90+})
91+
92+tape('create and load async, legacy', function (t) {
93+ try { require('fs').unlinkSync(path) } catch(e) {}
94+ ssbkeys.create(path, 'k256', function(err, k1) {
95+ if (err) throw err
96+ ssbkeys.load(path, function(err, k2) {
97+ if (err) throw err
98+
99+ t.equal(k2.curve, 'k256')
100+ t.equal(k1.id, k2.id)
101+ t.equal(k1.private, k2.private)
102+ t.equal(k1.public, k2.public)
103+
104+ t.end()
105+ })
106+ })
107+})
108+
109+tape('create and load sync, legacy', function (t) {
110+ try { require('fs').unlinkSync(path) } catch(e) {}
111+ var k1 = ssbkeys.createSync(path, 'k256', true)
112+ var k2 = ssbkeys.loadSync(path)
113+
114+ console.log(k2)
115+
116+ t.equal(k2.curve, 'k256')
117+ t.equal(k1.id, k2.id)
118+ t.equal(k1.private, k2.private)
119+ t.equal(k1.public, k2.public)
120+
121+ t.end()
122+})
123+
124+

Built with git-ssb-web