You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

546 lines
15 KiB

  1. package cryptonight
  2. import "fmt"
  3. import "gitlab.com/nitya-sattva/go-x11/hash"
  4. // HashSize holds the size of a hash in bytes.
  5. const HashSize = int(32)
  6. // BlockSize holds the size of a block in bytes.
  7. const BlockSize = uintptr(64)
  8. ////////////////
  9. type digest struct {
  10. ptr uintptr
  11. cnt uintptr
  12. h [16]uint64
  13. b [BlockSize]byte
  14. }
  15. // New returns a new digest compute a JH256 hash.
  16. func NewJhash256() hash.Digest {
  17. ref := &digest{}
  18. ref.Reset()
  19. return ref
  20. }
  21. ////////////////
  22. // Reset resets the digest to its initial state.
  23. func (ref *digest) Reset() {
  24. ref.ptr = 0
  25. ref.cnt = 0
  26. copy(ref.h[:], kInit[:])
  27. }
  28. // Sum appends the current hash to dst and returns the result
  29. // as a slice. It does not change the underlying hash state.
  30. func (ref *digest) Sum(dst []byte) []byte {
  31. dgt := *ref
  32. hsh := [64]byte{}
  33. dgt.Close(hsh[:], 0, 0)
  34. return append(dst, hsh[32:]...)
  35. }
  36. // Write more data to the running hash, never returns an error.
  37. func (ref *digest) Write(src []byte) (int, error) {
  38. sln := uintptr(len(src))
  39. fln := len(src)
  40. buf := ref.b[:]
  41. ptr := ref.ptr
  42. if sln < (BlockSize - ptr) {
  43. copy(buf[ptr:], src)
  44. ref.ptr += sln
  45. return int(sln), nil
  46. }
  47. var hi, lo [8]uint64
  48. hi[0] = ref.h[0x0]
  49. lo[0] = ref.h[0x1]
  50. hi[1] = ref.h[0x2]
  51. lo[1] = ref.h[0x3]
  52. hi[2] = ref.h[0x4]
  53. lo[2] = ref.h[0x5]
  54. hi[3] = ref.h[0x6]
  55. lo[3] = ref.h[0x7]
  56. hi[4] = ref.h[0x8]
  57. lo[4] = ref.h[0x9]
  58. hi[5] = ref.h[0xA]
  59. lo[5] = ref.h[0xB]
  60. hi[6] = ref.h[0xC]
  61. lo[6] = ref.h[0xD]
  62. hi[7] = ref.h[0xE]
  63. lo[7] = ref.h[0xF]
  64. for sln > 0 {
  65. cln := BlockSize - ptr
  66. if cln > sln {
  67. cln = sln
  68. }
  69. sln -= cln
  70. copy(ref.b[ptr:], src[:cln])
  71. src = src[cln:]
  72. ptr += cln
  73. if ptr == BlockSize {
  74. m0h := decUInt64le(buf[0:])
  75. m0l := decUInt64le(buf[8:])
  76. m1h := decUInt64le(buf[16:])
  77. m1l := decUInt64le(buf[24:])
  78. m2h := decUInt64le(buf[32:])
  79. m2l := decUInt64le(buf[40:])
  80. m3h := decUInt64le(buf[48:])
  81. m3l := decUInt64le(buf[56:])
  82. hi[0] ^= m0h
  83. lo[0] ^= m0l
  84. hi[1] ^= m1h
  85. lo[1] ^= m1l
  86. hi[2] ^= m2h
  87. lo[2] ^= m2l
  88. hi[3] ^= m3h
  89. lo[3] ^= m3l
  90. for r := uint64(0); r < 42; r += 7 {
  91. slMutateExtend(r+0, 0, hi[:], lo[:])
  92. slMutateExtend(r+1, 1, hi[:], lo[:])
  93. slMutateExtend(r+2, 2, hi[:], lo[:])
  94. slMutateExtend(r+3, 3, hi[:], lo[:])
  95. slMutateExtend(r+4, 4, hi[:], lo[:])
  96. slMutateExtend(r+5, 5, hi[:], lo[:])
  97. slMutateBasic(r+6, hi[:], lo[:])
  98. }
  99. hi[4] ^= m0h
  100. lo[4] ^= m0l
  101. hi[5] ^= m1h
  102. lo[5] ^= m1l
  103. hi[6] ^= m2h
  104. lo[6] ^= m2l
  105. hi[7] ^= m3h
  106. lo[7] ^= m3l
  107. ref.cnt++
  108. ptr = 0
  109. }
  110. }
  111. ref.h[0x0] = hi[0]
  112. ref.h[0x1] = lo[0]
  113. ref.h[0x2] = hi[1]
  114. ref.h[0x3] = lo[1]
  115. ref.h[0x4] = hi[2]
  116. ref.h[0x5] = lo[2]
  117. ref.h[0x6] = hi[3]
  118. ref.h[0x7] = lo[3]
  119. ref.h[0x8] = hi[4]
  120. ref.h[0x9] = lo[4]
  121. ref.h[0xA] = hi[5]
  122. ref.h[0xB] = lo[5]
  123. ref.h[0xC] = hi[6]
  124. ref.h[0xD] = lo[6]
  125. ref.h[0xE] = hi[7]
  126. ref.h[0xF] = lo[7]
  127. ref.ptr = ptr
  128. return fln, nil
  129. }
  130. // Close the digest by writing the last bits and storing the hash
  131. // in dst. This prepares the digest for reuse by calling reset. A call
  132. // to Close with a dst that is smaller then HashSize will return an error.
  133. func (ref *digest) Close(dst []byte, bits uint8, bcnt uint8) error {
  134. if ln := len(dst); HashSize > ln {
  135. return fmt.Errorf("JHash Close: dst min length: %d, got %d", HashSize, ln)
  136. }
  137. var ocnt uintptr
  138. var buf [128]uint8
  139. {
  140. off := uint8(0x80) >> bcnt
  141. buf[0] = uint8((bits & -off) | off)
  142. }
  143. if ref.ptr == 0 && bcnt == 0 {
  144. ocnt = 47
  145. } else {
  146. ocnt = 111 - ref.ptr
  147. }
  148. l0 := uint64(bcnt)
  149. l0 += uint64(ref.cnt << 9)
  150. l0 += uint64(ref.ptr << 3)
  151. l1 := uint64(ref.cnt >> 55)
  152. encUInt64be(buf[ocnt+1:], l1)
  153. encUInt64be(buf[ocnt+9:], l0)
  154. ref.Write(buf[:ocnt+17])
  155. for u := uintptr(0); u < 8; u++ {
  156. encUInt64le(dst[(u<<3):], ref.h[u+8])
  157. }
  158. ref.Reset()
  159. return nil
  160. }
  161. // Size returns the number of bytes required to store the hash.
  162. func (*digest) Size() int {
  163. return HashSize
  164. }
  165. // BlockSize returns the block size of the hash.
  166. func (*digest) BlockSize() int {
  167. return int(BlockSize)
  168. }
  169. ////////////////
  170. func decUInt64le(src []byte) uint64 {
  171. return (uint64(src[0]) |
  172. uint64(src[1])<<8 |
  173. uint64(src[2])<<16 |
  174. uint64(src[3])<<24 |
  175. uint64(src[4])<<32 |
  176. uint64(src[5])<<40 |
  177. uint64(src[6])<<48 |
  178. uint64(src[7])<<56)
  179. }
  180. func encUInt64le(dst []byte, src uint64) {
  181. dst[0] = uint8(src)
  182. dst[1] = uint8(src >> 8)
  183. dst[2] = uint8(src >> 16)
  184. dst[3] = uint8(src >> 24)
  185. dst[4] = uint8(src >> 32)
  186. dst[5] = uint8(src >> 40)
  187. dst[6] = uint8(src >> 48)
  188. dst[7] = uint8(src >> 56)
  189. }
  190. func encUInt64be(dst []byte, src uint64) {
  191. dst[0] = uint8(src >> 56)
  192. dst[1] = uint8(src >> 48)
  193. dst[2] = uint8(src >> 40)
  194. dst[3] = uint8(src >> 32)
  195. dst[4] = uint8(src >> 24)
  196. dst[5] = uint8(src >> 16)
  197. dst[6] = uint8(src >> 8)
  198. dst[7] = uint8(src)
  199. }
  200. func slMutateBasic(r uint64, hi, lo []uint64) {
  201. var tmp uint64
  202. tmp = kSpec[(r<<2)+0]
  203. hi[6] = ^hi[6]
  204. hi[0] ^= tmp & ^hi[4]
  205. tmp = tmp ^ (hi[0] & hi[2])
  206. hi[0] ^= hi[4] & hi[6]
  207. hi[6] ^= ^hi[2] & hi[4]
  208. hi[2] ^= hi[0] & hi[4]
  209. hi[4] ^= hi[0] & ^hi[6]
  210. hi[0] ^= hi[2] | hi[6]
  211. hi[6] ^= hi[2] & hi[4]
  212. hi[2] ^= tmp & hi[0]
  213. hi[4] ^= tmp
  214. tmp = kSpec[(r<<2)+1]
  215. lo[6] = ^lo[6]
  216. lo[0] ^= tmp & ^lo[4]
  217. tmp = tmp ^ (lo[0] & lo[2])
  218. lo[0] ^= lo[4] & lo[6]
  219. lo[6] ^= ^lo[2] & lo[4]
  220. lo[2] ^= lo[0] & lo[4]
  221. lo[4] ^= lo[0] & ^lo[6]
  222. lo[0] ^= lo[2] | lo[6]
  223. lo[6] ^= lo[2] & lo[4]
  224. lo[2] ^= tmp & lo[0]
  225. lo[4] ^= tmp
  226. tmp = kSpec[(r<<2)+2]
  227. hi[7] = ^hi[7]
  228. hi[1] ^= tmp & ^hi[5]
  229. tmp = tmp ^ (hi[1] & hi[3])
  230. hi[1] ^= hi[5] & hi[7]
  231. hi[7] ^= ^hi[3] & hi[5]
  232. hi[3] ^= hi[1] & hi[5]
  233. hi[5] ^= hi[1] & ^hi[7]
  234. hi[1] ^= hi[3] | hi[7]
  235. hi[7] ^= hi[3] & hi[5]
  236. hi[3] ^= tmp & hi[1]
  237. hi[5] ^= tmp
  238. tmp = kSpec[(r<<2)+3]
  239. lo[7] = ^lo[7]
  240. lo[1] ^= tmp & ^lo[5]
  241. tmp = tmp ^ (lo[1] & lo[3])
  242. lo[1] ^= lo[5] & lo[7]
  243. lo[7] ^= ^lo[3] & lo[5]
  244. lo[3] ^= lo[1] & lo[5]
  245. lo[5] ^= lo[1] & ^lo[7]
  246. lo[1] ^= lo[3] | lo[7]
  247. lo[7] ^= lo[3] & lo[5]
  248. lo[3] ^= tmp & lo[1]
  249. lo[5] ^= tmp
  250. hi[1] ^= hi[2]
  251. hi[3] ^= hi[4]
  252. hi[5] ^= hi[6] ^ hi[0]
  253. hi[7] ^= hi[0]
  254. hi[0] ^= hi[3]
  255. hi[2] ^= hi[5]
  256. hi[4] ^= hi[7] ^ hi[1]
  257. hi[6] ^= hi[1]
  258. lo[1] ^= lo[2]
  259. lo[3] ^= lo[4]
  260. lo[5] ^= lo[6] ^ lo[0]
  261. lo[7] ^= lo[0]
  262. lo[0] ^= lo[3]
  263. lo[2] ^= lo[5]
  264. lo[4] ^= lo[7] ^ lo[1]
  265. lo[6] ^= lo[1]
  266. tmp = hi[1]
  267. hi[1] = lo[1]
  268. lo[1] = tmp
  269. tmp = hi[3]
  270. hi[3] = lo[3]
  271. lo[3] = tmp
  272. tmp = hi[5]
  273. hi[5] = lo[5]
  274. lo[5] = tmp
  275. tmp = hi[7]
  276. hi[7] = lo[7]
  277. lo[7] = tmp
  278. }
  279. func slMutateExtend(r, ro uint64, hi, lo []uint64) {
  280. var tmp uint64
  281. tmp = kSpec[(r<<2)+0]
  282. hi[6] = ^hi[6]
  283. hi[0] ^= tmp & ^hi[4]
  284. tmp = tmp ^ (hi[0] & hi[2])
  285. hi[0] ^= hi[4] & hi[6]
  286. hi[6] ^= ^hi[2] & hi[4]
  287. hi[2] ^= hi[0] & hi[4]
  288. hi[4] ^= hi[0] & ^hi[6]
  289. hi[0] ^= hi[2] | hi[6]
  290. hi[6] ^= hi[2] & hi[4]
  291. hi[2] ^= tmp & hi[0]
  292. hi[4] ^= tmp
  293. tmp = kSpec[(r<<2)+1]
  294. lo[6] = ^lo[6]
  295. lo[0] ^= tmp & ^lo[4]
  296. tmp = tmp ^ (lo[0] & lo[2])
  297. lo[0] ^= lo[4] & lo[6]
  298. lo[6] ^= ^lo[2] & lo[4]
  299. lo[2] ^= lo[0] & lo[4]
  300. lo[4] ^= lo[0] & ^lo[6]
  301. lo[0] ^= lo[2] | lo[6]
  302. lo[6] ^= lo[2] & lo[4]
  303. lo[2] ^= tmp & lo[0]
  304. lo[4] ^= tmp
  305. tmp = kSpec[(r<<2)+2]
  306. hi[7] = ^hi[7]
  307. hi[1] ^= tmp & ^hi[5]
  308. tmp = tmp ^ (hi[1] & hi[3])
  309. hi[1] ^= hi[5] & hi[7]
  310. hi[7] ^= ^hi[3] & hi[5]
  311. hi[3] ^= hi[1] & hi[5]
  312. hi[5] ^= hi[1] & ^hi[7]
  313. hi[1] ^= hi[3] | hi[7]
  314. hi[7] ^= hi[3] & hi[5]
  315. hi[3] ^= tmp & hi[1]
  316. hi[5] ^= tmp
  317. tmp = kSpec[(r<<2)+3]
  318. lo[7] = ^lo[7]
  319. lo[1] ^= tmp & ^lo[5]
  320. tmp = tmp ^ (lo[1] & lo[3])
  321. lo[1] ^= lo[5] & lo[7]
  322. lo[7] ^= ^lo[3] & lo[5]
  323. lo[3] ^= lo[1] & lo[5]
  324. lo[5] ^= lo[1] & ^lo[7]
  325. lo[1] ^= lo[3] | lo[7]
  326. lo[7] ^= lo[3] & lo[5]
  327. lo[3] ^= tmp & lo[1]
  328. lo[5] ^= tmp
  329. hi[1] ^= hi[2]
  330. hi[3] ^= hi[4]
  331. hi[5] ^= hi[6] ^ hi[0]
  332. hi[7] ^= hi[0]
  333. hi[0] ^= hi[3]
  334. hi[2] ^= hi[5]
  335. hi[4] ^= hi[7] ^ hi[1]
  336. hi[6] ^= hi[1]
  337. lo[1] ^= lo[2]
  338. lo[3] ^= lo[4]
  339. lo[5] ^= lo[6] ^ lo[0]
  340. lo[7] ^= lo[0]
  341. lo[0] ^= lo[3]
  342. lo[2] ^= lo[5]
  343. lo[4] ^= lo[7] ^ lo[1]
  344. lo[6] ^= lo[1]
  345. tmp = (hi[1] & (kWrapValue[ro])) << (kWrapOffset[ro])
  346. hi[1] = ((hi[1] >> (kWrapOffset[ro])) & (kWrapValue[ro])) | tmp
  347. tmp = (lo[1] & (kWrapValue[ro])) << (kWrapOffset[ro])
  348. lo[1] = ((lo[1] >> (kWrapOffset[ro])) & (kWrapValue[ro])) | tmp
  349. tmp = (hi[3] & (kWrapValue[ro])) << (kWrapOffset[ro])
  350. hi[3] = ((hi[3] >> (kWrapOffset[ro])) & (kWrapValue[ro])) | tmp
  351. tmp = (lo[3] & (kWrapValue[ro])) << (kWrapOffset[ro])
  352. lo[3] = ((lo[3] >> (kWrapOffset[ro])) & (kWrapValue[ro])) | tmp
  353. tmp = (hi[5] & (kWrapValue[ro])) << (kWrapOffset[ro])
  354. hi[5] = ((hi[5] >> (kWrapOffset[ro])) & (kWrapValue[ro])) | tmp
  355. tmp = (lo[5] & (kWrapValue[ro])) << (kWrapOffset[ro])
  356. lo[5] = ((lo[5] >> (kWrapOffset[ro])) & (kWrapValue[ro])) | tmp
  357. tmp = (hi[7] & (kWrapValue[ro])) << (kWrapOffset[ro])
  358. hi[7] = ((hi[7] >> (kWrapOffset[ro])) & (kWrapValue[ro])) | tmp
  359. tmp = (lo[7] & (kWrapValue[ro])) << (kWrapOffset[ro])
  360. lo[7] = ((lo[7] >> (kWrapOffset[ro])) & (kWrapValue[ro])) | tmp
  361. }
  362. ////////////////
  363. /* these constants are for 512 bit hash */
  364. /*var kInit = []uint64{
  365. uint64(0x17aa003e964bd16f), uint64(0x43d5157a052e6a63),
  366. uint64(0x0bef970c8d5e228a), uint64(0x61c3b3f2591234e9),
  367. uint64(0x1e806f53c1a01d89), uint64(0x806d2bea6b05a92a),
  368. uint64(0xa6ba7520dbcc8e58), uint64(0xf73bf8ba763a0fa9),
  369. uint64(0x694ae34105e66901), uint64(0x5ae66f2e8e8ab546),
  370. uint64(0x243c84c1d0a74710), uint64(0x99c15a2db1716e3b),
  371. uint64(0x56f8b19decf657cf), uint64(0x56b116577c8806a7),
  372. uint64(0xfb1785e6dffcc2e3), uint64(0x4bdd8ccc78465a54),
  373. }*/
  374. // these constants are for 256 bit hash
  375. var kInit = []uint64{
  376. uint64(0xEBD3202C41A398EB), uint64(0xC145B29C7BBECD92),
  377. uint64(0xFAC7D4609151931C), uint64(0x38A507ED6820026),
  378. uint64(0x45B92677269E23A4), uint64(0x77941AD4481AFBE0),
  379. uint64(0x7A176B0226ABB5CD), uint64(0xA82FFF0F4224F056),
  380. uint64(0x754D2E7F8996A371), uint64(0x62E27DF70849141D),
  381. uint64(0x948F2476F7957627), uint64(0x6C29804757B6D587),
  382. uint64(0x6C0D8EAC2D275E5C), uint64(0xF7A0557C6508451),
  383. uint64(0xEA12247067D3E47B), uint64(0x69D71CD313ABE389),
  384. }
  385. var kSpec = []uint64{
  386. uint64(0x67f815dfa2ded572), uint64(0x571523b70a15847b),
  387. uint64(0xf6875a4d90d6ab81), uint64(0x402bd1c3c54f9f4e),
  388. uint64(0x9cfa455ce03a98ea), uint64(0x9a99b26699d2c503),
  389. uint64(0x8a53bbf2b4960266), uint64(0x31a2db881a1456b5),
  390. uint64(0xdb0e199a5c5aa303), uint64(0x1044c1870ab23f40),
  391. uint64(0x1d959e848019051c), uint64(0xdccde75eadeb336f),
  392. uint64(0x416bbf029213ba10), uint64(0xd027bbf7156578dc),
  393. uint64(0x5078aa3739812c0a), uint64(0xd3910041d2bf1a3f),
  394. uint64(0x907eccf60d5a2d42), uint64(0xce97c0929c9f62dd),
  395. uint64(0xac442bc70ba75c18), uint64(0x23fcc663d665dfd1),
  396. uint64(0x1ab8e09e036c6e97), uint64(0xa8ec6c447e450521),
  397. uint64(0xfa618e5dbb03f1ee), uint64(0x97818394b29796fd),
  398. uint64(0x2f3003db37858e4a), uint64(0x956a9ffb2d8d672a),
  399. uint64(0x6c69b8f88173fe8a), uint64(0x14427fc04672c78a),
  400. uint64(0xc45ec7bd8f15f4c5), uint64(0x80bb118fa76f4475),
  401. uint64(0xbc88e4aeb775de52), uint64(0xf4a3a6981e00b882),
  402. uint64(0x1563a3a9338ff48e), uint64(0x89f9b7d524565faa),
  403. uint64(0xfde05a7c20edf1b6), uint64(0x362c42065ae9ca36),
  404. uint64(0x3d98fe4e433529ce), uint64(0xa74b9a7374f93a53),
  405. uint64(0x86814e6f591ff5d0), uint64(0x9f5ad8af81ad9d0e),
  406. uint64(0x6a6234ee670605a7), uint64(0x2717b96ebe280b8b),
  407. uint64(0x3f1080c626077447), uint64(0x7b487ec66f7ea0e0),
  408. uint64(0xc0a4f84aa50a550d), uint64(0x9ef18e979fe7e391),
  409. uint64(0xd48d605081727686), uint64(0x62b0e5f3415a9e7e),
  410. uint64(0x7a205440ec1f9ffc), uint64(0x84c9f4ce001ae4e3),
  411. uint64(0xd895fa9df594d74f), uint64(0xa554c324117e2e55),
  412. uint64(0x286efebd2872df5b), uint64(0xb2c4a50fe27ff578),
  413. uint64(0x2ed349eeef7c8905), uint64(0x7f5928eb85937e44),
  414. uint64(0x4a3124b337695f70), uint64(0x65e4d61df128865e),
  415. uint64(0xe720b95104771bc7), uint64(0x8a87d423e843fe74),
  416. uint64(0xf2947692a3e8297d), uint64(0xc1d9309b097acbdd),
  417. uint64(0xe01bdc5bfb301b1d), uint64(0xbf829cf24f4924da),
  418. uint64(0xffbf70b431bae7a4), uint64(0x48bcf8de0544320d),
  419. uint64(0x39d3bb5332fcae3b), uint64(0xa08b29e0c1c39f45),
  420. uint64(0x0f09aef7fd05c9e5), uint64(0x34f1904212347094),
  421. uint64(0x95ed44e301b771a2), uint64(0x4a982f4f368e3be9),
  422. uint64(0x15f66ca0631d4088), uint64(0xffaf52874b44c147),
  423. uint64(0x30c60ae2f14abb7e), uint64(0xe68c6eccc5b67046),
  424. uint64(0x00ca4fbd56a4d5a4), uint64(0xae183ec84b849dda),
  425. uint64(0xadd1643045ce5773), uint64(0x67255c1468cea6e8),
  426. uint64(0x16e10ecbf28cdaa3), uint64(0x9a99949a5806e933),
  427. uint64(0x7b846fc220b2601f), uint64(0x1885d1a07facced1),
  428. uint64(0xd319dd8da15b5932), uint64(0x46b4a5aac01c9a50),
  429. uint64(0xba6b04e467633d9f), uint64(0x7eee560bab19caf6),
  430. uint64(0x742128a9ea79b11f), uint64(0xee51363b35f7bde9),
  431. uint64(0x76d350755aac571d), uint64(0x01707da3fec2463a),
  432. uint64(0x42d8a498afc135f7), uint64(0x79676b9e20eced78),
  433. uint64(0xa8db3aea15638341), uint64(0x832c83324d3bc3fa),
  434. uint64(0xf347271c1f3b40a7), uint64(0x9a762db734f04059),
  435. uint64(0xfd4f21d26c4e3ee7), uint64(0xef5957dc398dfdb8),
  436. uint64(0xdaeb492b490c9b8d), uint64(0x0d70f36849d7a25b),
  437. uint64(0x84558d7ad0ae3b7d), uint64(0x658ef8e4f0e9a5f5),
  438. uint64(0x533b1036f4a2b8a0), uint64(0x5aec3e759e07a80c),
  439. uint64(0x4f88e85692946891), uint64(0x4cbcbaf8555cb05b),
  440. uint64(0x7b9487f3993bbbe3), uint64(0x5d1c6b72d6f4da75),
  441. uint64(0x6db334dc28acae64), uint64(0x71db28b850a5346c),
  442. uint64(0x2a518d10f2e261f8), uint64(0xfc75dd593364dbe3),
  443. uint64(0xa23fce43f1bcac1c), uint64(0xb043e8023cd1bb67),
  444. uint64(0x75a12988ca5b0a33), uint64(0x5c5316b44d19347f),
  445. uint64(0x1e4d790ec3943b92), uint64(0x3fafeeb6d7757479),
  446. uint64(0x21391abef7d4a8ea), uint64(0x5127234c097ef45c),
  447. uint64(0xd23c32ba5324a326), uint64(0xadd5a66d4a17a344),
  448. uint64(0x08c9f2afa63e1db5), uint64(0x563c6b91983d5983),
  449. uint64(0x4d608672a17cf84c), uint64(0xf6c76e08cc3ee246),
  450. uint64(0x5e76bcb1b333982f), uint64(0x2ae6c4efa566d62b),
  451. uint64(0x36d4c1bee8b6f406), uint64(0x6321efbc1582ee74),
  452. uint64(0x69c953f40d4ec1fd), uint64(0x26585806c45a7da7),
  453. uint64(0x16fae0061614c17e), uint64(0x3f9d63283daf907e),
  454. uint64(0x0cd29b00e3f2c9d2), uint64(0x300cd4b730ceaa5f),
  455. uint64(0x9832e0f216512a74), uint64(0x9af8cee3d830eb0d),
  456. uint64(0x9279f1b57b9ec54b), uint64(0xd36886046ee651ff),
  457. uint64(0x316796e6574d239b), uint64(0x05750a17f3a6e6cc),
  458. uint64(0xce6c3213d98176b1), uint64(0x62a205f88452173c),
  459. uint64(0x47154778b3cb2bf4), uint64(0x486a9323825446ff),
  460. uint64(0x65655e4e0758df38), uint64(0x8e5086fc897cfcf2),
  461. uint64(0x86ca0bd0442e7031), uint64(0x4e477830a20940f0),
  462. uint64(0x8338f7d139eea065), uint64(0xbd3a2ce437e95ef7),
  463. uint64(0x6ff8130126b29721), uint64(0xe7de9fefd1ed44a3),
  464. uint64(0xd992257615dfa08b), uint64(0xbe42dc12f6f7853c),
  465. uint64(0x7eb027ab7ceca7d8), uint64(0xdea83eaada7d8d53),
  466. uint64(0xd86902bd93ce25aa), uint64(0xf908731afd43f65a),
  467. uint64(0xa5194a17daef5fc0), uint64(0x6a21fd4c33664d97),
  468. uint64(0x701541db3198b435), uint64(0x9b54cdedbb0f1eea),
  469. uint64(0x72409751a163d09a), uint64(0xe26f4791bf9d75f6),
  470. }
  471. var kWrapValue = []uint64{
  472. uint64(0x5555555555555555),
  473. uint64(0x3333333333333333),
  474. uint64(0x0F0F0F0F0F0F0F0F),
  475. uint64(0x00FF00FF00FF00FF),
  476. uint64(0x0000FFFF0000FFFF),
  477. uint64(0x00000000FFFFFFFF),
  478. }
  479. var kWrapOffset = []uint64{
  480. 1, 2, 4, 8, 16, 32,
  481. }