Skip to content

RingSide Replay Attack: Recovering the SEED → deriving Bitcoin wallet private keys and how 32-bit entropy instead of 256-bit led to the systematic compromise of crypto-asset funds.

Notifications You must be signed in to change notification settings

demining/RingSide-Replay-Attack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

RingSide Replay Attack: Recovering the SEED → deriving Bitcoin wallet private keys and how 32-bit entropy instead of 256-bit led to the systematic compromise of crypto-asset funds

This paper presents a comprehensive cryptanalytic review of the critical vulnerability  CVE-2023-39910 , codenamed  “Milk Sad ,” discovered in the widely used  Libbitcoin Explorer utility versions 3.0.0–3.6.0. The fundamental flaw lies in the use of a cryptographically insecure Mersenne Twister-32 (MT19937)  pseudorandom number generator  initialized by the system time, which catastrophically limits the entropy space to  32 bits  instead of the required 256 bits. The paper thoroughly examines the mechanism of  the RingSide Replay Attack , which allows for the automated recovery of Bitcoin wallet private keys, including lost ones, given the approximate time of their creation. A scientific analysis demonstrates that the vulnerability led to the compromise of over  227,200 unique Bitcoin addresses  and the theft of over  $900,000 USD in crypto assets .



Particular attention is given to the mathematical foundations of the attack, a practical methodology for recovering private keys using the  BTCDetect cryptographic tool , and recommendations for protecting cryptographic systems from entropy-based attacks.

1. Cryptographic Security and the Randomness Paradigm in the Bitcoin Ecosystem

The Bitcoin cryptocurrency ecosystem is a complex decentralized system whose security is fundamentally based on the principles of modern cryptography. The central element of this architecture is the Elliptic Curve Digital Signature Algorithm (ECDSA), implemented on a specialized  secp256k1 curve . However, even a mathematically flawless cryptographic scheme becomes completely vulnerable if its fundamental condition—high-quality random number generation—is violated.

1.1 Theoretical Foundations of Bitcoin Cryptographic Security

The Bitcoin network’s security is based on the computational difficulty of the Elliptic Curve Discrete Logarithm Problem ( ECDLP ).


RingSide Replay Attack: Recovering the SEED → deriving Bitcoin wallet private keys and how 32-bit entropy instead of 256-bit led to the systematic compromise of crypto-asset funds


The private key  k  is a random 256-bit integer that must be:

  • Absolutely unpredictable  – impossible to guess or calculate
  • Unique  – no collisions with other keys
  • Cryptographically secure  – resistant to known attacks

The public key  Q  is generated as a point on the elliptic curve by the scalar product of the private key and the generator point  G :

Q = k · G

where k is a private key ∈ [1, n-1], G is a generator point of the secp256k1 curve, n is the order of the group

The elliptic curve  secp256k1  is defined by the Weierstrass equation in abbreviated form:

y² ≡ x³ + 7 (mod p)

where p = 2 256  − 2 32  − 977 ≈ 1.158 × 10 77

The order of the group  n  of the curve secp256k1 is:

n = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141

n ≈ 1.158 × 10 77

The theoretical security of this cryptosystem is determined by the fact that the inverse operation—computing a private key  k  given a known public key  Q  —is computationally infeasible when correctly implemented. However, this statement is only true if the space of possible values  ​​of k  remains maximal ( ≈2256 ).

1.2 The fundamental role of entropy in cryptographic systems

The concept  of entropy  in cryptography dates back to the work of Claude Shannon, who laid the theoretical foundations of information theory. Shannon’s entropy is defined as a measure of uncertainty (randomness) in a system:

H(X) = −Σ p(xᵢ) log₂ p(xᵢ)

where H(X) is the entropy of a random variable X, p(xᵢ) is the probability of event xᵢ

Cryptographic applications require  maximum entropy , where all possible values ​​are equally probable. For a 256-bit Bitcoin private key, this means:

max  = log₂(2 256 ) = 256 bits

The critical importance of entropy is this: if a random number generator (RNG) produces predictable output or has a limited value space, an attacker can  try all possible private keys and recover cryptographic secrets. It was this fundamental flaw that caused the catastrophic Milk Sad  vulnerability  .

Definition 1 (Cryptographically secure PRNG):  A pseudorandom number generator (PRNG) is said to be cryptographically secure if, given the first  k  output bits, it is computationally infeasible to predict the (k+1)th bit with probability greater than ½ + ε, where ε is negligibly small.

1.3. Historical chronology of vulnerability discovery

In June-July 2023, security researchers detected an anomalous phenomenon in the Bitcoin blockchain: numerous wallets created at various times began systematically being emptied, despite the lack of communication between their owners. The  Distrust research team  conducted a comprehensive forensic analysis and determined that all compromised wallets had one thing in common: they were created using a command  bx seed from  Libbitcoin Explorer  version 3.x.

The results of the investigation were catastrophic:

ParameterMeaning
Total amount of funds stolen> $900,000 USD
Affected cryptocurrenciesBTC, ETH, XRP, DOGE, SOL, LTC, BCH, ZEC
Compromised Bitcoin addresses> 227,200
Vulnerable versions of Libbitcoin Explorer3.0.0 – 3.6.0
Period of operationJune – July 2023

The codename  “Milk Sad”  was proposed by researchers as the first two words of the BIP-39 mnemonic phrase generated with a zero seed (seed = 0), symbolically reflecting the “sad” state of a “milky” (immature, childish) cryptographic implementation.


2.1. Mersenne Twister Algorithm: Architecture and Cryptographic Weaknesses

Mersenne Twister (MT19937)  is a pseudorandom number generator developed by Makoto Matsumoto and Takuji Nishimura in 1997. The algorithm is based on a linear recurrent sequence over the finite field GF(2) and has the following characteristics:

ParameterThe meaning of MT19937
Period19937  − 1 (Mersenne number)
Word size32 bits
Size of the state624 × 32 = 19968 bits
Seed size32 bits
Uniformity (k-distribution)623-dimensionally uniformly distributed

Despite its excellent statistical properties (passing Diehard, TestU01 tests), the Mersenne Twister is categorically  NOT intended  for cryptographic applications for the following critical reasons:

Critical cryptographic flaws MT19937:

  • Linearity:  Internal state can be completely reconstructed from 624 consecutive 32-bit outputs
  • Limited seed space:  Only 2 32  ≈ 4.29 × 10 9  possible initial states
  • Determinism:  Identical seeds produce identical sequences
  • Predictability:  Given a known state, all past and future outputs can be calculated

2.2. Vulnerable implementation in Libbitcoin Explorer

A critical error in Libbitcoin Explorer versions 3.0.0–3.6.0 was located in the entropy generation module:

// pseudo_random.cpp (VULNERABLE VERSION)
data_chunk random_bytes(size_t length) {
    std::random_device random;           // Getting seed (system time)
    std::default_random_engine engine(random());  // MT19937 c 32-bit seed
    std::uniform_int_distribution distribution(0, 255);

    data_chunk result(length);
    for (auto& byte : result)
        byte = distribution(engine);
    return result;
}

When calling the command,  bx seed -b 256 | bx mnemonic-new the user expected to receive 256 bits of cryptographically strong entropy to generate a 24-word BIP-39 mnemonic phrase. However, the actual results were disastrous:

Expected entropy: 2256  ≈ 1.16 × 1077 Actual
entropy: 232  ≈ 4.29 × 109

Search space reduction: 10 68  times

Let’s formalize the vulnerability using rigorous mathematical notation. Let:

  • E  is the entropy (256 bits) generated to create the wallet
  • S  is the seed for MT19937, where S ∈ [0, 2 32 )
  • f(S)  is the function for generating the MT19937 sequence from seed  S
  • trunc 32 (x)  — extract the first 32 bytes from a sequence
  • bip39(E)  — entropy-to-mnemonic-phrase conversion
  • derive(m)  — derivation of a private key from a BIP-32 mnemonic
  • addr(k)  is a set of Bitcoin addresses, derivatives of the private key  k

Definition 2 (Milk Sad Vulnerability):
There exists a seed S such that:

∃ k, S : trunc 32 (f(S)) ≡ E (mod 2 256 )


such that

addr(derive(bip39(E))) = A target

where A target  is the target Bitcoin address.

The probability of successful recovery with a complete search of the space 2 32 :

P(success) = 1 − (1 − 1/N) 232

where N = 2,160  is the total number of possible Bitcoin addresses (P2PKH)

Since 2 32  ≪ 2 160 , the probability of a false match is negligible, and when the correct seed is found,  P(success) ≈ 1 .

2.4 Deterministic BIP-39/BIP-32 Transformation Chain

Once the original 32-bit seed is recovered , the private key reconstruction process becomes fully deterministic according to the BIP-39 and BIP-32 standards:

  1. Entropy generation:  seed → MT19937 → 256-bit pseudorandom sequence
  2. Checksum calculation:  SHA-256(entropy) → first 8 bits
  3. Mnemonic formation:  (entropy || checksum) → 24 BIP-39 words
  4. Master seed derivation:  PBKDF2-HMAC-SHA512(mnemonic, “mnemonic” || passphrase, 2048 iterations) → 512-bit seed
  5. Master key generation:  HMAC-SHA512(” Bitcoin seed “, master_seed) → (master_private_key, chain_code)
  6. Hierarchical derivation:  BIP-44 path: m/44’/0’/0’/0/0 → final private key

Transformation chain:

32bit  → MT19937 → E 256bit  → SHA256 → Mnemonic 24words  → PBKDF2 → Seed 512bit  → HMAC-SHA512 → (k, c) → BIP-44 → k final


3. RingSide Replay Attack Efficiency: Computational Analysis

3.1. Estimation of computational complexity

The total search space is 2 32  ≈ 4.29 × 10 9  possible seed values. If the wallet creation date (or approximate range) is known, the search space can be significantly reduced:

Space reduction with known date:

|S day | = 86,400 (seconds in a day)
Reduction: 2 32  / 86,400 ≈ 49,710 times

Performance on modern equipment:

EquipmentSearch speedThe time for a full search is 2 32
CPU (Intel i9-13900K)~10 6  seeds/sec~71 minutes
GPU (NVIDIA RTX 4090)~10 8  seeds/sec~43 seconds
FPGA cluster~10 10  seeds/sec< 1 second

3.2 Quantitative assessment of attack effectiveness

The effectiveness of the attack can be expressed through the ratio of the logarithms of the search spaces:

Attack Efficiency = log₂(2 32 ) / log₂(2 256 ) = 32/256 = 0.125 = 12.5%

This means that the search space is reduced by 87.5% from the theoretically safe level.


RingSide Replay Attack: Recovering the SEED → deriving Bitcoin wallet private keys and how 32-bit entropy instead of 256-bit led to the systematic compromise of crypto-asset funds

www.cryptou.ru/btcdetect


A Scientific Analysis of Using BTCDetect to Recover Private Keys

BTCDetect  is specialized software for cryptanalysis and recovery of lost Bitcoin wallets, based on identifying and exploiting vulnerabilities in cryptographic libraries. The tool implements the RingSide Replay Attack methodology and provides a practical implementation for recovering private keys from vulnerable wallets.


BTCDetect Architecture

BTCDetect consists of the following main modules:

  • Entropy Analysis Module:  Detecting Weak Sources of Randomness in Key Generation Procedures
  • PRNG Reconstruction Module :  Reproducing the state of a Mersenne Twister generator using known parameters
  • Key Derivation Module:  Implementation of a full BIP-39/BIP-32 chain for key recovery
  • Verification Module:  Matching recovered addresses with target blockchain data

BTCDetect’s algorithm

BTCDetect’s operating model consists of three main stages:

  1. Identifying vulnerable wallets:
  2. Enumerating the seed space:
    • Generating seed candidates based on a time range
    • Parallel computation of BIP-39 → BIP-32 chains
    • Comparison of received addresses with target ones
  3. Verification and recovery:
    • Confirming the correctness of the recovered key
    • Checking the validity of signatures
    • Documenting the results for forensic analysis

Let’s consider a documented case of private key recovery :

ParameterMeaning
Bitcoin address1NiojfedphT6MgMD7UsowNdQmx5JY15djG
Cost of recovered funds$61,025
Recovered private key (HEX)4ACBB2E3CE1EE22224219B71E3B72BF6C8F2C9AA1D992666DBD8B48AA826FF6B
Recovered key (WIF compressed)Kyj6yvb4oHHDGBW23C8Chzji3zdYQ5QMr8r9zWpGVHdvWuYqCGVU
Public key (compressed)03AE73430C02577F3A7DA6F3EDC51AF4ECBB41962B937DBC2D382CABB11D0D18CE

Validation of the recovered key confirms that it belongs to the acceptable range of scalars of the secp256k1 curve:

1 ≤ k < n

where n = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141

The scientific significance of BTCDetect

The BTCDetect methodology has broad scientific applications beyond the specific Milk Sad vulnerability:

  • Research of PRNG classes of vulnerabilities :  Linear congruential generators (LCG), insecure implementations random()
  • Blockchain Forensics:  Identifying Patterns of Compromised Wallets
  • Auditing Cryptographic Libraries:  Detecting Potential Vulnerabilities Before They Are Exploited
  • Educational Objectives:  To demonstrate the critical importance of cryptographically strong PRNGs

The Borromean hash function vulnerability

static ec_scalar borromean_hash(const hash_digest& M, const data_slice& R,
                                 uint32_t i, uint32_t j) NOEXCEPT
{
    // e = H(M || R || i || j)
    hash_digest hash{};
    stream::out::fast stream{ hash };
    hash::sha256::fast sink(stream);
    sink.write_bytes(R);
    sink.write_bytes(M);
    sink.write_4_bytes_big_endian(i);
    sink.write_4_bytes_big_endian(j);
    sink.flush();
    return hash;
}

The order of data concatenation (R || M || i || j) creates potential for length extension attacks in certain scenarios .

6.1. Requirements for entropy generation

PlatformRecommended source of entropy
Linux/Unix/dev/urandom or getrandom()
WindowsCryptGenRandom() or BCrypt API
PythonModule  secrets or os.urandom()
Crypto librariesOpenSSL  RAND_bytes(), libsodium randombytes()

This paper presents a detailed cryptanalysis of a critical vulnerability, designated  CVE-2023-39910 , codenamed  Milk Sad . The vulnerability was discovered in the popular  Libbitcoin Explorer  utility (versions 3.0.0–3.6.0) , which is used to create and manage Bitcoin wallets offline. The main flaw lies in the use of a cryptographically insecure  Mersenne Twister-32 (MT19937) pseudorandom number generator , initialized using the system time, which limits the entropy space to only  32 bits . This paper examines the mechanism of  the Ringside Replay Attack , which allows attackers to automate the process of recovering Bitcoin wallet private keys, including recovering lost wallets if their approximate creation time is known. Scientific analysis shows that the vulnerability led to the compromise of over  227,200 unique Bitcoin addresses  and the theft of cryptocurrency worth over  $900,000 . The article details the mathematical underpinnings of the attack, the private key recovery methodology, and the  BTCDetect crypto tool used to implement the recovery. It also provides security recommendations and countermeasures for cryptocurrency wallet developers and users.


1. The significance of the validation problem

The Bitcoin network’s security is fundamentally based on elliptic curve cryptography (ECDSA), specifically the  secp256k1 curve . A private key is a random 256-bit number that must be completely unpredictable and unique for each Bitcoin address. The public key is generated as a point on the elliptic curve by multiplying the curve generator G by the private key:

Q = k · G,
where k is the private key

The security of this mechanism depends entirely on the quality of the entropy used to generate the private key. If the random number generator (RNG) is predictable or has a limited value space, an attacker can try all possible private keys and recover cryptographic secrets. It was this fundamental vulnerability that caused  the Milk Sad disaster .

In June-July 2023, an unusual phenomenon was discovered on the Bitcoin blockchain: multiple wallets created in different years began to empty on the same date, despite no connection between their owners. The research team Distrust conducted a detailed analysis and discovered that all the compromised wallets had one thing in common: they were created using a command  bx seed from Libbitcoin Explorer version 3.x.


2. History of the Milk Sad vulnerability discovery

According to research, over  $900,000  worth of cryptocurrency (including BTC, ETH, XRP, DOGE, SOL, LTC, BCH, and ZEC) was stolen . Later, in 2025, the Milk Sad team updated their analysis and found that the number of compromised wallets amounted to over  227,200 unique Bitcoin addresses , making this attack one of the largest in the history of cryptocurrency security.

An investigation by Milk Sad, launched earlier in 2023, revealed that victims created their wallets on isolated Linux laptops using commands in Libbitcoin Explorer . In each case, users used bx to generate 24-word BIP39 mnemonic phrases, believing the tool provided sufficient randomness.

One of the commands used to generate the wallet looked like this:

bx seed -b 256 | bx mnemonic-new

It generated 256 bits of entropy, which was then converted into a 24-word mnemonic phrase. Due to the imperfections of the random number generator, the supposedly secure mnemonic phrase was actually predictable. Although Milk Sad victims created their wallets several years apart, investigators discovered that each of them used the same version of Libbitcoin Explorer , which unknowingly generated weak private keys.


RingSide Replay Attack: SEED Recovery → Bitcoin wallet private key derivation and how 32-bit entropy instead of 256-bit led to the systematic compromise of crypto-asset funds

3. Theoretical Foundations of Bitcoin and ECDSA Cryptography

3.1 secp256k1 Curve and the ECDSA Standard

ECDSA (Elliptic Curve Digital Signature Algorithm) is a cryptographic algorithm based on elliptic curve cryptography. Bitcoin uses a specific curve called  secp256k1 , which is defined by the equation:

y² ≡ x³ + 7 (mod p)
where p = 2^256 − 2^32 − 977

The secp256k1 curve has order n ≈ 2^256, meaning there are approximately 2^256 possible points on the curve. Generator G is the standard generating point for this curve, which is used for all computations in Bitcoin .

3.2 The process of generating private and public keys

The process of generating a key pair in Bitcoin is as follows:

  1. Entropy generation:  A 256-bit random number is generated, which serves as the private key k. This number must be in the range 1 ≤ k < n, where n is the order of the base point.
  2. Public Key Computation:  The public key Q is computed as Q = k · G, where · denotes scalar multiplication on an elliptic curve.
  3. Address generation:  A Bitcoin address is generated by hashing a public key and encoding the result.

The critical point is the entropy generation in step 1. If a weak random number generator is used, the space of possible private keys becomes significantly smaller than 2^256, allowing an attacker to try all possible keys and find the private key.


RingSide Replay Attack: SEED Recovery → Bitcoin wallet private key derivation and how 32-bit entropy instead of 256-bit led to the systematic compromise of crypto-asset funds

4. Mersenne Twister-32: architecture and disadvantages

4.1 History and description of the algorithm

The Mersenne Twister (MT19937) is a pseudorandom number generator developed by Matsumoto and Nishimura in 1997. The algorithm is based on a linear recurrence sequence over a finite field and generates a sequence of 32-bit integers. The algorithm is widely used in non-unique applications due to its good statistical properties and computational speed.

However,  the Mersenne Twister is absolutely  NOT intended  for cryptographic applications for the following reasons:

  1. Predictability:  The output values ​​of the RNG can be completely reconstructed given a sequence of 624 consecutive 32-bit outputs.
  2. Analysis vulnerability:  The internal state consists of 624 32-bit integers; if an attacker knows these values, they can predict all future outputs.
  3. Lack of cryptographic strength property:  The algorithm does not have the property that it is impossible to calculate the i-th element of the sequence without calculating all previous elements.

4.2 Using Mersenne Twister in Libbitcoin Explorer 3.x

In Libbitcoin Explorer 3.x, the entropy generation process for creating new wallets is implemented as follows:

// pseudo_random.cpp (vulnerable version) data_chunk random_bytes(size_t length) { std::random_device random; std::default_random_engine engine(random()); std::uniform_int_distribution<uint32_t> distribution(0, 255); data_chunk result(length); for (auto& byte : result) byte = distribution(engine); return result; }

In this code:

  • std::random_device random initializes the seed using the system time
  • std::default_random_engine (which is implemented as  std::mt19937) receives a single value from random_device
  • This seed typically contains only  32 bits of useful entropy  (the current system time in seconds or milliseconds)

The team  bx seed uses this function to generate initial entropy when creating new Bitcoin wallets. Here’s a typical call:

bx seed -b 256 | bx mnemonic-new

This command would generate 256 bits of random entropy, which would then be converted into a 24-word BIP-39 mnemonic phrase. However, due to the 32-bit limitation of the actual entropy space from  std::random_device, the entire mnemonic phrase can be reconstructed given the wallet’s creation time.


RingSide Replay Attack: SEED Recovery → Bitcoin wallet private key derivation and how 32-bit entropy instead of 256-bit led to the systematic compromise of crypto-asset funds

5.1 Principle 1: Limited Entropy Space

The space of possible seed values ​​for MT19937 is limited to 2^32 combinations (approximately 4.3 billion possible values). This means that the entire entropy space can be searched in a few days on a regular PC.

Search space = 2^32 ≈ 4.29 × 10^9 possible values

5.2 Principle 2: Predictability in Creation Time

If the wallet creation date (or approximate date range) is known, the search space can be further reduced. The system time used to initialize MT19937 can be reconstructed with a high degree of certainty if the following are known:

  • Year the wallet was created
  • Month/day (if known from transaction history)
  • Approximate time of day

Reducing the search space to a date range, such as one day, reduces the number of attempts by a factor of approximately 86,400 (the number of seconds in a day).

Once the original 256-bit entropy has been recovered, its transformation into a private key is fully deterministic according to the BIP-39 and BIP-32 standards:

  1. Entropy → SHA-256checksum → 24-word BIP-39 phrase
  2. BIP-39 phrase + passphrase → PBKDF2-HMAC-SHA512(2048 iterations) → 512-bit master seed
  3. Master seed → HMAC-SHA512("Bitcoin seed")→ master private key + chaincode

5.4 Formal Mathematical Definition of Vulnerability

Let:

  • E— the entropy to be generated (256 bits)
  • S— seed for MT19937, where S ∈ [0, 2^32)
  • f(S)— a function that generates the MT19937 sequence from seed S
  • trunc_32(x) is a function that takes the first 32 bytes from the MT19937 sequence
  • bip39(E)— entropy transformation into BIP-39 mnemonics
  • derive(m)— converting mnemonics into a private key
  • addr(k)— the set of all possible Bitcoin addresses , derivatives of a private key k

Vulnerability is defined as:
∃ k, S : trunc_32(f(S)) ≡ E (mod 256)
such thataddr(derive(bip39(E))) = A_target

where A_target is the target Bitcoin address.

5.5 Probability of successful recovery

When searching through the entire space 2^32:

P(success) = 1 − (1 − 1/N)^(2^32)
where N = 2^160 is the total number of possible Bitcoin addresses (for P2PKH addresses)

Since 2^32 << 2^160, the probability of a false match is negligible, and P(success) ≈ 1when the correct seed is found.


RingSide Replay Attack: SEED Recovery → Bitcoin wallet private key derivation and how 32-bit entropy instead of 256-bit led to the systematic compromise of crypto-asset funds

6. Private key recovery process

6.1 Key recovery algorithm

The process of recovering a private key for a compromised Bitcoin wallet consists of the following steps:

  1. Determining a date range:  The approximate wallet creation date is determined from the transaction history. This can be a known date or a range from several months to a year.
  2. Iterating over seed values:  For each day in the date range, all possible seed values ​​corresponding to the timestamps of that day are iterated over (86,400 values ​​per day).
  3. Entropy generation:  For each seed value, an MT19937 sequence is generated, from which the first 32 bytes are extracted and interpreted as entropy.
  4. Conversion to mnemonic:  The generated entropy is converted into BIP-39 mnemonic.
  5. Private key derivation:  The mnemonic is converted into a private key according to the BIP-32 hierarchy.
  6. Address generation: A corresponding Bitcoin address  is generated from the private key .
  7. Match check:  If the generated address matches the target address, the recovery is considered successful.

6.2 Computational complexity

On modern equipment (for example GPU NVIDIA RTX 3090):

  • If the exact date is known:  approximately 86,400 checks = several minutes on one GPU
  • If the year is known:  approximately 365 × 86,400 ≈ 31,536,000 checks = several hours on one GPU
  • If the full 2^32 space is used:  approximately 4,294,967,296 checks = several days on a single GPU

These calculations show that recovering a private key is practically feasible even for non-professional attackers.


RingSide Replay Attack: SEED Recovery → Bitcoin wallet private key derivation and how 32-bit entropy instead of 256-bit led to the systematic compromise of crypto-asset funds

7. Real-world example: recovering the address key 1NiojfedphT6MgMD7UsowNdQmx5JY15djG

7.1 Initial data of compromise

Let’s look at a documented case of recovering a private key from the Bitcoin address  1NiojfedphT6MgMD7UsowNdQmx5JY15djG :

ParameterMeaning
Bitcoin address1NiojfedphT6MgMD7UsowNdQmx5JY15djG
Cost of recovered funds$61,025
Recovered private key (HEX)4ACBB2E3CE1EE22224219B71E3B72BF6C8F2C9AA1D992666DBD8B48AA826FF6B
Recovered private key (WIF compressed)Kyj6yvb4oHHDGBW23C8Chzji3zdYQ5QMr8r9zWpGVHdvWuYqCGVU
Recovered private key (Decimal)95490713496748161492785334010456634825357659290488148536925849552527657999353

7.2 Key validation in secp256k1 space

The private key k must satisfy the constraint:

1 ≤ k < n
where n = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
≈ 1.158 × 10^77

Check result:  ✓ VALID (the key is within the allowed scalar range)

7.3 Calculating the public key and address

The recovered private key allows us to calculate the public key:

ParameterMeaning
Public key (uncompressed, 130 characters)04BC79D7CC638214D0FE1902A8F3A0EEC3F2B41F5792043559AD6161D23467C23 4BCD34142146FF3E0DF1648A2B83F392B738AF7598C5B137C2A4500B6E12CECFD
Public key (compressed, 66 characters)03AE73430C02577F3A7DA6F3EDC51AF4ECBB41962B937DBC2D382CABB11D0D18CE
Bitcoin address (uncompressed)1NiojfedphT6MgMD7UsowNdQmx5JY15djG

7.4 Practical significance of the recovered key

A recovered private key gives  complete control  over the Bitcoin wallet, allowing an attacker to:

Possibilities with a recovered private key:

  • Create and sign transactions to withdraw all funds to a controlled address
  • Import the key into any Bitcoin wallet (Electrum, Bitcoin Core, MetaMask, etc.)
  • Take complete control of an address and all its assets
  • Hide traces of compromise by deleting all logs and history

RingSide Replay Attack: SEED Recovery → Bitcoin wallet private key derivation and how 32-bit entropy instead of 256-bit led to the systematic compromise of crypto-asset funds

8. BTCDetect crypto tool: architecture and capabilities

8.1 General Description of BTCDetect

BTCDetect is software designed to recover lost Bitcoin wallets by applying cryptanalysis techniques and identifying vulnerabilities in cryptographic libraries such as SharpECC. SharpECC is a C# library for working with elliptic curve cryptography (ECC), which underlies key and signature generation in the Bitcoin ecosystem.

Despite its popularity, SharpECC has a number of critical vulnerabilities and bugs that can serve as entry points for recovering private keys of lost wallets.

8.2 The Basic Mechanism of BTCDetect

BTCDetect’s core mechanism relies on vulnerabilities such as  nonce generation errors  when creating ECDSA digital signatures. These errors allow BTCDetect software to use multiple signatures generated using the same private key to calculate the private key itself.

The recovered private key provides  full control  over the BTC address and the funds associated with it.

8.3 Types of vulnerabilities used by BTCDetect

BTCDetect exploits the following main types of vulnerabilities to recover lost Bitcoin wallets:

  1. Nonce generation errors:  If the nonce (the nonce used in the ECDSA signature) is generated with insufficient entropy or is repeated, this may lead to private key recovery.
  2. Weak signatures (short signatures):  An incorrect implementation may generate signatures that do not completely cover the space of possible values.
  3. Validation Issues:  Incomplete verification of signatures may allow certain protections to be bypassed.

8.4 Key recovery process via BTCDetect

BTCDetect detects and exploits these vulnerabilities by analyzing signatures and cryptographic data, using cryptanalysis techniques to recover private keys. The process includes:

  1. Signature Analysis:  BTCDetect collects multiple signatures created using a single private key.
  2. Pattern Detection:  The program analyzes these signatures to look for patterns that indicate errors in nonce generation or other weaknesses.
  3. Cryptanalysis:  Using linear algebra and modular arithmetic, BTCDetect calculates a possible private key.
  4. Verification:  The recovered key is verified by generating the corresponding public key and Bitcoin address .
  5. Regain Control:  After verification, the user can regain full control of the wallet.

8.5 Differences between BTCDetect and traditional recovery methods

BTCDetect operates at the level of cryptographic implementation vulnerability, which distinguishes it from traditional recovery methods:

MethodRequiresPossibilities
Seed phrase (BIP-39)24 or 12 mnemonic wordsRecovering all keys in the hierarchy
Backups (wallet.dat)Wallet.dat fileRestore all wallets
Direct key entryPrivate key (WIF or HEX)Control over a specific address
BTCDetectMultiple signatures or transaction historyRecovering keys without the original recovery data

8.6 BTCDetect Architecture

BTCDetect consists of the following main components:

  • Data Collector:  Collects signatures, public keys, and data from the Bitcoin blockchain.
  • Signature Analyzer:  Analyzes ECDSA signatures to find vulnerabilities.
  • Cryptanalyzer:  Performs mathematical analysis to recover a private key.
  • Verifier:  Checks the correctness of the recovered key.
  • Recovery Tool:  Provides the ability to export and use the recovered key.

8.7 Practical Application of BTCDetect

BTCDetect is used for:

  • Cryptanalysis:  Identifying vulnerabilities in cryptographic implementations.
  • Wallet Recovery:  Recover access to lost Bitcoin wallets if they are vulnerable.
  • Forensic analysis:  Analysis of compromised wallets to identify the source of the leak.
  • Security Research:  Testing cryptographic libraries for weaknesses.

RingSide Replay Attack: SEED Recovery → Bitcoin wallet private key derivation and how 32-bit entropy instead of 256-bit led to the systematic compromise of crypto-asset funds


9. Countermeasures and recommendations

9.1 Immediate actions for affected users

⚠️ For users who created Bitcoin wallets using Libbitcoin Explorer 3.x :

  1. Immediate migration of funds:
    • Create a new wallet using a cryptographically secure entropy generation method
    • Transfer all funds to the new address
    • Destroy or use the old address only for monitoring
  2. Compromise check:
  3. Recovering lost funds:
    • If the wallet was created on a known date, recovery methods can be used to retrieve the private key.
    • Transfer recovered funds to a secure wallet

9.2 Improvements for developers

9.2.1 Using a Cryptographically Secure PRNG (CSPRNG)

Entropy generation requirements:

  • Linux/macOS: /dev/urandom  or getrandom()
  • Windows: CryptGenRandom()  or modern APIs
  • C++: std::random_device  (with implementation caveat)
  • Python: os.urandom() ,  secrets module

The correct way to generate entropy in C++:

#include <fstream> #include <array> void secure_random_bytes(uint8_t* buf, size_t len) { std::ifstream urandom("/dev/urandom", std::ios::in | std::ios::binary); if (!urandom) throw std::runtime_error("Cannot open /dev/urandom"); urandom.read(reinterpret_cast<char*>(buf), len); if (urandom.gcount() != static_cast<std::streamsize>(len)) throw std::runtime_error("Read error from /dev/urandom"); } // Generate a protected private key std::array<uint8_t, 32> secret; secure_random_bytes(secret.data(), secret.size());

9.2.2 Minimum entropy requirements

  • For Bitcoin private keys:  256 bits minimum
  • For BIP-39 mnemonics:  128-256 bits depending on length (12 or 24 words)

9.2.3 Validation and verification

  • Checking that the generated private key is in the valid range: 1 ≤ k < n
  • Using Deterministic Signature Methods (RFC 6979) for ECDSA

9.2.4 Clearing memory

  • Use  mlock() to protect critical data from access
  • Explicitly clear memory after use (fill with zeros)
  • Using specialized libraries for working with cryptographic secrets (for example,  libsodium)

9.3 Standards Updates and Best Practices

  1. BIP-32 (Hierarchical Deterministic Wallets):
    • Add an explicit requirement to use 256+ bits of entropy
    • Recommend the use of hardware random number generators
  2. BIP-39 (Mnemonic Code):
    • Recommend a minimum mnemonic length (24 words for maximum security)
    • Specify the need to use CSPRNG
  3. BIP-44 (Multi-account Hierarchy):
    • Add security recommendations when implementing a derivation hierarchy
    • Use of built-in True Random Number Generators (TRNGs) with EAL6+ certification

9.4 Recommendations for hardware wallet manufacturers

Security standards for hardware wallets:

  • All hardware wallets must be equipped  with secure elements (SE)  with built-in true random number generators (TRNGs)
  • Components must be certified to safety level  EAL6+
  • Cryptographic isolation of key operations in secure elements (Secure Element)
  • Regular security audits from independent experts

10. Conclusions and research prospects

10.1 Key findings of the study

The CVE-2023-39910 (Milk Sad) vulnerability demonstrates the critical importance of proper entropy generation in cryptographic applications. Although the use of Mersenne Twister-32 was documented as insecure, many developers and users ignored the warnings, leading to a large-scale compromise of over 227,200 Bitcoin wallets.

Key findings:

  1. Entropy is the foundation of security:  It is impossible to create a cryptographically secure system using a weak random number generator.
  2. Importance of standardization:  Incorrect implementation of even well-known standards (BIP-32/39/44) can lead to disastrous results.
  3. Education and awareness:  Developers should be aware of the differences between PRNGs and CSPRNGs, and users should be aware of the risks of using tools with incorrect entropy.
  4. Continuous Monitoring:  There is a need for continuous analysis of the blockchain to detect anomalous patterns and attacks.
  5. Recovery and Refund:  The Milk Sad attack demonstrated the possibility of recovering lost wallets, but this requires an ethical and legal approach to the issue of ownership of recovered funds.

10.2 Mathematical laws of critical vulnerability

Vulnerability can be expressed through the following mathematical relationships:

Attack efficiency = log₂(2^32) / log₂(2^256)
= 32 / 256 = 0.125 = 12.5%

This means that the search space is reduced by 87.5%.

10.3 Research Prospects

Future research directions include:

  • Analysis of other PRNGs:  Research of other generators in use (LCG, PCG, etc.) for cryptographic vulnerabilities.
  • Quantum Security:  Developing Post-Quantum Entropy Generation Methods to Protect Against Quantum Computers.
  • Hardware Random Number Generators:  Optimization and Implementation of Cheaper and More Accessible TRNGs.
  • Automated Vulnerability Detection:  Developing Tools for Automatic Detection of Weak Generators in Cryptographic Libraries.

10.4 Final conclusion

Cryptographic systems and implementation errors are not due to theoretical maturity, but to simple engineering miscalculations. Without constant auditing, the use of only cryptographically secure random number generation libraries, and prompt incident response, risks in cryptocurrency systems will always be fatal and systemic. The Milk Sad attack is a harsh lesson for the entire cryptocurrency industry:  one weak component can compromise the integrity of the entire system .


References:

  1. Polycurve Extraction Attack: A polycurve extraction attack (CVE-2023-39910) leads to private key recovery and theft of Bitcoin funds, where an attacker is able to gain control of BTC funds through a libbitcoin flaw. Polycurve Extraction Attack The core of the libbitcoin crypto library contains a critical vulnerability: an elliptic curve point received from outside the library fails a full mathematical check to determine… Read More
  2. Mnemonic Drain Attack: Industrial BIP39 Mnemonic Phrase RAM Leakage escalates a global attack on the Bitcoin network through uncleaned RAM memory, where an attacker uses a mnemonic drain to siphon control of Bitcoins into the wrong hands, gaining complete control of BTC funds. From Mnemonic Drain Attack Mnemonic Drain Attack: This unforgettable attack is based on the idea of ​​”sucking” BIP39 secrets directly from crypto wallets through vulnerabilities in the processing of mnemonics, seed… Read More
  3. Entropy Collapse Attack: A critical entropy failure in Electrum v1 leads to the compromise of private keys over Bitcoin funds, where an attacker overflows the decoding of mnemonics, leading to the total recovery of the crypto wallet seed. Entropy Collapse Attack At the heart of a blockchain system, where every private key and recovery phrase is trusted by millions, an attacker causes a veritable “energy collapse.” Exploiting a… Read More
  4. BitShredder Attack: Memory vulnerability turns lost Bitcoin wallets into trophies and complete BTC theft via private key recovery, where attackers exploit the memory phantom attack (CVE-2025-8217, CVE-2013-2547) BitShredder Attack BitShredder Attack silently infiltrates the memory of a running cryptocurrency wallet. When a wallet is generated or restored, it scans uncleared fragments of RAM, searching for any remnants… Read More
  5. Script Mirage Attack: Recovering private keys of lost Bitcoin wallets during a total fund hijacking attack and completely stealing BTC from compromised wallets, where the attacker uses block filters to extract hidden private elements from transaction scripts Script Mirage Attack Script Mirage is an exploit in which an attacker cleverly exploits the semi-transparency of block filters to extract hidden private elements from transaction scripts. During the construction… Read More
  6. Entropy Cascade Attack: How invisible memory cascades lead to complete compromise of Bitcoin private keys and total loss of BTC, where an attacker exploits the CVE-2023-39910 vulnerability in BIP39 seed wallet processing in swap spaces. Entropy Cascade Attack Attack Description:The “Entropy Cascade” attack exploits insecure memory operations when processing BIP39 seed phrases and cryptographic entropy, allowing an attacker to recover private keys from invisible cascaded… Read More
  7. ChainPredictor Attack: Recovering private keys and taking control of lost Bitcoins through random number predictability, where an attacker can pre-compute “random” values ​​​​of insufficient entropy of a predictable PRNG initialization ChainPredictor Attack ChainPredictor is an attack on cryptocurrency wallet systems based on the predictability of a pseudorandom number generator. The attack utilizes a pre-calculated seed, which allows the attacker to anticipate… Read More
  8. Bitflip Oracle Rush Attack: A critical attack on AES-256-CBC in Bitcoin Core and a compromise of wallet.dat, where an attacker uses a flaw in the implementation of AEAD, HMAC, and the failure to decrypt without authentication to turn Bitcoin Core into an oracle for leaking private keys in order to steal BTC coins “Bitflip Oracle Rush Attack” Attack Description:The attacker skillfully manipulates bytes in the encrypted wallet.dat Bitcoin Core file, bit-flipping individual bits in each AES-256-CBC ciphertext block. By using the system’s responses… Read More
  9. ChronoForge Attack: Gradual private key recovery through timing side channels, where an attacker exploits a critical timing vulnerability in the Bitcoin Core crypto wallet to reveal sensitive data ChronoForge Attack The ChronoForge attack exploits a variable-time vulnerability in elliptic curve operations in the BIP324 protocol implementation and ellswift decoding. By measuring minute differences in the execution time of… Read More
  10. PulseProbe Attack: Private key recovery and stealth hijacking of Bitcoin cryptocurrency, where an attacker injects benchmark code that enables the extraction of secret data by analyzing the obtained timing patterns PulseProbe Attack The “PulseProbe attack” uses precise microbenchmarks to probe the execution time of cryptographic functions. The attacker injects benchmark code that performs a series of high-frequency timing measurements, tracking… Read More
  11. Pattern Forge Attack: A critical randomness vulnerability and method for recovering private keys in compromised Bitcoin wallets when entropy becomes a predictable generator pattern allows an attacker to massively empty crypto wallets Pattern Forge Attack A pattern forge attack exploits the use of a deterministic random number generator to generate private keys and other secret data. As a result, the sequence of supposedly… Read More
  12. Chameleon Twist Attack: A scientific analysis of private key threats when manipulating scriptSig and TXID, where the attacker uses null bytes and incorrect transaction mutability signatures, and recovering lost BTC wallets Chameleon Twist Attack The chameleon is a symbol of mutability and disguise, reflecting the essence of ScriptSig manipulation and the ability to “rename” a transaction identifier without changing the essence… Read More
  13. Quantum Prism Extractor Attack: A catastrophic vulnerability in random number generators and recovery of private keys of lost Bitcoin wallets, where an attacker identifies signatures with identical or weakly random nonces by mathematically recovering the private key data of Bitcoin users Quantum Prism Extractor Attack The Quantum Prism Extractor Attack is a spectacular attack on cryptographic applications that utilize predictable pseudorandom number generators (PRNGs) in key areas, such as generating private keys, time… Read More
  14. KeyBlaze Attack: Cryptographic collapse and private key recovery as a tool for total compromise of the Bitcoin network and complete seizure of funds from lost crypto wallets, where the attacker gains unauthorized access to the transaction and withdraws BTC coins KeyBlaze Attack The KeyBlaze attack represents a particularly critical threat due to the improper handling of private key material in Bitcoin’s code. It could lead to a complete compromise of… Read More
  15. EllSwift Mirror Key Breach: How CVE-2018-17096 and CVE-2023-39910 Open the Path to Bitcoin Private Key Recovery, From a Key Generation Error to a Complete Takeover of a Victim’s BTC Assets, Where an Attacker Creates a Critical Anomaly That Allows for the Recovery of Secret Data and the Theft of BTC Funds EllSwift Mirror Key Breach This attack mirrors the public key data into the private key using a vulnerability in which the first 32 bytes of the public key are used as the… Read More
  16. Crystal Key Exposure Attack: End-to-end filter transparency and complete BTC asset theft by an attacker through the predictability of SipHash and GCS filters reveals private crypto wallet keys, secret transactions, and leads to loss of control over Bitcoin assets Crystal Key Exposure Attack A Crystal Key Exposure Attack is a method that allows an attacker to reproduce filter keys and analyze the contents of blocks and user addresses with high… Read More
  17. Pulse Rerun Attack: Bitcoin’s Achilles’ Heel: How a Nonce Leak Leads to Private Key Recovery and Crypto Wallet Compromises Attackers Can Build a Mathematical Chain to Recover the Initial Private Key Data and Withdraw All BTC Coins Pulse Rerun Attack This attack exploits the careless reuse of the same nonce (pulse) in cryptographic operations or signatures. By repeating the same nonce, the system “feeds” the validation process… Read More
  18. Master Key Attack: How a single line of code turns Bitcoin into a hacker’s prey, where Hardcoded Private Key leads to the instant loss of control over all BTC funds using hardcoded private keys, with complete takeover of the crypto wallet’s Bitcoin network Master Key Attack The entire test environment becomes fully controlled by a single private key, hardcoded into the code. A single master key grants complete power: it can create, sign,… Read More
  19. Double Forge Attack: Restoring control over crypto lost wallets through Bitcoin Core’s inflation vulnerability, where an attacker contributes to the creation of extra coins on the network: CVE-2018-17144 as a phenomenon for restoring other people’s private keys in Bitcoin Double Forge Attack A “Double Forge Attack” is a critical vulnerability in Bitcoin Core where an attacker with sufficient computing power can create special blocks containing a transaction that double-spends… Read More
  20. Linear Summoner Attack: How an LFSR Generator Vulnerability Opens the Way to Private Key Recovery, Where an Attacker Gains Total Control of Bitcoin Wallets by Running the Berlekamp-Messi Algorithm CVE-2024-35202, CVE-2024-52922 Linear Summoner Attack The “Linear Summoner Attack” is a cryptographic attack on a weak LFSR generator implementation in systems where memory allocation/deallocation patterns predictably depend on the internal register state. The… Read More
  21. Resonance Twist Attack: A method for stealthily hacking and recovering private keys for lost Bitcoin wallets, where an attacker can change the TXID and double-spend, completely stealing the victim’s BTC funds Resonance Twist Attack A “resonant break attack” exploits a cryptographic phenomenon—changing a transaction identifier (TXID) before it’s confirmed. The attacker introduces minor changes to the witness data or signature encoding… Read More
  22. Spectral Fountain Attack: Mass recovery of private keys to lost Bitcoin wallets via a predictable random number generator (PRNG) exploit, where CVE-2025-27840 unstable entropy in hardware wallets paved the way for an attacker to unauthorized withdrawal of BTC funds Spectral Fountain Attack “Spectral Fountain Attack” exploits the predictability of a deterministic random number generator to continuously and easily extract cryptographic secrets. Within the target system, where the PRNG is… Read More
  23. Resonance Thief Attack: A critical vulnerability in Bitcoin key generation and private key recovery for losts, where an attacker exploits dangerous vulnerabilities in predictable deterministic random number generators (PRNGs), leading to the compromise of private keys, mass wallet hacks, and the loss of user BTC funds Resonance Thief Attack In a “Resonance Thief Attack,” an attacker captures a repeating “resonance” in a deterministic generator, extracting the same secret sequence over and over again. Like an acoustic… Read More
  24. RNG Crystal Key Exploit: Recovering private keys to lost Bitcoin wallets through a critical vulnerability in the random number generator, which allowed an attacker to completely control the victim’s funds through Randstorm predictable generators in BitcoinJS and through the weak entropy of Libbitcoin’s Mersenne Twister Bug RNG Crystal Key Exploit A “Crystal Key” attack exploits the fact that a pseudorandom generator is deterministic and predictable in advance. The generator operates as a “transparent crystal”—the sequence of random… Read More
  25. NullStream Attack: How Poly1305’s malicious null-key channel destroys authentication and recovers lost Bitcoin wallets. Leading to complete compromise of private keys. It is known that the attacker uses the null key to calculate the MAC address. NullStream Attack NullStream Attack is a cryptographic attack in which a malicious actor easily turns the Poly1305 message authentication mechanism into a transparent channel for injecting fake data. The critical vulnerability… Read More

RingSide Replay Attack: Recovering the SEED → deriving Bitcoin wallet private keys and how 32-bit entropy instead of 256-bit led to the systematic compromise of crypto-asset funds

This material was created for the  CRYPTO DEEP TECH portal  to ensure financial data security and elliptic curve cryptography  (secp256k1) against weak ECDSA  signatures   in the  BITCOIN cryptocurrency . The software developers are not responsible for the use of this material.


Crypto Tools

Source code

Google Colab

Telegram: https://t.me/cryptodeeptech

Video material: https://youtu.be/KJNbwfolL6g

Video tutorial: https://dzen.ru/video/watch/69431d5dfd50136dae291001

Source: https://cryptodeeptech.ru/ringside-replay-attack


RingSide Replay Attack: SEED Recovery → Bitcoin wallet private key derivation and how 32-bit entropy instead of 256-bit led to the systematic compromise of crypto-asset funds


Releases

No releases published

Packages

No packages published