Sha256: cd72f588eec5b071ce8e47d5618731fbd2da9228a320ff56545097e82da84f1f

Contents?: true

Size: 987 Bytes

Versions: 6

Compression:

Stored size: 987 Bytes

Contents

module Zilliqa
  module Util
    class Validator
      def self.public_key?(public_key)
        m = /(0x)?\h{66}/ =~ public_key
        m != nil
      end

      def self.private_key?(private_key)
        m = /(0x)?\h{64}/ =~ private_key
        m != nil
      end

      def self.address?(address)
        return true if bech32?(address)
        m = /(0x)?\h{40}/ =~ address
        m != nil
      end

      def self.signature?(signature)
        m = /(0x)?\h{128}/ =~ signature
        m != nil
      end

      # checksum_address?
      #
      # takes hex-encoded string and returns boolean if address is checksumed
      #
      # @param {string} address
      # @returns {boolean}
      def self.checksum_address?(address)
        self.address?(address) && Zilliqa::Account::Wallet::to_checksum_address(address) == address
      end

      def self.bech32?(address)
        m = /^zil1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{38}/ =~ address
        m != nil
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
zilliqa-0.1.6 lib/zilliqa/util/validator.rb
zilliqa-0.1.5 lib/zilliqa/util/validator.rb
zilliqa-0.1.4 lib/zilliqa/util/validator.rb
zilliqa-0.1.3 lib/zilliqa/util/validator.rb
zilliqa-0.1.2 lib/zilliqa/util/validator.rb
zilliqa-0.1.1 lib/zilliqa/util/validator.rb