Skip to content

[_] Switch to noble hybrid#34

Merged
TamaraFinogina merged 5 commits into
masterfrom
switch_to_noble_hybrid
Mar 18, 2026
Merged

[_] Switch to noble hybrid#34
TamaraFinogina merged 5 commits into
masterfrom
switch_to_noble_hybrid

Conversation

@TamaraFinogina
Copy link
Copy Markdown
Contributor

@TamaraFinogina TamaraFinogina commented Mar 18, 2026

Description

Currently, crypto has a custom implementation of the hybrid encryption algorithm. Recently, noble-post-quantum released a hybrid API, which provides an improved version called X-Wing. Switching to a noble implementation would help delegate method maintenance and align the implementation with the X-Wing article for future audits.

This PR switches to X-Wing hybrid encryotion for email encryption

Related Issues

MT-MN-02 from https://inxt.atlassian.net/wiki/spaces/T/pages/1007583233/PQ+Meet+Code+Security+Assessment#MT-MN-02

Checklist

  • Changes have been tested locally.
  • Unit tests have been written or updated as necessary.
  • The code adheres to the repository's coding standards.
  • Relevant documentation has been added or updated.
  • No new warnings or errors have been introduced.
  • SonarCloud issues have been reviewed and addressed.
  • QA Passed

Testing Process

unit tests

Additional Notes

no need for private/public key types then

@TamaraFinogina TamaraFinogina self-assigned this Mar 18, 2026
Copy link
Copy Markdown

@xabg2 xabg2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments related to the sender key are just for curiosity 😄

): Promise<HybridEncryptedEmail> {
try {
const { encryptionKey, params, enc } = await encryptEmailBody(email, isSubjectEncrypted);
const encryptedKey = await encryptKeysHybrid(encryptionKey, recipient.publicKeys, senderPrivateKey);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why sender key has been removed here? 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because X-Wing doesn't need it. Before, I was doing ECC secret derivation, Kyber KEM encapsulation that gave another secret, then deriving one key from both secrets. X-Wing does it differently; they take public key of the intended recipient as input and handle everything else. The hybrid key is this:
Screenshot 2026-03-18 at 13 43 11

export async function encryptEmailHybridForMultipleRecipients(
email: Email,
recipients: UserWithPublicKeys[],
senderPrivateKey: PrivateKeys,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

*/
export async function decryptEmailHybrid(
encryptedEmail: HybridEncryptedEmail,
senderPublicKeys: PublicKeys,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same (also remember to remove the params from the JSDoc) :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, will check

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment thread src/keystore-crypto/core.ts Outdated
Comment on lines 45 to 46
* @param userEmail - The ID of the user
* @param tag - The keystore type-specific tag string
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these params being used in the function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was before, fixed

@sonarqubecloud
Copy link
Copy Markdown

@TamaraFinogina TamaraFinogina merged commit a6fbcc2 into master Mar 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants