Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
geraldb committed Dec 9, 2022
1 parent 85a8e34 commit f9c0425
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 34 deletions.
36 changes: 18 additions & 18 deletions crypto-lite/Manifest.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
CHANGELOG.md
Manifest.txt
README.md
Rakefile
lib/crypto-lite.rb
lib/crypto-lite/config.rb
lib/crypto-lite/helper.rb
lib/crypto-lite/metal.rb
lib/crypto-lite/sign_rsa.rb
lib/crypto-lite/version.rb
lib/crypto.rb
lib/crypto/lite.rb
test/helper.rb
test/test_base58.rb
test/test_bitcoin_addr.rb
test/test_hash.rb
test/test_hash_sha.rb
test/test_version.rb
CHANGELOG.md
Manifest.txt
README.md
Rakefile
lib/crypto-lite.rb
lib/crypto-lite/config.rb
lib/crypto-lite/helper.rb
lib/crypto-lite/metal.rb
lib/crypto-lite/sign_rsa.rb
lib/crypto-lite/version.rb
lib/crypto.rb
lib/crypto/lite.rb
test/helper.rb
test/test_base58.rb
test/test_bitcoin_addr.rb
test/test_hash.rb
test/test_hash_sha.rb
test/test_version.rb
2 changes: 1 addition & 1 deletion crypto-lite/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Hoe.spec 'crypto-lite' do
self.history_file = 'CHANGELOG.md'

self.extra_deps = [
['digest-sha3-patched'],
['digest-lite'],
['base32-alphabets'],
['base58-alphabets'],
['elliptic'],
Expand Down
15 changes: 6 additions & 9 deletions crypto-lite/lib/crypto-lite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,19 @@
require 'base64'
require 'openssl'

## 3rd party gems
require 'digest/sha3' # e.g. keccak (original submission/proposal NOT official sha3)
## see https://rubygems.org/gems/digest-sha3-patched
## https://github.com/teamhedge/digest-sha3-ruby

## our own 3rd party (2nd party?)
require 'digest-lite' # e.g. keccak (original submission/proposal NOT official sha3)
require 'base32-alphabets'
require 'base58-alphabets'
require 'elliptic'



## our own code
require 'crypto-lite/version' # note: let version always go first
require 'crypto-lite/config'
require 'crypto-lite/metal'
require_relative 'crypto-lite/version' # note: let version always go first
require_relative 'crypto-lite/config'
require_relative 'crypto-lite/metal'



Expand Down Expand Up @@ -135,11 +132,11 @@ def self.strip0x( str ) ## todo/check: add alias e.g. strip_hex_prefix or suc



require 'crypto-lite/helper'
require_relative 'crypto-lite/helper'
include CryptoHelper # add convenience "top-level" / global helpers


require 'crypto-lite/sign_rsa'
require_relative 'crypto-lite/sign_rsa'
RSA = Crypto::RSA


Expand Down
17 changes: 12 additions & 5 deletions crypto-lite/lib/crypto-lite/metal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def self.base58bin_check( input )

def self.keccak256bin( input )
message = message( input ) ## "normalize" / convert to (binary) string
Digest::SHA3.digest( message, 256 )
Digest::KeccakLite.digest( message, 256 )
end

def self.rmd160bin( input )
Expand Down Expand Up @@ -56,14 +56,21 @@ def self.sha256bin( input, engine=nil ) ## todo/check: add alias sha256b or su
end
end

def self.sha3_256bin( input )

def self.sha3_256bin( input, engine=nil )
message = message( input ) ## "normalize" / convert to (binary) string

digest = OpenSSL::Digest.new( 'SHA3-256' )
digest.update( message )
digest.digest
if engine && ['openssl'].include?( engine.to_s.downcase )
puts " engine: #{engine}" if debug?
digest = OpenSSL::Digest.new( 'SHA3-256' )
digest.update( message )
digest.digest
else ## use "built-in" hash function from digest module
Digest::SHA3Lite.digest( message, 256 )
end
end


####
## helper
# def hash160( pubkey )
Expand Down
2 changes: 1 addition & 1 deletion crypto-lite/lib/crypto-lite/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module CryptoLite

MAJOR = 0
MINOR = 3
PATCH = 0
PATCH = 1
VERSION = [MAJOR,MINOR,PATCH].join('.')

def self.version
Expand Down

0 comments on commit f9c0425

Please sign in to comment.