code: async function kdf(hash_algo, X, length, param, stripLeading=false, stripTrailing=false) {
    // Note: X is little endian for Curve25519, big-endian for all others.
    // This is not ideal, but the RFC's are unclear
    // https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-02#appendix-B
    let i;
    if (stripLeading) {
      // Work around old go crypto bug
      for (i = 0; i < X.length && X[i] === 0; i++);
      X = X.subarray(i);
    }
    if (stripTrailing) {
      // Work around old OpenPGP.js bug
      for (i = X.length - 1; i >= 0 && X[i] === 0; i--);
      X = X.subarray(0, i + 1);
    }
    const digest = await hash.digest(hash_algo, util.concatUint8Array([
      new Uint8Array([0, 0, 0, 1]),
      X,
      param
    ]));
    return digest.subarray(0, length);
  }
docs: Key Derivation Function (RFC 6637)