Advertisement
Guest User

Untitled

a guest
Jul 26th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdint.h>
  3. #include <string.h>
  4. #include <stdio.h>
  5.  
  6.  
  7. #include "sha3/sph_shabal.h"
  8.  
  9. //#define DEBUG_ALGO
  10.  
  11. void axiomhash(void *output, const void *input)
  12. {
  13.  
  14. sph_shabal256_context ctx_shabal;
  15.  
  16. static unsigned char pblank[1];
  17. pblank[0] = 0;
  18.  
  19. // uint32_t hash[32];
  20. uint32_t hash;
  21.  
  22. sph_shabal256_init(&ctx_shabal);
  23. sph_shabal256 (&ctx_shabal, input, 80);
  24. sph_shabal256_close(&ctx_shabal, (&hash));
  25.  
  26. int R = 2;
  27. int N = 65536;
  28.  
  29. // std::vector<uint256> M(N);
  30. uint32_t M[524288] = { 0 };
  31.  
  32.  
  33. for(int i = 1; i < N; i++)
  34. {
  35. //HashShabal((unsigned char*)&M[i - 1], sizeof(M[i - 1]), (unsigned char*)&M[i]);
  36. sph_shabal256_init(&ctx_shabal);
  37. sph_shabal256 (&ctx_shabal, (unsigned char*)&M[i - 1], sizeof(M[i - 1]));
  38. sph_shabal256_close(&ctx_shabal, (unsigned char*)&M[i]);
  39. }
  40.  
  41. for(int r = 1; r < R; r ++)
  42. {
  43. for(int b = 0; b < N; b++)
  44. {
  45. int p = (b - 1 + N) % N;
  46. // int q = M[p].GetInt() % (N - 1);
  47. int q = M[p] % (N - 1);
  48. int j = (b + q) % N;
  49. // std::vector<uint256> pj(2);
  50. uint32_t pj[2] = { 0 };
  51.  
  52. pj[0] = M[p];
  53. pj[1] = M[j];
  54. //HashShabal((unsigned char*)&pj[0], 2 * sizeof(pj[0]), (unsigned char*)&M[b]);
  55. sph_shabal256_init(&ctx_shabal);
  56. sph_shabal256 (&ctx_shabal, (unsigned char*)&pj[0], 2 * sizeof(pj[0]));
  57. sph_shabal256_close(&ctx_shabal, (unsigned char*)&M[b]);
  58. }
  59. }
  60.  
  61. hash = M[N - 1];
  62.  
  63. memcpy(output, hash, 32);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement