-
Notifications
You must be signed in to change notification settings - Fork 283
Variable-length onion payloads #976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
2c06d41
Sphinx: typo in computeBlindingFactor
t-bast 314e3fc
Sphinx: implement multi-frame onion proposal
t-bast ac6ec1a
Sphinx: add tests for multi-frame onions
t-bast f75ae41
Sphinx: use 5 bits to encode number of frames.
t-bast 4014183
SphinxSpec: small clean-up
t-bast f2fff4f
Features: add multi-frame onion feature flag.
t-bast 02de66a
SphinxSpec: add official test vector.
t-bast 7bd8942
Sphinx: use variable-length payloads.
t-bast b4cbed5
SphinxSpec: add official variable-length test vector
t-bast 9c42e55
features: rename variable-length onion flag
t-bast 9a434d5
FeaturesSpec: update test name
t-bast 367d6eb
Sphinx: refactor onion objects.
t-bast 97622d4
Update varint codec name
t-bast 22b5faa
Use scodec for onion packet.
t-bast 0f28e8a
Use scodec for onion failure packet.
t-bast 5022847
Address PR comments:
t-bast b39769e
Create a decode-only codec to extract onion payload length
t-bast 52d7023
Clean-up a few nits:
t-bast 5946b6a
Add function to extract failure code from failure message
t-bast 4c6a05a
Clean-up failureOnionCodec
t-bast 0c13aea
Rename to OnionRouting everywhere.
t-bast 9506dd7
Add error log if onion payload decoder has remaining bytes
t-bast 9fa1dc3
Update onion feature bit.
t-bast 5a1c3b2
Clean-up: sort imports
t-bast b3232e4
Update test vectors to use big-endian varints
t-bast 358b20a
Sphinx: remove the tlv termination signal.
t-bast 873bb41
Formatting and small fixes
t-bast 40d9b1c
Merge master
t-bast File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
59 changes: 59 additions & 0 deletions
59
eclair-core/src/main/scala/fr/acinq/eclair/crypto/Mac.scala
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * Copyright 2019 ACINQ SAS | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package fr.acinq.eclair.crypto | ||
|
|
||
| import fr.acinq.bitcoin.ByteVector32 | ||
| import org.spongycastle.crypto.digests.SHA256Digest | ||
| import org.spongycastle.crypto.macs.HMac | ||
| import org.spongycastle.crypto.params.KeyParameter | ||
| import scodec.bits.ByteVector | ||
|
|
||
| /** | ||
| * Created by t-bast on 04/07/19. | ||
| */ | ||
|
|
||
| /** | ||
| * Create and verify message authentication codes. | ||
| */ | ||
| trait Mac32 { | ||
|
|
||
| def mac(message: ByteVector): ByteVector32 | ||
|
|
||
| def verify(mac: ByteVector32, message: ByteVector): Boolean | ||
|
|
||
| } | ||
|
|
||
| case class Hmac256(key: ByteVector) extends Mac32 { | ||
|
|
||
| override def mac(message: ByteVector): ByteVector32 = Mac32.hmac256(key, message) | ||
|
|
||
| override def verify(mac: ByteVector32, message: ByteVector): Boolean = this.mac(message) === mac | ||
|
pm47 marked this conversation as resolved.
|
||
|
|
||
| } | ||
|
|
||
| object Mac32 { | ||
|
|
||
| def hmac256(key: ByteVector, message: ByteVector): ByteVector32 = { | ||
| val mac = new HMac(new SHA256Digest()) | ||
| mac.init(new KeyParameter(key.toArray)) | ||
| mac.update(message.toArray, 0, message.length.toInt) | ||
| val output = new Array[Byte](32) | ||
| mac.doFinal(output, 0) | ||
| ByteVector32(ByteVector.view(output)) | ||
| } | ||
|
|
||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.