def self.encode(v)
    # encode v, which is a string of bytes, to base58.

    long_value = 0
    v.chars.to_a.reverse.each_with_index do |c, i|