opentimestamps/javascript-opentimestamps

.verify method bug?

certifirm opened this issue · 0 comments

I test the following code with an input file (OTS) that can be verified and upgraded:

let ruta_fichero_ots = require('path').resolve(sails.config.appPath) + '/sellostiempoweb/' + registro.id_usuario + '/' + registro.uid_fichero + '.pdf.ots';
let fichero_ots_buffer = await fs.readFile(ruta_fichero_ots);

let hash = Buffer.from(registro.hash, 'hex');

let detached = OpenTimestamps.DetachedTimestampFile.fromHash(new OpenTimestamps.Ops.OpSHA256(), hash);
const detachedOts = OpenTimestamps.DetachedTimestampFile.deserialize(fichero_ots_buffer);
let cambiado1 = await OpenTimestamps.upgrade(detachedOts);
let verifyResult = await OpenTimestamps.verify(detachedOts, detached);
let cambiado2 = await OpenTimestamps.upgrade(detachedOts);

console.log('CAMBIADO1: ' + cambiado1);
console.log('CAMBIADO2: ' + cambiado2);

The exit is:

CAMBIADO1: true
CAMBIADO2: false

It's like verify changes the input "detachedOts". But if I read detachedOTS variable before and after verifyResult, it's the same.