klay 0.0.2 → 0.0.3

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
  SHA256:
3
- metadata.gz: eca4a041d35e7ffbc2dccf83b255b906f66bf508e72c508fb832f260715dbc58
4
- data.tar.gz: 0b36085e063060251a207a6a218f0d663f3564a9b2027c9c46ea7d159f5f4b2d
3
+ metadata.gz: 8986fd6d80e3681e563bd7e54150159d8f4d5f965c2c78f1a20cd3bf8d6ba57c
4
+ data.tar.gz: aa908017c60bd2ca4655a08763aaec318de7aaabf5a064d9bab624ba3d0c9c56
5
5
  SHA512:
6
- metadata.gz: 442fc363c6d604137e212169d28f331ef272cca3f25396d73a2e9abafd8bebec295eb11bd6d5232846b984882af3b3ef12206342f1aba38ff990629c652f0f87
7
- data.tar.gz: 9a022d0e0d7d53e92c67c59b4e856b10629a20c296c848aa9a591e4ff47c604fc6a8881fef828d4e16f1cb8ac2c703c0388106c4cead57dab26474e77fee0adc
6
+ metadata.gz: 60d093d6d7c16a96cf453ce2303d1098bb00b8171f88b55d09aa4e2d0772c250fbb185da0946d6ff420a2c6c56d4eb5dd87931d8261a998c2e939c73b32765f8
7
+ data.tar.gz: 57e532d640d093d7049c71b66b110567ada2626cb2f03b69ca731c209968eecd02e96f136053b342cc7755407b6c05ed4790a929239b100810946189b31bc3f0
@@ -38,7 +38,7 @@ module Klay
38
38
  # @param message [String] the message string to be prefixed.
39
39
  # @return [String] an EIP-191 prefixed string.
40
40
  def prefix_message(message)
41
- "#{EIP191_PREFIX_BYTE}Klaytn Signed Message:\n#{message.size}#{message}"
41
+ "\u0019Klaytn Signed Message:\n#{message.size}#{message}"
42
42
  end
43
43
 
44
44
  # Dissects a signature blob of 65+ bytes into its `r`, `s`, and `v`
@@ -50,12 +50,12 @@ module Klay
50
50
  def dissect(signature)
51
51
  signature = Util.bin_to_hex signature unless Util.is_hex? signature
52
52
  signature = Util.remove_hex_prefix signature
53
- if signature.size < 130
53
+ if signature.size != 130
54
54
  raise SignatureError, "Unknown signature length #{signature.size}!"
55
55
  end
56
- r = signature[0, 64]
57
- s = signature[64, 128]
58
- v = signature[128]
56
+ r = signature[0...64]
57
+ s = signature[64...128]
58
+ v = signature[128..]
59
59
  return r, s, v
60
60
  end
61
61
 
@@ -71,7 +71,7 @@ module Klay
71
71
  r, s, v = dissect signature
72
72
  v = v.to_i(16)
73
73
  p v
74
- raise SignatureError, "Invalid signature v byte #{v} for chain ID #{chain_id}!" if v != 130
74
+ # raise SignatureError, "Invalid signature v byte #{v} for chain ID #{chain_id}!" if v != 130
75
75
  recovery_id = Chain.to_recovery_id v, chain_id
76
76
  signature_rs = Util.hex_to_bin "#{r}#{s}"
77
77
  recoverable_signature = context.recoverable_signature_from_compact signature_rs, recovery_id
@@ -79,6 +79,20 @@ module Klay
79
79
  Util.bin_to_hex public_key.uncompressed
80
80
  end
81
81
 
82
+ # def to_recovery_id(v)
83
+ # if (v == 0 || v == 1) {
84
+ # return v;
85
+ # }
86
+ # if (v < 27) {
87
+ # raise new SignatureError("v byte out of range: " + v);
88
+ # }
89
+ # if(v < 35) {
90
+ # // v = parity value {0,1} + 27
91
+ # return v - 27;
92
+ # }
93
+ # return ((v - 35) % 2) == 0 ? 0 : 1;
94
+ # end
95
+
82
96
  # Recovers a public key from a prefixed, personal message and
83
97
  # a signature on a given chain. (EIP-191)
84
98
  # Ref: https://eips.ethereum.org/EIPS/eip-191
data/lib/klay/version.rb CHANGED
@@ -16,5 +16,5 @@
16
16
  module Klay
17
17
 
18
18
  # Defines the version of the {Eth} module.
19
- VERSION = "0.0.2".freeze
19
+ VERSION = "0.0.3".freeze
20
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: klay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sehan Park