#include <stdio.h>
#include "api.h"
#include "randombytes.h"
#include "speed.h"
#include "cpucycles.h"

#define MLEN 59
#define NTESTS 10000

int main(void)
{
  unsigned int i;
  int ret;
  unsigned long long mlen=MLEN, smlen;
  unsigned char m[MLEN];
  unsigned char sm[SIG_BYTES];
  unsigned char pk[SIG_PUBLICKEYBYTES];
  unsigned char sk[SIG_SECRETKEYBYTES];
  unsigned long long t0[NTESTS], t1[NTESTS], t2[NTESTS];

  printf("\n**********************************\n");
  printf("PK Sizes : %d\n",SIG_PUBLICKEYBYTES);
  printf("SK Sizes : %d\n",SIG_SECRETKEYBYTES);
  printf("SIG Sizes: %d\n",SIG_BYTES); 
  printf("**********************************\n\n");
  
  for(i = 0; i < NTESTS; ++i) {
    randombytes(m, MLEN);

    t0[i] = cpucycles();
    sig_keygen(pk, sk);
    t0[i] = cpucycles() - t0[i];

	

    t1[i] = cpucycles();
    sig_sign(sk,m,mlen,sm,&smlen);
    t1[i] = cpucycles() - t1[i];


    t2[i] = cpucycles();
    ret=sig_verf(pk,sm,smlen,m,mlen);
    t2[i] = cpucycles() - t2[i];

    if(ret) {
      printf("Verification failed\n");
      return -1;
    }
  }

  print_results("keygen:", t0, NTESTS);
  print_results("sign: ", t1, NTESTS);
  print_results("verify: ", t2, NTESTS);


  
  
  return 0;
}
