My app on Android uses the built-in motion sensors to collect seed-data for the PRNG (java.security.SecureRandom) that is later to be used for key-generation. The user is told to shake the device so the incoming data should be somewhat pretty random. Also, too slow movements are ignored in order to avoid getting only 0s as seed if the device was not moved during the time of "recording".
In detail: Teh length of the movement-vector is calculated ($l = sqrt(x^2 + y^2 + z^2)$) and $9.81$ is subtracted from it in order to ignore gravity. If $l$ is less than 81% of the sensors Peek value the set of values is ignored. Otherwise the resulting values for x, y, z are beeing muliplied by $2^{28}$ (because bit-shifting is not supported on floats in Java), then XORed. These values then fill an array like that:
dataStack[dataSetsRecorded++ % dataStack.length] ^= value;
The question is: is that a high entropy or can this be predicted (e.g. because most phone users would shake the phone up and down but not sidewise and tablet users would rather tilt than shake the device)? Thanks :)
-9.81d
is there to ignore gravity (and i hardly think that astronauts will ever be using that app). Worst case: the attacker has software running on the device. Expected case: the attacker gets the resulting public-key and has less effort to factor the key by guessing the directions the generating device was moved to. $\endgroup$dataSetsRecorded % dataStack.length
thing). $\endgroup$((int) x) ^ ((((int) y) ^ ((int) z)) << 16)
, which is not accurately summarized by XORed. Also it multiplied by the float obtained from0xFFFFFFF
, which is $2^{28}-1$. We still do not have a model of how $x$, $y$, $z$ are derived, and most importantly a failure model of that. Much of the art of TRNG design is checking the source of entropy against its likely failures, given a model of the source; see this. Also: I guess $x$ $y$ $z$ are about acceleration, not movement as presently stated. $\endgroup$