From dbda6608e17f8366fecfc8027fa1cb4213100c8b Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Mon, 12 Apr 2021 08:36:17 -0700 Subject: [PATCH] chore: remove unused function (#355) Fixes #259 --- .../src/identity/ed25519.test.ts | 32 ------------------- .../authentication/src/identity/ed25519.ts | 20 ------------ 2 files changed, 52 deletions(-) diff --git a/packages/authentication/src/identity/ed25519.test.ts b/packages/authentication/src/identity/ed25519.test.ts index e568f5fe..857d26a4 100644 --- a/packages/authentication/src/identity/ed25519.test.ts +++ b/packages/authentication/src/identity/ed25519.test.ts @@ -71,38 +71,6 @@ test('DER decoding of invalid keys', async () => { }).toThrow(); }); -// Test vectors consist of [hex seed, private key, public key], taken from -// https://github.com/satoshilabs/slips/blob/master/slip-0010.md -const testVectorsSLIP10 = [ - [ - '000102030405060708090a0b0c0d0e0f', - '2b4be7f19ee27bbf30c667b642d5f4aa69fd169872f8fc3059c08ebae2eb19e7', - '00a4b2856bfec510abab89753fac1ac0e1112364e7d250545963f135f2a33188ed', - ], - [ - 'fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e' + - '7b7875726f6c696663605d5a5754514e4b484542', - '171cb88b1b3c1db25add599712e36245d75bc65a1a5c9e18d76f9f2b1eab4012', - '008fe9693f8fa62a4305a140b9764c5ee01e455963744fe18204b4fb948249308a', - ], -]; - -test('derive Ed25519 via SLIP 0010', async () => { - await Promise.all( - testVectorsSLIP10.map(([seed, privateKey, publicKey]) => { - const expectedPrivateKey = blobFromHex(privateKey); - // The SLIP 0010 test vectors contain a leading 0-byte for now obvious reason, the remainder - // makes sense. - const expectedPublicKey = blobFromHex(publicKey).slice(1, 33); - return Ed25519KeyIdentity.fromSeedWithSlip0010(blobFromHex(seed)).then(identity => { - const keyPair = identity.getKeyPair(); - expect(keyPair.secretKey.slice(0, 32)).toEqual(expectedPrivateKey); - expect(Ed25519PublicKey.from(keyPair.publicKey).toRaw()).toEqual(expectedPublicKey); - }); - }), - ); -}); - test('can encode and decode to/from JSON', async () => { const seed = new Array(32).fill(0); const key = Ed25519KeyIdentity.generate(new Uint8Array(seed)); diff --git a/packages/authentication/src/identity/ed25519.ts b/packages/authentication/src/identity/ed25519.ts index 6199122e..c3ad9b31 100644 --- a/packages/authentication/src/identity/ed25519.ts +++ b/packages/authentication/src/identity/ed25519.ts @@ -106,26 +106,6 @@ export class Ed25519KeyIdentity extends SignIdentity { ); } - // Derive an Ed25519 key pair according to SLIP 0010: - // https://github.com/satoshilabs/slips/blob/master/slip-0010.md - public static async fromSeedWithSlip0010(seed: Uint8Array): Promise { - const encoder = new TextEncoder(); - const rawKey = encoder.encode('ed25519 seed'); - const key = await window.crypto.subtle.importKey( - 'raw', - rawKey, - { - name: 'HMAC', - hash: { name: 'SHA-512' }, - }, - false, - ['sign'], - ); - const result = await window.crypto.subtle.sign('HMAC', key, seed.buffer); - const slipSeed = new Uint8Array(result.slice(0, 32)); - return this.generate(slipSeed); - } - public static fromParsedJson(obj: JsonnableEd25519KeyIdentity): Ed25519KeyIdentity { const [publicKeyDer, privateKeyRaw] = obj; return new Ed25519KeyIdentity(