Link to this headingEdward curve Digital Signature Algorithm (EdDSA)
- Small Key size
- Small Signature size (2 * key_size)
- High security level
Differences between ECDSA and EdDSA:
- There is a different but similar signing structure
- There are some Security Benefits
- The full Message Public key is included rather than just the x value. This removes two possible Points that can be accepted. Point P and the point -P.
- The Random value is specific to the private key and message. Making it deterministic.
- The signature makes it almost impossible to recover the secret key from a bad random.
Link to this headingKey Generation
= b
#Generate KeyPair
, =
Link to this headingSigning a Message
- Generate the privKey and publicKey
privKey = hash(seed)pubKey = privKey * G
- Generate a secret integer from the private key and message
r = hash(privKey + msg) mod q
- Generate the Random Public Integer
R = r * G
- Generate the Hash
h = hash(R + pubKey + msg) mod q
- Generate the public signature
s = (r + h * privKey) mod q - Return the signature { R, s }
Link to this headingImplementation
### EdDSA
#Derive Information
=
=
= *
#Generate a Random Number hashed from the private key and the message
=
= %
#Generate Random and make a new Point
= *
#Calculate the hash of the public Information
# Message_PublicKey | Sender_PublicKey | Message
= %
#Generate S
= %
return
= b
#Generate KeyPair
, =
#1118376335731908256068732195467137787275566017941934643723748303483550337980 Curve25519: x=31592139095823145743735521290207490847011069353785999562280993997344601755653, y=21673586675302998803223294955405643770844065999969499514651060183576782057508
#Generate Signature
=
#{'message_key': b'\x02\x19\xebq\x90\x93\xa7\x0e\xe8\xff\xb5\x8f\xca\x85\xc9\xfd\xc8sP\xa4g;\xcf\xa3cgI\xb7\x99@x\x9e\x8d', 'signature': 4635426480053735016845786485222519126656916118819117425364207333976983427746}
#Check Signature
=
#True
Link to this headingVerifying a Message
Comparison Identity:
p_1 = s * G
= (r + h * privKey) \pmod{q} * G
= (r * G) + (h * privKey * G ) \pmod{q}
= R + h * (privKey * G ) \pmod{q}
= R + h * pubKey \pmod{q}
- Calculate the hash from the public key, R and the message.
h = hash(R + pubKey + msg) \pmod{q}
- Using the Random, hash and public key provided generate a candidate for the signature canadate
s_1 = (R + h * pubKey) \pmod{q}
- Make Comparison using the provided signature
-p_1 = s * G
- Compare p_1 and p_2
P1 == P2
Link to this headingImplementation
#Derive Information
=
=
=
#Calculate Point 1 from the signature["signature"] int
= *
#Calculate the hash of the public Information
# Message_PublicKey | Sender_PublicKey | Message
= %
#R' = (h * s1) * G + (r * s1) * pubKey
=
#Because of the way this is checked there are two possible public keys. The one that is used and the negative point
return ==
= b
#Generate KeyPair
, =
#1118376335731908256068732195467137787275566017941934643723748303483550337980 Curve25519: x=31592139095823145743735521290207490847011069353785999562280993997344601755653, y=21673586675302998803223294955405643770844065999969499514651060183576782057508
#Generate Signature
=
#{'message_key': b'\x02\x19\xebq\x90\x93\xa7\x0e\xe8\xff\xb5\x8f\xca\x85\xc9\xfd\xc8sP\xa4g;\xcf\xa3cgI\xb7\x99@x\x9e\x8d', 'signature': 4635426480053735016845786485222519126656916118819117425364207333976983427746}
#Check Signature
=
#True
Link to this headingMath Proof
Point 1 Identities:
\begin{aligned}
P_1 &= s * G \\
P_1 &= (r + h * privKey) * G \mod{q} \\
P_1 &= (r *G) + (h * privKey) * G \mod{q} \\
P_1 &= R + (h * privKey) * G \mod{q} \\
P_1 &= R + h * (privKey * G) \mod{q} \\
P_1 &= R + h * (pubKey) \mod{q} \\
P_1 &= R + h * pubKey \mod{q} \\
\end{aligned}
Point 2 Identities:
P2 = R + h * pubKey