// generateBarriers creates the encoding barriers between rounds that compute ShiftRows and re-encodes data. func generateBarriers(rs *common.RandomSource, out *Construction, inputMask, outputMask, sr *matrix.Matrix) { // Generate the ShiftRows and re-encoding matrices. out.ShiftRows[0] = MaskSwap(rs, 16, 0).Compose(*sr).Compose(*inputMask) for round := 1; round < 10; round++ { out.ShiftRows[round] = MaskSwap(rs, 16, round).Compose(*sr).Compose(MaskSwap(rs, 32, round-1)) } // We need to apply a final matrix transformation to convert the double-level encoding to a block-level one. out.FinalMask = outputMask.Compose(MaskSwap(rs, 32, 9)) }