Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 16 additions & 20 deletions algorithms/algebraic/hidden_shift/hidden_shift.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
"tags": []
},
"source": [
"# Hidden-Shift problem for bent functions using the classiq platform"
"# Hidden-Shift Problem for Bent Functions"
]
},
{
"cell_type": "markdown",
"id": "450fbc3a-2837-44e7-90bc-e695a87ba220",
"metadata": {},
"source": [
"Here we implement the hidden shift algorithm for the familty of boolean bent functions."
"Here we implement the hidden shift algorithm for the family of Boolean bent functions using the Classiq platform."
]
},
{
"cell_type": "markdown",
"id": "a13a1783-065a-46aa-9967-ba2d5affd33e",
"metadata": {},
"source": [
"First, make sure we have all necessary packages:"
"Make sure we have all necessary packages:"
]
},
{
Expand Down Expand Up @@ -51,7 +51,7 @@
"tags": []
},
"source": [
"On the first part, we assume we know how to implement the dual of $f$, and get $s$ according to the algorithm in [[1](#first)]:![Screen Shot 2023-06-27 at 18.05.48.png](attachment:663333d5-eb52-4150-a00d-8683e816d860.png)"
"We assume we know how to implement the dual of $f$ and get $s$ according to the algorithm in [[1](#first)]:![Screen Shot 2023-06-27 at 18.05.48.png](attachment:663333d5-eb52-4150-a00d-8683e816d860.png)"
]
},
{
Expand All @@ -63,9 +63,7 @@
{
"name": "stdout",
"output_type": "stream",
"text": [
""
]
"text": []
}
],
"source": [
Expand Down Expand Up @@ -143,7 +141,7 @@
"id": "64d54218-7d9c-420a-92ff-1f719d2aa638",
"metadata": {},
"source": [
"# More complex functions"
"## More Complex Functions"
]
},
{
Expand Down Expand Up @@ -239,7 +237,7 @@
"id": "c27a578d-5380-460d-9833-15557d4e292a",
"metadata": {},
"source": [
"## Now create the ciruit:"
"## Creating the Circuit"
]
},
{
Expand All @@ -253,8 +251,7 @@
"output_type": "stream",
"text": [
"f_dual: (((((((((x[5]) & (y[0])) ^ ((x[2]) & (y[1]))) ^ ((x[7]) & (y[2]))) ^ ((x[0]) & (y[3]))) ^ ((x[6]) & (y[4]))) ^ ((x[3]) & (y[5]))) ^ ((x[1]) & (y[6]))) ^ ((x[4]) & (y[7]))) ^ ((((((((x[5]) & (x[2])) & (x[7])) & (x[0])) & (x[6])) & (x[3])) & (x[1])) & (x[4]))\n",
"g: (((((((((x[0]) & (y[3])) ^ (((x[1]) ^ 1) & (y[6]))) ^ ((x[2]) & ((y[1]) ^ 1))) ^ (((x[3]) ^ 1) & (y[5]))) ^ ((x[4]) & (y[7]))) ^ ((x[5]) & (y[0]))) ^ ((x[6]) & (y[4]))) ^ ((x[7]) & (y[2]))) ^ ((((((((y[0]) & ((y[1]) ^ 1)) & (y[2])) & (y[3])) & (y[4])) & (y[5])) & (y[6])) & (y[7]))\n",
""
"g: (((((((((x[0]) & (y[3])) ^ (((x[1]) ^ 1) & (y[6]))) ^ ((x[2]) & ((y[1]) ^ 1))) ^ (((x[3]) ^ 1) & (y[5]))) ^ ((x[4]) & (y[7]))) ^ ((x[5]) & (y[0]))) ^ ((x[6]) & (y[4]))) ^ ((x[7]) & (y[2]))) ^ ((((((((y[0]) & ((y[1]) ^ 1)) & (y[2])) & (y[3])) & (y[4])) & (y[5])) & (y[6])) & (y[7]))\n"
]
}
],
Expand Down Expand Up @@ -359,7 +356,7 @@
"tags": []
},
"source": [
"# Hidden Shift without the dual function"
"## Hidden Shift Without the Dual Function"
]
},
{
Expand All @@ -372,7 +369,7 @@
"id": "0bf70e08-3ea7-43b8-afc2-0271f124323f",
"metadata": {},
"source": [
"We now use the second algorithm described in [[2](#second)]. This algorithm only requires to implement $f$ and not its dual, however requires $O(n)$ samples from the circuit.\n",
"We now use the second algorithm described in [[2](#second)]. This algorithm only requires implementing $f$ and not its dual; however, it requires $O(n)$ samples from the circuit.\n",
"![Screen Shot 2023-06-27 at 18.08.23.png](attachment:e8a93a2f-8965-4181-9083-78e12dc0f48b.png)"
]
},
Expand All @@ -389,8 +386,7 @@
"output_type": "stream",
"text": [
"f: (((((((((x[0]) & (y[3])) ^ ((x[1]) & (y[6]))) ^ ((x[2]) & (y[1]))) ^ ((x[3]) & (y[5]))) ^ ((x[4]) & (y[7]))) ^ ((x[5]) & (y[0]))) ^ ((x[6]) & (y[4]))) ^ ((x[7]) & (y[2]))) ^ ((((((((y[0]) & (y[1])) & (y[2])) & (y[3])) & (y[4])) & (y[5])) & (y[6])) & (y[7]))\n",
"g: (((((((((x[0]) & (y[3])) ^ (((x[1]) ^ 1) & (y[6]))) ^ ((x[2]) & ((y[1]) ^ 1))) ^ (((x[3]) ^ 1) & (y[5]))) ^ ((x[4]) & (y[7]))) ^ ((x[5]) & (y[0]))) ^ ((x[6]) & (y[4]))) ^ ((x[7]) & (y[2]))) ^ ((((((((y[0]) & ((y[1]) ^ 1)) & (y[2])) & (y[3])) & (y[4])) & (y[5])) & (y[6])) & (y[7]))\n",
""
"g: (((((((((x[0]) & (y[3])) ^ (((x[1]) ^ 1) & (y[6]))) ^ ((x[2]) & ((y[1]) ^ 1))) ^ (((x[3]) ^ 1) & (y[5]))) ^ ((x[4]) & (y[7]))) ^ ((x[5]) & (y[0]))) ^ ((x[6]) & (y[4]))) ^ ((x[7]) & (y[2]))) ^ ((((((((y[0]) & ((y[1]) ^ 1)) & (y[2])) & (y[3])) & (y[4])) & (y[5])) & (y[6])) & (y[7]))\n"
]
}
],
Expand Down Expand Up @@ -451,7 +447,7 @@
"metadata": {},
"source": [
"Out of the sampled results, we look for $n$ independent samples, from which we can extract s.\n",
"1000 samples should be enough with a very high probability."
"One thousand samples should be enough with a very high probability."
]
},
{
Expand All @@ -464,10 +460,10 @@
"outputs": [],
"source": [
"# The galois library is a package that extends NumPy arrays to operate over finite fields.\n",
"# we wlll use it as our equations are binary equations\n",
"# we will use it as our equations are binary equations\n",
"import galois\n",
"\n",
"# here we work over boolean arithmetics - F(2)\n",
"# here we work over Boolean arithmetics - F(2)\n",
"GF = galois.GF(2)\n",
"\n",
"\n",
Expand Down Expand Up @@ -507,7 +503,7 @@
"tags": []
},
"source": [
"We now left with solving the equation and extracting $s$:"
"We now solve the equation and extract $s$:"
]
},
{
Expand Down Expand Up @@ -543,7 +539,7 @@
"id": "2e47bb31-04e8-4698-b42e-13ca9722018e",
"metadata": {},
"source": [
"And we got successfully the same shift."
"And we successfully received the same shift."
]
},
{
Expand Down