Skip to content

Commit

Permalink
Merge pull request #186 from marekkirejczyk/DSA_intuition
Browse files Browse the repository at this point in the history
Dsa intuition - teaser 3
  • Loading branch information
martawleklinska committed Jul 12, 2024
2 parents a9d30d1 + 2994c34 commit 4fc41c7
Show file tree
Hide file tree
Showing 31 changed files with 445 additions and 103 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/render.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++ ffmpeg texlive-latex-extra --fix-missing
- name: Update CA certificates
run: sudo apt-get install --reinstall ca-certificates
- name: Install fonts
run: |
mkdir ~/texmf
curl -L -o ~/texmf/mnsymbol.zip https://mirrors.ctan.org/fonts/mnsymbol.zip
curl -k -L -o ~/texmf/mnsymbol.zip https://mirrors.ctan.org/fonts/mnsymbol.zip
unzip ~/texmf/mnsymbol.zip -d ~/texmf
cd ~/texmf/mnsymbol/tex && ls && latex MnSymbol.ins
mkdir -p ~/texmf/tex/latex/MnSymbol/
Expand All @@ -44,6 +46,5 @@ jobs:
- uses: actions/upload-artifact@v3
with:
name: Movie HQ
path: media/videos/main/1080p60/EllipticCurves.mp4
path: media/videos/main/**/EllipticCurves.mp4
retention-days: 5

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ noarch
todo.md
.ruff_cache
.idea/*
venv
Binary file added data/sound/episode3/slide2-0.mp3
Binary file not shown.
Binary file added data/sound/episode3/slide2-1.mp3
Binary file not shown.
Binary file added data/sound/episode3/slide2-2.mp3
Binary file not shown.
Binary file added data/sound/episode3/slide2-3.mp3
Binary file not shown.
Binary file added data/sound/episode3/slide2-4.mp3
Binary file not shown.
Binary file added data/sound/episode3/slide2-5.mp3
Binary file not shown.
Binary file added data/sound/episode3/slide2-6.mp3
Binary file not shown.
Binary file added data/sound/episode3/slide2-7.mp3
Binary file not shown.
Binary file added data/sound/teaser3/background.mp3
Binary file not shown.
Binary file modified data/sound/teaser3/slide2-0.mp3
Binary file not shown.
Binary file modified data/sound/teaser3/slide2-2.mp3
Binary file not shown.
Binary file modified data/sound/teaser3/slide2-3.mp3
Binary file not shown.
Binary file modified data/sound/teaser3/slide2-4.mp3
Binary file not shown.
Binary file added data/sound/teaser3/slide2-4_2.mp3
Binary file not shown.
Binary file modified data/sound/teaser3/slide2-5.mp3
Binary file not shown.
Binary file modified data/sound/teaser3/slide3.mp3
Binary file not shown.
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ soundfile
pyloudnorm
pycryptodome
cryptography
manim_editor
setuptools
4 changes: 2 additions & 2 deletions script/movie
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ else
quality_arg=$1
fi

echo python -m manim -p $quality_arg zkmarek/video/main.py
python -m manim -p $quality_arg zkmarek/video/main.py
echo python3 -m manim -p $quality_arg zkmarek/video/main.py
python3 -m manim -p $quality_arg zkmarek/video/main.py

9 changes: 6 additions & 3 deletions zkmarek/video/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
from zkmarek.video.slides.teaser2.ec_rec_teaser import ECRecoverSlide as ECRteaser
from zkmarek.video.slides.teaser2.sponsored import Sponsored as SponsoredTeaser
from zkmarek.video.slides.teaser3.intuition import Intuition
from zkmarek.video.slides.teaser3.credits import Credits as CreditsT3
from zkmarek.video.slides.teaser3.e2_reference import TitleSlide as E2Reference

config.width = 16
config.height = 9
Expand Down Expand Up @@ -163,16 +165,17 @@
TEASER3 = [
Intro(
sound="data/sound/teaser3/slide0-0.mp3",
background_sound="data/sound/teaser2/backgroundt.mp3",
background_sound="data/sound/teaser3/background.mp3",
),
Sponsored(),
TitleSlide(
E2Reference(
"Intuition behind digital signature",
sound="data/sound/teaser3/slide3.mp3",
pre_wait_time=1.5,
wait_time=3,
),
Intuition(),
Subscribe("data/sound/episode1/s28.wav"),
CreditsT3(),
]

EPISODE3 = [
Expand Down
214 changes: 189 additions & 25 deletions zkmarek/video/slides/episode3/pairing.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
from manim import (
DOWN,
UP,
LEFT,
RIGHT,
Brace,
FadeIn,
FadeOut,
MathTex,
Text,
Unwrite,
Write,
VGroup,
MoveToTarget,
ReplacementTransform,
Indicate,
)

from manim import (DOWN, UP, Brace, FadeIn, FadeOut, MathTex, Text,
Unwrite, Write)

from zkmarek.video.constant import PRIMARY_COLOR, SECONDARY_COLOR
from zkmarek.video.constant import (
PRIMARY_COLOR,
SECONDARY_COLOR,
PRIMARY_FONT,
HIGHLIGHT_COLOR,
)
from zkmarek.video.slides.common.slide_base import SlideBase
from zkmarek.video.slides.episode3.morphin_math_text import MorphinMathText

from zkmarek.video.mobjects.equation_box import EquationBoxWithIcons
from zkmarek.video.slides.episode3.discreete_polynomial_chart import DiscreetePolynomialChart
def poly(x):
return x * x * x - x * x * 2 + x * 3 + 4

class Pairing(SlideBase):
definition_label: MathTex
Expand All @@ -26,23 +48,23 @@ def __init__(self):
super().__init__("Pairing")

def construct(self):
self.definition_label = MathTex(r"Pairing", font_size=50, color=PRIMARY_COLOR)
self.definition = MathTex(r"e: {{G_1}} \times {{G_2}} \rightarrow {{G_T}}", font_size=70, color=PRIMARY_COLOR)
self.brace1 = Brace(self.definition[1], DOWN, color=PRIMARY_COLOR)
self.brace2 = Brace(self.definition[3], DOWN, color=PRIMARY_COLOR)
self.brace3 = Brace(self.definition[5], DOWN, color=PRIMARY_COLOR)
self.definition_label = Text("Pairing", font_size=50, color=PRIMARY_COLOR, font = PRIMARY_FONT)
self.definition = MathTex(r"{{e}}: {{G_1}} \times {{G_2}} \rightarrow {{G_T}}", font_size=70, color=PRIMARY_COLOR)
self.brace1 = Brace(self.definition[2], DOWN, color=PRIMARY_COLOR)
self.brace2 = Brace(self.definition[4], DOWN, color=PRIMARY_COLOR)
self.brace3 = Brace(self.definition[6], DOWN, color=PRIMARY_COLOR)
self.brace1.shift(UP * 2.5)
self.brace2.shift(UP * 2.5)
self.brace3.shift(UP * 2.5)
self.brace1_label = Text(r"Subgroup of points on elliptic curve", font_size=30, color=PRIMARY_COLOR)
self.brace1_label = Text(r"Subgroup of points on elliptic curve", font_size=30, color=PRIMARY_COLOR, font = PRIMARY_FONT)
self.brace1.put_at_tip(self.brace1_label)
self.brace2_label = Text(r"Subgroup of points on elliptic curve", font_size=30, color=PRIMARY_COLOR)
self.brace2_label = Text(r"Subgroup of points on elliptic curve", font_size=30, color=PRIMARY_COLOR, font = PRIMARY_FONT)
self.brace2.put_at_tip(self.brace2_label)
self.brace3_label = Text(r"Prime field", font_size=30, color=PRIMARY_COLOR)
self.brace3_label = Text(r"Prime field", font_size=30, color=PRIMARY_COLOR, font = PRIMARY_FONT)
self.brace3.put_at_tip(self.brace3_label)

self.bilinearity_label = MathTex(r"Bilinearity", font_size=40, color=SECONDARY_COLOR)
self.bilinearity = MathTex(r"e(P + P', Q) = e(P, Q) \cdot e(P', Q)", font_size=40, color=SECONDARY_COLOR)
self.chart = DiscreetePolynomialChart(41, poly).scale(0.55)
self.bilinearity_label = Text("Bilinearity", font_size=40, color=SECONDARY_COLOR, font = PRIMARY_FONT)
self.bilinearity = MathTex(r"e({{P}} + {{P'}}, Q) = {{e(P, Q)}} \cdot {{e(P', Q)}}", font_size=40, color=SECONDARY_COLOR)
self.bilinearity_morph = MorphinMathText([
r"{{e(aP, bQ)}}",
r"{{e(aP, bQ)}} = e({{a}}P, bQ){{ }}",
Expand All @@ -56,13 +78,16 @@ def construct(self):
r"{{e(aP, bQ)}} = e({{ }}P, bQ){{^a}} = e(aP, {{ }}Q){{^b}} = e({{ }}P, {{ }}Q){{^{ab}}}"
" = e({{b}}P, {{a}}Q){{ }}",
r"{{e(aP, bQ)}} = e({{ }}P, {{ }}Q){{^{ab}}} = e({{b}}P, {{a}}Q){{ }}"
])

self.non_degeneracy_label = MathTex(r"Non-degeneracy", font_size=40, color=SECONDARY_COLOR)
]).shift(DOWN)
self.multiplying = MathTex(r"a\cdot P = {{P+P+P \cdots}}", color = HIGHLIGHT_COLOR, font_size =40).next_to(self.bilinearity, DOWN).shift(DOWN)
self.multiplying_brace = Brace(self.multiplying[1], DOWN, color = PRIMARY_COLOR)
self.multiplying_brace_label = Text(r"a times", font_size=30, color=PRIMARY_COLOR, font = PRIMARY_FONT)
self.multiplying_brace.put_at_tip(self.multiplying_brace_label)
self.non_degeneracy_label = Text("Non-degeneracy", font_size=40, color=SECONDARY_COLOR, font = PRIMARY_FONT)
nd_text = r"\forall{a \in G_1}, \forall{b \in G_2} (a, b \neq \mathcal{O}"
nd_text += r" \Rightarrow e(a, b) \neq 1_{G_T}) "
self.non_degeneracy = MathTex(nd_text, font_size=40, color=SECONDARY_COLOR)
self.computability_label = MathTex(r"Computability", font_size=40, color=SECONDARY_COLOR)
self.computability_label = Text("Computability", font_size=40, color=SECONDARY_COLOR, font = PRIMARY_FONT)

self.definition_label.to_edge(UP)
self.definition.next_to(self.definition_label, DOWN)
Expand All @@ -73,27 +98,166 @@ def construct(self):
self.computability_label.next_to(self.non_degeneracy, DOWN, buff=0.6)

def animate_in(self, scene):
self.new_subsection(
scene, "what is a pairing", "data/sound/episode3/slide2-0.mp3"
)
scene.play(Write(self.definition_label))
scene.play(Write(self.definition))

scene.play(FadeIn(self.brace1))
scene.play(FadeIn(self.brace1_label))
scene.play(FadeOut(self.brace1), FadeOut(self.brace1_label))
scene.play(
FadeOut(self.brace1),
FadeOut(self.brace1_label))

scene.play(FadeIn(self.brace2))
scene.play(FadeIn(self.brace2_label))
scene.play(FadeOut(self.brace2), FadeOut(self.brace2_label))
scene.play(
FadeOut(self.brace2),
FadeOut(self.brace2_label))

scene.play(FadeIn(self.brace3))
scene.play(FadeIn(self.brace3_label))
scene.play(FadeOut(self.brace3), FadeOut(self.brace3_label))
scene.play(
FadeOut(self.brace3),
FadeOut(self.brace3_label))
scene.wait(2.7)
scene.play(Indicate(self.definition[0], color = HIGHLIGHT_COLOR))

self.new_subsection(scene, "bilinear definition", "data/sound/episode3/slide2-1.mp3")
scene.play(Write(self.bilinearity_label))
scene.play(Write(self.bilinearity))
scene.wait(2)
scene.play(Indicate(self.bilinearity[1], color = PRIMARY_COLOR))
scene.play(Indicate(self.bilinearity[3], color = PRIMARY_COLOR))
scene.wait(2.5)
scene.play(Indicate(self.bilinearity[5], color = PRIMARY_COLOR))
scene.play(Indicate(self.bilinearity[7], color = PRIMARY_COLOR))
scene.wait(3.5)
self.other_things = VGroup(self.bilinearity, self.bilinearity_label, self.definition)
self.other_things.generate_target()
self.other_things.target.shift(LEFT*4.5).scale(0.4)
scene.play(MoveToTarget(self.other_things))
self.chart.gen_points()
scene.play(FadeIn(self.chart))
self.new_subsection(
scene, "bilinearity example", "data/sound/episode3/slide2-2.mp3"
)
self.example_bilinearity(scene)

self.new_subsection(scene, "multiplying", "data/sound/episode3/slide2-4.mp3")
self.bilinearity_morph.animate_in(scene)
scene.play(Unwrite(self.bilinearity))
scene.play(self.bilinearity_morph.texs[-1].animate.next_to(self.bilinearity_label, DOWN))
self.new_subsection(
scene, "explaining the multiplying", "data/sound/episode3/slide2-5.mp3"
)
scene.play(
self.bilinearity_morph.texs[-1].animate.next_to(
self.bilinearity_label, DOWN
), Unwrite(self.bilinearity)
)
scene.play(Write(self.multiplying), Write(self.multiplying_brace), Write(self.multiplying_brace_label))
scene.wait(3)
scene.play(Unwrite(self.multiplying), Unwrite(self.multiplying_brace), Unwrite(self.multiplying_brace_label))

self.new_subsection(scene, "non degeneracy", "data/sound/episode3/slide2-6.mp3")
scene.play(Write(self.non_degeneracy_label))
scene.play(Write(self.non_degeneracy))

self.new_subsection(scene, "computability", "data/sound/episode3/slide2-7.mp3")
scene.play(Write(self.computability_label))

def example_bilinearity(self, scene):
scene.wait(3)
scene.play(FadeOut(self.chart))
self.example_operaton = (
MathTex(r"e(x,y)=2^{xy}", color=HIGHLIGHT_COLOR)
.next_to(self.definition_label, DOWN)
)
self.x = MathTex(r"x=4", color=HIGHLIGHT_COLOR).to_edge(RIGHT+UP).shift(LEFT)
y1 = MathTex(r"y=5", color=HIGHLIGHT_COLOR).next_to(self.x, DOWN)
self.y = MathTex(r"y=2+3", color=HIGHLIGHT_COLOR).next_to(self.x, DOWN)
scene.wait(1)
scene.play(Write(self.example_operaton), run_time=0.7)
scene.wait(6)
scene.play(Write(self.x), Write(y1), run_time=0.7)
scene.wait(2.5)
scene.play(ReplacementTransform(y1, self.y))
pairing_bilin1 = EquationBoxWithIcons.create(
"⎘",
"{{e(4,2+3)}}",
SECONDARY_COLOR,
).shift(DOWN).scale(1.2)
pairing_bilin2 = EquationBoxWithIcons.create(
"⎘",
"{{e(4,2+3)}} = {{e(4, 2)\cdot e(4,3)}}",
SECONDARY_COLOR).shift(DOWN).scale(1.2)
pairing_bilin3 = EquationBoxWithIcons.create(
"⎘",
"{{e(4,2+3)}} = {{e(4, 2)\cdot e(4,3)}} = {{2^{4\cdot 2}\cdot2^{4\cdot 3}}}",
SECONDARY_COLOR,
).shift(DOWN).scale(1.2)

pairing_bilin3 = EquationBoxWithIcons.create(
"⎘",
"{{e(4,2+3)}} = {{e(4, 2)\cdot e(4,3)}} = {{2^{4\cdot 2}\cdot2^{4\cdot 3}}} = {{2^{20}}}",
SECONDARY_COLOR).scale(1.2).shift(DOWN)

pairing_bilin4 = EquationBoxWithIcons.create(
"⎘",
"{{e(4,2+3)}} = {{2^{20}}}",
SECONDARY_COLOR).shift(DOWN).scale(1.2)
scene.play(Write(pairing_bilin1), run_time=0.7)
scene.wait(0.6)
scene.play(ReplacementTransform(pairing_bilin1, pairing_bilin2), run_time=0.7)
scene.wait(0.6)
scene.play(ReplacementTransform(pairing_bilin2, pairing_bilin3), run_time=0.7)
scene.wait(0.6)
scene.play(ReplacementTransform(pairing_bilin3, pairing_bilin4), run_time=0.7)

self.new_subsection(
scene, "finishing example", "data/sound/episode3/slide2-3.mp3"
)
pairing_bilin5 = EquationBoxWithIcons.create(
"⎘",
"{{e(4,2+3)}} = {{2^{20}}}",
SECONDARY_COLOR,
"⎘",
"{{e(4,5)}}",
SECONDARY_COLOR,
).shift(DOWN).scale(1.2)
pairing_bilin6 = EquationBoxWithIcons.create(
"⎘",
"{{e(4,2+3)}} = {{2^{20}}}",
SECONDARY_COLOR,
"⎘",
"{{e(4,5)}} = {{2^{4\cdot 5}}}",
SECONDARY_COLOR,
).shift(DOWN).scale(1.2)
pairing_bilin7 = EquationBoxWithIcons.create(
"⎘",
"{{e(4,2+3)}} = {{2^{20}}}",
SECONDARY_COLOR,
"⎘",
"{{e(4,5)}} = {{2^{4\cdot 5}}} = {{2^{20}}}",
SECONDARY_COLOR,
).shift(DOWN).scale(1.2)
scene.play(ReplacementTransform(pairing_bilin4,pairing_bilin5), run_time=0.7)
scene.wait(1)
scene.play(ReplacementTransform(pairing_bilin5, pairing_bilin6), run_time=0.7)
scene.wait(1)
scene.play(ReplacementTransform(pairing_bilin6, pairing_bilin7), run_time=0.7)
scene.wait(1)

scene.play(
Unwrite(self.example_operaton),
Unwrite(self.x),
Unwrite(self.y),
FadeOut(pairing_bilin7)

)
self.other_things.generate_target()
self.other_things.target.shift(RIGHT*4.5).scale(1/0.4)
scene.play(MoveToTarget(self.other_things))



Binary file added zkmarek/video/slides/teaser3/Docs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added zkmarek/video/slides/teaser3/Lock Open@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added zkmarek/video/slides/teaser3/Locked@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed zkmarek/video/slides/teaser3/arrow_left.png
Binary file not shown.
Binary file removed zkmarek/video/slides/teaser3/arrow_right.png
Binary file not shown.
40 changes: 40 additions & 0 deletions zkmarek/video/slides/teaser3/credits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from manim import DOWN, UP, MoveToTarget, Text, VGroup, rate_functions

from zkmarek.video.constant import PRIMARY_COLOR, PRIMARY_FONT, SECONDARY_COLOR
from zkmarek.video.slides.common.slide_base import SlideBase


class Credits(SlideBase):
group: VGroup

def __init__(self):
super().__init__("Credits")

def construct(self):
self.group = VGroup()

def add_title(self, text: Text):
result = Text(text, font=PRIMARY_FONT, color=PRIMARY_COLOR)
if len(self.group) > 0:
result.next_to(self.group[-1], direction=DOWN, buff=1)
self.group.add(result)

def add_credit(self, text):
result = Text(text, font=PRIMARY_FONT, color=SECONDARY_COLOR, font_size=30)
result.next_to(self.group[-1], direction=DOWN, buff=0.2)
self.group.add(result)

def animate_in(self, scene):
self.add_title("Idea and voice")
self.add_credit("Marek Kirejczyk @zkmarek")
self.add_title("Code and animation")
self.add_credit("Marek Kirejczyk @zkmarek")
self.add_credit("Marta Wleklińska @martawleklinska")

self.add_title("Music from Udio AI music")
self.group.generate_target()
self.group.shift(5 * DOWN)
self.group.target.shift(16 * UP)
scene.play(
MoveToTarget(self.group, run_time=32, rate_func=rate_functions.linear)
)
Loading

0 comments on commit 4fc41c7

Please sign in to comment.