lib/garbler.go
func (g Garbler) garbledSequence(length int, numGarbled int) string {
	if numGarbled > length {
		panic("should not require more garbled chars than string length")
	}
	var ret string
	numCanGarble := 0
	sequence := []string{"c", "v", "c", "c", "v"}
	sequencePosition := 0
	for i := 0; i < length; i++ {
		if i%2 == 0 && numCanGarble < numGarbled {
			//make things garblable if required:
			//make every other character garblable until we reach numGarblable
			if sequence[sequencePosition] == "c" {
				ret += string(ConsonantGarblers[randInt(len(ConsonantGarblers))])
			} else {
				ret += string(VowelGarblers[randInt(len(VowelGarblers))])
			}
			numCanGarble++
			sequencePosition = (sequencePosition + 1) % len(sequence)
			continue
		}
		//no need to garble this character, just generate a random vowel/consonant
		if sequence[sequencePosition] == "c" {
			ret += string(Consonants[randInt(len(Consonants))])
		} else {
			ret += string(Vowels[randInt(len(Vowels))])
		}
		sequencePosition = (sequencePosition + 1) % len(sequence)
	}
	if numCanGarble >= numGarbled {
		return ret
	}
	//we've made even-numbered chars garbled, now start with the odd-numbered ones
	for i := 0; i < length; i++ {
		if i%2 == 1 && numCanGarble < numGarbled {
			//make things garblable if required:
			//make every other character garblable until we reach numGarblable
			if sequence[sequencePosition] == "c" {
				ret += string(ConsonantGarblers[randInt(len(ConsonantGarblers))])
			} else {
				ret += string(VowelGarblers[randInt(len(VowelGarblers))])
			}
			numCanGarble++
			sequencePosition = (sequencePosition + 1) % len(sequence)
		} else if numCanGarble >= numGarbled {
			return ret
		}
	}
	//if we reach this point, something went horribly wrong
	panic("ouch")
}
func (g Garbler) garbledSequence(length int, numGarbled int) string {
	if numGarbled > length {
		panic("should not require more garbled chars than string length")
	}
	var ret string
	numCanGarble := 0
	sequence := []string{"c", "v", "c", "c", "v"}
	sequencePosition := 0
	for i := 0; i < length; i++ {
		if i%2 == 0 && numCanGarble < numGarbled {
			//make things garblable if required:
			//make every other character garblable until we reach numGarblable
			if sequence[sequencePosition] == "c" {
				ret += string(ConsonantGarblers[randInt(len(ConsonantGarblers))])
			} else {
				ret += string(VowelGarblers[randInt(len(VowelGarblers))])
			}
			numCanGarble++
			sequencePosition = (sequencePosition + 1) % len(sequence)
			continue
		}
		//no need to garble this character, just generate a random vowel/consonant
		if sequence[sequencePosition] == "c" {
			ret += string(Consonants[randInt(len(Consonants))])
		} else {
			ret += string(Vowels[randInt(len(Vowels))])
		}
		sequencePosition = (sequencePosition + 1) % len(sequence)
	}
	if numCanGarble >= numGarbled {
		return ret
	}
	//we've made even-numbered chars garbled, now start with the odd-numbered ones
	for i := 0; i < length; i++ {
		if i%2 == 1 && numCanGarble < numGarbled {
			//make things garblable if required:
			//make every other character garblable until we reach numGarblable
			if sequence[sequencePosition] == "c" {
				ret += string(ConsonantGarblers[randInt(len(ConsonantGarblers))])
			} else {
				ret += string(VowelGarblers[randInt(len(VowelGarblers))])
			}
			numCanGarble++
			sequencePosition = (sequencePosition + 1) % len(sequence)
		} else if numCanGarble >= numGarbled {
			return ret
		}
	}
	//if we reach this point, something went horribly wrong
	panic("ouch")
}
//the environ sequence is:
//consonant, vowel, consonant, consonant, vowel, [some other stuff]
//we generalize it by removing [some other stuff] and allowing the sequence
//to repeat arbitrarily often. we also allow garbling and adding some extra
//digits.