mirror of
https://github.com/saymrwulf/NTT-learning.git
synced 2026-09-05 19:20:41 +00:00
130 lines
5 KiB
Text
130 lines
5 KiB
Text
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"pedagogy": {
|
|
"role": "meta",
|
|
"difficulty": 1,
|
|
"kind": "orientation",
|
|
"title": "Studio Goals"
|
|
}
|
|
},
|
|
"source": "## META | difficulty 1 | Studio Goals\n\nThis studio frames implementation reading.\n\nKeep three lenses separate:\n\n- algebraic purpose\n- array dataflow\n- protocol-specific conventions\n"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"pedagogy": {
|
|
"role": "mandatory",
|
|
"difficulty": 3,
|
|
"kind": "explanation",
|
|
"title": "Forward And Inverse Flow Side By Side"
|
|
}
|
|
},
|
|
"source": "## MANDATORY | difficulty 3 | Forward And Inverse Flow Side By Side\n\nThe goal here is not to claim the same cell-by-cell formula for both directions.\nThe goal is to compare the same pairing structure while noticing that forward and inverse flows push arithmetic in opposite directions.\n"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"pedagogy": {
|
|
"role": "mandatory",
|
|
"difficulty": 3,
|
|
"kind": "demo",
|
|
"title": "Compare Cooley-Tukey And Gentleman-Sande Views"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": "# MANDATORY | difficulty 3 | Compare Cooley-Tukey And Gentleman-Sande Views\n\nfrom ntt_learning.toy_ntt import action_rows, apply_ct_stage, apply_gs_stage\n\nvalues = [2, 5, 7, 1, 3, 6, 4, 0]\nct_output, ct_actions = apply_ct_stage(values, block_size=4, zetas=[1, 4, 1, 4], modulus=17)\ngs_output, gs_actions = apply_gs_stage(values, block_size=4, zetas=[1, 4, 1, 4], modulus=17)\n\nprint(\"input:\", values)\nprint(\"ct output:\", ct_output)\nprint(\"gs output:\", gs_output)\nprint(\"ct trace:\", action_rows(ct_actions))\nprint(\"gs trace:\", action_rows(gs_actions))\n"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"pedagogy": {
|
|
"role": "mandatory",
|
|
"difficulty": 2,
|
|
"kind": "exercise",
|
|
"title": "Debug Checklist"
|
|
}
|
|
},
|
|
"source": "## MANDATORY | difficulty 2 | Debug Checklist\n\nWhen a stage looks wrong, inspect these in order:\n\n1. wrong pairings\n2. wrong zeta value\n3. wrong sign in the subtraction branch\n4. wrong direction choice between forward-style and inverse-style flow\n"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"pedagogy": {
|
|
"role": "mandatory",
|
|
"difficulty": 2,
|
|
"kind": "exercise",
|
|
"title": "Compare Baseline And Wrong-Zeta Output"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": "# MANDATORY | difficulty 2 | Compare Baseline And Wrong-Zeta Output\n\nfrom ntt_learning.toy_ntt import apply_ct_stage\n\nvalues = [3, 1, 4, 1]\nbaseline, _ = apply_ct_stage(values, block_size=2, zetas=1, modulus=17)\nwrong_zeta, _ = apply_ct_stage(values, block_size=2, zetas=3, modulus=17)\n\nprint(\"baseline:\", baseline)\nprint(\"wrong zeta:\", wrong_zeta)\n"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"pedagogy": {
|
|
"role": "facultative",
|
|
"difficulty": 4,
|
|
"kind": "exploration",
|
|
"title": "Optional Ordering Preview"
|
|
}
|
|
},
|
|
"source": "## FACULTATIVE | difficulty 4 | Optional Ordering Preview\n\nBit-reversal is important later, but it is deliberately optional here so the main route can stay focused on pair mechanics first.\n"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"pedagogy": {
|
|
"role": "facultative",
|
|
"difficulty": 4,
|
|
"kind": "exploration",
|
|
"title": "Inspect Bit-Reversed Order"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": "# FACULTATIVE | difficulty 4 | Inspect Bit-Reversed Order\n\nfrom ntt_learning.toy_ntt import bit_reversed_order\n\nprint(bit_reversed_order([0, 1, 2, 3, 4, 5, 6, 7]))\n"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"pedagogy": {
|
|
"role": "meta",
|
|
"difficulty": 1,
|
|
"kind": "handoff",
|
|
"title": "Next Notebook"
|
|
}
|
|
},
|
|
"source": "## META | difficulty 1 | Next Notebook\n\nNext notebook: return to `../../COURSE_BLUEPRINT.ipynb` and extend the course into Kyber-specific notebooks.\n"
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"name": "python"
|
|
},
|
|
"ntt_learning": {
|
|
"title": "Studio: Convolution To Toy NTT",
|
|
"contract_version": "0.1",
|
|
"sequence": [
|
|
"notebooks/START_HERE.ipynb",
|
|
"notebooks/COURSE_BLUEPRINT.ipynb",
|
|
"notebooks/foundations/01_convolution_to_toy_ntt/lecture.ipynb",
|
|
"notebooks/foundations/01_convolution_to_toy_ntt/lab.ipynb",
|
|
"notebooks/foundations/01_convolution_to_toy_ntt/problems.ipynb",
|
|
"notebooks/foundations/01_convolution_to_toy_ntt/studio.ipynb"
|
|
]
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|