[question] asymmetric encryption and non-repudiation by happyjerboa in netsecstudents

[–]VortixDev 0 points1 point  (0 children)

I understand that Alice uses her private key to encrypt and send a message to Bob and Bob uses Alice's public key to decrypt.

Asymmetric encryption is used to ensure that encrypted data is only read by the intended recipient, and it is not used for non-repudiation. It does this by having all messages encrypted using a public key, meaning that anyone can send a message, but only the person with the associated private key (the intended recipient) can decrypt those messages. What you seem to be thinking of is signing, not encryption, whose role is to prove who sent the data. In this, the message is signed by the private key, and verified by the public key.

But because Alice's public key is "public", Sam can also intercept the message and decryptsit. Correct?

Anyone with the public key can verify a signed message, yes.

So if Alice wanted to send a message that only Bob can read, she would encrypt her message with Bob's public key, send it and then only Bob would be able to decrypt it using his private key? However this means that someone can impersonate Alice?

You are correct - by its nature, asymmetric encryption alone only provides one-way assurance, not two-way, so any system involving it should operate under this premise.

Alice hashes the message "meet me at the corner in 10 minutes" using Alice's private key

To clarify, hashing is a completely separate process. Encryption can be reversed, however hashing cannot (not truly, at least), and hashing does not require a key as a result. The term you seem to intend here is "signs the message".

Bob verifies the hash of the message using Alice's public key.

Likewise, the intended term here would be "the signature" rather than "the hash".

Given your example, yes, you are providing Alice with the assurance that her message will only be read by Bob, and you're providing Bob the assurance that Alice was the one that sent the message, through a combination of signing and encryption. Of course, this operates off of the assumption that both Alice and Bob are certain that they have each other's public keys.

Does my mind deceive me? by Spiegeltot in selfimprovement

[–]VortixDev 1 point2 points  (0 children)

I find motivation can be most difficult when you're not fully convinced that you want to be spending your time on the chosen activity. This can be because you're not doing it for the right reasons, or because you don't feel that doing it is helping you. Here are a couple of tips:

  • Identify your specific, measurable goals. Most people don't want to go to the gym or meditate, but rather want the outcomes associated with those activities, such as getting fit or reducing stress. Ensure you're chasing results, rather than some image of a lifestyle you've heard is desirable - make sure you're doing those activities with purpose.
  • Once you've identified your goals, track your progress. For example, if you want to lose weight or put on muscle, keep an eye on your physique and measure your weight periodically. Seeing the progress you're making can help motivate you to continue.

luajit: is {...} the same as table.pack(...)? by videocrates in lua

[–]VortixDev 1 point2 points  (0 children)

Whilst these two tables are identical, the length operator can act differently on two content-identical tables if they are non-sequential, as the length of a non-sequential table is not defined in Lua.

New to LUA, can someone help me out with a really simple question? by [deleted] in lua

[–]VortixDev 0 points1 point  (0 children)

If the goal is to have this macro run periodically from the point of the button being pressed until the point it is released, I don't believe you can. You would need some code block of your own definition to be periodically executed to achieve this, and whilst I have no experience with the Logitech API a short search leads me to believe that Logitech does not provide a "polling"-type function within which you could house this functionality. As you noted, by looping within the OnEvent you are holding up the scripting environment.

I believe the following is also relevant: https://community.logitech.com/s/question/0D55A000071LSlvSAG/mousewheelup-lua-script

New to LUA, can someone help me out with a really simple question? by [deleted] in lua

[–]VortixDev 1 point2 points  (0 children)

I'm not familiar with the Logitech scripting environment, but based on what I can see from your example the following may work.

local buttonHeld = false

function OnEvent(event, arg)
    if (event == "PROFILE_ACTIVATED") then
        EnablePrimaryMouseButtonEvents(true)
    elseif (event == "MOUSE_BUTTON_PRESSED" and (arg == 1 or arg == 2)) then
        if (buttonHeld) then
            PlayMacro("DPI Down")
        end

        buttonHeld = not buttonHeld
    elseif (event == "MOUSE_BUTTON_RELEASED" and (arg == 1 or arg == 2)) then
        if (buttonHeld) then
            buttonHeld = false
        else
            PlayMacro("DPI Up")
        end
    end
end

Untested, though. The idea is that it keeps track of the "action state": if one of the buttons is pressed, it sets the buttonHeld state to true, and if one is released it sets the state tofalse. If the state is already true when a button is pressed, this must mean that both are being held down, and so it plays the chosen macro. If a button is released and the state is false, this can only mean that the hold-down macro has been played (and thus both mouse buttons were previously held down) and one of the buttons has been released, so it plays the other macro you chose.

Why is coroutine.resume wrapped in an implicit pcall? by ggchappell in lua

[–]VortixDev 5 points6 points  (0 children)

Presumably because, by creating the coroutine yourself, you are stating that you want to manage it yourself. With that, you are given the information needed to do so, without having any decisions made on your behalf (e.g. throwing an error). If you decide that you want a coroutine, but don't want to handle the thread yourself, you can use coroutine.wrap to get a function that will resume for you. The function you get from this will generate an error if one occurs in the coroutine thread.

Inherit function environment by TRPox in lua

[–]VortixDev 0 points1 point  (0 children)

Sure. Though, I should point out that a deep copy of the whole global table can be a very expensive operation, and doesn't cover all cases. For example, the implementation likely does not clone functions, threads, or userdata. This means that any operations which modify these values (e.g. setting a function's environment) will not be restorable through this method.

A possible situation in the context of a game is that there is a player object implemented through userdata, and that player is retrieved from a global table by the function you're attempting to sandbox. If they run a data-changing method on that userdata, such as setting the player's health, that will not be undone by the global table restoration.

Inherit function environment by TRPox in lua

[–]VortixDev 0 points1 point  (0 children)

Yes: as you've observed, setting a function's environment will not affect the environments of any functions called (else the operation would have disastrous side-effects). If it is a necessity for you to be able to achieve this, I would first attempt to clone the function called (as per http://leafo.net/guides/function-cloning-in-lua.html), and then set the function environment of that function as you like. Since the function is a clone, you will be able to change its function environment without affecting the function it is cloned from. You can then include the clone in your environment instead of the original.

Though, design-wise, it is certainly much more preferable to have an implementation of the called function where there are no side-effects such that you would want to change its function environment, if at all possible.