eth 0.4.11 → 0.4.18

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
- SHA1:
3
- metadata.gz: 6436ecdbcecdf75d62a47c1aadcca3b8056774a3
4
- data.tar.gz: c60fefe544a070c75cd0a60c80ed6d7df7ddca2f
2
+ SHA256:
3
+ metadata.gz: 2cfb1dbda97ae8033690aeb0ffe7410e2db112dbb3d2c78f34bad15db7dcbf45
4
+ data.tar.gz: '039a0fc3b15cd132f1409fc8636f32d501f237e338628c63672f21fed81047af'
5
5
  SHA512:
6
- metadata.gz: 3757924cd14cbe89260b08d88c9aa157a914b8ed7afa6086d8c08335dd77a006ec74f37ba4ab7febc835644f75112a68b5bbf3c91224411753d78211f81ab5e8
7
- data.tar.gz: 286f9d8b76042b74f1930855cafd34648d3308156eaab17e4a2a8c3ebe3f12692444284c9b797cc555dbaf61fe96b46a515ec0b882a925d524f67f6193736f4a
6
+ metadata.gz: e69bf16bccb10f673673c8f45167817930549813a3e9fa33b64e868a618f6bbd810c23a8512c1a0f535a18d38238b71ab18afdfd438e6ebd8cffb2deb5256a79
7
+ data.tar.gz: 67c6de579f25a7b9cdecd8fee97f5df927d8f0145c03b9604c324e86925ba905f6e98b42e49b1487178842ea25efe3a8f0ea35162ee96666db85345bf0281bd4
@@ -0,0 +1,36 @@
1
+ ---
2
+ name: Build
3
+
4
+ on:
5
+ pull_request:
6
+ branches:
7
+ - develop
8
+ push:
9
+ branches:
10
+ - develop
11
+
12
+ jobs:
13
+ build:
14
+ runs-on: ${{ matrix.os }}
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ os: [ubuntu-latest, macos-latest]
19
+ ruby: ['2.7', '3.0']
20
+ steps:
21
+ - uses: actions/checkout@v2
22
+ - uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ bundler-cache: true
26
+ - name: Brew Automake
27
+ run: |
28
+ brew install automake
29
+ if: startsWith(matrix.os, 'macOS')
30
+ - name: Install Dependencies
31
+ run: |
32
+ git submodule update --init
33
+ bundle install
34
+ - name: Run Tests
35
+ run: |
36
+ bundle exec rspec
@@ -0,0 +1,44 @@
1
+ ---
2
+ name: CodeQL
3
+
4
+ on:
5
+ pull_request:
6
+ branches:
7
+ - develop
8
+ push:
9
+ branches:
10
+ - develop
11
+
12
+ jobs:
13
+ analyze:
14
+ name: Analyze
15
+ runs-on: ubuntu-latest
16
+ permissions:
17
+ actions: read
18
+ contents: read
19
+ security-events: write
20
+ strategy:
21
+ fail-fast: false
22
+ matrix:
23
+ language:
24
+ - ruby
25
+ steps:
26
+ - name: "Checkout repository"
27
+ uses: actions/checkout@v2
28
+ - name: "Initialize CodeQL"
29
+ uses: github/codeql-action/init@v1
30
+ with:
31
+ languages: "${{ matrix.language }}"
32
+ - name: Autobuild
33
+ uses: github/codeql-action/autobuild@v1
34
+ - name: "Perform CodeQL Analysis"
35
+ uses: github/codeql-action/analyze@v1
36
+ - uses: ruby/setup-ruby@v1
37
+ with:
38
+ ruby-version: '2.7'
39
+ bundler-cache: true
40
+ - name: "Run rufo code formatting checks"
41
+ run: |
42
+ gem install rufo
43
+ rufo --check ./lib
44
+ rufo --check ./spec
@@ -0,0 +1,26 @@
1
+ ---
2
+ name: Docs
3
+
4
+ on:
5
+ push:
6
+ branches:
7
+ - develop
8
+
9
+ jobs:
10
+ docs:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - uses: ruby/setup-ruby@v1
15
+ with:
16
+ ruby-version: '2.7'
17
+ bundler-cache: true
18
+ - name: Run Yard Doc
19
+ run: |
20
+ gem install yard
21
+ yard doc
22
+ - name: Deploy GH Pages
23
+ uses: JamesIves/github-pages-deploy-action@4.1.7
24
+ with:
25
+ branch: gh-pages
26
+ folder: doc/
data/.gitignore CHANGED
@@ -1,10 +1,43 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
1
+ *.DS_Store
2
+
3
+ /test/test_vectors.rb
4
+ /ext/digest/Makefile
5
+ /ext/digest/keccak.so
6
+ /ext/digest/mkmf.log
7
+
8
+ *.o
9
+ *.so
10
+ *.gem
11
+ *.log
12
+ *.rbc
13
+ /.config
14
+ /.rake_tasks~
5
15
  /coverage/
6
- /doc/
16
+ /InstalledFiles
7
17
  /pkg/
8
- /spec/reports/
9
18
  /tmp/
10
- .ruby-version
19
+
20
+ # RSpec configuration and generated files:
21
+ /.rspec
22
+ /spec/examples.txt
23
+
24
+ # Documentation cache and generated files:
25
+ /.yardoc/
26
+ /_yardoc/
27
+ /doc/
28
+ /rdoc/
29
+
30
+ # Environment normalization:
31
+ /.bundle/
32
+ /vendor/bundle/*
33
+ !/vendor/bundle/.keep
34
+ /lib/bundler/man/
35
+
36
+ # For a library or gem, you might want to ignore these files since the code is
37
+ # intended to run in multiple environments; otherwise, check them in:
38
+ /Gemfile.lock
39
+ /.ruby-version
40
+ /.ruby-gemset
41
+
42
+ # Unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
43
+ .rvmrc
data/CHANGELOG.md CHANGED
@@ -6,13 +6,33 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
7
  ### Unreleased
8
8
 
9
- ## [0.4.11]
9
+ ## [0.4.17]
10
+ ### Changed
11
+ - Gems: bump version to 0.4.17 [#70](https://github.com/se3000/ruby-eth/pull/70)
12
+ - Gems: bump keccak to 1.3.0 [#69](https://github.com/se3000/ruby-eth/pull/69)
13
+
14
+ ## [0.4.16]
15
+ ### Changed
16
+ - Docs: update changelog [#65](https://github.com/se3000/ruby-eth/pull/65)
17
+ - Gems: bump version to 0.4.16 [#65](https://github.com/se3000/ruby-eth/pull/65)
18
+ - License: update copyright notice [#64](https://github.com/se3000/ruby-eth/pull/64)
19
+ - Docs: add badges to readme [#64](https://github.com/se3000/ruby-eth/pull/64)
20
+ - Git: deprecating master [#63](https://github.com/se3000/ruby-eth/pull/63)
21
+ - CI: replace travis with github actions [#62](https://github.com/se3000/ruby-eth/pull/62)
22
+ - Gems: replace digest-sha3-patched with keccak [#58](https://github.com/se3000/ruby-eth/pull/58)
23
+
24
+ ## [0.4.13], [0.4.14], [0.4.15]
25
+ _Released as [`eth-patched`](https://github.com/q9f/ruby-eth) from a different source tree._
26
+
27
+ ## [0.4.12]
28
+ ### Changed
29
+ - Bump rake version because of security vulnerability
10
30
 
31
+ ## [0.4.11]
11
32
  ### Added
12
33
  - Support for recovering signatures with a V value below 27 (like from Ledger hardware wallets)
13
34
 
14
35
  ## [0.4.10]
15
-
16
36
  ### Changed
17
37
  - Use updated sha3 dependency
18
38
  - Improved OpenSSL support
@@ -21,38 +41,31 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
21
41
  - Changed Eth::Configuration.default_chain_id back to .chain_id for dependent libraries.
22
42
 
23
43
  ## [0.4.9]
24
-
25
44
  ### Changed
26
45
  - [escoffon](https://github.com/escoffon) added support for chain IDs larger than 120.
27
46
 
28
47
  ## [0.4.8]
29
-
30
48
  ### Added
31
49
  - [@buhrmi](https://github.com/buhrmi) added Eth::Key#personal_sign.
32
50
  - [@buhrmi](https://github.com/buhrmi) added Eth::Key#personal_recover.
33
51
 
34
52
  ## [0.4.7]
35
-
36
53
  ### Changed
37
54
  - Updated MoneyTree dependency.
38
55
 
39
56
  ## [0.4.6]
40
-
41
57
  ### Added
42
58
  - Support scrypt private key decryption
43
59
 
44
60
  ## [0.4.5]
45
-
46
61
  ### Changed
47
62
  - Further improve Open SSL configurability
48
63
 
49
64
  ## [0.4.4]
50
-
51
65
  ### Changed
52
66
  - Support old versions of SSL to help avoid preious breaking changes
53
67
 
54
68
  ## [0.4.3]
55
-
56
69
  ### Added
57
70
  - Eth::Key::Encrypter class to handle encrypting keys.
58
71
  - Eth::Key.encrypt as a nice wrapper around Encrypter class.
@@ -60,7 +73,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
60
73
  - Eth::Key.decrypt as a nice wrapper around Decrypter class.
61
74
 
62
75
  ## [0.4.2]
63
-
64
76
  ### Added
65
77
  - Address#valid? to validate EIP55 checksums.
66
78
  - Address#checksummed to generate EIP55 checksums.
@@ -72,12 +84,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
72
84
 
73
85
 
74
86
  ## [0.4.1]
75
-
76
87
  ### Changed
77
88
  - Tx#hash includes the '0x' hex prefix.
78
89
 
79
90
  ## [0.4.0]
80
-
81
91
  ### Added
82
92
  - Tx#data_bin returns the data field of a transaction in binary.
83
93
  - Tx#data_hex returns the data field of a transaction as a hexadecimal string.
data/Gemfile CHANGED
@@ -1,4 +1,9 @@
1
- source 'https://rubygems.org'
1
+ # frozen_string_literal: true
2
2
 
3
- # Specify your gem's dependencies in ethereum-tx.gemspec
3
+ # ref: https://github.com/GemHQ/money-tree/issues/50
4
+ gem "money-tree", git: "https://github.com/GemHQ/money-tree.git"
5
+
6
+ source "https://rubygems.org"
7
+
8
+ # Specify your gem's dependencies in eth.gemspec
4
9
  gemspec
data/LICENSE.txt CHANGED
@@ -1,6 +1,7 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 Steve Ellis
3
+ Copyright (c) 2016-2021 Steve Ellis
4
+ Copyright (c) 2021-2022 Afri Schoedon
4
5
 
5
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
7
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,4 +1,10 @@
1
- # Eth [![Travis-CI](https://travis-ci.org/se3000/ruby-eth.svg?branch=master)](https://travis-ci.org/se3000/ruby-eth) [![Code Climate](https://codeclimate.com/github/se3000/ruby-eth/badges/gpa.svg)](https://codeclimate.com/github/se3000/ruby-eth) [![Gitter](https://badges.gitter.im/ruby-eth/Lobby.svg)](https://gitter.im/ruby-eth/Lobby)
1
+ # Eth for Ruby
2
+ [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/se3000/ruby-eth/Build)](https://github.com/se3000/ruby-eth/actions)
3
+ [![GitHub release (latest by date)](https://img.shields.io/github/v/release/se3000/ruby-eth)](https://github.com/se3000/ruby-eth/releases)
4
+ [![Gem](https://img.shields.io/gem/v/eth)](https://rubygems.org/gems/eth)
5
+ [![Gem](https://img.shields.io/gem/dt/eth)](https://rubygems.org/gems/eth)
6
+ [![GitHub top language](https://img.shields.io/github/languages/top/se3000/ruby-eth?color=red)](https://github.com/se3000/ruby-eth/pulse)
7
+ [![GitHub](https://img.shields.io/github/license/se3000/ruby-eth)](LICENSE)
2
8
 
3
9
  A simple library to build and sign Ethereum transactions. Allows separation of key and node management. Sign transactions and handle keys anywhere you can run ruby, broadcast transactions through any node.
4
10
 
@@ -12,7 +18,7 @@ gem 'eth'
12
18
 
13
19
  And then execute:
14
20
 
15
- $ bundle
21
+ $ bundle install
16
22
 
17
23
  Or install it yourself as:
18
24
 
@@ -118,7 +124,7 @@ end
118
124
 
119
125
  ## Contributing
120
126
 
121
- Bug reports and pull requests are welcome on GitHub at https://github.com/se3000/ethereum-tx. Tests are encouraged.
127
+ Bug reports and pull requests are welcome on GitHub at https://github.com/se3000/ruby-eth. Tests are encouraged.
122
128
 
123
129
  ### Tests
124
130
 
@@ -136,7 +142,7 @@ rspec
136
142
 
137
143
  ## License
138
144
 
139
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
145
+ The gem is available as open-source software under the terms of the [MIT License](http://opensource.org/licenses/MIT).
140
146
 
141
147
  ## TODO
142
148
 
data/eth.gemspec CHANGED
@@ -1,31 +1,47 @@
1
+ # frozen_string_literal: true
1
2
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'eth/version'
3
+
4
+ lib = File.expand_path("lib", __dir__).freeze
5
+ $LOAD_PATH.unshift lib unless $LOAD_PATH.include? lib
6
+
7
+ require "eth/version"
5
8
 
6
9
  Gem::Specification.new do |spec|
7
- spec.name = "eth"
8
- spec.version = Eth::VERSION
9
- spec.authors = ["Steve Ellis"]
10
- spec.email = ["email@steveell.is"]
11
-
12
- spec.summary = %q{Simple API to sign Ethereum transactions.}
13
- spec.description = %q{Library to build, parse, and sign Ethereum transactions.}
14
- spec.homepage = "https://github.com/se3000/ruby-eth"
15
- spec.license = "MIT"
16
-
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
19
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
10
+ spec.name = "eth"
11
+ spec.version = Eth::VERSION
12
+ spec.authors = ["Steve Ellis", "Afri Schoedon"]
13
+ spec.email = ["email@steveell.is", "ruby@q9f.cc"]
14
+
15
+ spec.summary = %q{Simple API to sign Ethereum transactions.}
16
+ spec.description = %q{Library to build, parse, and sign Ethereum transactions.}
17
+ spec.homepage = "https://github.com/se3000/ruby-eth"
18
+ spec.license = "MIT"
19
+
20
+ spec.metadata = {
21
+ "homepage_uri" => "https://github.com/se3000/ruby-eth",
22
+ "source_code_uri" => "https://github.com/se3000/ruby-eth",
23
+ "github_repo" => "https://github.com/se3000/ruby-eth",
24
+ "bug_tracker_uri" => "https://github.com/se3000/ruby-eth/issues",
25
+ }.freeze
26
+
27
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
30
  spec.require_paths = ["lib"]
31
+ spec.test_files = spec.files.grep %r{^(test|spec|features)/}
32
+
33
+ spec.add_dependency "keccak", "~> 1.3"
34
+ spec.add_dependency "ffi", "~> 1.15"
35
+ spec.add_dependency "money-tree", "~> 0.11"
36
+ spec.add_dependency "openssl", "~> 3.0"
37
+ spec.add_dependency "rlp", "~> 0.7"
38
+ spec.add_dependency "scrypt", "~> 3.0"
21
39
 
22
- spec.add_dependency 'digest-sha3-patched', '~> 1.1'
23
- spec.add_dependency 'ffi', '~> 1.0'
24
- spec.add_dependency 'money-tree', '~> 0.10.0'
25
- spec.add_dependency 'rlp', '~> 0.7.3'
26
- spec.add_dependency 'scrypt', '~> 3.0.6'
40
+ spec.platform = Gem::Platform::RUBY
41
+ spec.required_ruby_version = ">= 2.6", "< 4.0"
27
42
 
28
- spec.add_development_dependency 'pry', '~> 0.1'
29
- spec.add_development_dependency 'rake', '~> 10.0'
30
- spec.add_development_dependency 'rspec', '~> 3.0'
43
+ spec.add_development_dependency "bundler", "~> 2.2"
44
+ spec.add_development_dependency "pry", "~> 0.14"
45
+ spec.add_development_dependency "rake", "~> 13.0"
46
+ spec.add_development_dependency "rspec", "~> 3.10"
31
47
  end
data/lib/eth/address.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  module Eth
2
2
  class Address
3
-
4
3
  def initialize(address)
5
4
  @address = Utils.prefix_hex(address)
6
5
  end
@@ -25,7 +24,6 @@ module Eth
25
24
  Utils.prefix_hex(cased.join)
26
25
  end
27
26
 
28
-
29
27
  private
30
28
 
31
29
  attr_reader :address
@@ -57,6 +55,5 @@ module Eth
57
55
  def unprefixed
58
56
  Utils.remove_hex_prefix address
59
57
  end
60
-
61
58
  end
62
59
  end
data/lib/eth/gas.rb CHANGED
@@ -1,9 +1,7 @@
1
1
  module Eth
2
2
  class Gas
3
-
4
3
  GTXCOST = 21000 # TX BASE GAS COST
5
4
  GTXDATANONZERO = 68 # TX DATA NON ZERO BYTE GAS COST
6
5
  GTXDATAZERO = 4 # TX DATA ZERO BYTE GAS COST
7
-
8
6
  end
9
7
  end
@@ -1,5 +1,5 @@
1
- require 'json'
2
- require 'scrypt'
1
+ require "json"
2
+ require "scrypt"
3
3
 
4
4
  class Eth::Key::Decrypter
5
5
  include Eth::Utils
@@ -19,16 +19,15 @@ class Eth::Key::Decrypter
19
19
  bin_to_hex decrypted_data
20
20
  end
21
21
 
22
-
23
22
  private
24
23
 
25
24
  attr_reader :data, :key, :password
26
25
 
27
26
  def derive_key(password)
28
27
  case kdf
29
- when 'pbkdf2'
28
+ when "pbkdf2"
30
29
  @key = OpenSSL::PKCS5.pbkdf2_hmac(password, salt, iterations, key_length, digest)
31
- when 'scrypt'
30
+ when "scrypt"
32
31
  # OpenSSL 1.1 inclues OpenSSL::KDF.scrypt, but it is not available usually, otherwise we could do: OpenSSL::KDF.scrypt(password, salt: salt, N: n, r: r, p: p, length: key_length)
33
32
  @key = SCrypt::Engine.scrypt(password, salt, n, r, p, key_length)
34
33
  else
@@ -37,8 +36,8 @@ class Eth::Key::Decrypter
37
36
  end
38
37
 
39
38
  def check_macs
40
- mac1 = keccak256(key[(key_length/2), key_length] + ciphertext)
41
- mac2 = hex_to_bin crypto_data['mac']
39
+ mac1 = keccak256(key[(key_length / 2), key_length] + ciphertext)
40
+ mac2 = hex_to_bin crypto_data["mac"]
42
41
 
43
42
  if mac1 != mac2
44
43
  raise "Message Authentications Codes do not match!"
@@ -50,11 +49,11 @@ class Eth::Key::Decrypter
50
49
  end
51
50
 
52
51
  def crypto_data
53
- @crypto_data ||= data['crypto'] || data['Crypto']
52
+ @crypto_data ||= data["crypto"] || data["Crypto"]
54
53
  end
55
54
 
56
55
  def ciphertext
57
- hex_to_bin crypto_data['ciphertext']
56
+ hex_to_bin crypto_data["ciphertext"]
58
57
  end
59
58
 
60
59
  def cipher_name
@@ -64,41 +63,41 @@ class Eth::Key::Decrypter
64
63
  def cipher
65
64
  @cipher ||= OpenSSL::Cipher.new(cipher_name).tap do |cipher|
66
65
  cipher.decrypt
67
- cipher.key = key[0, (key_length/2)]
66
+ cipher.key = key[0, (key_length / 2)]
68
67
  cipher.iv = iv
69
68
  end
70
69
  end
71
70
 
72
71
  def iv
73
- hex_to_bin crypto_data['cipherparams']['iv']
72
+ hex_to_bin crypto_data["cipherparams"]["iv"]
74
73
  end
75
74
 
76
75
  def salt
77
- hex_to_bin crypto_data['kdfparams']['salt']
76
+ hex_to_bin crypto_data["kdfparams"]["salt"]
78
77
  end
79
78
 
80
79
  def iterations
81
- crypto_data['kdfparams']['c'].to_i
80
+ crypto_data["kdfparams"]["c"].to_i
82
81
  end
83
82
 
84
83
  def kdf
85
- crypto_data['kdf']
84
+ crypto_data["kdf"]
86
85
  end
87
86
 
88
87
  def key_length
89
- crypto_data['kdfparams']['dklen'].to_i
88
+ crypto_data["kdfparams"]["dklen"].to_i
90
89
  end
91
90
 
92
91
  def n
93
- crypto_data['kdfparams']['n'].to_i
92
+ crypto_data["kdfparams"]["n"].to_i
94
93
  end
95
94
 
96
95
  def r
97
- crypto_data['kdfparams']['r'].to_i
96
+ crypto_data["kdfparams"]["r"].to_i
98
97
  end
99
98
 
100
99
  def p
101
- crypto_data['kdfparams']['p'].to_i
100
+ crypto_data["kdfparams"]["p"].to_i
102
101
  end
103
102
 
104
103
  def digest
@@ -108,6 +107,4 @@ class Eth::Key::Decrypter
108
107
  def digest_name
109
108
  "sha256"
110
109
  end
111
-
112
-
113
110
  end
@@ -1,5 +1,5 @@
1
- require 'json'
2
- require 'securerandom'
1
+ require "json"
2
+ require "securerandom"
3
3
 
4
4
  class Eth::Key::Encrypter
5
5
  include Eth::Utils
@@ -48,7 +48,6 @@ class Eth::Key::Encrypter
48
48
  @id ||= options[:id] || SecureRandom.uuid
49
49
  end
50
50
 
51
-
52
51
  private
53
52
 
54
53
  attr_reader :derived_key, :encrypted_key, :key, :options
@@ -57,7 +56,7 @@ class Eth::Key::Encrypter
57
56
  @cipher ||= OpenSSL::Cipher.new(cipher_name).tap do |cipher|
58
57
  cipher.encrypt
59
58
  cipher.iv = iv
60
- cipher.key = derived_key[0, (key_length/2)]
59
+ cipher.key = derived_key[0, (key_length / 2)]
61
60
  end
62
61
  end
63
62
 
@@ -74,7 +73,7 @@ class Eth::Key::Encrypter
74
73
  end
75
74
 
76
75
  def mac
77
- keccak256(derived_key[(key_length/2), key_length] + encrypted_key)
76
+ keccak256(derived_key[(key_length / 2), key_length] + encrypted_key)
78
77
  end
79
78
 
80
79
  def cipher_name
@@ -107,22 +106,21 @@ class Eth::Key::Encrypter
107
106
 
108
107
  def salt
109
108
  @salt ||= if options[:salt]
110
- hex_to_bin options[:salt]
111
- else
112
- SecureRandom.random_bytes(salt_length)
113
- end
109
+ hex_to_bin options[:salt]
110
+ else
111
+ SecureRandom.random_bytes(salt_length)
112
+ end
114
113
  end
115
114
 
116
115
  def iv
117
116
  @iv ||= if options[:iv]
118
- hex_to_bin options[:iv]
119
- else
120
- SecureRandom.random_bytes(iv_length)
121
- end
117
+ hex_to_bin options[:iv]
118
+ else
119
+ SecureRandom.random_bytes(iv_length)
120
+ end
122
121
  end
123
122
 
124
123
  def address
125
124
  Eth::Key.new(priv: key).address
126
125
  end
127
-
128
126
  end
data/lib/eth/key.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Eth
2
2
  class Key
3
- autoload :Decrypter, 'eth/key/decrypter'
4
- autoload :Encrypter, 'eth/key/encrypter'
3
+ autoload :Decrypter, "eth/key/decrypter"
4
+ autoload :Encrypter, "eth/key/encrypter"
5
5
 
6
6
  attr_reader :private_key, :public_key
7
7
 
@@ -17,7 +17,7 @@ module Eth
17
17
  end
18
18
 
19
19
  def self.personal_recover(message, signature)
20
- bin_signature = Utils.hex_to_bin(signature).bytes.rotate(-1).pack('c*')
20
+ bin_signature = Utils.hex_to_bin(signature).bytes.rotate(-1).pack("c*")
21
21
  OpenSsl.recover_compact(Utils.keccak256(Utils.prefix_message(message)), bin_signature)
22
22
  end
23
23
 
@@ -41,6 +41,7 @@ module Eth
41
41
  def address
42
42
  Utils.public_key_to_address public_hex
43
43
  end
44
+
44
45
  alias_method :to_address, :address
45
46
 
46
47
  def sign(message)
@@ -60,10 +61,9 @@ module Eth
60
61
  end
61
62
 
62
63
  def personal_sign(message)
63
- Utils.bin_to_hex(sign(Utils.prefix_message(message)).bytes.rotate(1).pack('c*'))
64
+ Utils.bin_to_hex(sign(Utils.prefix_message(message)).bytes.rotate(1).pack("c*"))
64
65
  end
65
66
 
66
-
67
67
  private
68
68
 
69
69
  def message_hash(message)
@@ -72,8 +72,7 @@ module Eth
72
72
 
73
73
  def valid_s?(signature)
74
74
  s_value = Utils.v_r_s_for(signature).last
75
- s_value <= Secp256k1::N/2 && s_value != 0
75
+ s_value <= Secp256k1::N / 2 && s_value != 0
76
76
  end
77
-
78
77
  end
79
78
  end