lightning-onion 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lightning/onion/packet.rb +6 -3
- data/lib/lightning/onion/sphinx.rb +3 -1
- data/lib/lightning/onion/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c676e3e173135c4fb63cc8cf9d42936342f0a144
|
4
|
+
data.tar.gz: b2600dd7b5ee1215d1037aca1ee05734946dd57f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d23269a725290926473ddaa35f816a006f29ba1048a724e634f81efe39d8e856f3c998b967e7284cf165db2a8b4aa1849a60568c5a6c7b0f286341bc36b0b265
|
7
|
+
data.tar.gz: ef568c4316a57737a824c9f95a7aa797d8d87c338f4899e045244b08bbb9627c8f5137e19839708fe90cca1530e2ccd7147ad95844899a5126bb511e96fb2bce
|
@@ -3,19 +3,22 @@
|
|
3
3
|
module Lightning
|
4
4
|
module Onion
|
5
5
|
class Packet
|
6
|
+
include Lightning::Onion::Sphinx
|
7
|
+
|
6
8
|
attr_accessor :version, :public_key, :routing_info, :hmac
|
9
|
+
|
7
10
|
def initialize(version, public_key, routing_info, hmac)
|
8
11
|
@version = version
|
9
12
|
@public_key = public_key
|
10
13
|
@routing_info = routing_info
|
11
|
-
raise "invalid size #{routing_info.size}" unless routing_info.size ==
|
14
|
+
raise "invalid size #{routing_info.size}" unless routing_info.size == MAX_HOPS * HOP_LENGTH * 2
|
12
15
|
@hmac = hmac
|
13
16
|
end
|
14
17
|
|
15
18
|
def self.parse(payload)
|
16
19
|
version, public_key, rest = payload.unpack('aH66a*')
|
17
|
-
routing_info = rest[0...
|
18
|
-
hmac = rest[
|
20
|
+
routing_info = rest[0...MAX_HOPS * HOP_LENGTH].bth
|
21
|
+
hmac = rest[MAX_HOPS * HOP_LENGTH..-1].bth
|
19
22
|
new(version, public_key, routing_info, hmac)
|
20
23
|
end
|
21
24
|
|
@@ -4,14 +4,16 @@ module Lightning
|
|
4
4
|
module Onion
|
5
5
|
module Sphinx
|
6
6
|
VERSION = "\x00"
|
7
|
+
PUBKEY_LENGTH = 33
|
7
8
|
PAYLOAD_LENGTH = 33
|
8
9
|
MAC_LENGTH = 32
|
9
10
|
MAX_HOPS = 20
|
10
11
|
HOP_LENGTH = PAYLOAD_LENGTH + MAC_LENGTH
|
11
12
|
MAX_ERROR_PAYLOAD_LENGTH = 256
|
12
13
|
ERROR_PACKET_LENGTH = MAC_LENGTH + MAX_ERROR_PAYLOAD_LENGTH + 2 + 2
|
14
|
+
PACKET_LENGTH = VERSION.bytesize + PUBKEY_LENGTH + MAX_HOPS * HOP_LENGTH + MAC_LENGTH
|
13
15
|
|
14
|
-
LAST_PACKET = Lightning::Onion::Packet.new(VERSION, "\x00" *
|
16
|
+
LAST_PACKET = Lightning::Onion::Packet.new(VERSION, "\x00" * PUBKEY_LENGTH, '00' * MAX_HOPS * HOP_LENGTH, '00' * MAC_LENGTH)
|
15
17
|
|
16
18
|
def self.make_packet(session_key, public_keys, payloads, associated_data)
|
17
19
|
ephemereal_public_keys, shared_secrets = compute_keys_and_secrets(session_key, public_keys)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lightning-onion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hajime Yamaguchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: algebrick
|