🇬🇧
Go+ Encyclopedia
English
English
  • 📗Intro
    • Hello, Web3!
    • Recent Security Incidents
  • 👿Vulnerabilities Cases
    • Blockchain Network
      • Eclipse Attack
    • Smart Contract
      • Symmetry Breaking
        • XCarnival
      • Hash Collision
        • Poly Network
      • Flash Loan
        • Cream Finance
      • General NFT
        • ERC721R Bug
        • Sleep Minting
      • Cross-chain Bridge
        • Poly Network
        • Nomad
      • Proxy Contract
        • Audius
    • User Client
      • Clipboard Safety
      • Metamask Demonic Vulnerability
    • Replay Attack
      • Wintermute & OP
    • Phishing
      • Frontend Hijack
        • Premint.xyz
      • Fake User Interface
      • Fake E-mail Address
    • Basic Cryptography
      • Fault Attack
        • ECDSA random numbers
        • Ed25519
    • Zero-knowledge Proof
      • Aliasing Attack
  • 🏝️Miscellaneous
    • Tools
Powered by GitBook
On this page
  • Abstract
  • Cryptography Background
  • Private Key: k
  • Derived Integer: a
  • Public Key: A
  • Signature Generation: (R,s)
  • Verify the Signature
  • Unsafe Implementations
  • Summary
  • References
  1. Vulnerabilities Cases
  2. Basic Cryptography
  3. Fault Attack

Ed25519

PreviousECDSA random numbersNextZero-knowledge Proof

Last updated 2 years ago

Abstract

EdDSA algorithm itself is proved secure, but some EdDSA libraries implemented API in an unsafe way that could lead to private key exposure.

Cryptography Background

Edwards-curve Digital Signature Algorithm (EdDSA) is a scheme using a variant of based on .

The EdDSA signature algorithm and its variants Ed25519 and Ed448 are technically described in the .

Private Key: k

k = A random number generated from RNG.

Derived Integer: a

Calculate the digest of Private Key:

H(k)=(h0,h1,...,h2b−1)H(k)=(h_0,h_1,...,h_{2b-1})H(k)=(h0​,h1​,...,h2b−1​)

Then calculate the integer a:

a=2b−2+∑3⩽i⩽b−32ihi∈{2b−2,2b−2+8,...,2b−1−8}a = 2^{b-2} + \sum_{\substack 3⩽i⩽b-3} 2^ih_i \in \lbrace {2^{b-2},2^{b-2}+8,...,2^{b-1}-8} \rbracea=2b−2+3​⩽i⩽b−3∑​2ihi​∈{2b−2,2b−2+8,...,2b−1−8}

Later, you'll see this a is also a number that can't be leaked since it acts like private key.

Public Key: A

B is the base point of the Curve

Signature Generation: (R,s)

For message M:

l is the order of the subgroup generated by point B.

Now we have the signature (R,s). As you can see, you can calculate any signature if you know a, the same thing as you know the private key k.

Verify the Signature

​

Unsafe Implementations

Now, consider a kind of function implementations:

//PSEUDO CODE
func sign(message M, publicKey A){    
    R = rB
    S=(r+H(R,A,M)a) mod l
    return (R,S)    
}

This sign() allows a caller to input arbitrary message and public key. If he uses same M but different A, he can compute the integer a, the equivalence to private key k:

Summary

This is an unsafe implementation. It doesn't mean it's a bug that can 100% be exploited now but may have some unpredicted effects in the future.

Developers should be familiar enough with the underlying cryptography to avoid it.

References

A=aBA = aBA=aB
r=H(hb,...,h2b−1,M)∈0,1,...22b−1r=H(h_b,...,h_{2b-1},M) \in 0,1,...2^{2b}-1r=H(hb​,...,h2b−1​,M)∈0,1,...22b−1
R=rBR=rBR=rB
s=(r+H(R,A,M)a) mod ls=(r+H(R,A,M)a)\bmod ls=(r+H(R,A,M)a)modl
if 8sB==8R+8H(R,A,M)Aif\space 8sB == 8R+8H(R,A,M)Aif 8sB==8R+8H(R,A,M)A
a=(S−S′)[H(R,A,M)−H(R,A′,M)]−1 mod la=(S-S')[H(R,A,M)-H(R,A',M)]^{-1} \bmod la=(S−S′)[H(R,A,M)−H(R,A′,M)]−1modl

There are many libs with this problem, you can .

check this list
https://twitter.com/kostascrypto/status/1535579208960790528
https://datatracker.ietf.org/doc/html/rfc8032
digital signature
Schnorr signature
twisted Edwards curves
RFC 8032
👿
Page cover image