invalid tag error cannot be caught?
Closed this issue · 5 comments
jdutchak commented
updated from 0.1.4 to 0.4.0 now i keep getting invalid tag error - has something changed here? what should I look for?
Error: invalid tag
at Object.decrypt (node_modules/@noble/ciphers/src/chacha.ts:266:48)
paulmillr commented
any specific test vector you could share?
jdutchak commented
gives hard error that some apps cannot recover from ie Preact with ViteJS and Electron --- vs just wrong or invalid tag error depending on lib ver 0.1.4 or 0.4.0
const d = XChaCha20Poly1305.decrypt({
data : new Uint8Array(10),
key : new Uint8Array(32),
nonce : new Uint8Array(24),
tag : new Uint8Array(16)
})
console.log(d)
paulmillr commented
Works fine for me with 0.4.0, the error is correctly catched:
import { xchacha20poly1305 } from '@noble/ciphers/chacha';
const key = new Uint8Array(32);
const nonce = new Uint8Array(24);
const chacha = xchacha20poly1305(key, nonce);
try {
const data_ = chacha.decrypt(new Uint8Array(32));
} catch (error) {
// console.log('log', error)
}
jdutchak commented
do you not need to pass a tag in 0.4.0 ?
paulmillr commented
huh? it was never needed, not even in 0.1.4