nonce and iv size

This commit is contained in:
Sam Hadow 2025-03-19 13:27:01 +01:00
parent e1c1963084
commit bf71a47dc6

View File

@ -111,8 +111,8 @@ export function create_listener(form, input, messages) {
function encrypt_message(message, user_pubkey) { function encrypt_message(message, user_pubkey) {
let encryption_key = sending_ratchets[user_pubkey].next(); let encryption_key = sending_ratchets[user_pubkey].next();
let encoded_msg = (new TextEncoder()).encode(message); let encoded_msg = (new TextEncoder()).encode(message);
let iv = generateRandomUint8Array(); let iv = generateRandomUint8Array(12);
let nonce = generateRandomUint8Array(); let nonce = generateRandomUint8Array(12);
let associated_data = concatUint8Arrays(fromHexString(user_pubkey), getRoundedUTCTime()); let associated_data = concatUint8Arrays(fromHexString(user_pubkey), getRoundedUTCTime());
let {cipher, tag} = keccakAEAD.encrypt(encryption_key, encoded_msg, iv, associated_data, nonce); let {cipher, tag} = keccakAEAD.encrypt(encryption_key, encoded_msg, iv, associated_data, nonce);
return {cipher: toHexString(cipher), return {cipher: toHexString(cipher),