From 1ddde97548e088c6a7fc88e66f2fb9c67f527758 Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Sun, 10 Mar 2024 19:33:04 +0100 Subject: [PATCH] Initial commit --- pom.xml | 54 +++++++++++++++++++ .../jmaa/pbc/PbcVanityAddressSearcher.java | 52 ++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 pom.xml create mode 100644 src/main/jmaa/pbc/PbcVanityAddressSearcher.java diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..403986a --- /dev/null +++ b/pom.xml @@ -0,0 +1,54 @@ + + + 4.0.0 + jmaa + pbc-vanity-address + jar + 4.0.0 + + + + AGPL-3.0-or-later + https://www.gnu.org/licenses/agpl.txt + repo + + + + + + gitlab-partisiablockchain + https://gitlab.com/api/v4/groups/12499775/-/packages/maven/ + + + + + com.partisiablockchain + pom + 4.57.0 + + + + + com.secata.tools + coverage + + + com.partisiablockchain.core + blockchain + 4.74.0 + + + ch.qos.logback + logback-classic + 1.4.12 + + + + + 17 + 17 + UTF-8 + + diff --git a/src/main/jmaa/pbc/PbcVanityAddressSearcher.java b/src/main/jmaa/pbc/PbcVanityAddressSearcher.java new file mode 100644 index 0000000..68df91b --- /dev/null +++ b/src/main/jmaa/pbc/PbcVanityAddressSearcher.java @@ -0,0 +1,52 @@ +package jmaa.pbc; + +/** Search for PBC vanity addresses. + * + *

Based on Jesper Balman Gravgaard's original version. + */ +public final class PbcVanityAddressSearcher { + + /** The vanity prefix to hunt for. */ + public static final String VANITY_PREFIX = "00badc0de"; + + @Test + void randomKeys() throws InterruptedException { + List searchers = new ArrayList<>(); + for(int i=0;i<8;i++) { + final Thread searcher = new Thread(new KeySearcher(i)); + searcher.start(); + searchers.add(searcher); + } + + for (Thread searcher : searchers) { + searcher.join(); + } + + } + + record KeySearcher(int id) implements Runnable { + + @Override + public void run() { + long start = System.nanoTime(); + for(int i=0;i<100_000_000;i++) { + final KeyPair keyPair = new KeyPair(); + final BlockchainPublicKey publicKey = keyPair.getPublic(); + final BlockchainAddress address = publicKey.createAddress(); + if(address.writeAsString().startsWith(VANITY_PREFIX)) { + System.out.println("["+id+"] match: "+address.writeAsString()+ " - "+keyPair.getPrivateKey().toString(16)); + } + if (i % 1_000_000 == 0) { + final long now = System.nanoTime(); + final long duration = (now - start) / 1_000_000; + System.out.print("["+id+":"+i+"] "+duration+" "); + start = now; + } + if ((id==0) && (i % 1_000_000 == 10_000)) { + System.out.println(); + } + } + } + } + +}