// WARNING: This file is auto-generated by a script.
// Any changes made to this file may be overwritten.
// Please modify the code generation script instead.
// Path to the code generation script: scripts/gen_c_api.py

#pragma once
#ifndef GRUMPKIN_API_H
#define GRUMPKIN_API_H

#include <cuda_runtime.h>
#include "gpu-utils/device_context.cuh"
#include "merkle-tree/merkle.cuh"
#include "matrix/matrix.cuh"
#include "curves/params/grumpkin.cuh"
#include "msm/msm.cuh"
#include "vec_ops/vec_ops.cuh"
#include "poseidon/poseidon.cuh"

extern "C" cudaError_t grumpkin_precompute_msm_bases_cuda(
  grumpkin::affine_t* bases,
  int msm_size,
  msm::MSMConfig& config,
  grumpkin::affine_t* output_bases);

extern "C" cudaError_t grumpkin_msm_cuda(
  const grumpkin::scalar_t* scalars, const grumpkin::affine_t* points, int msm_size, msm::MSMConfig& config, grumpkin::projective_t* out);

extern "C" bool grumpkin_eq(grumpkin::projective_t* point1, grumpkin::projective_t* point2);

extern "C" void grumpkin_to_affine(grumpkin::projective_t* point, grumpkin::affine_t* point_out);

extern "C" void grumpkin_generate_projective_points(grumpkin::projective_t* points, int size);

extern "C" void grumpkin_generate_affine_points(grumpkin::affine_t* points, int size);

extern "C" cudaError_t grumpkin_affine_convert_montgomery(
  grumpkin::affine_t* d_inout, size_t n, bool is_into, device_context::DeviceContext& ctx);

extern "C" cudaError_t grumpkin_projective_convert_montgomery(
  grumpkin::projective_t* d_inout, size_t n, bool is_into, device_context::DeviceContext& ctx);

extern "C" cudaError_t grumpkin_build_merkle_tree(
  const grumpkin::scalar_t* leaves,
  grumpkin::scalar_t* digests,
  unsigned int height,
  unsigned int input_block_len, 
  const hash::Hasher<grumpkin::scalar_t, grumpkin::scalar_t>* compression,
  const hash::Hasher<grumpkin::scalar_t, grumpkin::scalar_t>* bottom_layer,
  const merkle_tree::TreeBuilderConfig& tree_config);

  extern "C" cudaError_t grumpkin_mmcs_commit_cuda(
    const matrix::Matrix<grumpkin::scalar_t>* leaves,
    unsigned int number_of_inputs,
    grumpkin::scalar_t* digests,
    const hash::Hasher<grumpkin::scalar_t, grumpkin::scalar_t>* hasher,
    const hash::Hasher<grumpkin::scalar_t, grumpkin::scalar_t>* compression,
    const merkle_tree::TreeBuilderConfig& tree_config);

extern "C" cudaError_t grumpkin_poseidon_create_cuda(
  poseidon::Poseidon<grumpkin::scalar_t>** poseidon,
  unsigned int arity,
  unsigned int alpha,
  unsigned int partial_rounds,
  unsigned int full_rounds_half,
  const grumpkin::scalar_t* round_constants,
  const grumpkin::scalar_t* mds_matrix,
  const grumpkin::scalar_t* non_sparse_matrix,
  const grumpkin::scalar_t* sparse_matrices,
  const grumpkin::scalar_t domain_tag,
  device_context::DeviceContext& ctx);

extern "C" cudaError_t grumpkin_poseidon_load_cuda(
  poseidon::Poseidon<grumpkin::scalar_t>** poseidon,
  unsigned int arity,
  device_context::DeviceContext& ctx);

extern "C" cudaError_t grumpkin_poseidon_hash_many_cuda(
  const poseidon::Poseidon<grumpkin::scalar_t>* poseidon,
  const grumpkin::scalar_t* inputs,
  grumpkin::scalar_t* output,
  unsigned int number_of_states,
  unsigned int input_block_len,
  unsigned int output_len,
  hash::HashConfig& cfg);

extern "C" cudaError_t
  grumpkin_poseidon_delete_cuda(poseidon::Poseidon<grumpkin::scalar_t>* poseidon);

extern "C" cudaError_t grumpkin_mul_cuda(
  grumpkin::scalar_t* vec_a, grumpkin::scalar_t* vec_b, int n, vec_ops::VecOpsConfig& config, grumpkin::scalar_t* result);

extern "C" cudaError_t grumpkin_add_cuda(
  grumpkin::scalar_t* vec_a, grumpkin::scalar_t* vec_b, int n, vec_ops::VecOpsConfig& config, grumpkin::scalar_t* result);

extern "C" cudaError_t grumpkin_accumulate_cuda(
  grumpkin::scalar_t* vec_a, grumpkin::scalar_t* vec_b, int n, vec_ops::VecOpsConfig& config);

extern "C" cudaError_t grumpkin_sub_cuda(
  grumpkin::scalar_t* vec_a, grumpkin::scalar_t* vec_b, int n, vec_ops::VecOpsConfig& config, grumpkin::scalar_t* result);

extern "C" cudaError_t grumpkin_transpose_matrix_cuda(
  const grumpkin::scalar_t* input,
  uint32_t row_size,
  uint32_t column_size,
  grumpkin::scalar_t* output,
  device_context::DeviceContext& ctx,
  bool on_device,
  bool is_async);

extern "C" cudaError_t grumpkin_bit_reverse_cuda(
  const grumpkin::scalar_t* input, uint64_t n, vec_ops::BitReverseConfig& config, grumpkin::scalar_t* output);


extern "C" void grumpkin_generate_scalars(grumpkin::scalar_t* scalars, int size);

extern "C" cudaError_t grumpkin_scalar_convert_montgomery(
  grumpkin::scalar_t* d_inout, size_t n, bool is_into, device_context::DeviceContext& ctx);

#endif