@@ -246,7 +246,7 @@ case class LocalCommit(index: Long, spec: CommitmentSpec, commitTxAndRemoteSig:
246246object LocalCommit {
247247 def fromCommitSig (keyManager : ChannelKeyManager , params : ChannelParams , fundingTxId : TxId ,
248248 fundingTxIndex : Long , remoteFundingPubKey : PublicKey , commitInput : InputInfo ,
249- commit : CommitSig , localCommitIndex : Long , spec : CommitmentSpec , localPerCommitmentPoint : PublicKey , localNonce_opt : Option [( SecretNonce , IndividualNonce )] )(implicit log : LoggingAdapter ): Either [ChannelException , LocalCommit ] = {
249+ commit : CommitSig , localCommitIndex : Long , spec : CommitmentSpec , localPerCommitmentPoint : PublicKey )(implicit log : LoggingAdapter ): Either [ChannelException , LocalCommit ] = {
250250 val (localCommitTx, htlcTxs) = Commitment .makeLocalTxs(keyManager, params.channelConfig, params.channelFeatures, localCommitIndex, params.localParams, params.remoteParams, fundingTxIndex, remoteFundingPubKey, commitInput, localPerCommitmentPoint, spec)
251251 commit.sigOrPartialSig match {
252252 case Left (sig) =>
@@ -255,12 +255,9 @@ object LocalCommit {
255255 }
256256 case Right (psig) =>
257257 val fundingPubkey = keyManager.fundingPublicKey(params.localParams.fundingKeyPath, fundingTxIndex).publicKey
258- val Some ( localNonce) = localNonce_opt
258+ val localNonce = keyManager.verificationNonce(params.localParams.fundingKeyPath, fundingTxIndex, keyManager.keyPath(params.localParams, params.channelConfig), localCommitIndex)
259259 if (! localCommitTx.checkPartialSignature(psig, fundingPubkey, localNonce._2, remoteFundingPubKey)) {
260260 log.debug(s " fromCommitSig: invalid partial signature $psig fundingPubkey = $fundingPubkey, fundingTxIndex = $fundingTxIndex localCommitIndex = $localCommitIndex localNonce = $localNonce remoteFundingPubKey = $remoteFundingPubKey" )
261-
262- val localNonce1 = keyManager.verificationNonce(params.localParams.fundingKeyPath, fundingTxIndex, keyManager.keyPath(params.localParams, params.channelConfig), localCommitIndex)
263- log.debug(s " with $localNonce1 ${localCommitTx.checkPartialSignature(psig, fundingPubkey, localNonce1._2, remoteFundingPubKey)}" )
264261 return Left (InvalidCommitmentSignature (params.channelId, fundingTxId, fundingTxIndex, localCommitTx.tx))
265262 }
266263 }
@@ -705,7 +702,7 @@ case class Commitment(fundingTxIndex: Long,
705702 (copy(nextRemoteCommit_opt = Some (nextRemoteCommit)), commitSig)
706703 }
707704
708- def receiveCommit (keyManager : ChannelKeyManager , params : ChannelParams , changes : CommitmentChanges , localPerCommitmentPoint : PublicKey , commit : CommitSig , localNonce_opt : Option [( SecretNonce , IndividualNonce )] )(implicit log : LoggingAdapter ): Either [ChannelException , Commitment ] = {
705+ def receiveCommit (keyManager : ChannelKeyManager , params : ChannelParams , changes : CommitmentChanges , localPerCommitmentPoint : PublicKey , commit : CommitSig )(implicit log : LoggingAdapter ): Either [ChannelException , Commitment ] = {
709706 // they sent us a signature for *their* view of *our* next commit tx
710707 // so in terms of rev.hashes and indexes we have:
711708 // ourCommit.index -> our current revocation hash, which is about to become our old revocation hash
@@ -716,7 +713,7 @@ case class Commitment(fundingTxIndex: Long,
716713 // and will increment our index
717714 val localCommitIndex = localCommit.index + 1
718715 val spec = CommitmentSpec .reduce(localCommit.spec, changes.localChanges.acked, changes.remoteChanges.proposed)
719- LocalCommit .fromCommitSig(keyManager, params, fundingTxId, fundingTxIndex, remoteFundingPubKey, commitInput, commit, localCommitIndex, spec, localPerCommitmentPoint, localNonce_opt ).map { localCommit1 =>
716+ LocalCommit .fromCommitSig(keyManager, params, fundingTxId, fundingTxIndex, remoteFundingPubKey, commitInput, commit, localCommitIndex, spec, localPerCommitmentPoint).map { localCommit1 =>
720717 log.info(s " built local commit number= $localCommitIndex toLocalMsat= ${spec.toLocal.toLong} toRemoteMsat= ${spec.toRemote.toLong} htlc_in={} htlc_out={} feeratePerKw= ${spec.commitTxFeerate} txid= ${localCommit1.commitTxAndRemoteSig.commitTx.tx.txid} fundingTxId= $fundingTxId" , spec.htlcs.collect(DirectedHtlc .incoming).map(_.id).mkString(" ," ), spec.htlcs.collect(DirectedHtlc .outgoing).map(_.id).mkString(" ," ))
721718 copy(localCommit = localCommit1)
722719 }
@@ -1112,12 +1109,7 @@ case class Commitments(params: ChannelParams,
11121109
11131110 // Signatures are sent in order (most recent first), calling `zip` will drop trailing sigs that are for deactivated/pruned commitments.
11141111 val active1 = active.zip(commits).map { case (commitment, commit) =>
1115- val localNonce_opt = if (params.commitmentFormat.useTaproot) {
1116- Some (keyManager.verificationNonce(params.localParams.fundingKeyPath, commitment.fundingTxIndex, channelKeyPath, localCommitIndex + 1 ))
1117- } else {
1118- None
1119- }
1120- commitment.receiveCommit(keyManager, params, changes, localPerCommitmentPoint, commit, localNonce_opt) match {
1112+ commitment.receiveCommit(keyManager, params, changes, localPerCommitmentPoint, commit) match {
11211113 case Left (f) => return Left (f)
11221114 case Right (commitment1) => commitment1
11231115 }
@@ -1268,7 +1260,7 @@ case class Commitments(params: ChannelParams,
12681260 // we cannot compare partial signatures directly as they are not deterministic (a new signing nonce is used every time a signature is computed)
12691261 // => instead we simply check that the provided partial signature is valid for our latest commit tx
12701262 val localFundingKey = keyManager.fundingPublicKey(params.localParams.fundingKeyPath, latest.fundingTxIndex).publicKey
1271- val Some ( localNonce) = generateLocalNonce( keyManager, latest.fundingTxIndex, latest.localCommit.index)
1263+ val localNonce = keyManager.verificationNonce(params.localParams.fundingKeyPath , latest.fundingTxIndex, keyManager.keyPath(params.localParams, params.channelConfig), latest.localCommit.index)._2
12721264 latest.localCommit.commitTxAndRemoteSig.commitTx.checkPartialSignature(psig, localFundingKey, localNonce, latest.remoteFundingPubKey)
12731265 }
12741266
@@ -1387,35 +1379,6 @@ case class Commitments(params: ChannelParams,
13871379 def resolveCommitment (spendingTx : Transaction ): Option [Commitment ] = {
13881380 all.find(c => spendingTx.txIn.map(_.outPoint).contains(c.commitInput.outPoint))
13891381 }
1390-
1391- /**
1392- * Generate local verification nonces for a specific funding tx index and commit tx index
1393- *
1394- * @param keyManager key manager that will generate actual nonces
1395- * @param fundingIndex funding tx index
1396- * @param commitIndex commit tx index
1397- * @return a public nonce for thr provided fundint tx index and commit tx index if taproot is used, None otherwise
1398- */
1399- def generateLocalNonce (keyManager : ChannelKeyManager , fundingIndex : Long , commitIndex : Long ): Option [IndividualNonce ] = {
1400- if (latest.params.commitmentFormat.useTaproot) {
1401- Some (keyManager.verificationNonce(params.localParams.fundingKeyPath, fundingIndex, keyManager.keyPath(params.localParams, params.channelConfig), commitIndex)._2)
1402- } else {
1403- None
1404- }
1405- }
1406-
1407- /**
1408- * Create local verification nonces a specific funding tx index and a range of commit tx indexes
1409- *
1410- * @param keyManager key manager that will generate actual nonces
1411- * @param fundingIndex funding tx index
1412- * @param commitIndexes range of commit tx indexes
1413- * @return a list of nonces if raproot is used, or an empty list
1414- */
1415- def generateLocalNonces (keyManager : ChannelKeyManager , fundingIndex : Long , commitIndexes : Long * ): List [IndividualNonce ] = {
1416- commitIndexes.toList.flatMap(commitIndex => generateLocalNonce(keyManager, fundingIndex, commitIndex))
1417- }
1418-
14191382}
14201383
14211384object Commitments {
0 commit comments