module NostrManager
  class VerifySignature < NostrManagerService
    def initialize(event:)
      @event = Nostr::Event.new(**event)
    end

    def call
      Schnorr.check_sig!(
        [@event.id].pack('H*'),
        [@event.pubkey].pack('H*'),
        [@event.sig].pack('H*')
      )
    rescue Schnorr::InvalidSignatureError
      false
    end
  end
end
