function toUIntBytes(x, littleEndian = false) {
if(x < 0) {
throw new Error('x must be >= 0')
}
const bits = minPower(x);
const bytes = bits / 8;
const arr = new ArrayBuffer(bytes);
const view = new DataView(arr);
view[`setUint${bits}`](0, x, littleEndian);
return arr;
}