This file is indexed.

/usr/share/rubygems-integration/all/gems/faker-1.6.6/lib/faker/bitcoin.rb is in ruby-faker 1.6.6-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require 'digest'
require 'securerandom'

module Faker
  class Bitcoin < Base
    class << self

      PROTOCOL_VERSIONS = {
        main: 0,
        testnet: 111
      }

      def address
        address_for(:main)
      end

      def testnet_address
        address_for(:testnet)
      end

      protected

      def base58(str)
        alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
        base = alphabet.size

        lv = 0
        str.split('').reverse.each_with_index { |v,i| lv += v.unpack('C')[0] * 256**i }

        ret = ''
        while lv > 0 do
          lv, mod = lv.divmod(base)
          ret << alphabet[mod]
        end

        npad = str.match(/^#{0.chr}*/)[0].to_s.size
        '1'*npad + ret.reverse
      end

      def address_for(network)
        version = PROTOCOL_VERSIONS.fetch(network)
        hash = SecureRandom.hex(20)
        packed = version.chr + [hash].pack("H*")
        checksum = Digest::SHA2.digest(Digest::SHA2.digest(packed))[0..3]
        base58(packed + checksum)
      end
    end
  end
end