Some refactoring work to split KSV generation from key generation. This, along
with the addition of a transpose function, allows us to generate sink keys too.
The irony of asserting copyright on this code is not lost on me. However, it's
become a trigger response whenever I release anything to the world now :).