function toDER(x) {
  let i = 0;
  while (x[i] === 0) ++i;
  if (i === x.length) return ZERO;
  x = x.slice(i);
  if (x[0] & 0x80) return tools.concat([ZERO, x]);
  return x;
}
Converts a buffer to a DER-encoded buffer.
@param x - The buffer to be converted.
@returns The DER-encoded buffer.