-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add signature when including
invreq_bip_353_name
When including a BIP 353 HRN, we also require including a signature of the `invoice_request` using one of the keys from the offer stored in the BIP 353 DNS record. We only add the BIP 353 HRN to our contacts list after verifying that it matches the offer we retrieved.
- Loading branch information
Showing
6 changed files
with
207 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ import fr.acinq.lightning.wire.OfferTypes | |
import fr.acinq.lightning.wire.TlvStream | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertTrue | ||
import kotlin.test.assertFalse | ||
|
||
class ContactsTestsCommon : LightningTestSuite() { | ||
|
||
|
@@ -35,6 +37,9 @@ class ContactsTestsCommon : LightningTestSuite() { | |
assertEquals("810641fab614f8bc1441131dc50b132fd4d1e2ccd36f84b887bbab3a6d8cc3d8", contactSecretAlice.primarySecret.toHex()) | ||
val contactSecretBob = Contacts.computeContactSecret(bobOfferAndKey, aliceOfferAndKey.offer) | ||
assertEquals(contactSecretAlice, contactSecretBob) | ||
val payerAddress = UnverifiedContactAddress(ContactAddress.fromString("[email protected]")!!, bobOfferAndKey.privateKey.publicKey()) | ||
assertTrue(payerAddress.verify(bobOfferAndKey.offer)) | ||
assertFalse(payerAddress.verify(aliceOfferAndKey.offer)) | ||
} | ||
run { | ||
// The remote offer contains an issuer_id and a blinded path. | ||
|
@@ -53,7 +58,8 @@ class ContactsTestsCommon : LightningTestSuite() { | |
assertEquals("4e0aa72cc42eae9f8dc7c6d2975bbe655683ada2e9abfdfe9f299d391ed9736c", contactSecretAlice.primarySecret.toHex()) | ||
val contactSecretBob = Contacts.computeContactSecret(OfferTypes.OfferAndKey(bobOffer, issuerKey), aliceOfferAndKey.offer) | ||
assertEquals(contactSecretAlice, contactSecretBob) | ||
|
||
val payerAddress = UnverifiedContactAddress(ContactAddress.fromString("[email protected]")!!, issuerKey.publicKey()) | ||
assertTrue(payerAddress.verify(bobOffer)) | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,7 +77,7 @@ class OfferPaymentMetadataTestsCommon { | |
} | ||
|
||
@Test | ||
fun `encode - decode v2 metadata with contact information`() { | ||
fun `encode - decode v2 metadata with contact offer`() { | ||
val nodeKey = randomKey() | ||
val preimage = randomBytes32() | ||
val paymentHash = Crypto.sha256(preimage).byteVector32() | ||
|
@@ -111,6 +111,29 @@ class OfferPaymentMetadataTestsCommon { | |
assertEquals(metadata, OfferPaymentMetadata.fromPathId(nodeKey, pathId, paymentHash)) | ||
} | ||
|
||
@Test | ||
fun `encode - decode v2 metadata with contact address`() { | ||
val nodeKey = randomKey() | ||
val preimage = randomBytes32() | ||
val paymentHash = Crypto.sha256(preimage).byteVector32() | ||
val metadata = OfferPaymentMetadata.V2( | ||
offerId = randomBytes32(), | ||
amount = 200_000_000.msat, | ||
preimage = preimage, | ||
payerKey = randomKey().publicKey(), | ||
payerNote = "hello there", | ||
quantity = 1, | ||
contactSecret = randomBytes32(), | ||
payerOffer = null, | ||
payerAddress = UnverifiedContactAddress(ContactAddress.fromString("[email protected]")!!, randomKey().publicKey()), | ||
createdAtMillis = 0 | ||
) | ||
assertEquals(metadata, OfferPaymentMetadata.decode(metadata.encode())) | ||
val pathId = metadata.toPathId(nodeKey) | ||
assertEquals(236, pathId.size()) | ||
assertEquals(metadata, OfferPaymentMetadata.fromPathId(nodeKey, pathId, paymentHash)) | ||
} | ||
|
||
@Test | ||
fun `decode invalid path_id`() { | ||
val nodeKey = randomKey() | ||
|
Oops, something went wrong.