@atproto/crypto 0.1.1 → 0.2.0

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.
@@ -1,50 +0,0 @@
1
- import EcdsaKeypair from '../src/p256/keypair'
2
- import Secp256k1Keypair from '../src/secp256k1/keypair'
3
- import * as p256 from '../src/p256/operations'
4
- import * as secp from '../src/secp256k1/operations'
5
-
6
- describe('exports and reimports keys', () => {
7
- describe('secp256k1', () => {
8
- let keypair: Secp256k1Keypair
9
- let imported: Secp256k1Keypair
10
-
11
- it('has the same DID', async () => {
12
- keypair = await Secp256k1Keypair.create({ exportable: true })
13
- const exported = await keypair.export()
14
- imported = await Secp256k1Keypair.import(exported, { exportable: true })
15
-
16
- expect(keypair.did()).toBe(imported.did())
17
- })
18
-
19
- it('produces a valid signature', async () => {
20
- const data = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8])
21
- const sig = await imported.sign(data)
22
-
23
- const validSig = await secp.verifyDidSig(keypair.did(), data, sig)
24
-
25
- expect(validSig).toBeTruthy()
26
- })
27
- })
28
-
29
- describe('P-256', () => {
30
- let keypair: EcdsaKeypair
31
- let imported: EcdsaKeypair
32
-
33
- it('has the same DID', async () => {
34
- keypair = await EcdsaKeypair.create({ exportable: true })
35
- const exported = await keypair.export()
36
- imported = await EcdsaKeypair.import(exported, { exportable: true })
37
-
38
- expect(keypair.did()).toBe(imported.did())
39
- })
40
-
41
- it('produces a valid signature', async () => {
42
- const data = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8])
43
- const sig = await imported.sign(data)
44
-
45
- const validSig = await p256.verifyDidSig(keypair.did(), data, sig)
46
-
47
- expect(validSig).toBeTruthy()
48
- })
49
- })
50
- })