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 +4 -4
- data/lib/eth/rpc_signer.rb +2 -4
- data/lib/eth/signature.rb +37 -1
- data/lib/eth/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: 861710a42df399aa56c12849aa8bddc34c026177
|
4
|
+
data.tar.gz: 1138b8eb0192546ecb105f9565a506a86fac1bc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 730cf54252f4bc86fd69e5f40ff81d423d036068193d4c6960e03903497129a08fde8befe4c9c4b7a9dfecb169a212cb3d4b80894e81927bbacbb397b1ac0201
|
7
|
+
data.tar.gz: 3be0d1f603f981b47920ff09c5b4deb07d2ed146031c77cdf4afb28b4cd8cb07a490e4af26fdee473275682f2dab0eb4420e5758dadba0ae6403a7ee4d56289a
|
data/lib/eth/rpc_signer.rb
CHANGED
@@ -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.
|
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
|
|
data/lib/eth/signature.rb
CHANGED
@@ -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,
|
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
|
data/lib/eth/version.rb
CHANGED
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.
|
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-
|
12
|
+
date: 2017-07-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: digest-sha3
|