digix-eth 0.5.3 → 0.5.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: 5e7df4d4bba9a5121f8b756583debbda521b9b43
4
- data.tar.gz: 3db4a3248cd01a335bec26367058101506601273
3
+ metadata.gz: 861710a42df399aa56c12849aa8bddc34c026177
4
+ data.tar.gz: 1138b8eb0192546ecb105f9565a506a86fac1bc7
5
5
  SHA512:
6
- metadata.gz: a3c56f70f23cfd7ee042c66dd74f7af57776df13588406af03f65962b9d97eb6f841668e90eb23b20ad55a2810a19eb9161a0f333843e40bfa4645a96b73f0d4
7
- data.tar.gz: fc7ac72fea792523a1c4a3c14bf124b5ed607a0f37faa580770009393c95d16255f8a57e04d43a04d9ecb77164067de51b263c15dfb024504fa6e13c6a658668
6
+ metadata.gz: 730cf54252f4bc86fd69e5f40ff81d423d036068193d4c6960e03903497129a08fde8befe4c9c4b7a9dfecb169a212cb3d4b80894e81927bbacbb397b1ac0201
7
+ data.tar.gz: 3be0d1f603f981b47920ff09c5b4deb07d2ed146031c77cdf4afb28b4cd8cb07a490e4af26fdee473275682f2dab0eb4420e5758dadba0ae6403a7ee4d56289a
@@ -9,14 +9,12 @@ module Eth
9
9
 
10
10
  def sign_message(message)
11
11
  payload = Eth::Signature.new(message)
12
+ payload.signer = @key.address
12
13
  payload.prefixed_message = Eth::Utils.prefix_message(message)
13
14
  payload.hash = Eth::Utils.keccak256(payload.prefixed_message)
14
- payload.hash_hex = Eth::Utils.bin_to_prefixed_hex(payload.hash)
15
15
  payload.signature = @key.sign(payload.prefixed_message)
16
- payload.signature_hex = Eth::Utils.bin_to_prefixed_hex(payload.signature)
17
16
  payload.v, payload.r, payload.s = Eth::Utils.v_r_s_for(payload.signature)
18
- payload.rpc = Eth::Utils.zpad_int(payload.r, 32) + Eth::Utils.zpad_int(payload.s, 32) + [(payload.v - 27)].pack('C')
19
- payload.rpc_hex = Eth::Utils.bin_to_prefixed_hex(payload.rpc)
17
+ payload.rpc_signature = Eth::Utils.zpad_int(payload.r, 32) + Eth::Utils.zpad_int(payload.s, 32) + [(payload.v - 27)].pack('C')
20
18
  return payload
21
19
  end
22
20
 
@@ -1,7 +1,43 @@
1
+ class String
2
+
3
+ def to_urlsafe_base64
4
+ if is_hex?
5
+ Base64.urlsafe_encode64(Eth::Utils.hex_to_bin(self))
6
+ else
7
+ Base64.urlsafe_encode64(self)
8
+ end
9
+ end
10
+
11
+ def from_urlsafe_base64
12
+ Base64.urlsafe_decode64(self)
13
+ end
14
+
15
+ def to_hex
16
+ if self.is_hex?
17
+ return self
18
+ else
19
+ Eth::Utils.bin_to_prefixed_hex(self)
20
+ end
21
+ end
22
+
23
+ def is_hex?
24
+ !self.gsub("0x", '')[/\H/]
25
+ end
26
+
27
+ end
28
+
1
29
  module Eth
2
30
  class Signature
3
31
 
4
- attr_accessor :message, :signer, :prefixed_message, :hash, :hash_hex, :signature, :signature_hex, :rpc, :rpc_hex, :v, :r, :s
32
+ attr_accessor :message,
33
+ :signer,
34
+ :prefixed_message,
35
+ :hash,
36
+ :signature,
37
+ :rpc_signature,
38
+ :v,
39
+ :r,
40
+ :s
5
41
 
6
42
  def initialize(message)
7
43
  @message = message
@@ -1,3 +1,3 @@
1
1
  module Eth
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: digix-eth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Ellis
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-07-15 00:00:00.000000000 Z
12
+ date: 2017-07-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: digest-sha3