Skip to content

Commit

Permalink
fix decryption key padding for ed25519
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshuchawla009 committed Sep 27, 2024
1 parent 7620150 commit 2a9fc69
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/helpers/metadataUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,11 @@ export const decryptSeedData = async (seedBase64: string, finalUserKey: BN) => {
const seedUtf8 = Buffer.from(seedBase64, "base64").toString("utf-8");
const seedJson = JSON.parse(seedUtf8) as EncryptedSeed;
const bufferMetadata = { ...encParamsHexToBuf(seedJson.metadata), mode: "AES256" };
const bufferKey = decryptionKey.scalar.toArrayLike(Buffer);
const decText = await decrypt(bufferKey, {
const paddedDecryptionKey = Buffer.from(decryptionKey.scalar.toString("hex", 64), "hex");
if (paddedDecryptionKey.length < 32) {
throw new Error(`decryption Key length must be less than 32. got ${paddedDecryptionKey.length}`);
}
const decText = await decrypt(paddedDecryptionKey, {
...bufferMetadata,
ciphertext: Buffer.from(seedJson.enc_text, "hex"),
});
Expand Down

0 comments on commit 2a9fc69

Please sign in to comment.