How to meter and limit number of files encrypted? First my apologies if this isn't the right forum for this but here's my problem :


I have a black box that takes an input file and produces an output file.
I want to sell this black box to a customer but I want to meter/limit the number of files the customer can use with this box. A counter would not be fair to the customer since they might use the box multiple times with the same input file.
I could request the customer to send me the input file every time and I can encrypt it so that the black box would only work with my encryption. The problem with this is that the customer may not want to give me the input file.
I could ask the customer to generate some sort of key based on each input file; I can then generate another key for the black box and send it to the customer to use. This seems like a workable solution and I would guess this kind of scheme has a known name and has been studied before.


Encryption is not my area (I'm into building black boxes) so I would appreciate if someone can point me to the right terminology to use to search for this kind of metering scheme.
I believe the concept you're looking for is a cryptographical hash.  This is a function that takes a (potentially) long input, produces a short (fixed length) output, and for which it is impractical to find two different inputs that generate the same output.  It is a fixed function; anyone (including your customer) can generate a hash for any input.

How it would work is:


The customer would generate the hash of their file, and send it to you
You would take this hash, and generate a key (or signature) for that hash, and send it to the black box
The black box would take the signature and the file, compute the hash of the file, and verify that the hash corresponds to the signature.  If so, it'll go ahead and process the file (and produce the output).


One common cryptographical hash function is SHA-256; it has an output which is 256 bits (64 hex digits long); it needs to be that long to avoid attacks where someone computes a long series of hashes, and looks for two different inputs that happen to generate the same hash.

Alternatively, if the limit on the number of times that a black box can be used isn't too large, the black box could just compute and store the hashes of the input files itself.  In this case, if the customer submits an input twice, the black box will compute the same hash value, see that it's already on its list, and realize that it's recomputing an input.