@polkadot/util
Version:
A collection of useful utilities for @polkadot
17 lines (16 loc) • 595 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.isRiscV = void 0;
const eq_js_1 = require("../u8a/eq.js");
const u8a_js_1 = require("./u8a.js");
const ELF_MAGIC = new Uint8Array([0x7f, 0x45, 0x4c, 0x46]); // ELF magic bytes: 0x7f, 'E', 'L', 'F'
/**
* @name isRiscV
* @summary Tests if the input has a RISC-V header
* @description
* Checks to see if the input Uint8Array contains a valid RISC-V header
*/
function isRiscV(bytes) {
return (0, u8a_js_1.isU8a)(bytes) && (0, eq_js_1.u8aEq)(bytes.subarray(0, 4), ELF_MAGIC);
}
exports.isRiscV = isRiscV;
;