## Phasestream 2 - Cyberapocalypse 2021 CTF

This is a writeup for the challenge Phasestream 2, part of the Hack the box's Cyberapocalypse CTF 2021, category Crypto.

### Prompt​

The aliens have learned of a new concept called "security by obscurity". Fortunately for us they think it is a great idea and not a description of a common mistake. We've intercepted some alien comms and think they are XORing flags with a single-byte key and hiding the result inside 9999 lines of random data, Can you find the flag?

## Quantum Programming - Abstraction level 2: State Machine and Algorithms

We have been on quite the adventure so far. Let's recap our progress.

• We've shown that by encoding information onto n qubits in superposition, we can manipulate the whole system of 2n states by only changing the state of one qubit.
• We represented the state of each qubit as a simple 2D vector.
• We've established that we can change the state of a single qubit (or two) by applying different logic gates to it, similarly to a classical logic gate.
• We can now visualise the superposed state of the qubit (indeed of the whole system) on the Bloch sphere.
• We know how to entangle two qubits, so that their states are correlated.

Now the time has come to start putting it all together. Wouldn't it be nice to actually string some gates together, and see what happens?

Well, in order to see what happens, we might want to be able to visualise the flow of our qubits' states, so we can see how each gate manipulates each qubit at each step.

## Quantum Programming - Abstraction level 1: Logic Gates

We have previously worked out that a quantum computer operates logically on qubits, which are the quantum counterparts of classical bits. We've learned that a qubit can stay in a superposition while we operate on it, and then we can collapse it into a definite state upon measurement. So, for the majority of our time spent programming on the quantum computer, we will be thinking of the qubits in their state of superposition.

What would be extremely useful for our intuition now, would be to have a way to visualise this superposition. Enter the Bloch Sphere. This tool allows us to represent the whole state-space of a single qubit in one (very simple) geometric shape - the unit sphere. Think of it as the unit circle in trigonometry.

## Quantum Programming by abstracting ourselves from Quantum Mechanics: Abstraction level 0

The invention of the personal computer, and the further development of the hundreds of programming languages which utilise it has allowed us programmers to completely abstract ourselves from the world of electrons flowing through solid matter, and further from the low level programming of turning gates and transistors on and off to produce binary data.

## Celestial Navigation - coordinate systems

Nowadays you would be hard-pressed to amaze anyone with the knowledge that stars are these ever-moving objects in the sky, at wildly different distances from us and each-other. Not only that, but many of the objects in the night sky we recognise as stars are often whole galaxies containing billions of stars, or giant clouds of gas glowing with the intensity of stars in our eyes, or god knows what else.

## On approximating irrational numbers as fractions (algorithms)

Rational numbers are easy. They include the integers, with which you can count up and down the number line, as well as fractions - written as the division of two integers or as a finitely-long decimal expansion.

But there aren't that many rational numbers on the real number line, as there are irrationals. These beasts of infinitely-long decimal expansions take the vast majority of the infinity of real numbers. They can't be written as a fraction, and they can't be written exactly as a decimal expansion (it would be infinitely long).

## Simulating the Vicsek Model (with time delay) - How do birds flock and insects swarm

In two previous posts we got to know two main things:

1. We can analyse the behaviour of groups of animals using statistical tools like correlation functions
2. We can simulate this behaviour using for example the Vicsek model, and by analysing it the same way as natural groups we can measure the accurateness of the model in replicating natural phenomena.

We also learned that the standard Vicsek model suffers from one weakness: it lacks an inertial term, which seems to be important in imitating the behaviour of biological systems. So the goal of this post will be to figure out a way to simulate the Vicsek model with time delay. Let's start by

## Analysing the equations of motion​

$\vec{v_i}(t+1) = v_{0}\mathscr{R}_{\eta}\Theta \left[ \vec{v_i}(t) + \sum_{ j \neq i }{ n_{ij} \vec{v_j}(t) } \right] ,$
$\vec{r_i}(t+1) = \vec{r_i}(t) + \vec{v_i}(t+1) .$

## How do birds flock and insects swarm: the Problem with current models

if you haven't seen the first part of this introduction, absolutely go check it out for context.

In this post we'll unravel how does the delay in a group of animals affect the group, and what should we understand under said delay (keyword: slowpoke). To get there, let's analyse the last two paragraphs of the introduction to my thesis, where we'll see what problems can be spotted in previous research, and motivate ourselves to look for solutions.