"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileContents = void 0;
const blake3_1 = require("@noble/hashes/blake3");
const __1 = require("..");
class FileContents {
    constructor(contents) {
        this.contents = contents;
    }
    static deserialize(source, header, size) {
        const position = header.nextU64();
        return new FileContents(source.slice(Number(position), Number(position + size)));
    }
    async verified(hash) {
        const res = await this.contents.arrayBuffer();
        if (!(0, __1.compare)(hash, (0, blake3_1.blake3)(new Uint8Array(res)))) {
            throw new Error('hash sum mismatch');
        }
        return res;
    }
}
exports.FileContents = FileContents;
//# sourceMappingURL=fileContents.js.map