Abstract hash function from core SGP routine.
Make SGP core routine recursive and parameterize hashRounds (not yet optionized).