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.