### Suggested Configuration Output Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/performance.md Example of the suggested configuration block displayed by OpenCLInfo based on device capabilities. ```text ... (all the CL_DEVICE_* lines) ... SUGGESTED START CONFIG (heuristic from the info above; sweep keysPerWorkItem to confirm): producerOpenCL.batchSizeInBits = 21 producerOpenCL.keysPerWorkItem = 256 ``` -------------------------------- ### Interpret OpenCL device output Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/tuning-your-gpu.md Example output showing device identification and suggested starting configuration parameters. ```text --- Info for OpenCL device: NVIDIA RTX 500 Ada Generation Laptop GPU --- CL_DEVICE_NAME: NVIDIA RTX 500 Ada Generation Laptop GPU CL_DEVICE_MAX_COMPUTE_UNITS: 16 CL_DEVICE_MAX_MEM_ALLOC_SIZE: 1023 MByte SUGGESTED START CONFIG (heuristic from the info above; sweep keysPerWorkItem to confirm): producerOpenCL.batchSizeInBits = 21 producerOpenCL.keysPerWorkItem = 256 ``` -------------------------------- ### TuneConfiguration Report Output Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/tuning-your-gpu.md Example of the performance report generated during GPU tuning, showing measured candidates per second and filter recommendations. ```text Arms (all figures MEASURED on this machine): batchSizeInBits keysPerWorkItem candidates/s addresses checked/s 23 64 64,588,860.65 1,006,766.88 23 256 94,791,059.02 1,473,710.16 ... Winner (MEASURED): batchSizeInBits=23 keysPerWorkItem=256 at 94,791,059.02 candidates/s. Filter choice - total = probe + fpr x verification: verification cost 12.61 us MEASURED on this database FUSE_8 probe 76.70 ns, fpr 0.003874 DOCUMENTED constants -> total 125.55 ns FUSE_16 probe 80.40 ns, fpr 0.000016 DOCUMENTED constants -> total 80.60 ns Recommended: FUSE_16 (DERIVED, not measured) Paste-ready configuration: { ... } ``` -------------------------------- ### Execute Maven Build Commands Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/CLAUDE.md Standard Maven commands for compiling, testing, and packaging the project. Note that the project does not include a Maven wrapper, so a local Maven installation is required. ```bash # Compile only mvn compile # Run all tests mvn test # Build fat JAR with all dependencies mvn package -P assembly # Build without tests mvn package -DskipTests # Generate coverage report mvn test jacoco:report # Skip LMDB-specific tests (useful when LMDB native libs unavailable) mvn test -Dnet.ladenthin.bitcoinaddressfinder.disableLMDBTest=true ``` -------------------------------- ### Extend LMDBBase for Shared Setup Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/TEST_WRITING_GUIDE.md Extend LMDBBase to automatically gain access to @Rule folder, network, keyUtility, and LMDB helpers. ```java public class MyLMDBTest extends LMDBBase { // LMDBBase provides: @Rule folder, network, keyUtility, and LMDB helpers } ``` -------------------------------- ### Kernel Resource Usage Log Output Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/performance.md Example of the log output generated by OpenCLContext during initialization, showing kernel work-group size and memory usage. ```text Kernel resource usage: kernelMaxWorkGroupSize=256 workGroupSizeMultiple=32 privateMemBytes=640 localMemBytes=… ``` -------------------------------- ### Conventional Commit Message Examples Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/CONTRIBUTING.md Examples of commit messages following the Conventional Commits 1.0.0 specification. ```text feat(keyproducer): add socket key producer fix(consumer): close LMDB env on shutdown docs(readme): refresh quickstart chore(deps): bump guava to 33.5.0-jre ``` -------------------------------- ### Build and Run the Application Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/CLAUDE.md Use Maven to package the application into a fat JAR and execute it using a configuration file. ```bash # Build fat JAR mvn package -P assembly -DskipTests # Run (replace config path as needed) java -jar target/bitcoinaddressfinder-1.8.0-SNAPSHOT-jar-with-dependencies.jar \ examples/config_Find_8CPUProducer.json ``` -------------------------------- ### Run the application with a configuration file Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/CONTRIBUTING.md Execute the built assembly JAR by providing a path to a JSON configuration file. ```bash java -jar target/bitcoinaddressfinder-*-jar-with-dependencies.jar \ examples/config_Find_8CPUProducer.json ``` -------------------------------- ### Clone the repository Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/CONTRIBUTING.md Initial step to set up a local development environment by cloning the forked repository. ```bash git clone https://github.com//BitcoinAddressFinder.git ``` -------------------------------- ### Run the test suite Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/CONTRIBUTING.md Execute the full test suite using the Maven wrapper to ensure changes do not break existing functionality. ```bash ./mvnw test ``` -------------------------------- ### Execute OpenCLInfo via CLI Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/tuning-your-gpu.md Direct command to run the discovery tool using the Java runtime. ```bash java -jar bitcoinaddressfinder-1.8.0-SNAPSHOT-jar-with-dependencies.jar config_OpenCLInfo.json ``` -------------------------------- ### Apply Spotless Formatting Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/CLAUDE.md Execute this command before committing changes to Java files to ensure code style compliance. ```bash mvn spotless:apply ``` -------------------------------- ### Registering the machine Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/measurements/README.md Detects hardware and updates machines.json. Use --set for manual overrides or --dry-run to preview. ```bash python docs/measurements/register_machine.py --set storage="" python docs/measurements/register_machine.py --dry-run # preview only python docs/measurements/register_machine.py --id my-own-name # override the generated id ``` ```bash python docs/measurements/register_machine.py --set gpu="RTX 500 Ada,Arc Pro Graphics" ``` -------------------------------- ### Run full lifecycle for Javadoc reproduction Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/CLAUDE.md Use this command to simulate the release build process locally. It ensures the Javadoc plugin runs in the correct phase relative to the compiler plugin. ```bash mvn -P release clean package -DskipTests -Dgpg.skip=true \ -Dnet.ladenthin.bitcoinaddressfinder.disableLMDBTest=true # expected: BUILD SUCCESS + target/*-javadoc.jar ``` -------------------------------- ### Initialize LMDB Test Databases Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/TEST_WRITING_GUIDE.md Use TestAddressesLMDB and TestAddressesFiles to create test database environments. ```java TestAddressesLMDB testAddressesLMDB = new TestAddressesLMDB(); TestAddressesFiles testAddresses = new TestAddressesFiles(compressed); File lmdbFolderPath = testAddressesLMDB.createTestLMDB(folder, testAddresses, useStaticAmount, false); ``` -------------------------------- ### Run Linux/macOS Tuner Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/tuning-your-gpu.md Make the shell script executable and run it, or execute with direct redirection. ```bash chmod +x run_TuneConfiguration.sh ./run_TuneConfiguration.sh ``` ```bash ./run_TuneConfiguration.sh > log_TuneConfiguration_gpu0.txt 2>&1 ``` -------------------------------- ### Execute common Maven build and test commands Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/CONTRIBUTING.md Use these commands to compile, test, package, and generate coverage reports for the project. ```bash # Compile only ./mvnw compile # Run the full test suite ./mvnw test # Build a fat JAR with all dependencies (assembly profile) ./mvnw package -P assembly # Build without running tests ./mvnw package -DskipTests # Generate a JaCoCo code-coverage report (target/site/jacoco/index.html) ./mvnw test jacoco:report # Skip LMDB-specific tests when native LMDB libraries are unavailable ./mvnw test -Dnet.ladenthin.bitcoinaddressfinder.disableLMDBTest=true ``` -------------------------------- ### Configure OpenCLInfo command Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/tuning-your-gpu.md A JSON configuration file used to trigger the OpenCL device discovery process. ```json { "command": "OpenCLInfo" } ``` -------------------------------- ### Configure LMDB Path Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/tuning-your-gpu.md Point the consumer to the LMDB directory to measure database lookup costs. ```json "lmdbConfigurationReadOnly": { "lmdbDirectory": "lmdb", ... } ``` -------------------------------- ### Run Windows Tuner Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/tuning-your-gpu.md Execute the configured batch script. ```bat run_TuneConfiguration.bat ``` -------------------------------- ### Implement C-Prefix Configuration POJOs Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/CODE_WRITING_GUIDE.md New features should be driven by a C-prefixed POJO, which is passed as the first argument to the constructor. ```java public class CMyFeature { public int threads = 1; public @Nullable String optionalParam; } // Constructor receives the config as first argument: public MyFeature(CMyFeature config, KeyUtility keyUtility, Logger logger) { this.config = config; this.keyUtility = keyUtility; this.logger = logger; } ``` -------------------------------- ### Run JMH benchmarks locally Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/CLAUDE.md Use these commands to build the test classpath and execute the JMH runner directly. Ensure the --add-opens flags match the project's pom.xml configuration. ```bash # 1. materialise the full test-scope classpath (includes jmh-core) mvn -q dependency:build-classpath -Dmdep.outputFile=target/cp-test.txt -DincludeScope=test # 2. run JMH directly; prepend the project's own classes to the dependency classpath. # The --add-opens set must match pom.xml (lmdbjava reflects into sun.nio.ch). java --add-opens=java.base/java.lang=ALL-UNNAMED \ --add-opens=java.base/java.io=ALL-UNNAMED \ --add-opens=java.base/java.nio=ALL-UNNAMED \ --add-opens=java.base/jdk.internal.ref=ALL-UNNAMED \ --add-opens=java.base/jdk.internal.misc=ALL-UNNAMED \ --add-opens=java.base/sun.nio.ch=ALL-UNNAMED \ -cp "target/test-classes;target/classes;$(cat target/cp-test.txt)" \ org.openjdk.jmh.Main GpuFuse8FilterBenchmark -p batchSizeInBits=19 -f 1 -wi 1 -w 30 -i 1 -r 200 ``` -------------------------------- ### Configure Device Index Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/tuning-your-gpu.md Specify the platform and device index for the GPU in the producerOpenCL block. ```json "platformIndex": 0, "deviceIndex": 0, ``` -------------------------------- ### Materializing the classpath Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/measurements/README.md Generates the test classpath required for running benchmarks. ```bash mvn -q dependency:build-classpath -Dmdep.outputFile=target/cp-test.txt -DincludeScope=test ``` -------------------------------- ### Configure automatic multi-GPU enumeration Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/tuning-your-gpu.md Leave the producerOpenCL array empty to allow the tuner to automatically detect and measure all available GPUs on the system. ```json "producerOpenCL": [] ``` -------------------------------- ### Calculate Tuner Run Time Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/tuning-your-gpu.md Formula to estimate the total duration of the tuning process based on configuration parameters. ```text run time = number of arms × (warmupSecondsPerArm + secondsPerArm) ``` -------------------------------- ### Verify Producer Subclasses Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/TEST_WRITING_GUIDE.md Use AbstractProducerTest helpers to verify producer initialization and release cycles. ```java AbstractProducerTest.verifyInitProducer(producer); AbstractProducerTest.verifyReleaseProducer(producer); ``` -------------------------------- ### Project Directory Structure Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/CLAUDE.md Visual representation of the project's file hierarchy and module responsibilities. ```text BitcoinAddressFinder/ ├── src/ │ ├── main/ │ │ ├── java/net/ladenthin/bitcoinaddressfinder/ # layered packages (top → bottom) │ │ │ ├── cli/ # Entry: CLI entry point (Main.java) │ │ │ ├── engine/ # Orchestration: Finder, Shutdown │ │ │ ├── command/ # Orchestration: CCommand impls (LMDB import/export) │ │ │ ├── producer/ # Pipeline: runtime key producers (queue feeders) │ │ │ ├── consumer/ # Pipeline: ConsumerJava + Consumer contract │ │ │ ├── keyproducer/ # Capability: key/secret generation strategies (+ BIP39KeyProducer) │ │ │ ├── opencl/ # Capability: OpenCL device/platform + runtime (Context/Task/GridResult) │ │ │ ├── persistence/ # Capability: presence backends (+ bloom, inmemory, lmdb) │ │ │ ├── io/ # InputOutput: address/secret file reading + parsing │ │ │ ├── model/ # Foundation: value/domain types (Hash160, PublicKeyBytes, …) │ │ │ ├── util/ # Foundation: stateless crypto/byte helpers (KeyUtility, BitHelper, …) │ │ │ ├── core/ # Foundation: lifecycle contracts (Interruptable, Startable, …) │ │ │ ├── secret/ # Foundation: secret-supply primitives (SecretSupplier, BIP39Wordlist) │ │ │ ├── statistics/ # Foundation: Statistics, ReadStatistic │ │ │ ├── configuration/ # Config POJOs (C-prefixed); depends only on constants │ │ │ └── constants/ # Constants leaf (secp256k1 spec, kernel layout) │ │ └── resources/ │ │ ├── *.cl / *.h # OpenCL kernels and headers │ │ └── simplelogger.properties │ └── test/ │ └── java/net/ladenthin/bitcoinaddressfinder/ │ └── *.java # JUnit 6 (Jupiter) tests ├── examples/ # Sample JSON configs and run scripts │ ├── config_*.json │ ├── run_*.bat # Windows launchers │ ├── run_*.sh # Linux/macOS launchers (mirror the .bat flags) │ ├── logbackConfiguration.xml │ ├── addresses/ # Sample address files │ └── secrets/ # Sample secrets files ├── helper/ # Utility scripts (address scraping, wallet ops) ├── .github/workflows/ # CI/CD pipelines ├── pom.xml ├── .mvn/jvm.config └── README.md ``` -------------------------------- ### Register machine variants Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/tuning-your-gpu.md Alternative execution modes for registering hardware, including dry runs and manual overrides. ```bash python docs/measurements/register_machine.py --dry-run # show the entry, write nothing python docs/measurements/register_machine.py --id my-laptop # choose the id yourself python docs/measurements/register_machine.py --set cpu.l3_mb=32 # fill in a field it missed ``` -------------------------------- ### Apply manual producerOpenCL configuration Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/tuning-your-gpu.md Use these specific values within the producerOpenCL block of your config_Find.json file to manually set tuning parameters. ```json "batchSizeInBits": 23, "keysPerWorkItem": 256, "gpuFilterType": "FUSE_16" ``` -------------------------------- ### Manually set GPU devices Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/tuning-your-gpu.md Overrides the detected GPU list with a comma-separated string if automatic detection is incomplete. ```bash python docs/measurements/register_machine.py --set gpu="RTX 500 Ada,Arc Pro Graphics" ``` -------------------------------- ### Run OpenCL Correctness Tests Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/performance.md Executes the suite of OpenCL integration and unit tests to verify kernel correctness before performance benchmarking. ```bash mvn test -Dtest='ProbeAddressesOpenCLTest,ProbeAddressesManySeedsOpenCLTest,OpenCLCompactOutputIntegrationTest,OpenCLContextTest,OpenCLKernelModeMatrixTest,OpenCLFe10x26ParityTest,Fuse8GpuHashParityTest,ProducerOpenCLTest,OpenCLPrecomputeKernelTest' ``` -------------------------------- ### Run JMH Benchmarks Directly Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/performance.md Use this command sequence to execute JMH benchmarks directly, ensuring the JVM fork correctly inherits the test-scope classpath. ```bash # 1. materialise the full test-scope classpath (includes jmh-core) mvn -q dependency:build-classpath -Dmdep.outputFile=target/cp-test.txt -DincludeScope=test # 2. run JMH directly; the --add-opens set must match pom.xml (lmdbjava reflects into # sun.nio.ch). Use ';' as the classpath separator on Windows, ':' on POSIX. java --add-opens=java.base/java.lang=ALL-UNNAMED \ --add-opens=java.base/java.io=ALL-UNNAMED \ --add-opens=java.base/java.nio=ALL-UNNAMED \ --add-opens=java.base/jdk.internal.ref=ALL-UNNAMED \ --add-opens=java.base/jdk.internal.misc=ALL-UNNAMED \ --add-opens=java.base/sun.nio.ch=ALL-UNNAMED \ -cp "target/test-classes;target/classes;$(cat target/cp-test.txt)" \ org.openjdk.jmh.Main GridSizeSweepBenchmark \ -p batchSizeInBits=20 -p keysPerWorkItem=1,2,4,8,16,32,64 -f 1 -wi 1 -w 20 -i 3 -r 20 ``` -------------------------------- ### Reproduce Field Multiplication Benchmark Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/performance.md Execute the JMH benchmark to verify the performance of the field multiplication implementation. ```bash # after: mvn -q dependency:build-classpath -Dmdep.outputFile=target/cp-test.txt -DincludeScope=test java -cp "target/test-classes;target/classes;$(cat target/cp-test.txt)" \ org.openjdk.jmh.Main FieldMulBenchmark -p gridSizeInBits=18 -p iterations=4096 -f 1 -wi 1 -w 20 -i 3 -r 50 ``` -------------------------------- ### Extract Static Methods to Helper Class Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/skills/tdd.md Demonstrates the refactoring pattern of moving static methods from a domain class into a dedicated, testable helper class. ```java // AddressTxtLine.java — hard to test in isolation private static byte[] decodeBech32CharsetToValues(String base32String) { ... } ``` ```java // Bech32Helper.java — small, focused, testable public class Bech32Helper { public byte[] decodeBech32CharsetToValues(String base32String) { ... } } ``` ```java // AddressTxtLine.java Bech32Helper bech32Helper = new Bech32Helper(); // ... byte[] payload = bech32Helper.extractPKHFromBitcoinCashAddress(address); ``` -------------------------------- ### Reproduce OpenJDK ByteBuffer hashCode in OpenCL C Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/TODO.md Implementation of the OpenJDK heap buffer hash formula for use in OpenCL kernels, ensuring byte-for-byte compatibility with Java's ByteBuffer.hashCode(). ```c int h = 1; for (int i = 19; i >= 0; i--) h = 31 * h + (int)(byte)get(i); return h; ``` -------------------------------- ### Configure Find Operation Mode Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/CLAUDE.md Defines a configuration for the Find command using 8 CPU threads and a specific LMDB directory. ```json { "command": "Find", "finder": { "producers": [ { "producerJava": { "threads": 8, "keyProducers": [{ "keyProducerJavaRandom": {} }] } } ], "consumerJava": { "lmdbConfigurationReadOnly": { "lmdbDirectory": "/path/to/lmdb" } } } } ``` -------------------------------- ### Run PIT Mutation Testing Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/CLAUDE.md Execute mutation testing using the specified Maven lifecycle prefix. ```bash mvn test-compile org.pitest:pitest-maven:mutationCoverage ``` -------------------------------- ### Register machine hardware Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/tuning-your-gpu.md Detects system hardware and generates a machine entry in the measurements file. ```bash python docs/measurements/register_machine.py --set storage="Samsung 990 PRO 4TB NVMe" ``` -------------------------------- ### Running benchmarks Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/measurements/README.md Executes JMH benchmarks for filter lookup latency and database performance. Ensure --add-opens flags match the project configuration. ```bash java -Xmx12g --add-opens=java.base/java.lang=ALL-UNNAMED \ --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED \ --add-opens=java.base/jdk.internal.ref=ALL-UNNAMED \ --add-opens=java.base/jdk.internal.misc=ALL-UNNAMED \ --add-opens=java.base/sun.nio.ch=ALL-UNNAMED \ -cp "target/test-classes;target/classes;$(cat target/cp-test.txt)" \ org.openjdk.jmh.Main FilterLookupBenchmark \ -p entries=100000,1000000,10000000 -f 1 -wi 3 -w 2 -i 5 -r 3 ``` ```bash ... org.openjdk.jmh.Main FilterLookupBenchmark \ -p backend=BLOOM,TRUNCATED_LONG_64,BINARY_FUSE_8,BINARY_FUSE_16,BLOCKED_BLOOM \ -p entries=50000000,100000000 -f 1 -wi 2 -w 2 -i 4 -r 3 ``` ```bash # 10,737,418 entries at bitsPerEntry=12 reproduces the Full DB's 12.5 bits/entry ... net.ladenthin.bitcoinaddressfinder.benchmark.FilterMeasurementMain \ "prng:10737418" BLOCKED_BLOOM 2000000 12 ``` ```bash ... net.ladenthin.bitcoinaddressfinder.benchmark.FilterMeasurementMain \ /path/to/lmdb BLOCKED_BLOOM 5000000 ``` -------------------------------- ### Run FilterMeasurementMain benchmark Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/performance.md Executes the benchmark utility to measure performance metrics for a specified backend type against an LMDB directory. ```bash # after the classpath step above java -Xmx6g \ --add-opens=java.base/java.lang=ALL-UNNAMED \ --add-opens=java.base/java.io=ALL-UNNAMED \ --add-opens=java.base/java.nio=ALL-UNNAMED \ --add-opens=java.base/jdk.internal.ref=ALL-UNNAMED \ --add-opens=java.base/jdk.internal.misc=ALL-UNNAMED \ --add-opens=java.base/sun.nio.ch=ALL-UNNAMED \ -cp "target/test-classes;target/classes;$(cat target/cp-test.txt)" \ net.ladenthin.bitcoinaddressfinder.benchmark.FilterMeasurementMain \ /path/to/lmdb BLOCKED_BLOOM 5000000 ``` -------------------------------- ### WebSocket Scanner Client Logic Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/examples/websocket_scanner.html Core JavaScript implementation for managing WebSocket connections, range alignment, and UI state for key scanning. ```javascript "use strict"; const KEY_BYTES = 32; const KEY_BITS = 256; let ws = null; let running = false; let config = null; // {batchSizeInBits, batchUsePrivateKeyIncrement, secretByteLength} let step = 0n; // 2^batchSizeInBits — the only correct increment, see note below let fromBase = 0n; let toBase = 0n; let nextBase = 0n; let inFlight = 0; let sent = 0, checked = 0, hits = 0, keys = 0; let blocks = new Map(); // base (string) -> cell element const $ = (id) => document.getElementById(id); function log(text, isHit) { const div = document.createElement("div"); if (isHit) div.className = "h"; div.textContent = text; $("results").prepend(div); } /** Renders a 256-bit big integer, with the swept low bits marked instead of printed. */ function renderBits(base) { const bits = base.toString(2).padStart(KEY_BITS, "0"); const sweptBits = config ? config.batchSizeInBits : 0; const fixed = bits.slice(0, KEY_BITS - sweptBits); let html = '' + fixed + ''; if (sweptBits > 0) html += '' + "X".repeat(sweptBits) + ''; $("bits").innerHTML = html; } function toFixedBytes(value) { let hex = value.toString(16).padStart(KEY_BYTES * 2, "0"); if (hex.length > KEY_BYTES * 2) hex = hex.slice(-KEY_BYTES * 2); const out = new Uint8Array(KEY_BYTES); for (let i = 0; i < KEY_BYTES; i++) out[i] = parseInt(hex.substr(i * 2, 2), 16); return out; } /** * The server aligns every incoming base down to a multiple of 2^batchSizeInBits. Sending a base * that is not aligned means the same block is swept again while the rest of the range is never * touched — silently, because nothing rejects it. So align here and advance by exactly one grid. */ function alignDown(value) { return step === 0n ? value : (value / step) * step; } function buildMap() { const map = $("map"); map.innerHTML = ""; blocks = new Map(); if (step === 0n || toBase <= fromBase) return; const total = (toBase - fromBase) / step; const capped = total > 4000n ? 4000n : total; // a map, not a pixel-per-key rendering for (let i = 0n; i < capped; i++) { const cell = document.createElement("div"); cell.className = "blk"; const base = fromBase + i * step; cell.title = base.toString(16); map.appendChild(cell); blocks.set(base.toString(16), cell); } } function markBlock(baseHex, cls) { const cell = blocks.get(baseHex); if (!cell) return; cell.classList.remove("pending", "flash"); cell.classList.add(cls); } function flashBlock(baseHex) { const cell = blocks.get(baseHex); if (!cell) return; cell.classList.add("flash"); setTimeout(() => { cell.classList.remove("flash"); cell.classList.add("pending"); }, 90); } function randomBase() { const raw = new Uint8Array(KEY_BYTES); crypto.getRandomValues(raw); let hex = ""; for (const b of raw) hex += b.toString(16).padStart(2, "0"); return alignDown(BigInt("0x" + hex)); } /** Keeps `lookahead` batches in flight so the server's queue never runs dry between batches. ``` -------------------------------- ### Implement compact output buffer in OpenCL Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/TODO.md Uses an atomic counter to claim output slots for hits, ensuring only successful results are written to the output buffer. ```opencl __global volatile uint* hit_count // initialised to 0 before kernel launch __global uchar* hit_results // pre-allocated for MAX_HITS entries // Inside each work-item, after computing hash160 and running the Fuse-8 check: if (fuse_hit) { uint idx = atomic_add(hit_count, 1u); // claim the next output slot if (idx < MAX_HITS) { hit_results[idx * 20 .. idx*20+19] = my_hash160; } } // Work-items that did NOT hit write nothing — they have no slot in hit_results. ``` -------------------------------- ### Locate Test Resources Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/TEST_WRITING_GUIDE.md Use Path.of to resolve paths to test resource files within the project structure. ```java private final Path resourceDirectory = Path.of("src", "test", "resources"); private final Path testRoundtripDirectory = resourceDirectory.resolve("roundtrip"); private final Path configFile = testRoundtripDirectory.resolve("config_AddressFilesToLMDB.json"); ``` -------------------------------- ### Canonical Test Structure for Helper Classes Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/skills/tdd.md Demonstrates the required AAA structure, editor-fold grouping, and Hamcrest assertion usage for helper class testing. ```java // Bech32HelperTest.java — canonical structure public class Bech32HelperTest { private final KeyUtility keyUtility = new KeyUtility( new NetworkParameterFactory().getNetwork(), new ByteBufferUtility(false)); // @Test public void decodeBech32CharsetToValues_fullCharset_returnsValuesZeroToThirtyOne() { // arrange Bech32Helper sut = new Bech32Helper(); byte[] expected = {0,1,2,...,31}; // act byte[] result = sut.decodeBech32CharsetToValues(Bech32Helper.CHARSET); // assert assertThat(result, is(expected)); } @Test(expected = IllegalArgumentException.class) public void decodeBech32CharsetToValues_invalidCharacter_throwsException() { // arrange Bech32Helper sut = new Bech32Helper(); // act sut.decodeBech32CharsetToValues("i"); // 'i' is not in the Bech32 character set } // } ``` -------------------------------- ### Create a feature branch Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/CONTRIBUTING.md Create a new branch from the main branch to isolate feature development. ```bash git checkout -b feat/my-feature main ``` -------------------------------- ### Conditionally skip tests with OpenCLPlatformAssume Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/TEST_WRITING_GUIDE.md Use the OpenCLPlatformAssume class to skip tests if the required OpenCL environment is not available on the host platform. ```java @OpenCLTest @Test public void build_oneOpenCLDevice_returnsPlatformWithDevice() { new OpenCLPlatformAssume().assumeOpenCLLibraryLoadableAndOneOpenCL2_0OrGreaterDeviceAvailable(); // test body } ``` -------------------------------- ### Benchmark safegcd performance with JMH Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/performance.md Execute a JMH benchmark to compare safegcd against the legacy binary GCD implementation using specific kernel parameters. ```bash # (after the classpath step in §6) — sweeps the inverse at the operating point java <--add-opens flags from §6> -cp "target/test-classes;target/classes;$(cat target/cp-test.txt)" \ org.openjdk.jmh.Main GpuFuse8FilterBenchmark \ -p gpuFilter=true -p batchSizeInBits=19 -p keysPerWorkItem=128 \ -p useSafeGcdInverse=true,false -f 1 -wi 1 -w 20 -i 3 -r 40 ``` -------------------------------- ### Run Kernel Performance Benchmark Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/performance.md Executes the GpuFuse8FilterBenchmark using JMH to measure performance across different kernel profiling stages. ```bash # (after the classpath step above) — compact mode keeps it compute-bound java <--add-opens flags> -cp "target/test-classes;target/classes;$(cat target/cp-test.txt)" \ org.openjdk.jmh.Main GpuFuse8FilterBenchmark \ -p gpuFilter=true -p batchSizeInBits=20 -p keysPerWorkItem=128 \ -p kernelProfileStage=FULL,ONE_HASH160,NO_HASH160 -f 1 -wi 1 -w 20 -i 3 -r 20 ``` -------------------------------- ### Producer-Consumer Architecture Pattern Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/CLAUDE.md Visual representation of the data flow between key producers and the address consumer. ```text [Producers] → LinkedBlockingQueue → [ConsumerJava] ``` -------------------------------- ### Adjust keysPerWorkItemCandidates Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/tuning-your-gpu.md Define the range of work item candidates to sweep, with larger values recommended for modern GPUs. ```json "keysPerWorkItemCandidates": [1, 4, 16, 64, 256], ``` ```json "keysPerWorkItemCandidates": [16, 64, 256, 512, 1024, 2048], ``` -------------------------------- ### Use BitHelper Radix Constants Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/CODE_WRITING_GUIDE.md Always reference radix values through BitHelper constants instead of using bare integer literals. ```java // ❌ BAD new BigInteger("FF", 16); // ✅ GOOD new BigInteger("FF", BitHelper.RADIX_HEX); ``` -------------------------------- ### Configure Socket Timeouts Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/TEST_WRITING_GUIDE.md Use TestTimeProvider constants to ensure consistent socket timeout and retry configurations in tests. ```java config.timeout = TestTimeProvider.DEFAULT_SOCKET_TIMEOUT; config.readRetryCount = TestTimeProvider.DEFAULT_RETRY_COUNT; ``` -------------------------------- ### Set targetDatabaseEntries Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/tuning-your-gpu.md Specify the total number of addresses in the target database to ensure accurate synthetic filter sizing. ```json "targetDatabaseEntries": 141045995, ``` -------------------------------- ### CSV column layout Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/tuning-your-gpu.md The required header format for contributing performance data via CSV files. ```text machine_id,gpu,date,batch_size_in_bits,keys_per_work_item,candidates_per_second,addresses_checked_per_second,seconds_per_arm,warmup_seconds,verification_micros_measured,winner,kernel ``` -------------------------------- ### Configure Windows Batch Script Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/tuning-your-gpu.md Modify the batch file to specify the configuration filename and enable output redirection. ```bat config_TuneConfiguration_gpu0.json ``` ```bat >> log_TuneConfiguration_gpu0.txt 2>&1 ``` -------------------------------- ### WebSocket Scanner Logic Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/examples/websocket_scanner.html Core functions for managing WebSocket connections, batch processing, and UI updates for the Bitcoin address scanner. ```javascript */ function pump() { if (!running || !ws || ws.readyState !== WebSocket.OPEN) return; const lookahead = parseInt($("lookahead").value, 10) || 1; while (inFlight < lookahead) { let base; if ($("mode").value === "random") { base = randomBase(); } else { if (nextBase >= toBase) { if (inFlight === 0) { log("Range complete."); stop(); } return; } base = nextBase; nextBase += step; } ws.send(toFixedBytes(base)); sent++; inFlight++; $("statSent").textContent = sent; renderBits(base); flashBlock(base.toString(16)); } } function onBatch(msg) { checked++; keys += msg.checkedCount || 0; inFlight = Math.max(0, inFlight - 1); $("statChecked").textContent = checked; $("statKeys").textContent = keys; if (msg.secretBase) { const hex = BigInt("0x" + msg.secretBase).toString(16); markBlock(hex, msg.hits && msg.hits.length ? "hit" : "done"); } if (msg.hits && msg.hits.length) { hits += msg.hits.length; $("statHits").textContent = hits; for (const h of msg.hits) { log("HIT address=" + h.address + " compressed=" + h.compressed + "\n privateKey=" + h.privateKey, true); } } pump(); } function onConfig(msg) { config = msg; step = 1n << BigInt(msg.batchSizeInBits); $("bitsLabel").textContent = msg.batchSizeInBits; $("configLine").textContent = "Server grid: batchSizeInBits=" + msg.batchSizeInBits + " (" + step.toString() + " keys per message), secretByteLength=" + msg.secretByteLength; const warn = $("configWarning"); if (!msg.batchUsePrivateKeyIncrement) { warn.className = "danger"; warn.textContent = "This server runs with batchUsePrivateKeyIncrement=false. It then wants one secret per " + "candidate instead of one base per grid, which this page cannot feed at a useful rate. " + "Set it to true in the producer configuration."; $("btnStart").disabled = true; } else { warn.className = ""; warn.textContent = ""; $("btnStart").disabled = false; } } function connect() { ws = new WebSocket($("wsUrl").value); ws.binaryType = "arraybuffer"; ws.onopen = () => { $("btnConnect").disabled = true; $("btnDisconnect").disabled = false; $("configLine").textContent = "Connected. Waiting for the server to announce its grid size…"; }; ws.onmessage = (event) => { let msg; try { msg = JSON.parse(event.data); } catch (e) { return; } if (msg.type === "config") onConfig(msg); else if (msg.type === "batch") onBatch(msg); }; ws.onclose = () => { stop(); $("btnConnect").disabled = false; $("btnDisconnect").disabled = true; $("btnStart").disabled = true; $("configLine").textContent = "Disconnected."; }; ws.onerror = () => log("WebSocket error — is the server running and is broadcastResults enabled?"); } function start() { if (!config) { log("No server configuration yet."); return; } fromBase = alignDown(BigInt("0x" + $("fromHex").value.trim().replace(/^0x/, ""))); toBase = alignDown(BigInt("0x" + $("toHex").value.trim().replace(/^0x/, ""))); nextBase = fromBase; sent = checked = hits = keys = 0; inFlight = 0; $("statSent").textContent = $("statChecked").textContent = $("statHits").textContent = $("statKeys").textContent = 0; buildMap(); running = true; $("btnStart").disabled = true; $("btnStop").disabled = false; pump(); } function stop() { running = false; $("btnStart").disabled = !config; $("btnStop").disabled = true; } $("btnConnect").onclick = connect; $("btnDisconnect").onclick = () => { if (ws) ws.close(); }; $("btnStart").onclick = start; $("btnStop").onclick = stop; ``` -------------------------------- ### WebSocket and UI Control Logic Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/examples/websocket.html Functions to manage WebSocket connections, automate rounds, and update the visual grid based on generated bit patterns. ```javascript let round = 0; let running = false; let intervalId = null; let ws = null; function connectWebSocket() { const url = document.getElementById("wsUrl").value; if (ws && ws.readyState <= 1) return; ws = new WebSocket(url); ws.onopen = () => console.log("WebSocket connected"); ws.onmessage = (event) => console.log("Received:", event.data); ws.onerror = (err) => console.error("WebSocket error:", err); ws.onclose = () => console.log("WebSocket closed"); } function disconnectWebSocket() { if (ws) ws.close(); } function startRounds() { if (running) return; const delay = parseInt(document.getElementById("delay").value, 10) || 1000; running = true; intervalId = setInterval(() => { round++; document.getElementById("roundDisplay").textContent = `Round: ${round}`; runUserCode(round); }, delay); } function stopRounds() { running = false; clearInterval(intervalId); } function runUserCode(currentRound) { const code = document.getElementById("userScript").value; const wrapper = `(function(round) { ${code} return createNumber(round); })`; try { const generatedFunc = eval(wrapper); const result = generatedFunc(currentRound); updateGrid(result); if (ws && ws.readyState === WebSocket.OPEN) { ws.send(result); } } catch (e) { console.error("Error in user script:", e); } } function updateGrid(byteArray) { const bitGrid = document.getElementById("bitGrid"); bitGrid.innerHTML = ""; const bits = []; for (let i = 0; i < byteArray.length; i++) { for (let b = 7; b >= 0; b--) { bits.push((byteArray[i] >> b) & 1); } } while (bits.length < 256) bits.push(0); bits.length = 256; const reversed = [...bits].reverse(); for (let i = 0; i < 256; i++) { const div = document.createElement("div"); div.className = "cell" + (reversed[i] ? " on" : ""); div.textContent = 256 - i; bitGrid.appendChild(div); } document.getElementById("bitString").textContent = reversed.join(""); let hex = ""; for (let i = 0; i < 32; i++) { let byte = 0; for (let j = 0; j < 8; j++) { byte = (byte << 1) | reversed[i * 8 + j]; } hex += byte.toString(16).padStart(2, "0"); } document.getElementById("hexString").textContent = hex; } runUserCode(0); ``` -------------------------------- ### Implement timing-sensitive tests with @AwaitTimeTest Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/TEST_WRITING_GUIDE.md Tests asserting on durations must use AwaitTimeTests constants and override POJO configuration fields instead of relying on static state. ```java @AwaitTimeTest @Test public void interrupt_keysQueueNotEmpty_waitedForDuration() throws IOException, InterruptedException { CConsumerJava cConsumerJava = new CConsumerJava(); cConsumerJava.awaitQueueEmptySeconds = AwaitTimeTests.AWAIT_DURATION.toSeconds(); // ... arrange, including building the ConsumerJava from cConsumerJava ... long beforeAct = System.currentTimeMillis(); consumerJava.interrupt(); long afterAct = System.currentTimeMillis(); Duration waitTime = Duration.ofMillis(afterAct - beforeAct); assertThat(waitTime, is(greaterThan( AwaitTimeTests.AWAIT_DURATION.minus(AwaitTimeTests.IMPRECISION) ))); } ``` -------------------------------- ### Inject Behavior via Lambda Callbacks Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/CODE_WRITING_GUIDE.md Use functional interfaces for dependency injection in constructors instead of relying on subclassing. ```java public AddressFile( File file, ReadStatistic readStatistic, Network network, Consumer addressConsumer, Consumer rejectedLineConsumer ) { ... } ``` -------------------------------- ### Define Shared Test Fields Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/TEST_WRITING_GUIDE.md Commonly used fields for BitcoinAddressFinder tests including network, key utility, and bit helper. ```java private final Network network = new NetworkParameterFactory().getNetwork(); private final KeyUtility keyUtility = new KeyUtility(network, new ByteBufferUtility(false)); private final BitHelper bitHelper = new BitHelper(); ``` -------------------------------- ### MurmurHash3 64-bit Primitive Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/TODO.md The core hash primitive used for Fuse8 filter calculations in the OpenCL kernel. ```c static ulong murmur64(ulong h) { // 5 lines — the entire hash primitive h ^= h >> 33; h *= 0xff51afd7ed558ccdUL; h ^= h >> 33; h *= 0xc4ceb9fe1a85ec53UL; h ^= h >> 33; return h; } ``` -------------------------------- ### Binary Fuse Filter Lookup Logic Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/TODO.md The core lookup logic using Murmur3 finalizer and fingerprint reduction, designed to be portable between Java and OpenCL C. ```java // Java (identical logic to the OpenCL kernel below) long h = murmur64(key ^ seed); // Murmur3 finalizer (3 multiplies + shifts) byte fp = (byte)(h ^ (h >>> 32)); // 8-bit fingerprint int h0 = reduce((int)h, seg); // reduce(x,m) = (uint)(x * (ulong)m >>> 32) int h1 = reduce((int)(h >> 21), seg) + seg; int h2 = reduce((int)(h >> 42), seg) + 2 * seg; return (table[h0] ^ table[h1] ^ table[h2]) == fp; ``` -------------------------------- ### Implement Interruptable Interface Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/CODE_WRITING_GUIDE.md Producer and consumer classes must implement the Interruptable interface to support graceful shutdown. ```java public class MyProducer extends AbstractProducer implements Interruptable { @Override public void interrupt() { // signal the work loop to stop } } ``` -------------------------------- ### Regenerate performance plots and tables Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/measurements/README.md Executes the plotting script to update all performance visualizations and generated tables based on the current CSV data. ```bash python docs/measurements/plot.py ``` -------------------------------- ### Define OpenCL result struct memory layout Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/TODO.md Updated memory layout for the OpenCL result struct to accommodate flags and padding for 4-byte alignment. ```text [0–31] X coordinate (32 bytes, unchanged) [32–63] Y coordinate (32 bytes, unchanged) [64–83] hash160 uncompressed (20 bytes, unchanged) [84–103] hash160 compressed (20 bytes, unchanged) [104] flags (uint8_t) [105–107] padding to 4-byte alignment = 108 bytes/work-item (+4 bytes vs today's 104, +3.8 % PCIe bandwidth) ``` -------------------------------- ### Total Cost Calculation Formula Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/docs/filter-selection.md The mathematical model used to determine the total cost of a filter lookup. ```text total = probe + false-positive-rate × verification ``` -------------------------------- ### Apply @ToStringTest annotation Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/TEST_WRITING_GUIDE.md Use this annotation when validating toString() implementations to ensure proper test categorization. ```java @ToStringTest @Test public void toString_whenCalled_containsClassNameAndIdentityHash() { // ... assertThat(output, matchesPattern("ProducerJava@\\p{XDigit}+")); } ``` -------------------------------- ### Bit Manipulation and Randomization Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/examples/websocket.html Functions to set specific bits in a byte array and generate a random number based on a specified bit count. ```javascript function setBitsInRange(secret, randomBytes, bitOffset, bitCount) { for (let i = 0; i < bitCount; i++) { const bitVal = (randomBytes[Math.floor(i / 8)] >> (7 - (i % 8))) & 1; const bitIndex = bitOffset + i; const byteIndex = Math.floor(bitIndex / 8); const bitPos = 7 - (bitIndex % 8); if (bitVal) { secret[byteIndex] |= (1 << bitPos); } } } function create_random_LSB(bitsToSet) { const secret = new Uint8Array(32); // 256 bits = 32 bytes const bitOffset = 0; // start at LSB const randomBytes = new Uint8Array(Math.ceil(bitsToSet / 8)); crypto.getRandomValues(randomBytes); setBitsInRange(secret, randomBytes, bitOffset, bitsToSet); return secret; } function createNumber(round) { return create_random_LSB(71); } ``` -------------------------------- ### Disable LMDB Tests Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/CLAUDE.md System property to skip LMDB-related tests during execution. ```bash -Dnet.ladenthin.bitcoinaddressfinder.disableLMDBTest=true ``` -------------------------------- ### Define GPU-side result flags bitmask Source: https://github.com/bernardladenthin/bitcoinaddressfinder/blob/main/TODO.md Bitmask structure for the uint8_t flags field in the GPU result struct, indicating address lookup results. ```text bit 0 (0x01): uncompressed hash160 lookup positive — no false negatives guaranteed bit 1 (0x02): compressed hash160 lookup positive — no false negatives guaranteed bits 2–7: reserved for future address-type variants (P2SH, bech32, …) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.