1 | import { u8aEq } from '../u8a/eq.js';
|
2 | import { isU8a } from './u8a.js';
|
3 | const ELF_MAGIC = new Uint8Array([0x7f, 0x45, 0x4c, 0x46]); // ELF magic bytes: 0x7f, 'E', 'L', 'F'
|
4 | /**
|
5 | * @name isRiscV
|
6 | * @summary Tests if the input has a RISC-V header
|
7 | * @description
|
8 | * Checks to see if the input Uint8Array contains a valid RISC-V header
|
9 | */
|
10 | export function isRiscV(bytes) {
|
11 | return isU8a(bytes) && u8aEq(bytes.subarray(0, 4), ELF_MAGIC);
|
12 | }
|