Sha256: be418d77cc3108b9bd330b36619be46666c4b966c68cd836b68f0b8d80131341

Contents?: true

Size: 664 Bytes

Versions: 6

Compression:

Stored size: 664 Bytes

Contents

module Bip44
  module Ethereum
    def get_ethereum_address(path)
      node = @wallet_node.node_for_path(path)

      # from bitcoin public key to ethereum public key
      group = ECDSA::Group::Secp256k1
      public_key = ECDSA::Format::PointOctetString.decode(node.public_key.to_bytes, group) # a point
      ethereum_public = public_key.x.to_s(16) + public_key.y.to_s(16)

      # from ethereum public key to ethereum address
      bytes = Bip44::Utils.hex_to_bin(ethereum_public)
      address_bytes = Digest::SHA3.new(256).digest(bytes)[-20..-1]
      address = Bip44::Utils.bin_to_hex(address_bytes)
      Bip44::Utils.prefix_hex(address)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bip44-0.2.9 lib/bip44/ethereum.rb
bip44-0.2.8 lib/bip44/ethereum.rb
bip44-0.2.7 lib/bip44/ethereum.rb
bip44-0.2.6 lib/bip44/ethereum.rb
bip44-0.2.5 lib/bip44/ethereum.rb
bip44-0.2.4 lib/bip44/ethereum.rb