// Copyright (c) 2019-2024 The Hush developers // Distributed under the GPLv3 software license, see the accompanying // file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html // Copyright (c) 2016-2016 John Tromp, The Zcash developers // Equihash solver #include "sodium.h" #ifdef __APPLE__ #include "pow/tromp/osx_barrier.h" #endif #include "compat/endian.h" #include // for types uint32_t,uint64_t #include // for functions memset #include // for function qsort typedef uint32_t u32; typedef unsigned char uchar; // algorithm parameters, prefixed with W to reduce include file conflicts #ifndef WN #define WN 200 #endif #ifndef WK #define WK 9 #endif #define NDIGITS (WK+1) #define DIGITBITS (WN/(NDIGITS)) static const u32 PROOFSIZE = 1<= *indices1) return POW_OUT_OF_ORDER; uchar hash0[WN/8], hash1[WN/8]; int vrf0 = verifyrec(ctx, indices, hash0, r-1); if (vrf0 != POW_OK) return vrf0; int vrf1 = verifyrec(ctx, indices1, hash1, r-1); if (vrf1 != POW_OK) return vrf1; for (int i=0; i < WN/8; i++) hash[i] = hash0[i] ^ hash1[i]; int i, b = r * DIGITBITS; for (i = 0; i < b/8; i++) if (hash[i]) return POW_NONZERO_XOR; if ((b%8) && hash[i] >> (8-(b%8))) return POW_NONZERO_XOR; return POW_OK; } int compu32(const void *pa, const void *pb) { int32_t retval; u32 a = *(u32 *)pa, b = *(u32 *)pb; retval = a