Skip to content

Commit

Permalink
Merge pull-request #287
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewkmin committed May 16, 2024
2 parents e6a2f6c + e2faf45 commit 8c619d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/crypto/src/__tests__/crypto-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
generateP256KeyPair,
decryptBundle,
extractPrivateKeyFromPKCS8Bytes,
compressRawPublicKey,
} from "../crypto";

// Mock data for testing
Expand All @@ -33,6 +34,15 @@ describe("Turnkey Crypto Primitives", () => {
expect(keyPair.privateKey).toBeTruthy();
expect(keyPair.publicKey).toBeTruthy();
expect(keyPair.publicKeyUncompressed).toBeTruthy();
expect(keyPair.privateKey).not.toEqual(keyPair.publicKey);
expect(keyPair.publicKey).not.toEqual(keyPair.publicKeyUncompressed);
});

test("compressRawPublicKey - returns a valid value", () => {
const { publicKey, publicKeyUncompressed } = generateP256KeyPair();
expect(
compressRawPublicKey(uint8ArrayFromHexString(publicKeyUncompressed))
).toEqual(uint8ArrayFromHexString(publicKey));
});

test("decryptBundle - successfully decrypts a credential bundle", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/crypto/src/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export const generateP256KeyPair = (): KeyPair => {
);
return {
privateKey: uint8ArrayToHexString(privateKey),
publicKey: uint8ArrayToHexString(privateKey),
publicKey: uint8ArrayToHexString(publicKey),
publicKeyUncompressed,
};
};
Expand Down

0 comments on commit 8c619d1

Please sign in to comment.