What is Double Hashing?
더블 해싱은 데이터를 두 번 해시하는 것을 의미합니다. 같은 함수로 두 번, 때로는 두 가지 다른 함수를 사용할 수도 있습니다. 결과는 여전히 짧고 고정된 지문이지만, 보호층이 하나 더 추가됩니다. 그것은 여행가의 짐를 잠그고, 그 안에 또 다른 가방을 넣어 다시 잠그는 것과 같습니다.
“Double Hashing means twice the security, always.” Not quite. It mainly helps against specific attacks and design quirks, and in some systems it is chosen for implementation simplicity, not for a magic two times safety boost.
How Double Hashing works
다음은 Bitcoin 스타일의 논리를 사용한 간단한 흐름입니다. 짧고 간단하게.
- Step 1: You start with data, like a block header or a transaction.
- Step 2: Run it through a cryptographic hash function to get a digest.
- Step 3: Take that digest and hash it again. Same function or a different one, depending on the design.
- Step 4: Use the final digest as an identifier, like a transaction ID (TxID) or a block header hash for proof of work.
- Step 5: Anyone can verify by repeating the two hashes and checking the match. Quick, deterministic, done.
That is Double Hashing doing its thing.
Why Double Hashing Matters
그럼 bragging rights 외에 무엇을 얻을 수 있을까요?
- Benefit: Extra defense against certain attack classes, like length extension on some single pass setups.
- Perspective: It supports network level checks that reinforce immutability of records that have been mined and widely verified.
- Relevance: You will bump into it with Bitcoin block headers, some address formats, and many libraries that expose double SHA 256 by default.
Double Hashing을 테스트할 때는 알려진 벡터와 대조하고 바이트 순서와 인코딩을 각 통과 전후에 주의하세요. 아주 작은 불일치 하나로도 유령을 쫓아다닐 수 있습니다.
Key Characteristics of Double Hashing
The highlights you will care about:
- Layers: Two passes give a second independent squeeze on the data.
- Determinism: Same input means the same output every time, across both passes.
- Practicality: Easy to verify at scale since each pass is quick.
How is Double Hashing calculated?
You compute a hash of the input, then hash that result again. Written as a formula:
H2(x) = H(H(x)) Example in Bitcoin land:
H2(x) = SHA 256(SHA 256(x)) Addresses often use a mixed pair:
Hmix(x) = RIPEMD 160(SHA 256(x)) Variations
Same idea, different flavors:
- same: One function twice, like SHA 256 then SHA 256 again.
- mixed: Two different functions in sequence, like SHA 256 then RIPEMD 160.
- address: Bitcoin style addresses hash a public key with SHA 256 then RIPEMD 160, which is a classic Double Hashing combo.
Double Hashing is simple to compute but watch your inputs. Endian quirks, padding rules, and newline characters can sabotage your result even when your code looks perfect.
Example
Bitcoin miners compute SHA 256 twice on a block header, and nodes verify the same two passes before accepting the block.
Fun Fact
Satoshi chose double SHA 256 for headers in part to blunt length extension style attacks and to keep different components from ever relying on a single raw pass, a tidy engineering move that aged well.
Wrap-Up
In short, Double Hashing is hashing twice for tighter checks and cleaner design, a tiny extra step that big systems count on every day.