Sha256: fedb7b7a815363a4a4e7f86d406347b8e81356a5e80a3cbff49162f982195df0

Contents?: true

Size: 618 Bytes

Versions: 1

Compression:

Stored size: 618 Bytes

Contents

# frozen_string_literal: true

module Ed25519
  # Public key for verifying digital signatures
  class VerifyKey
    def initialize(key)
      raise ArgumentError, "seed must be 32 bytes long" unless key.length == PUBLIC_KEY_BYTES
      @key = key
    end

    def verify(signature, message)
      if signature.length != SIGNATURE_BYTES
        raise ArgumentError, "expected #{SIGNATURE_BYTES} byte signature, got #{signature.length}"
      end

      Ed25519::Engine.verify(@key, signature, message)
    end

    def inspect
      to_s
    end

    def to_bytes
      @key
    end
    alias to_str to_bytes
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ed25519-0.1.0 lib/ed25519/verify_key.rb