// See constructions/common/keygen_tools.go func MaskEncoding(rs *common.RandomSource, surface common.Surface) func(int, int) encoding.Nibble { return func(position, subPosition int) encoding.Nibble { label := make([]byte, 16) label[0], label[1], label[2], label[3], label[4] = 'M', 'E', byte(position), byte(subPosition), byte(surface) return rs.Shuffle(label) } }
// See constructions/common/keygen_tools.go func XOREncoding(rs *common.RandomSource, round int, surface common.Surface) func(int, int) encoding.Nibble { return func(position, gate int) encoding.Nibble { label := make([]byte, 16) label[0], label[1], label[2], label[3], label[4] = 'X', byte(round), byte(position), byte(gate), byte(surface) return rs.Shuffle(label) } }
// See constructions/common/keygen_tools.go func RoundEncoding(rs *common.RandomSource, round int, surface common.Surface, shift func(int) int) func(int) encoding.Nibble { return func(position int) encoding.Nibble { position = 2*shift(position/2) + position%2 label := make([]byte, 16) label[0], label[1], label[2], label[3] = 'R', byte(round), byte(position), byte(surface) return rs.Shuffle(label) } }
// Encodes the output of a MB^(-1) Table / the input of an XOR Table. // // position: Position in the state array, counted in *bytes*. // subPosition: Position in the MB^(-1) Table's ouptput for this byte, counted in nibbles. func MBInverseEncoding(rs *common.RandomSource, round, position, subPosition int) encoding.Nibble { label := make([]byte, 16) label[0], label[1], label[2], label[3], label[4] = 'M', 'I', byte(round), byte(position), byte(subPosition) return rs.Shuffle(label) }