class ChaCha20Poly1305KeyManager extends KeyTypeManager<ChaCha20Poly1305Key> {

  @Override
  public KeyFactory<ChaCha20Poly1305KeyFormat, ChaCha20Poly1305Key> keyFactory() {
    return new KeyFactory<ChaCha20Poly1305KeyFormat, ChaCha20Poly1305Key>(
        ChaCha20Poly1305KeyFormat.class) {
      @Override
      public void validateKeyFormat(ChaCha20Poly1305KeyFormat format)
          throws GeneralSecurityException {}

      @Override
      public ChaCha20Poly1305KeyFormat parseKeyFormat(ByteString byteString)
          throws InvalidProtocolBufferException {
        return ChaCha20Poly1305KeyFormat.parseFrom(
            byteString, ExtensionRegistryLite.getEmptyRegistry());
      }

      @Override
      public ChaCha20Poly1305Key createKey(ChaCha20Poly1305KeyFormat format)
          throws GeneralSecurityException {
        return ChaCha20Poly1305Key.newBuilder()
            .setVersion(getVersion())
            .setKeyValue(ByteString.copyFrom(Random.randBytes(KEY_SIZE_IN_BYTES)))
            .build();
      }
    };
  }

    ChaCha20Poly1305KeyManager();

}