I have not been able to find any credible source which tried to prove or disprove the randomness of mouse movements.

It might be relevant to mention that a quick look at the Puttygen source code indicates that it seems to generates private keys solely based on mouse movements. It fills an array with the time of mouse movement events in the even cells and the mouse position in the odd cells, sprinkles some magic shuffling over it (shuffling memory, xoring fields), and calls some RSA/DSA/EC* key generator with the array as argument. Whether there is serious evidence that mouse movement is a good entropy source is quite important for such use-cases. Note that this is different from using it as an additional source, such as in the Linux kernel, which will only increase the quality even if it's a mediocre source.

I have a hard time believing nobody ever looked into this. What am I missing?

  • 1
    At its core, a mouse is an analog to digital converter. There is some event which may considered at least pseudo random which is sampled at a particular frequency. The result is a digital value that varies in a non-periodic way.... So, the question regarding mouse movements isn't really about mouse movements... it's about using an external A/D conversion of some event as a source of entropy. Some random number generators use a lamp... not LED mind you, a lamp... and then sample the value of current running through the lamp over time. – RubberStamp Feb 20 at 1:02
  • 2
    The lack of papers eems surprising - after all we know that one of the fundamentals of RNG is that writing some random code will produce a very poor RNG (I think Knuth had a nice formulation of this - and a nice example from personal experience) – Hagen von Eitzen Feb 20 at 3:19
  • 3
    Mouse movement, if sampled at the interrupt level, is an extremely good source of randomness because of the natural stochasticity of our neuromuscular system. I'm sure some operating system HID APIs are not good enough due to the predictability of task scheduling, so sampling /dev/input/mouse0 might not be great, but mouse and keyboard inputs are absolutely useful when the CPU's cycle counter is sampled in an interrupt handler. (Writing as a comment instead of an answer because I haven't linked to any research papers, as the question is asking for) – forest Feb 20 at 3:47
  • 2
    @Luc I think I could write an answer, but it would boil down to "there are no such papers, but here's some reasons why it's really, really hard to predict motion at these scales". Would something like that work? – forest Feb 20 at 8:47
  • 2
    @Luc, additionally to the significant differences from one person to another, you also have to consider the device type, accuracy (as in dpi) and settings (OS part of settings). Any of the 4 types of information, if missing, will lead to no practical result. Yes, such a determination is mathematically possible but extremely improbable if at least one of the 4 elements mentioned is missing. – Overmind Feb 20 at 12:30

I do not believe there are any research papers that describe the unpredictability of the neuromuscular system in the context of computer security and at the sample rates that are relevant, so I can't link the research papers you want. However, I can explain at least a few of the reasons why human movement is so stochastic and unpredictable. It all boils down to a simple fact: Living tissue is a really, really sloppy medium for information transmission. This has been known for a very long time and has constantly been a thorn in the side of computational neuroscience. Biological neural networks are terrible computers.

The transmission speed of neurons varies, sometimes significantly. Even within a single neuron, the speed is variable. In addition, the number of action potentials (electrical signals that propagate down the axon) sent in succession is dependent on the probability that microscopic ion channels will open at any given time. Additionally, muscles have a high amount of jitter. The force from a muscle does not come from a scalar increase in activity, but from discrete bunches of muscle cells, called motor units, being activated. Even if we flex as hard as we can, we can only activate around 30% of motor units. This random motor unit recruitment leads to the twitchy vibration typical of voluntary skeletal muscles.

The combination of the extremely stochastic behavior of neurons and the probabilistic activation of muscle cells leads to minute variable delays in timing. While these delays are imperceptible to a human, a computer ticking away at billions of times per second quickly notices this. Millions of cycles can pass by due to the random delays intrinsic to neural transmission, and these random delays can be measured and used as a source of entropy. While we do not have any research showing exactly how many bits of entropy each action potential will generate, we can make an extremely conservative guess and say that the entire process, from brain to muscle to keystroke, leaves us with less than a single bit of entropy. All it takes then is a few hundred keystrokes to obtain a cryptographically significant amount of entropy.

The stochastic behavior of the human brain is described quite well here (see sections 3 and 4).

Entropy from keystrokes or mouse movements thus comes from two sources:

  1. Individual variations in people due to a unique number neurons and unique neural circuits.

  2. Time-dependent variations in action potential transmission speed, motor unit recruitment, etc.

All of this results in random delays that, while irrelevant to everyday tasks, is quite visible to a computer with sometimes even sub-nanosecond temporal resolution. If we sample the time of events (not just data like mouse pointer position or key being pressed), we can safely say that it contains at least a nominal amount of entropy. After all, given all this stochastic randomness, it should become obvious that it is impossible to guess, within nanoseconds, how long it will take a signal originating in our brain to depress a key. Even if it is so predictable that we can guess with 50% accuracy how long it will take, it still gives us another bit of entropy to add to our entropy pool, of which we need not much more than a hundred.

However, it's important to know that it's easy to get entropy collection wrong. You can't just sample mouse movement and use system time as a clock. You need to trigger the sampling immediately when the event occurs. This means collection must occur within the kernel, typically within an interrupt handler. Otherwise, it's very possible that predictable scheduling delays will taint the collected entropy. After all, what's the good of a random keypress event if it's buffered as soon as it occurs and is only released to userspace in predictable intervals? You should always leave entropy collection to the OS itself.

  • I'd like an experiment... something like 1 Setup a mouse on a mechanical platform that 1a moves the mouse in circles ... 1b vibrates the mouse using a motor set at a particular and uniform speed... 2 have a human move the mouse ... calculate the entropy of the output of each... and see if moving the mouse with a motor running at uniform speed produces similar levels of entropy to human generated motions.... lastly this answer does not take into account the security sense of using a computer peripheral device as an entropy source.... has it been compromised? simulated? – RubberStamp Feb 20 at 11:36
  • 1
    @RubberStamp No need to do an experiment. Just look at old slot machines. People may try their hardest to get their timing just right, but our movements are so jittery that this fact holds up the multi-billion dollar gambling industry. As for the security of the peripheral device, that's entirely tangential to the main point. – forest Feb 20 at 11:39
  • * >No need to do an experiment * ... Experimental evidence is the core of science. Of course, we need experimental data to verify the claims... Is mouse gathered entropy driven by the human input as you claim or can similar entropy be gathered from a mouse that is moved by a uniformly spinning machine that vibrates a platform? If the machine vibrated mouse generates similar levels of entropy, then the human-neuron connection is too low a level... and the human is no longer required, just an event of particular "sloppiness" – RubberStamp Feb 20 at 11:50
  • 1
    @RubberStamp Unfortunately, mere randomness doesn't imply data suitable for cryptographic purposes. It might appear very random but still be predictable, especially if it's a chaotic system. While experiments can be useful, that specific experiment implemented with the methods you describe would not necessarily give valid results. My "just look at slot machines" claim was intended to be a brief a fortiori argument, not a literal alternative to empirical evidence or the scientific method. – forest Feb 20 at 11:52
  • >Unfortunately, mere randomness doesn't imply data suitable for cryptographic purposes. ... all the more reason for experimental data to be included as justification... The experiment may take a few weeks depending on my time... I've got the equipment, just need to setup... Anyone interested in seeing the results of an experiment as I've outlined? – RubberStamp Feb 20 at 12:07

IMHO, the concept is borrow from mouse movement user fingerprinting, in which, the scale of complexity is totally different when apply for key generation.

If you start comparing both, you will notice, user identification using mouse movement fingerprinting required less entropy to improve identification, high false positive is acceptable. Thus, them mouse movement fingerprinting will yield a high accuracy.

On the other hand, mouse movement key generator is using high entropy subject to the person mood and environment, which I doubt anyone can reproduce in any control environment. E.g. a person in empty stomach will move the mouse differently compare to a full stomach.

  • 1
    I think mouse movement fingerprinting/biometrics is much newer. – forest Feb 21 at 1:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.