implement spn algebra template

This commit is contained in:
2024-08-12 12:46:34 -05:00
parent 347e75a13a
commit fd7d8dd0c7
5 changed files with 14682 additions and 115 deletions

View File

@@ -6,25 +6,25 @@
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2024-08-02T22:22:16.261963Z",
"start_time": "2024-08-02T22:22:15.861856Z"
"end_time": "2024-08-11T22:25:25.992246Z",
"start_time": "2024-08-11T22:25:25.829841Z"
}
},
"source": "from src.models import SubstitutionKey\n",
"outputs": [],
"execution_count": 2
"execution_count": 1
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-08-02T22:22:16.442689Z",
"start_time": "2024-08-02T22:22:16.434147Z"
"end_time": "2024-08-11T22:25:26.228563Z",
"start_time": "2024-08-11T22:25:25.993216Z"
}
},
"cell_type": "code",
"source": [
"width = 7\n",
"height = 10\n",
"width = 70\n",
"height = 100\n",
"s1 = SubstitutionKey.init_matrix(width, height)\n",
"s2 = SubstitutionKey.init_matrix(width, height)\n",
"s3 = SubstitutionKey.init_matrix(width, height)\n",
@@ -57,7 +57,7 @@
],
"id": "58883d386ec57cc4",
"outputs": [],
"execution_count": 3
"execution_count": 2
},
{
"metadata": {},

View File

@@ -1,14 +1,16 @@
# 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
- block size: The number of characters we encode in a block. Block size isn't using in this notebook
- key height: The alphabet length. If we want to encode bytes, our alphabet length is 256.
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 height: The alphabet length. 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 }}`.
- key width: The number of bytes an encrypted character is in our alphabet.
In this document, we will use the following parameters:
```
height = {{ height }}
width = {{ width }}

View File

@@ -20,8 +20,8 @@ def render_spn_algebra(data: dict):
if __name__ == "__main__":
height = 10
width = 7
height = 9
width = 8
total_attr = height * width
i0 = InnerKey.init_matrix(width, height)
i1 = InnerKey.init_matrix(width, height)

File diff suppressed because one or more lines are too long

View File

@@ -297,6 +297,7 @@ class ServerPersistentMediumKeys(BaseModel):
class MutualEphemeralDataKeys(BaseModel):
alpha_key: SubstitutionKey
inner_key_1: InnerKey
inner_key_2: InnerKey
outer_key_1: OuterKey
outer_key_2: OuterKey
outer_key_3: OuterKey
@@ -306,6 +307,7 @@ class MutualEphemeralDataKeys(BaseModel):
return MutualEphemeralDataKeys(
alpha_key=SubstitutionKey.init_matrix(width, height, 255),
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_2=OuterKey.init_matrix(height),
outer_key_3=OuterKey.init_matrix(height),
@@ -323,6 +325,7 @@ class MutualEphemeralMediumKeys(BaseModel):
outer_key_6: OuterKey
inner_key_1: InnerKey
inner_key_2: InnerKey
inner_key_4: InnerKey
inner_key_3: InnerKey
@@ -337,6 +340,7 @@ class MutualEphemeralMediumKeys(BaseModel):
outer_key_5=OuterKey.init_matrix(height),
outer_key_6=OuterKey.init_matrix(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_3=InnerKey.init_matrix(width, height),
)