Securely testing the presence of an item in a list without exposing the list Not even sure what terms would describe what I'm looking for, but the general idea:


  Given a list of strings of a finite length, determine whether or not a test string belongs to the list. Then, produce a new list of strings containing the difference of the original list and the test string.


In pseudocode, this would probably look something like:

def list = envelope(["string1", "string2", "string3"])

def validate( collection, test ) {
    if ( contains( collection, test ) ) {
        return remove( collection, test )
    } else {
        throw Exception
    }
}

// In Use
validate( list, "string2")
-&gt; envelope( ["string1", "string3"] )

validate( list, "string4")
-&gt; Exception


One person told me this sounded like the way a blockchain works, but given everything I've read and my rudimentary understanding of blockchain, I'm skeptical. Is there another process or protocol available that I can use to make the above function?
You could use convergent encryption for this.


For each item to be inserted, compute its hash, then encrypt it by deriving a key from that hash. Insert the ciphertext (discarding the hash/key).
To test for the presence of an item, hash it, encrypt, look for matching ciphertext.


You would likely want to use something like a hash table or a search tree (dictionary or set), instead of a flat list, to avoid $O(n)$ scan when looking for an item.

Note that the user can brute force / dictionary attack the scheme by encrypting chosen items and checking them against the list.