Trying out math typesetting


Cryptography   Misc 2018-08-20

I think I may need maths a lot in my posts so the second step is to set up some math engine. The default math engine suggested by Kramdown is MathJax. That was fairly easy to set up but I found KaTeX a better option because it is faster.

After fumbling with these web stuffs that I was not used to, I finally got KaTeX working by mainataining a local copy of KaTeX and using some JavaScript (See Reference). The KaTeX gem suggested in Kramdown with KaTeX did not work for me. Maybe I made some incorrect configurations. Anyways it is working now, Hooray.

Update
I wanted to use Jekyll plugins that are not supported by Github, so I decided to somehow build my site locally and then push the contents onto github. Then I found an elegant solution using Travis CI for Github Pages Deployment. I cannot believe I used another 3 hours to make Travis CI working. Anyway, it is working again. I reckon I will not have much time to deploy comment systems or RSS feed when next semester starts….

Something meaningful in this blog post.

So here is my solution to Exercise 2.22 ( Bias correction ) in A Graduate Course in Applied Cryptography.

Background

In cryptography, we have various formal models for the definiton of Security which enable analyses of ciphers.
To formalize Semantic Security of a cipher over , we define the following game.

Game ( Bit-guessing version of SS )
There are two parties, the challenger () and the adversary (). We normally think of both of them as probabilistic polynomial time machines. The game proceeds as follows.

  1. generates a uniform bit and ;
  2. chooses two messages and and sends them to .
  3. encrypts and sends it to .
  4. After examining , outputs a guess .

Define the advantage Adv as .
The cipher is SS iff for all PPT , the advantage is negligible (in security parameter ).

A short description of the problem

In the previous definition we take the absolute value of the advantage. This is a good definition because if our adversary breaking SS actually has the correct guess with probability of some for non-negligible, we can make another adversary who always output the opposite of what outputs. Then has sucess probability greater than .

But is the above argument actually valid? Spoiler: NO.
In the problem, we explore how an adversary who guesses wrong more often (i.e. can be converted into one who guesses right more often, while preserving the non-negligiblilty of the advantage.

Part (a) and (b) of the Problem

Part (a) showed that one can construct an adversary with success probability .
The construction has two phases.

  1. first acts as a challenger and test using a randomly generated and .
  2. then runs using inputs from the real challenger .
    • If in 1. guessed correctly, simply outputs whatever bit output.
    • Otherwise, outputs the opposite of whatever bit output.

The success probability can be found by direct calculation on some probabilties.

Part (b) raised the question of why one cannot simply construct that flips the output of and argue that one of or always outputs correct bit with positive .

The explanation is kind of tricky but quite interesting in my opinion. One should understand the formal definitions of SS (that one using security parameter ) to understand the problem.
Spoiler Alert: is actually a function in , so it can be positive or negative (or both).

Part (c) of the problem

First construction

Part (c) asks the reader to give a solution with success probability at least .
I am not sure about the correctness of my solution because I proved a somehow stronger weird-looking result.

First assume is a known non-negligible function, i.e. we know constants and such that for infinitely many .

Let . Let be the following adversary.

  1. Run indepedent tests of .
  2. Run using inputs from the real challenger .
    • If guesses right more often in the previous tests, we output whatever output when faced with the real challenger .
    • Otherwise we output the oppositie of ’s output.

Analysis

Let be the number of correct guesses in phase 1. of the algorithm, then

is negligible. Similarly is negligible.

So if we denote negligible functions with the symbol negl, we have

is polynomial in , we can boost it by some polynomial factor of to make the negligible term arbtrarily small. Thus we have proven there exists a PPT with success probability at least .

Removing the neccessity of knowing

In the first construstion we need to know how is bounded to construct a concrete adversary. We can actually remove this requirement if we only need to show the existence of such a machine.

The trick is to construct a series of machines for . And make have the same construction as , except it uses . Then among these PPT we should be able to find one using more tests than . I wish to use the LaTeX environment proof but KaTeX did not seem to support it otherwise I would like to put a box or something here to show I have completed the proof in a single paragraph.

Post Script

The proof was not very elegant but the construction was quite straight forward. I wonder if there are better solutions. Do you find cryptography interesting?

Reference

using-katex-in-jekyll (Chinese only)