private static Bytes encodePublicKeyBytes(HpkeParameters.KemId kemId, byte[] publicKeyBytes)
      throws GeneralSecurityException {
    BigInteger n = BigIntegerEncoding.fromUnsignedBigEndianBytes(publicKeyBytes);
    byte[] encodedPublicKeyBytes =
        BigIntegerEncoding.toBigEndianBytesOfFixedLength(
            n, HpkeUtil.getEncodedPublicKeyLength(kemId));
    return Bytes.copyFrom(encodedPublicKeyBytes);
  }
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