Skip to content

Commit

Permalink
aesthetic changes in slides - synchro
Browse files Browse the repository at this point in the history
  • Loading branch information
martawleklinska committed Aug 8, 2024
1 parent d70167b commit a48b52d
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 73 deletions.
8 changes: 4 additions & 4 deletions zkmarek/video/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
from zkmarek.video.slides.episode3.credits import Credits as CreditsE3
from zkmarek.video.slides.episode4.KZG import KZG
# from zkmarek.video.slides.episode4.PCS import PolynomialCommitment
from zkmarek.video.slides.episode4.verkle import Verkle
# from zkmarek.video.slides.episode4.verkle import Verkle
from zkmarek.video.slides.e4.polynomials import Polynomials
from zkmarek.video.slides.e4.commitment import Commitment
from zkmarek.video.slides.e4.e3_reference import Episode3Reference
Expand Down Expand Up @@ -170,14 +170,14 @@

EPISODE4 = [
Episode3Reference(),
TitleSlide("Polynomials", sound="data/sound/e4/slide0-4.mp3", wait_time=2.5),
TitleSlide("Polynomials", subtitle="KZG: Kate, Zaverucha and Goldberg", sound="data/sound/e4/slide0-4.mp3", wait_time=5),
Polynomials(),
Commitment(),
# PolynomialCommitment(),
# TitleSlide("KZG", subtitle="Kate, Zaverucha and Goldberg"),
KZG(),
Verkle(),
Subscribe("data/sound/episode1/s28.wav"),
# Verkle(),
# Subscribe("data/sound/episode1/s28.wav"),
]

EPISODE5 = [
Expand Down
6 changes: 3 additions & 3 deletions zkmarek/video/slides/e4/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Chart(VGroup):
def __init__(self, include_details=True, **kwargs):
super().__init__(**kwargs)
self.include_details = include_details
step = 2 if include_details else 20
step = 10 if include_details else 20
self.ax = Axes(
x_range=[-4.5, 3.1, step],
y_range=[-3.2, 27, step],
Expand All @@ -35,9 +35,9 @@ def __init__(self, include_details=True, **kwargs):
self.add(self.ax)
if include_details:
self.labels = self.ax.get_axis_labels(
SingleStringMathTex(r"\mathbb{R}", tex_template=template,
SingleStringMathTex(r"x", tex_template=template,
font_size=26, color=PRIMARY_COLOR),
SingleStringMathTex(r"\mathbb{R}", tex_template=template,
SingleStringMathTex(r"y", tex_template=template,
font_size=26, color=PRIMARY_COLOR)
)
self.add(self.labels)
Expand Down
47 changes: 17 additions & 30 deletions zkmarek/video/slides/e4/commitment.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from manim import LEFT, RIGHT, FadeIn, ImageMobject, Text, DOWN, UP, Write, MathTex, TransformMatchingShapes, Brace, Group, MoveToTarget, FadeOut, Indicate, Arrow
from manim import LEFT, RIGHT, FadeIn, ImageMobject, Text, DOWN, UP, Write, MathTex, TransformMatchingShapes, Brace, Group, MoveToTarget, FadeOut, Indicate, Arrow, AddTextLetterByLetter, ReplacementTransform, ValueTracker, Create

from zkmarek.video.constant import SECONDARY_COLOR, PRIMARY_FONT, PRIMARY_COLOR
from zkmarek.video.slides.common.slide_base import SlideBase
from zkmarek.video.mobjects.dot_on_curve import DotOnCurve
from zkmarek.video.slides.e4.chart import Chart

from zkmarek.video.slides.e4.curve import Curve
class Commitment(SlideBase):
chart: Chart

Expand All @@ -18,49 +19,33 @@ def construct(self):
self.commiter_label = Text("Commiter", color = PRIMARY_COLOR, font=PRIMARY_FONT).next_to(self.commiter, DOWN, buff = 0.4)
self.verifier_label = Text("Verifier", color = PRIMARY_COLOR, font=PRIMARY_FONT).next_to(self.verifier, DOWN, buff = 0.4)

person = ImageMobject("data/images/person.png").scale(0.4)

self.person1 = person.copy().shift(LEFT)
self.person2 = person.copy().shift(RIGHT)
self.person3 = person.copy().shift(UP)
self.person4 = person.copy().shift(DOWN)
self.tau = MathTex(r"\tau", font_size = 60, color = SECONDARY_COLOR)
self.tau_encrypted = MathTex(r"\tau \cdot G", font_size = 60, color = SECONDARY_COLOR)
self.message = Text("message", font = PRIMARY_FONT, color = PRIMARY_COLOR, font_size=50)

self.commitment = MathTex(r"C = P({{\tau}}) \cdot {{G_1}}", color = SECONDARY_COLOR)
self.ec_point = Brace(self.commitment, DOWN, color = PRIMARY_COLOR)
self.ec_point_label = Text(r"elliptic curve point", font_size=15, color=PRIMARY_COLOR, font = PRIMARY_FONT)
self.ec_point.put_at_tip(self.ec_point_label)
self.chart = Chart(include_details=True).scale(0.6)

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

def animate_in(self, scene):
self.new_subsection(scene, "intro", "data/sound/e4/slide2-0.mp3")
scene.wait(4)
scene.wait(1.5)
scene.play(FadeIn(self.commiter))
scene.play(FadeIn(self.verifier))
scene.wait(0.5)
scene.play(Write(self.commiter_label))
scene.play(Write(self.verifier_label))

self.new_subsection(scene, "committing", "data/sound/e4/slide2-1.mp3")
scene.wait(2)
scene.play(FadeIn(self.person1), run_time=0.5)
scene.play(FadeIn(self.person2), run_time=0.5)
scene.play(FadeIn(self.person3), run_time=0.5)
scene.play(FadeIn(self.person4), run_time=0.5)
scene.play(FadeIn(self.tau), run_time=0.5)
scene.wait(4)
scene.play(TransformMatchingShapes(self.tau, self.tau_encrypted))

self.trusted_setup = Group(self.person1, self.person2, self.person3, self.person4, self.tau_encrypted)
self.trusted_setup.generate_target()
self.trusted_setup.target.to_edge(UP+RIGHT).scale(0.4)
scene.wait(2)
scene.play(MoveToTarget(self.trusted_setup))
scene.play(AddTextLetterByLetter(self.message), run_time=2.5)

self.new_subsection(scene, "what is commitment", "data/sound/e4/slide2-3.mp3")
scene.wait(1.5)
scene.play(Write(self.commitment))
scene.play(ReplacementTransform(self.message, self.commitment))
scene.wait(1.5)
scene.play(Indicate(self.commitment[1], color = PRIMARY_COLOR))
scene.wait(1.5)
Expand All @@ -87,24 +72,26 @@ def animate_in(self, scene):
scene.play(MoveToTarget(self.commiter), MoveToTarget(self.commiter_label), MoveToTarget(self.verifier), MoveToTarget(self.verifier_label))
scene.wait(1.5)
self.commitment.generate_target()
self.commitment.target.shift(UP*1.5)
self.commitment.target.shift(UP*2)
scene.play(MoveToTarget(self.commitment))

self.chart.next_to(self.commitment, DOWN)
self.chart.next_to(self.commitment, DOWN).shift(DOWN)

scene.play(Write(self.chart), Write(create_arrow(self.commitment, self.chart)))
scene.wait(2)
scene.play(Indicate(self.commitment[1], color = PRIMARY_COLOR))
scene.wait(1)
scene.play(Indicate(self.trusted_setup))

self.new_subsection(scene, "opening", "data/sound/e4/slide2-5.mp3")
scene.wait(1.5)
scene.play(Create(self.p.dot))
scene.play(Write(self.p.label))

self.new_subsection(scene, "kzg", "data/sound/e4/slide2-6.mp3")
scene.wait(5)

def animate_out(self, scene):
scene.play(FadeOut(self.trusted_setup, self.commiter, self.verifier, self.commiter_label, self.verifier_label, self.commitment))
scene.play(FadeOut(self.commiter, self.verifier, self.commiter_label, self.verifier_label, self.commitment))

def create_arrow(start, end):
return Arrow(
Expand Down
10 changes: 5 additions & 5 deletions zkmarek/video/slides/e4/e3_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ def create_arrow(self):
def animate_in(self, scene):
self.new_subsection(scene, "Intro", sound="data/sound/e4/slide0-1.mp3")
self.create_arrow()
self.slide = Ceremony()
self.slide.construct()
self.slide2 = Polynomial()
self.slide2.construct()

scene.play(MoveToTarget(self.label, rate_func=rate_functions.ease_out_bounce, run_time=1),
MoveToTarget(self.arrow, rate_func=rate_functions.ease_out_bounce, run_time=1))
scene.play(ApplyWave(VGroup(self.label, self.arrow)), run_time=2)
self.slide = Ceremony()
self.slide.construct()

self.new_subsection(scene, "to recap", "data/sound/e4/slide0-2.mp3")
scene.play(FadeOut(self.arrow, self.label))
self.slide.animate_miniature(scene)

self.new_subsection(scene, "polynomial", "data/sound/e4/slide0-3.mp3")
scene.play(FadeOut(self.slide))
self.slide2 = Polynomial()
self.slide2.construct()
scene.wait(0.5)
self.slide2.animate_miniature(scene)

Expand Down
32 changes: 21 additions & 11 deletions zkmarek/video/slides/e4/polynomials.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def construct(self):
self.x = MathTex(r"x", color = SECONDARY_COLOR).next_to(self.title_label, DOWN)
self.polynomial_eqn1 = MathTex(r"P(x) = x", color = SECONDARY_COLOR)
self.polynomial_eqn = MathTex(r"P(x) = {{a_n}} \cdot {{x^n}} + {{a_{n-1} }}\cdot {{x^{n-1} }} + \cdots + {{a_1}} \cdot {{x}} + {{a_0}}", color = SECONDARY_COLOR)
self.polynomial_eqn3 = MathTex(r"P(x) = {{a_2}} \cdot {{x^2}} + {{a_{1} }}\cdot {{x }} + {{a_0}}", color = SECONDARY_COLOR)
self.polynomial_eqn2 = MathTex(r"P(x) = {{x}}^n + {{x}}^{n-1} + \cdots + {{x}}", color = SECONDARY_COLOR)
self.polynomial = MathTex(r"P(x) = 2 x^2 + 3x - 2", color = SECONDARY_COLOR).to_edge(DOWN)
self.polynomial2 = MathTex(r"P(x) = 2 x^2 + 3x - 2 = (2x-1)(x+2)", color = SECONDARY_COLOR).to_edge(DOWN)
Expand Down Expand Up @@ -44,6 +45,9 @@ def construct(self):
self.p25 = ValueTracker(-2)
a25 = Curve.from_x(self.p25.get_value())
self.root1 = DotOnCurve(self.chart.ax, "(-2,0)", a25)
self.p05 = ValueTracker(0.5)
a05 = Curve.from_x(self.p05.get_value())
self.root2 = DotOnCurve(self.chart.ax, "(0.5,0)", a05)

self.point = []
self.N = 30 # n/o of points
Expand Down Expand Up @@ -90,12 +94,12 @@ def animate_in(self, scene):
scene.wait(1)
scene.play(Create(self.chart.ax), run_time=2)
scene.wait(1.5)
scene.play(Create(self.p1.dot))
scene.play(Write(self.p1.label))
scene.play(Create(self.p2.dot))
scene.play(Write(self.p2.label))
scene.play(Create(self.p3.dot))
scene.play(Write(self.p3.label))
scene.play(Create(self.p1.dot), run_time=0.5)
scene.play(Write(self.p1.label), run_time=0.7)
scene.play(Create(self.p2.dot), run_time=0.5)
scene.play(Write(self.p2.label), run_time=0.7)
scene.play(Create(self.p3.dot), run_time=0.5)
scene.play(Write(self.p3.label), run_time=0.7)
scene.play(Indicate(self.polynomial_eqn, color = PRIMARY_COLOR))
scene.wait(1)
scene.play(TransformMatchingShapes(self.p1.label.copy(), self.poly_point1))
Expand All @@ -104,12 +108,17 @@ def animate_in(self, scene):

self.new_subsection(scene, "interpolation", "data/sound/e4/slide1-3.mp3")
scene.play(Write(self.chart.graph))
scene.wait(3)
scene.wait(2)
scene.play(Indicate(self.polynomial_eqn[1], color = HIGHLIGHT_COLOR), Indicate(self.polynomial_eqn[5], color = HIGHLIGHT_COLOR), Indicate(self.polynomial_eqn[9], color = HIGHLIGHT_COLOR), Indicate(self.polynomial_eqn[13], color = HIGHLIGHT_COLOR), run_time=0.5)

for i in range(self.N):
point = self.point[i]
scene.play(Create(point.dot), run_time=0.05)
scene.wait(2)
scene.play(TransformMatchingShapes(self.polynomial_eqn, self.polynomial))

scene.wait(1)
scene.play(TransformMatchingShapes(self.polynomial_eqn, self.polynomial_eqn3))
scene.wait(1.5)
scene.play(TransformMatchingShapes(self.polynomial_eqn3, self.polynomial))
scene.wait(1)
for i in range(self.N):
point = self.point[i]
Expand All @@ -119,8 +128,9 @@ def animate_in(self, scene):
scene.wait(2)
scene.play(Indicate(self.p1.dot))
self.root1.label.shift(UP*0.2)
scene.play(Create(self.root1))
scene.play(Indicate(self.root1))
self.root2.label.shift(DOWN*0.2)
scene.play(Create(self.root1), Create(self.root2))
scene.play(Indicate(self.root1, color = SECONDARY_COLOR), Indicate(self.root2, color = SECONDARY_COLOR))
scene.play(TransformMatchingShapes(self.polynomial, self.polynomial2))
scene.wait(4)

Expand Down
2 changes: 1 addition & 1 deletion zkmarek/video/slides/episode3/ceremony.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def animate_miniature(self, scene):
scene.play(Indicate(self.vector_0.cells[0][1][2], color = HIGHLIGHT_COLOR), Indicate(self.vector_1.cells[0][1][2], color = HIGHLIGHT_COLOR), Indicate(self.vector_k.cells[0][1][2], color = HIGHLIGHT_COLOR))

scene.wait(2)
scene.play(FadeOut(self.vector_0, self.vector_1, self.vector_k, self.person, self.person2, self.person3, self.tau_0, self.tau_1, self.tau_k))
scene.play(FadeOut(self.vector_0, self.vector_1, self.vector_k, self.person, self.person2, self.person3, self.tau_0, self.tau_1, self.tau_k, self.three_dot))

def animate_out(self, scene):
scene.play(FadeOut(self.person, self.person2, self.person3, self.tau_0, self.tau_1, self.tau_k, self.title_label, self.three_dot, self.vector_0, self.vector_1, self.vector_k, self.tau))
12 changes: 5 additions & 7 deletions zkmarek/video/slides/episode3/polynomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,15 @@ def animate_miniature(self, scene):
rectangle = Rectangle(color=PRIMARY_COLOR, width=15, height=8)
text = Text("Evaluating a polynomial", color=SECONDARY_COLOR,
font=PRIMARY_FONT, font_size=50).scale(0.65)
self.add(rectangle, self.polynomial, self.polynomial_G, self.vector, self.chart, self.polynomial_tau0, self.tau, self.p1.dot)
self.add(rectangle, self.polynomial, self.polynomial_G, self.vector, self.polynomial_tau0, self.tau, self.p1.dot)
self.scale(0.65)
text.next_to(rectangle, DOWN, buff=0.4)
scene.play(FadeIn(text, rectangle, self.polynomial, self.vector))
self.add(text)
scene.wait(2)
scene.play(TransformMatchingShapes(self.polynomial, self.polynomial_G))
scene.wait(1.5)
scene.wait(2)
scene.play(TransformMatchingShapes(VGroup(self.vector[0][1].copy(), self.vector[1][1].copy(), self.polynomial_G), self.polynomial_tau0))
self.polynomial_tau0.generate_target()
self.polynomial_tau0.target.to_edge(DOWN).shift(UP)
scene.play(FadeIn(self.chart), MoveToTarget(self.polynomial_tau0))
scene.play(Create(self.p1.dot))
scene.play(Write(self.tau))

scene.wait(2)
scene.play(FadeOut(self.polynomial_tau0, self.vector, text, rectangle))
23 changes: 11 additions & 12 deletions zkmarek/video/slides/episode4/KZG.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
FadeIn,
FadeOut,
MathTex,
TransformMatchingTex,
VGroup,
TransformMatchingShapes,
Group,
ReplacementTransform,
Indicate
)
Expand Down Expand Up @@ -46,7 +46,7 @@ def construct(self):
color=PRIMARY_COLOR,
)
self.verification2 = MathTex(
r"e( q(\tau)\cdot G_1, (\tau-z) \cdot G_2) ) = e(P(\tau\cdot G_1) - y \cdot G_1, G_2)",
r"e( {{q(\tau)\cdot G_1}}, (\tau-z) \cdot G_2) ) = e({{P(\tau)\cdot G_1}} - y \cdot G_1, G_2)",
color=PRIMARY_COLOR,
).to_edge(DOWN)
self.verification3 = MathTex(
Expand Down Expand Up @@ -100,8 +100,11 @@ def animate_in(self, scene):
self.new_subsection(scene, "what is quotient", "data/sound/e4/slide3-2.mp3")
scene.play(Indicate(self.equation))
scene.wait(4)
scene.play(Indicate(self.equation[4], color = SECONDARY_COLOR))
scene.play(Indicate(self.equation[6], color = SECONDARY_COLOR))
scene.play(Indicate(self.equation[8], color = SECONDARY_COLOR))
scene.wait(2)
scene.play(Indicate(self.equation[2], color = SECONDARY_COLOR))
scene.play(Indicate(self.equation[4], color = SECONDARY_COLOR))

self.chart.animate_shift_dots(scene, self.y.value)
self.chart.animate_shift_dots_wrap_fix(scene, self.y.value)
Expand Down Expand Up @@ -136,15 +139,11 @@ def animate_in(self, scene):
self.new_subsection(scene, "definitions of C and PI", "data/sound/e4/slide3-7.mp3")
scene.wait(4)
scene.play(
TransformMatchingTex(
VGroup(self.verification, self.proof.copy()), self.verification2
)
TransformMatchingShapes(
Group(self.verification[1].copy(), self.proof.copy(), self.verification[7].copy(), self.commitment.copy(), self.verification), self.verification2
), run_time=2
)

self.new_subsection(scene, "bilinear", "data/sound/e4/slide3-8.mp3")
scene.play(
TransformMatchingTex(
VGroup(self.verification2, self.commitment.copy()), self.verification3
)
)
scene.wait(2.5)
scene.play(ReplacementTransform(self.verification3, self.verification4))

0 comments on commit a48b52d

Please sign in to comment.