Skip to content

Commit

Permalink
feat(issuer-sdk): use ephemeral encryption private key
Browse files Browse the repository at this point in the history
  • Loading branch information
ditoglez committed Dec 10, 2024
1 parent bbff067 commit 86d950c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
3 changes: 0 additions & 3 deletions packages/issuer-sdk-js/src/create-issuer-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ describe("createIssuerConfig", () => {

it("should correctly initialize and return config", async () => {
const signingKeyPair = nacl.sign.keyPair();
const encryptionKeyPair = nacl.box.keyPair();

const params = {
nodeUrl: "http://mock-node-url",
signingKeyPair,
encryptionKeyPair,
};

const result = await createIssuerConfig(params);
Expand All @@ -69,7 +67,6 @@ describe("createIssuerConfig", () => {
dbid: "mock-dbid",
kwilClient: expect.any(Object),
kwilSigner: expect.any(KwilSigner),
encryptionKeyPair: expect.any(Object),
signingKeyPair: expect.any(Object),
});
});
Expand Down
3 changes: 0 additions & 3 deletions packages/issuer-sdk-js/src/create-issuer-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,13 @@ export interface IssuerConfig {
kwilClient: NodeKwil;
kwilSigner: KwilSigner;
signingKeyPair: nacl.SignKeyPair;
encryptionKeyPair: nacl.SignKeyPair;
}

type CreateIssuerConfigParams = {
chainId?: string;
dbId?: string;
nodeUrl: string;
signingKeyPair: nacl.SignKeyPair;
encryptionKeyPair: nacl.BoxKeyPair;
};

export async function createIssuerConfig(params: CreateIssuerConfigParams): Promise<IssuerConfig> {
Expand All @@ -83,6 +81,5 @@ export async function createIssuerConfig(params: CreateIssuerConfigParams): Prom
}),
kwilSigner: createKwilSigner(params.signingKeyPair),
signingKeyPair: params.signingKeyPair,
encryptionKeyPair: params.encryptionKeyPair,
};
}
9 changes: 3 additions & 6 deletions packages/issuer-sdk-js/src/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,9 @@ const buildInsertableIDOSCredential = (
receiverEncryptionPublicKey: Uint8Array;
},
): InsertableIDOSCredential => {
const ephemeralKeyPair = nacl.box.keyPair();
const content = Base64Codec.decode(
encryptContent(
plaintextContent,
receiverEncryptionPublicKey,
issuerConfig.encryptionKeyPair.secretKey,
),
encryptContent(plaintextContent, receiverEncryptionPublicKey, ephemeralKeyPair.secretKey),
);

const { public_notes, public_notes_signature } = buildUpdateablePublicNotes(issuerConfig, {
Expand All @@ -71,7 +68,7 @@ const buildInsertableIDOSCredential = (
),

issuer_auth_public_key: HexCodec.encode(issuerConfig.signingKeyPair.publicKey, true),
encryption_public_key: Base64Codec.encode(issuerConfig.encryptionKeyPair.publicKey),
encryption_public_key: Base64Codec.encode(ephemeralKeyPair.publicKey),
};
};

Expand Down

0 comments on commit 86d950c

Please sign in to comment.