Skip to content

Commit

Permalink
chore: remove unused function (dfinity#355)
Browse files Browse the repository at this point in the history
  • Loading branch information
hansl authored Apr 12, 2021
1 parent b85054a commit dbda660
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 52 deletions.
32 changes: 0 additions & 32 deletions packages/authentication/src/identity/ed25519.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
20 changes: 0 additions & 20 deletions packages/authentication/src/identity/ed25519.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Ed25519KeyIdentity> {
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(
Expand Down

0 comments on commit dbda660

Please sign in to comment.