mercredi 27 novembre 2019

Asynchronous data (entropy) collection in python

I'm trying to code a PRNG which adds entropy into its state. To do that, i want to use multiple entropy sources, that would collect the entropy asynchronously into buckets, and the PRNG itself would then take the data from them.

What is the best way to build such asynchronous data collection in python?

class EntropyBuckets(object):
    buckets = [[]] ## only an example, this should be a structure capable of working with asynchronously added data

    def get_entropy(self):
        pass

In essence this would be used by the PRNG. During initialization all of the entropy sources would start running asynchronously for the duration of the process. PRNG would then be able to request entropy without being blocked (due to waiting for more data).

class EntropySource(object):
    entropy_bucket = None # reference to a single EntropyBuckets bucket where it adds its entropy

This is just some random class to represent the source. It can define any methods, but the main point is it only has reference to single bucket it adds entropy into. There is no further interaction with teh parent class outside of when it gets shut down.

As for what these sources are, it can be anything from cpu temp, clocks, keyboard or mouse data, etc.

Just to reiterate, the question is only about what would be the best way to asynchronously collect data like this.




Aucun commentaire:

Enregistrer un commentaire