Broke the keystore code into a separate source file

This code ensures that sequence numbers are not re-used.  But if two concurrent clients simultaneously use the same previously unseen key string, they could create two new sequence numbers that correspond to it.  See issue #4.