1
0
mirror of https://github.com/ACINQ/eclair.git synced 2024-11-19 01:43:22 +01:00

Make signing payment requests faster (#1754)

* Make signing payment requests faster

There was a much more efficient method to compute the pukey recovery id that was not used.
This commit is contained in:
Fabrice Drouin 2021-04-02 16:15:07 +02:00 committed by GitHub
parent b25e5523e7
commit 13217610ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -108,8 +108,9 @@ case class PaymentRequest(prefix: String, amount: Option[MilliSatoshi], timestam
*/
def sign(priv: PrivateKey): PaymentRequest = {
val sig64 = Crypto.sign(hash, priv)
val (pub1, _) = Crypto.recoverPublicKey(sig64, hash)
val recid = if (nodeId == pub1) 0.toByte else 1.toByte
// in order to tell what the recovery id is, we actually recover the pubkey ourselves and compare it to the real one
val pub0 = Crypto.recoverPublicKey(sig64, hash, 0.toByte)
val recid = if (nodeId == pub0) 0.toByte else 1.toByte
val signature = sig64 :+ recid
this.copy(signature = signature)
}
@ -574,4 +575,3 @@ object PaymentRequest {
Bech32.encode(hrp, int5s.toArray)
}
}