Skip to content

Commit 1321761

Browse files
authored
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.
1 parent b25e552 commit 1321761

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

eclair-core/src/main/scala/fr/acinq/eclair/payment/PaymentRequest.scala

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

0 commit comments

Comments
 (0)