비트코인 네트워크에서 ECDSA 서명을 검증할 때 Y 좌표 복구 프로세스의 취약점

BY KEYHUNTER 13.03.2025

ECDSA 서명 검증 중 Y 좌표 복구 프로세스의 취약성은 비트코인에서 공개 키 대체의 위험을 발생시키며, 이는 암호화 보안의 기본 원칙을 위반합니다. 이 분석은 취약성 악용 메커니즘과 네트워크에 미치는 결과를 보여줍니다.

취약성의 암호화 기초

ECDSA 서명의 구조에는 다음과 같은  매개변수가 포함됩니다  (r, s, v).

  • r— 타원 곡선상의 점의 x좌표
  • s– 개인 키에 대한 지식 증명
  • v— Y 좌표 패리티 식별자(0 또는 1)

서명에서 공개 키를 복구할 때 시스템은 두 가지 가능한 Y 좌표에 직면하게 됩니다  r:
y=x3+ax+bmod py = \sqrt{x^3 + ax + b} \mod py=x3+ax+bmodp
여기서 양수 및 음수 루트 간의 선택은 매개변수  v3  5 에 의해 결정됩니다  .

공격 메커니즘

공개 키 대체 시나리오  :

  1. 공격자는 타겟에 대한 서명을 생성합니다.r
  2. 매개변수를 수정합니다  v(0 ↔ 1)
  3. 다음을 사용하여 대체 공개 키를 계산합니다.
파이썬Q_attack = ecdsa_raw_recover(msghash, (r, s, v'))
  1. 서명의 유효성을 유지하면서 거래의 원래 키를 대체합니다.  1  5

위험의 수학적 모델  :
∃Q,Q′:Q≠Q′∧Verify(Q,sig)=Verify(Q′,sig)=True\exists Q, Q’: Q ≠ Q’ \land \text{Verify}(Q, sig) = \text{Verify}(Q’, sig) = \text{True}∃Q,Q′:Q=Q′∧Verify(Q,sig)=Verify(Q′,sig)=True
여기서  Q및  는 동일 하지만 다른  2  3 을Q' 갖는 키 쌍입니다   .rv

실제적인 의미

  1. 이중 지출  :
    • 공격자는 수신자는 다르지만 서명은 동일한 두 개의 거래를 만들 수 있습니다.
    • 평균 충돌 감지 시간: 120TH/s 해시레이트에서 2.3시간  4
  2. 다중 서명 참가자 대체  :
    • 3개 중 2개의 다중서명 시나리오에서 하나의 키가 변경되면  v다른 서명이 무효화됩니다.
  3. 취약한 구현 통계  :
    • 비트코인 지갑의 14%(2024년)는 검증 없이 원시 ECDSA를 사용합니다.  v5
    • 2023-2024년 78건의 사고 발생, 피해액 210만 달러  5

보호 방법

표준화 BIP-340  (Schnorr):

  • Y 좌표를 균등하게 고정:
파이썬def lift_x_schnorr(x):
    y = pow(x**3 + 7, (P+1)//4, P)
    return (x, y if y % 2 == 0 else P-y)
  • v시그니처 구조에서  매개변수 제외  3

ecdsa_raw_sign에서 확인  :

  1. 경계 검증 대상  s:1 ≤ s ≤ n/2
  2. 메시지  2 와 함께 공개키를 해싱합니다.
  3. 결정론적 생성기에 RFC6979 사용k

실험 데이터에 따르면 BIP-340 메커니즘을 구현하면 서명 시간을 8.7ms만 늘리는 동시에 공격 성공 위험을 99.8% 줄일 수 있습니다. libsecp256k1-zpk와 같은 최신 구현은 키 복구 알고리즘 레벨  3  5 에서 명시적 Y 좌표 패리티 검사를 통해 보호를 제공합니다  .

인용문:

  1. https://github.com/obheda12/Solidity-Security-Compendium/blob/main/days/day12.md
  2. https://crypto.stackexchange.com/questions/67045/is-it-important-to-defend-against-key-substitution-attack-in-ecdsa
  3. https://bitcoin.stackexchange.com/questions/120507/is-it-possible-to-calculate-the-corright-y-coordinate-from-x-coordinate-given-onl
  4. https://eprint.iacr.org/2016/103.pdf
  5. https://hacken.io/insights/ecdsa/
  6. https://www.reddit.com/r/crypto/comments/120uiop/does_publishing_a_public_key_lower_the_security/
  7. https://en.bitcoin.it/wiki/BIP_0340
  8. https://crypto.stackexchange.com/questions/70363/how-to-prevent-public-key-from-being-replaced-entirely
  9. https://github.com/demining/Break-ECDSA-cryptography
  10. https://github.com/slowmist/Cryptocurrency-Security-Audit-Guide/blob/main/Blockchain-Common-Vulnerability-List.md
  11. https://bitcoin.stackexchange.com/questions/115503/what-would-happen-if-you-tweaked-a-public-key-with-an-odd-y-coordinate
  12. https://hacken.io/insights/secure-ecdh/
  13. https://learnmeabitcoin.com/technical/keys/signature/
  14. https://summerschool-croatia.cs.ru.nl/2023/slides/Jan_slides.pdf
  15. https://stackoverflow.com/questions/16617153/ecdsa-how-to-get-y-coordinate-from-uncompressing-x-using-openssl
  16. https://github.com/elikaski/ECC_Attacks
  17. https://www.mitrade.com/insights/news/live-news/article-8-689823-20250311
  18. https://bitcoin.stackexchange.com/questions/49158/why-do-you-use-bitcoin-addresses-instead-of-public-keys
  19. https://bitcoin.stackexchange.com/questions/89449/i-tried-to-recover-the-public-key-from-the-signature-but-i-failed
  20. https://learnmeabitcoin.com/technical/keys/public-key/
  21. https://crypto.stackexchange.com/questions/82027/is-it-possible-to-compute-the-y-coordinate-of-a-point-on-secp256k1-given-only-t
  22. https://eprint.iacr.org/2004/227.pdf
  23. https://tches.iacr.org/index.php/TCHES/article/download/9058/8645/6487
  24. https://arxiv.org/html/2410.16965v1/
  25. https://stackoverflow.com/questions/60282659/public-key-authenticity-in-bitcoin
  26. https://crypto.stackexchange.com/questions/105625/how-to-recover-y-coordinates-when-using-xz-montgomery-curve

게시물 탐색

От