Conventions
Below is a table of conversions between pseudocode and python functions located in playcrypt.tools and playcrypt.primitives. By importing those two modules you will have access to all of the functions used in the table below.
In our code we use strings to represent cipher and plain text messages. This means that we need several custom functions in order to perform common pseduocode tasks such as XORing two messages together.
Pseudocode |
Python function |
---|---|
EXT-GCD(a, N) → (d, a’, N’) |
|
MOD-INV(a, N) → a -1 mod N |
|
s 1 || s 2 || … || s n |
|
string → int |
|
⟨x⟩ (int → string) |
|
⟨x⟩ s.t. length of string |
|
<s> + num mod 2 size |
|
s1 ⊕ s2 |
|
string1 || string2 |
|
⊥ |
|
a mod N |
|
0n |
|
1n |
|
R ←$ {0, 1} n |
|
M ∈ D |
|
M ∉ D |
|
2n |
|
∣s∣ |
|
AESk(m) |
|
AES-1 k (m) |
|
*s is an array of strings