implement spn algebra template
This commit is contained in:
@@ -6,25 +6,25 @@
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": true,
|
"collapsed": true,
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
"end_time": "2024-08-02T22:22:16.261963Z",
|
"end_time": "2024-08-11T22:25:25.992246Z",
|
||||||
"start_time": "2024-08-02T22:22:15.861856Z"
|
"start_time": "2024-08-11T22:25:25.829841Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"source": "from src.models import SubstitutionKey\n",
|
"source": "from src.models import SubstitutionKey\n",
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"execution_count": 2
|
"execution_count": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
"end_time": "2024-08-02T22:22:16.442689Z",
|
"end_time": "2024-08-11T22:25:26.228563Z",
|
||||||
"start_time": "2024-08-02T22:22:16.434147Z"
|
"start_time": "2024-08-11T22:25:25.993216Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"source": [
|
"source": [
|
||||||
"width = 7\n",
|
"width = 70\n",
|
||||||
"height = 10\n",
|
"height = 100\n",
|
||||||
"s1 = SubstitutionKey.init_matrix(width, height)\n",
|
"s1 = SubstitutionKey.init_matrix(width, height)\n",
|
||||||
"s2 = SubstitutionKey.init_matrix(width, height)\n",
|
"s2 = SubstitutionKey.init_matrix(width, height)\n",
|
||||||
"s3 = SubstitutionKey.init_matrix(width, height)\n",
|
"s3 = SubstitutionKey.init_matrix(width, height)\n",
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
],
|
],
|
||||||
"id": "58883d386ec57cc4",
|
"id": "58883d386ec57cc4",
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"execution_count": 3
|
"execution_count": 2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
# Permutation Algebra
|
# Permutation Algebra
|
||||||
This notebook is a prerequisite to following the DARC tutorial
|
This notebook is a prerequisite to the [DARC](darc.md) tutorial
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Key Generation Parameters
|
## Key Generation Parameters
|
||||||
- block size: The number of characters we encode in a block. Block size isn't using in this notebook
|
- key height: The alphabet length. To encode bytes, our alphabet length is 256.
|
||||||
- key height: The alphabet length. If we want to encode bytes, our alphabet length is 256.
|
To encode lowercase letters a-z our alphabet length is 26. To encode a {{ height }} key {{ width }} attribute nKode interface, our alphabet is `{{ height }} x {{ width }} = {{ total_attr }}`.
|
||||||
If we want to encode lowercase letters a-z our alphabet length is 26. NKodes {{ height }} key {{ width }} attribute alphabet is {{ total_attr }}.
|
|
||||||
- key width: The number of bytes an encrypted charter is in our alphabet.
|
|
||||||
|
|
||||||
|
- key width: The number of bytes an encrypted character is in our alphabet.
|
||||||
|
|
||||||
|
|
||||||
|
In this document, we will use the following parameters:
|
||||||
```
|
```
|
||||||
height = {{ height }}
|
height = {{ height }}
|
||||||
width = {{ width }}
|
width = {{ width }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ def render_spn_algebra(data: dict):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
height = 10
|
height = 9
|
||||||
width = 7
|
width = 8
|
||||||
total_attr = height * width
|
total_attr = height * width
|
||||||
i0 = InnerKey.init_matrix(width, height)
|
i0 = InnerKey.init_matrix(width, height)
|
||||||
i1 = InnerKey.init_matrix(width, height)
|
i1 = InnerKey.init_matrix(width, height)
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -297,6 +297,7 @@ class ServerPersistentMediumKeys(BaseModel):
|
|||||||
class MutualEphemeralDataKeys(BaseModel):
|
class MutualEphemeralDataKeys(BaseModel):
|
||||||
alpha_key: SubstitutionKey
|
alpha_key: SubstitutionKey
|
||||||
inner_key_1: InnerKey
|
inner_key_1: InnerKey
|
||||||
|
inner_key_2: InnerKey
|
||||||
outer_key_1: OuterKey
|
outer_key_1: OuterKey
|
||||||
outer_key_2: OuterKey
|
outer_key_2: OuterKey
|
||||||
outer_key_3: OuterKey
|
outer_key_3: OuterKey
|
||||||
@@ -306,6 +307,7 @@ class MutualEphemeralDataKeys(BaseModel):
|
|||||||
return MutualEphemeralDataKeys(
|
return MutualEphemeralDataKeys(
|
||||||
alpha_key=SubstitutionKey.init_matrix(width, height, 255),
|
alpha_key=SubstitutionKey.init_matrix(width, height, 255),
|
||||||
inner_key_1=InnerKey.init_matrix(width, height),
|
inner_key_1=InnerKey.init_matrix(width, height),
|
||||||
|
inner_key_2=InnerKey.init_matrix(width, height),
|
||||||
outer_key_1=OuterKey.init_matrix(height),
|
outer_key_1=OuterKey.init_matrix(height),
|
||||||
outer_key_2=OuterKey.init_matrix(height),
|
outer_key_2=OuterKey.init_matrix(height),
|
||||||
outer_key_3=OuterKey.init_matrix(height),
|
outer_key_3=OuterKey.init_matrix(height),
|
||||||
@@ -323,6 +325,7 @@ class MutualEphemeralMediumKeys(BaseModel):
|
|||||||
outer_key_6: OuterKey
|
outer_key_6: OuterKey
|
||||||
|
|
||||||
inner_key_1: InnerKey
|
inner_key_1: InnerKey
|
||||||
|
inner_key_2: InnerKey
|
||||||
inner_key_4: InnerKey
|
inner_key_4: InnerKey
|
||||||
inner_key_3: InnerKey
|
inner_key_3: InnerKey
|
||||||
|
|
||||||
@@ -337,6 +340,7 @@ class MutualEphemeralMediumKeys(BaseModel):
|
|||||||
outer_key_5=OuterKey.init_matrix(height),
|
outer_key_5=OuterKey.init_matrix(height),
|
||||||
outer_key_6=OuterKey.init_matrix(height),
|
outer_key_6=OuterKey.init_matrix(height),
|
||||||
inner_key_1=InnerKey.init_matrix(width, height),
|
inner_key_1=InnerKey.init_matrix(width, height),
|
||||||
|
inner_key_2=InnerKey.init_matrix(width, height),
|
||||||
inner_key_4=InnerKey.init_matrix(width, height),
|
inner_key_4=InnerKey.init_matrix(width, height),
|
||||||
inner_key_3=InnerKey.init_matrix(width, height),
|
inner_key_3=InnerKey.init_matrix(width, height),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user