private static SecretBytes encodePrivateKeyBytes(
      HpkeParameters.KemId kemId, byte[] privateKeyBytes, @Nullable SecretKeyAccess access)
      throws GeneralSecurityException {
    BigInteger n = BigIntegerEncoding.fromUnsignedBigEndianBytes(privateKeyBytes);
    byte[] encodedPrivateKeyBytes =
        BigIntegerEncoding.toBigEndianBytesOfFixedLength(
            n, HpkeUtil.getEncodedPrivateKeyLength(kemId));
    return SecretBytes.copyFrom(encodedPrivateKeyBytes, SecretKeyAccess.requireAccess(access));
  }
Returns the proto serialization of a {@link HpkePublicKey}.

@param access may be null for public key material
@throws GeneralSecurityException if the key cannot be serialized (e.g. unknown variant)
java_src/src/main/java/com/google/crypto/tink/hybrid/HpkeProtoSerialization.java