dgb-wallet/packages/p2p/native/odo_glue.cpp
Digibyte.X 93cd8b4bf4 daemon: verify proof-of-work on every synced header; fork choice by work
DigiByte is multi-algorithm, so this brings in six hash functions:
SHA256d and Scrypt in JS, and Qubit, Skein, Groestl and Odocrypt from
DigiByte Core's own C sources compiled to WebAssembly (packages/p2p/native,
emscripten via docker). Each header is checked against its nBits target and
the network powLimit before it can enter the chain; a peer serving an
invalid or future-dated header is benched. Competing branches are accepted
only when they carry more accumulated work than what they replace.

npm run pow:test -w @dgb-wallet/p2p verifies real mainnet headers of all
six algorithms and that a tampered header fails.
2026-10-02 18:37:31 +02:00

9 lines
351 B
C++

// C-callable shim around DigiByte Core's OdoCrypt class and the Keccak-p[800]
// permutation (both C++ in Core's src/crypto). Mirrors hashodo.h.
#include "src/odocrypt.h"
#include "src/KeccakP-800-SnP.h"
extern "C" void odo_hash(uint32_t key, char* state100) {
OdoCrypt(key).Encrypt(state100, state100);
KeccakP800_Permute_12rounds(state100);
}