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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ab9c2e28c21df3eaba32de0c6f94e42fd20706c
4
- data.tar.gz: e959dd65032a7f2da7691bce6fb88b2fb204b3ba
3
+ metadata.gz: c676e3e173135c4fb63cc8cf9d42936342f0a144
4
+ data.tar.gz: b2600dd7b5ee1215d1037aca1ee05734946dd57f
5
5
  SHA512:
6
- metadata.gz: a1d3b593b58cb084effcadf2ba13e005aad49883cd1f51913fedb9cc9a5e6513878378511b76374007f7e63db62932908b1d7c9c3bddfc78db79a2e94314bb23
7
- data.tar.gz: 30f204b6fffe908f3a9d8cc233d30285610a374f50f3e55ce82e7c021788d5a59618ac4049ad41177890a3ce968ec33f4a52ed91107c7d2e8f4dedf870764ac9
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 == 1300 * 2
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...20 * 65].bth
18
- hmac = rest[20 * 65..-1].bth
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" * 33, '00' * MAX_HOPS * HOP_LENGTH, '00' * MAC_LENGTH)
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)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lightning
4
4
  module Onion
5
- VERSION = '0.2.3'
5
+ VERSION = '0.2.4'
6
6
  end
7
7
  end
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.3
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-08 00:00:00.000000000 Z
11
+ date: 2018-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: algebrick