Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gems: rename sha3 to keccak #6

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions etherlite.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_dependency "digest-sha3", "~> 1.1"
spec.add_dependency "power-types", "~> 0.1"
spec.add_dependency "eth", "~> 0.4.4"
spec.add_dependency "activesupport"
spec.add_dependency "keccak", "~> 1.3"
spec.add_dependency "power-types", "~> 0.4"
spec.add_dependency "eth", "~> 0.4"
spec.add_dependency "activesupport", "~> 6.1"

spec.add_development_dependency "bundler", "~> 2.1.4"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "guard", "~> 2.14"
spec.add_development_dependency "bundler", "~> 2.2"
spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "rspec", "~> 3.10"
spec.add_development_dependency "guard", "~> 2.18"
spec.add_development_dependency "guard-rspec", "~> 4.7"
spec.add_development_dependency "webmock", "~> 3.7.5"
spec.add_development_dependency "pry"
spec.add_development_dependency "webmock", "~> 3.14"
spec.add_development_dependency "pry", "~> 0.14"
end
2 changes: 1 addition & 1 deletion lib/etherlite.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "digest/sha3"
require "digest/keccak"
require "active_support/all"
require "forwardable"
require "net/http"
Expand Down
2 changes: 1 addition & 1 deletion lib/etherlite/commands/utils/validate_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def perform

def valid_checksum?
trimmed_address = @address.gsub(/^0x/, '')
address_hash = Etherlite::Utils.sha3 trimmed_address.downcase
address_hash = Etherlite::Utils.keccak trimmed_address.downcase

trimmed_address.chars.each_with_index do |c, i|
hash_byte = address_hash[i].to_i(16)
Expand Down
2 changes: 1 addition & 1 deletion lib/etherlite/contract/event_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def self.signature
end

def self.topic
'0x' + Etherlite::Utils.sha3(signature)
'0x' + Etherlite::Utils.keccak(signature)
end

def self.decode(_connection, _json)
Expand Down
2 changes: 1 addition & 1 deletion lib/etherlite/contract/function.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def encode(_values)
encoded_inputs = Etherlite::Support::Array.encode(@inputs.map(&:type), _values)

if @name
signature_hash = Etherlite::Utils.sha3 signature
signature_hash = Etherlite::Utils.keccak signature
'0x' + signature_hash[0..7] + encoded_inputs
else
encoded_inputs # if no name is provided, just render arguments
Expand Down
4 changes: 2 additions & 2 deletions lib/etherlite/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module Etherlite
module Utils
extend self

def sha3(_data)
Digest::SHA3.hexdigest(_data, 256)
def keccak(_data)
Digest::Keccak.hexdigest(_data, 256)
end

def uint_to_hex(_value, bytes: 32)
Expand Down