Files
salvium-rs/test/debug-aes4rx4.js
T
Matt Hess 7730b6993f ● Add AssemblyScript WASM VM for RandomX full mode
- Create assembly/vm.ts with full RandomX VM implementation
    - 256 instructions, 2048 iterations per hash
    - Native u64/f64 operations in WebAssembly
    - Full mode dataset lookups (2GB pre-computed)

  - Update miner to use WASM VM for full mode
    - mining-worker-asm.js uses pre-compiled WASM
    - ~32 H/s per thread (4x faster than light mode)
    - 8 threads achieves ~260 H/s

  - Clean up redundant code
    - Remove mining-worker-full.js (old JIT approach)
    - Consolidate 'asm' mode into 'full' mode
2026-01-18 01:16:10 +00:00

61 lines
2.1 KiB
JavaScript

/**
* Debug: Verify fillAes4Rx4 output matches C++ reference
*
* This tests the Program struct generation, which has:
* entropyBuffer[16] = 128 bytes
* programBuffer[256] = 2048 bytes
* Total = 2176 bytes filled by fillAes4Rx4
*/
import { fillAes4Rx4 } from '../src/randomx/aes.js';
import { blake2b } from '../src/blake2b.js';
function bytesToHex(bytes, limit = bytes.length) {
return Array.from(bytes.slice(0, limit)).map(b => b.toString(16).padStart(2, '0')).join('');
}
console.log('=== fillAes4Rx4 Debug ===\n');
// Seed is tempHash from blake2b("This is a test", 64)
const input = new TextEncoder().encode('This is a test');
const tempHash = blake2b(input, 64);
console.log('Input: "This is a test"');
console.log(`TempHash (64 bytes): ${bytesToHex(tempHash)}`);
console.log();
// Generate program struct (2176 bytes)
const ENTROPY_SIZE = 128;
const PROGRAM_BYTES = 256 * 8; // 2048
const progData = fillAes4Rx4(tempHash, new Uint8Array(ENTROPY_SIZE + PROGRAM_BYTES));
console.log(`Program struct size: ${progData.length} bytes`);
console.log();
console.log('First 64 bytes of entropy (should be first AES output):');
console.log(` ${bytesToHex(progData, 64)}`);
console.log();
console.log('Bytes 64-128 of entropy:');
console.log(` ${bytesToHex(progData.slice(64, 128))}`);
console.log();
console.log('First 64 bytes of program (bytes 128-192):');
console.log(` ${bytesToHex(progData.slice(128, 192))}`);
console.log();
// Parse first 8 instructions
console.log('First 8 parsed instructions:');
for (let i = 0; i < 8; i++) {
const offset = ENTROPY_SIZE + i * 8;
const opcode = progData[offset];
const dst = progData[offset + 1] & 7;
const src = (progData[offset + 1] >> 4) & 7;
const mod = progData[offset + 2];
const imm32 = progData[offset + 4] |
(progData[offset + 5] << 8) |
(progData[offset + 6] << 16) |
(progData[offset + 7] << 24);
console.log(` [${i}] opcode=${opcode.toString(16).padStart(2,'0')} dst=${dst} src=${src} mod=${mod.toString(16).padStart(2,'0')} imm32=${(imm32 >>> 0).toString(16).padStart(8,'0')}`);
}