diff --git a/packages/core/src/modules/x509/X509Certificate.ts b/packages/core/src/modules/x509/X509Certificate.ts index 746cf3a45..058b885b7 100644 --- a/packages/core/src/modules/x509/X509Certificate.ts +++ b/packages/core/src/modules/x509/X509Certificate.ts @@ -61,7 +61,8 @@ export class X509Certificate { if (keyBytes[0] !== 0x04) { throw new X509Error('Received P256 key with 65 bytes, but key did not start with 0x04. Invalid key') } - keyBytes = compress(keyBytes) + // TODO(crypto): the compress method is bugged because it does not expect the required `0x04` prefix. Here we strip that and receive the expected result + keyBytes = compress(keyBytes.slice(1)) } const key = new Key(keyBytes, keyType) diff --git a/packages/core/src/modules/x509/__tests__/X509Service.test.ts b/packages/core/src/modules/x509/__tests__/X509Service.test.ts index c7a479ca9..141185fb6 100644 --- a/packages/core/src/modules/x509/__tests__/X509Service.test.ts +++ b/packages/core/src/modules/x509/__tests__/X509Service.test.ts @@ -127,14 +127,14 @@ describe('X509Service', () => { const x509Certificate = X509Service.parseCertificate(agentContext, { encodedCertificate }) expect(x509Certificate.publicKey.publicKey.length).toStrictEqual(33) - expect(x509Certificate.publicKey.publicKeyBase58).toStrictEqual('tzf7ci2SqwnesE1Ppb8NPhWfMJpuWpRETfLegmsaooBY') + expect(x509Certificate.publicKey.publicKeyBase58).toStrictEqual('23vfBuUJkWXTC3zZWMh1TR57CTubFjFfhm4CGfgszRMHU') const jwk = getJwkFromKey(x509Certificate.publicKey) expect(jwk).toBeInstanceOf(P256Jwk) expect(jwk).toMatchObject({ - x: 'BIk8LYNHkG3GzWm39javS_1TP5YYTwqtrNEIMNpEcds', - y: '2UODj-scC_6OYXAeLtWqbo6SP4tU1coNPU0qLjxCBCE', + x: 'iTwtg0eQbcbNabf2Nq9L_VM_lhhPCq2s0Qgw2kRx29s', + y: 'YKwXDRz8U0-uLZ3NSI93R_35eNkl6jHp6Qg8OCup7VM', }) })