Skip to content

Commit

Permalink
further synchro
Browse files Browse the repository at this point in the history
  • Loading branch information
martawleklinska committed Aug 20, 2024
1 parent 3621806 commit 2a959c1
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 42 deletions.
2 changes: 1 addition & 1 deletion zkmarek/video/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@

EPISODE4 = [
Episode3Reference(),
TitleSlide("Polynomials", sound="data/sound/e4/slide0-5.mp3", wait_time=5),
TitleSlide("Polynomials", sound="data/sound/e4/slide0-5.mp3", wait_time=3),
Polynomials(),
TitleSlide("Commitments", sound="data/sound/e4/slide2-0.mp3", wait_time=3.5),
Commitment(),
Expand Down
15 changes: 9 additions & 6 deletions zkmarek/video/slides/e4/commitment.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ def __init__(self):
super().__init__("Commitment")

def construct(self):
self.title_text = Text("Commitment scheme", font = PRIMARY_FONT, color = PRIMARY_COLOR, font_size=100).to_edge(UP)
self.title_text = Text("Commitment scheme", font = PRIMARY_FONT, color = PRIMARY_COLOR, font_size=40).to_edge(UP)
self.verifier = ImageMobject("data/images/person.png")
self.commiter = ImageMobject("data/images/person_blue.png")
self.rectangle = Rectangle(height=1.5, width=4, color = PRIMARY_COLOR).next_to(self.commiter, LEFT + UP, buff = 0)
self.rectangle = Rectangle(height=1.5, width=4, color = PRIMARY_COLOR).to_edge(LEFT + UP, buff = 0)
self.rectangle_copy = Rectangle(height=1.5, width=4, color = PRIMARY_COLOR).next_to(self.commiter, LEFT + UP, buff = 0)
self.commitment = Text("secret message", font = PRIMARY_FONT, color = PRIMARY_COLOR).next_to(self.commiter, UP+LEFT, buff = 0.3)
self.commitment_copy = Text("secret message", font = PRIMARY_FONT, color = PRIMARY_COLOR).next_to(self.commiter, UP+LEFT, buff = 0.3)
self.verifier.shift(3*RIGHT)
self.lock = ImageMobject("data/images/Locked@2x.png").next_to(self.commitment, RIGHT, buff = 0.1)
self.lock_copy = ImageMobject("data/images/Locked@2x.png").next_to(self.commitment, RIGHT, buff = 0.1)
self.lock = ImageMobject("data/images/Locked@2x.png").scale(0.4).next_to(self.commitment, RIGHT, buff = 0.1)
self.lock_copy = ImageMobject("data/images/Locked@2x.png").scale(0.4).next_to(self.commitment, RIGHT, buff = 0.1)
self.tex = Tex(load("zkmarek/video/slides/e4/properties.tex"), color=SECONDARY_COLOR)

def animate_in(self, scene):
Expand All @@ -33,13 +33,16 @@ def animate_in(self, scene):
scene.play(MoveToTarget(self.commiter))
scene.play(FadeIn(self.verifier))
scene.wait(1)
scene.play(Write(self.commitment))
scene.wait(2)
scene.play(FadeIn(self.lock))

self.commitment_copy.generate_target()
self.commitment_copy.target.next_to(self.verifier, UP+RIGHT, buff = 0.3)
self.commitment_copy.target.next_to(self.verifier, UP+RIGHT, buff = 0.1)
self.lock_copy.generate_target()
self.lock_copy.target.next_to(self.commitment_copy, RIGHT, buff = 0.1)
self.rectangle_copy.generate_target()
self.rectangle_copy.target.next_to(self.verifier, UP+RIGHT, buff=0)
self.rectangle_copy.target.to_edge(UP+RIGHT)
scene.play(MoveToTarget(self.rectangle_copy), MoveToTarget(self.commitment_copy), run_time=2)

self.new_subsection(scene, "properties of commitment", "data/sound/e4/slide2-2.mp3")
Expand Down
41 changes: 17 additions & 24 deletions zkmarek/video/slides/e4/poly_commitment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from manim import LEFT, RIGHT, FadeIn, ImageMobject, Text, DOWN, UP, Write, MathTex, MoveToTarget, FadeOut, Indicate, Arrow, ValueTracker, Create, TransformMatchingShapes, Unwrite
from manim import LEFT, RIGHT, FadeIn, ImageMobject, Text, DOWN, UP, Write, MathTex, FadeOut, Indicate, ValueTracker, Create, TransformMatchingShapes, Unwrite

from zkmarek.video.constant import SECONDARY_COLOR, PRIMARY_FONT, PRIMARY_COLOR, HIGHLIGHT_COLOR
from zkmarek.video.slides.common.slide_base import SlideBase
Expand All @@ -22,25 +22,25 @@ def construct(self):

self.message = Text("message", font = PRIMARY_FONT, color = PRIMARY_COLOR, font_size=50)

self.chart = Chart(include_details=True).scale(0.4).to_edge(LEFT+UP).shift(DOWN*0.3)
self.commitment = MathTex(r"C = P({{\tau}}) \cdot {{G_1}}", color = SECONDARY_COLOR).next_to(self.chart, DOWN, buff = 0.2)
self.commitment_copy = MathTex(r"C = P({{\tau}}) \cdot {{G_1}}", color = SECONDARY_COLOR).next_to(self.verifier, UP+RIGHT, buff = 0.2)
self.chart = Chart(include_details=True).scale(0.5).to_edge(LEFT+UP).shift(DOWN*0.3)
self.commitment = MathTex(r"C = p({{\tau}}) \cdot {{G_1}}", color = SECONDARY_COLOR).next_to(self.chart, DOWN, buff = 0.4)
self.commitment_copy = MathTex(r"C = p({{\tau}}) \cdot {{G_1}}", color = SECONDARY_COLOR).next_to(self.verifier, RIGHT, buff = 0.2)

self.point = ValueTracker(-1.849)
a = Curve.from_x(self.point.get_value())
self.p = DotOnCurve(self.chart.ax, "(z, y)", a)

self.p.label.shift(LEFT*0.65)
self.point_tau = ValueTracker(2)
a_tau = Curve.from_x(self.point_tau.get_value())
self.p_tau = DotOnCurve(self.chart.ax, r"({{\tau}}, {{?}})", a_tau)
self.p_tau.label.shift(DOWN*0.15+LEFT*0.15).scale(1.1)

self.trusted_setup = MathTex(r"{{\tau^1}} \cdot {{G_1}} + {{\tau^2}} \cdot {{G_1}} + {{\cdots}} + {{\tau^n}} \cdot {{G_1}} ").next_to(self.commiter, DOWN, buff = 0.1).shift(RIGHT)
self.trusted_setup1 = MathTex(r"\left[ {{\tau^1}} + {{\tau^2}} + {{\cdots}} + {{\tau^n}} \right] \cdot {{G_1}} ").next_to(self.commiter, DOWN, buff = 0.1).shift(RIGHT)
self.trusted_setup2 = MathTex(r"P({{\tau}}) \cdot{{G_1}} = \left[ {{\tau^1}} + {{\tau^2}} + {{\cdots}} + {{\tau^n}} \right] \cdot {{G_1}} ").next_to(self.commiter, DOWN, buff = 0.1).shift(RIGHT)
self.trusted_setup = MathTex(r"{{\tau^1}} \cdot {{G_1}} + {{\tau^2}} \cdot {{G_1}} + {{\cdots}} + {{\tau^n}} \cdot {{G_1}} ", color = SECONDARY_COLOR).next_to(self.commiter_label, DOWN, buff = 0.1).shift(RIGHT)
self.trusted_setup1 = MathTex(r"\left[ {{\tau^1}} + {{\tau^2}} + {{\cdots}} + {{\tau^n}} \right] \cdot {{G_1}} ", color = SECONDARY_COLOR).next_to(self.commiter_label, DOWN, buff = 0.1).shift(RIGHT)
self.trusted_setup2 = MathTex(r"p({{\tau}}) \cdot{{G_1}} = \left[ {{\tau^1}} + {{\tau^2}} + {{\cdots}} + {{\tau^n}} \right] \cdot {{G_1}} ", color = SECONDARY_COLOR).next_to(self.commiter_label, DOWN, buff = 0.1).shift(RIGHT)

self.opening = MathTex(r"p(z) = y", color = SECONDARY_COLOR).shift(3*UP)

self.polynomial = MathTex("p(x)", color = PRIMARY_COLOR).next_to(self.chart, DOWN, buff = 0).scale(0.4)

def animate_in(self, scene):
self.new_subsection(scene, "intro", "data/sound/e4/slide3-1.mp3")
Expand All @@ -55,10 +55,10 @@ def animate_in(self, scene):
scene.play(Indicate(self.chart.graph, color = HIGHLIGHT_COLOR))

self.new_subsection(scene, "committing", "data/sound/e4/slide3-2.mp3")
scene.wait(4)
scene.wait(5)

scene.play(Create(self.p_tau))
scene.wait(1.5)
scene.wait(2)
scene.play(Indicate(self.p_tau[1], color = HIGHLIGHT_COLOR))
scene.play(Create(self.commitment))

Expand All @@ -67,20 +67,16 @@ def animate_in(self, scene):
# scene.play(Indicate(self.commitment[1], color = PRIMARY_COLOR))
scene.play(Indicate(self.commitment[3], color = PRIMARY_COLOR))

scene.wait(2.5)
scene.wait(3.5)
scene.play(Indicate(self.chart.graph, color = HIGHLIGHT_COLOR))

self.new_subsection(scene, "what is verifiers job", "data/sound/e4/slide3-4.mp3")
scene.play(TransformMatchingShapes(self.commitment.copy(), self.commitment_copy))
scene.wait(1.5)

self.arrow = Arrow(start=self.polynomial.get_top(), end=self.chart.graph.get_bottom(), color =PRIMARY_COLOR)

scene.wait(2)
scene.wait(3.5)
scene.play(Indicate(self.commitment[1], color = PRIMARY_COLOR))

self.new_subsection(scene, "how to know what is tau?", "data/sound/e4/slide3-5.mp3")
scene.wait(1.5)
scene.wait(3)
tau = MathTex(r"\tau = ?", color = SECONDARY_COLOR).next_to(self.verifier, RIGHT, buff = 0)
scene.play(Write(tau))

Expand All @@ -91,7 +87,7 @@ def animate_in(self, scene):
scene.play(TransformMatchingShapes(self.trusted_setup, self.trusted_setup1))
scene.wait(2)
scene.play(TransformMatchingShapes(self.trusted_setup1, self.trusted_setup2))
scene.wait(2.5)
scene.wait(1.5)
scene.play(Indicate(self.trusted_setup2[3], color = HIGHLIGHT_COLOR))
scene.wait(1.5)
scene.play(Indicate(self.trusted_setup2[1], color = HIGHLIGHT_COLOR))
Expand All @@ -103,17 +99,14 @@ def animate_in(self, scene):
scene.play(FadeOut(self.commitment))
scene.wait(2)
scene.play(TransformMatchingShapes(self.p.label.copy(), self.opening))
scene.play(Write(self.polynomial))
scene.play(Write(self.arrow))

self.new_subsection(scene, "enough info", "data/sound/e4/slide3-8.mp3")
scene.wait(2)
scene.play(Indicate(self.verifier, color = HIGHLIGHT_COLOR))
scene.wait(2)
scene.wait(3.5)
scene.play(Indicate(self.opening, color = HIGHLIGHT_COLOR), Indicate(self.p, color = HIGHLIGHT_COLOR))
scene.wait(2)
scene.play(Indicate(self.chart.graph, color = HIGHLIGHT_COLOR))

def animate_out(self, scene):
scene.play(FadeOut(self.commiter, self.verifier, self.commiter_label, self.verifier_label, self.opening, self.chart))
scene.play(FadeOut(self.commiter, self.verifier, self.commiter_label, self.verifier_label, self.opening, self.chart.ax, self.chart.labels, self.chart.graph, self.p_tau, self.p, self.trusted_setup2, self.commitment_copy))

21 changes: 12 additions & 9 deletions zkmarek/video/slides/e4/polynomials.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ def animate_in(self, scene):
scene.play(Create(self.root1), run_time=0.4)
scene.play(Create(self.root2), run_time=0.4)
scene.play(Create(self.root3), run_time=0.4)
scene.play(Indicate(self.root1, color = SECONDARY_COLOR), Indicate(self.root2, color = SECONDARY_COLOR), Indicate(self.root3))
scene.play(Indicate(self.root1, color = SECONDARY_COLOR), Indicate(self.root2, color = SECONDARY_COLOR), Indicate(self.root3, color = SECONDARY_COLOR))
scene.play(TransformMatchingShapes(self.polynomial, self.polynomial_roots))
scene.play(Indicate(self.chart.ax[0], color = HIGHLIGHT_COLOR), Indicate(self.root1.label[1], color = HIGHLIGHT_COLOR, scale_factor=2), Indicate(self.root2.label[1], color = HIGHLIGHT_COLOR, scale_factor=2), Indicate(self.root3.label[1], color = HIGHLIGHT_COLOR, scale_factor=2), Indicate(self.polynomial_roots[1], color = HIGHLIGHT_COLOR), Indicate(self.polynomial_roots[3], color = HIGHLIGHT_COLOR), Indicate(self.polynomial_roots[5], color = HIGHLIGHT_COLOR))
scene.play(Indicate(self.root1.label[1], color = HIGHLIGHT_COLOR, scale_factor=2), Indicate(self.root2.label[1], color = HIGHLIGHT_COLOR, scale_factor=2), Indicate(self.root3.label[1], color = HIGHLIGHT_COLOR, scale_factor=2), Indicate(self.polynomial_roots[1], color = HIGHLIGHT_COLOR), Indicate(self.polynomial_roots[3], color = HIGHLIGHT_COLOR), Indicate(self.polynomial_roots[5], color = HIGHLIGHT_COLOR))
scene.wait(1.1)
scene.play(Indicate(self.chart.ax[1], color = HIGHLIGHT_COLOR), Indicate(self.root1.label[3], color = HIGHLIGHT_COLOR, scale_factor=2), Indicate(self.root2.label[3], color = HIGHLIGHT_COLOR, scale_factor=2), Indicate(self.root3.label[3], color = HIGHLIGHT_COLOR, scale_factor=2))
scene.play(Indicate(self.root1.label[3], color = HIGHLIGHT_COLOR, scale_factor=2), Indicate(self.root2.label[3], color = HIGHLIGHT_COLOR, scale_factor=2), Indicate(self.root3.label[3], color = HIGHLIGHT_COLOR, scale_factor=2))
scene.play(TransformMatchingShapes(self.polynomial_roots, self.polynomial2))
scene.wait(1)
scene.play(Indicate(self.polynomial2[11], color = HIGHLIGHT_COLOR), Indicate(self.root2, color = HIGHLIGHT_COLOR))
Expand Down Expand Up @@ -225,7 +225,7 @@ def animate_in(self, scene):
scene.wait(2)
scene.play(FadeOut(self.intersect_sub))
scene.wait(2)
self.polynomial.to_edge(DOWN).scale(0.7)
self.polynomial.to_edge(DOWN).shift(LEFT*3).scale(0.7)
scene.play(FadeOut(self.line_subtract, self.minus, self.subtract_z, self.quotient_z), TransformMatchingShapes(self.polynomial_z, self.polynomial))

self.new_subsection(scene, "finite fields", "data/sound/e4/slide1-6.mp3")
Expand Down Expand Up @@ -269,27 +269,30 @@ def animate_in(self, scene):

self.new_subsection(scene, "P(1)", "data/sound/e4/slide1-9.mp3")
scene.play(Indicate(self.p1, color = HIGHLIGHT_COLOR), TransformMatchingShapes(self.polynomial0_modulo5, self.polynomial1_modulo5), run_time=1.2)
scene.wait(0.4)

scene.play(Indicate(self.polynomial1_modulo5[11], color = HIGHLIGHT_COLOR))
scene.wait(0.5)
scene.play(Indicate(self.polynomial0_modulo5[13], color = HIGHLIGHT_COLOR))
scene.play(Indicate(self.polynomial1_modulo5[13], color = HIGHLIGHT_COLOR))
scene.wait(4)
scene.play(ApplyWave(self.chart1.ax[1], DIRECTION=UP))
scene.wait(2)

self.new_subsection(scene, "p=23", "data/sound/e4/slide1-10.mp3")
scene.play(TransformMatchingShapes(self.polynomial1_modulo5, self.polynomial_modulo23))
scene.wait(2.3)
scene.play(TransformMatchingShapes(self.polynomial1_modulo5, self.polynomial_modulo23))
self.chart2.gen_points()
scene.play(FadeOut(self.chart1), FadeIn(self.chart2))
scene.wait(2)

self.new_subsection(scene, "p=41", "data/sound/e4/slide1-11.mp3")
scene.play(TransformMatchingShapes(self.polynomial1_modulo5, self.polynomial_modulo23))
scene.play(TransformMatchingShapes(self.polynomial1_modulo23, self.polynomial_modulo41))
self.chart3.gen_points()
scene.play(FadeOut(self.chart2), FadeIn(self.chart3))

scene.wait(2)
scene.wait(1)

def animate_out(self, scene):
scene.play(FadeOut(self.chart3, self.chart.ax, self.chart.graph, self.chart.labels, self.title_label, self.polynomial_modulo41, self.p0, self.p1, self.p2, self.p3))

def animate_random_number(self, scene):
first_number = random.randint(1, 20)
Expand Down
9 changes: 7 additions & 2 deletions zkmarek/video/slides/episode3/polynomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,20 @@ def animate_miniature(self, scene):
text.next_to(rectangle, DOWN, buff=0.4)
scene.play(FadeIn(text, rectangle, self.polynomial, self.vector))
self.add(text)
scene.wait(2)
scene.wait(0.1)
scene.play(Indicate(self.vector.cells[0][1][0], color = HIGHLIGHT_COLOR), run_time=0.7)
scene.play(Indicate(self.vector.cells[1][1][0], color = HIGHLIGHT_COLOR), run_time=0.7)
scene.play(Indicate(self.vector.cells[3][1][0], color = HIGHLIGHT_COLOR), run_time=0.7)
scene.play(Indicate(self.vector.cells[0][1][2], color = HIGHLIGHT_COLOR), run_time=0.7)
scene.play(Indicate(self.vector.cells[1][1][2], color = HIGHLIGHT_COLOR), run_time=0.7)
scene.play(Indicate(self.vector.cells[3][1][2], color = HIGHLIGHT_COLOR), run_time=0.7)
scene.wait(3)

self.new_subsection(scene, "polynomial", "data/sound/e4/slide0-4.mp3")
scene.wait(2.5)
scene.play(TransformMatchingShapes(self.polynomial, self.polynomial_G))
scene.wait(2)
scene.play(TransformMatchingShapes(VGroup(self.vector[0][1].copy(), self.vector[1][1].copy(), self.polynomial_G), self.polynomial_tau0))

scene.wait(2)
scene.wait(4)
scene.play(FadeOut(self.polynomial_tau0, self.vector, text, rectangle))

0 comments on commit 2a959c1

Please sign in to comment.