Skip to content

Commit

Permalink
first draft of envelope opening etc
Browse files Browse the repository at this point in the history
  • Loading branch information
martawleklinska committed Aug 21, 2024
1 parent 9d3bb79 commit 709eca8
Showing 1 changed file with 72 additions and 33 deletions.
105 changes: 72 additions & 33 deletions zkmarek/video/slides/e4/poly_commitment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from manim import LEFT, RIGHT, FadeIn, ImageMobject, Text, DOWN, UP, Write, MathTex, FadeOut, Indicate, ValueTracker, Create, TransformMatchingShapes, Unwrite, MoveToTarget, Group, Tex, Polygon, VGroup, Transform
from manim import LEFT, RIGHT, FadeIn, ImageMobject, Text, DOWN, UP, Write, MathTex, FadeOut, Indicate, ValueTracker, Create, TransformMatchingShapes, MoveToTarget, Group, Tex, Polygon, VGroup, Transform

from zkmarek.video.utils import load
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,9 +23,9 @@ def construct(self):

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

self.chart = Chart(include_details=True).scale(0.5).next_to(self.commiter, LEFT).shift(UP*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).shift(DOWN*0.8)
self.chart = Chart(include_details=True).scale(0.5).next_to(self.commiter, LEFT).shift(UP*1.3)
self.commitment = MathTex(r"C = p({{\tau}}) \cdot {{G_1}}", color = SECONDARY_COLOR).next_to(self.commiter, LEFT+DOWN, buff = 0.4).shift(UP)
self.commitment_copy = MathTex(r"C = p({{\tau}}) \cdot {{G_1}}", color = SECONDARY_COLOR).next_to(self.commiter, RIGHT, buff = 0.4).shift(UP)

self.point = ValueTracker(-1.849)
a = Curve.from_x(self.point.get_value())
Expand All @@ -40,17 +41,16 @@ def construct(self):
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).shift(RIGHT*1.5)

self.opening = MathTex(r"p(z) = y", color = SECONDARY_COLOR).shift(2*UP)
self.lock = ImageMobject("data/images/Locked@2x.png").scale(0.25).next_to(self.commitment, RIGHT, buff = 0.1)
self.tex = Tex(load("zkmarek/video/slides/e4/properties.tex"), color=SECONDARY_COLOR)
self.envelope_body_closed = Polygon(
[-3, -1, 0], [3, -1, 0], [3, 1, 0], [-3, 1, 0],
fill_color=PRIMARY_COLOR, fill_opacity=0.5
)
).scale(0.6)

self.envelope_flap_closed = Polygon(
[-3, 1, 0], [3, 1, 0], [0, -0.6, 0],
fill_color=HIGHLIGHT_COLOR, fill_opacity=0.5
)
).scale(0.6)

self.outline_closed = VGroup(
self.envelope_body_closed.copy().set_fill(opacity=0.2),
Expand All @@ -59,84 +59,123 @@ def construct(self):
self.envelope_body = Polygon(
[-3, -1, 0], [3, -1, 0], [3, 1, 0], [-3, 1, 0],
fill_color=PRIMARY_COLOR, fill_opacity=0.5
)
).scale(0.6)
self.envelope_flap = Polygon(
[-3, 1, 0], [3, 1, 0], [0, 3, 0],
fill_color=HIGHLIGHT_COLOR, fill_opacity=0.5
)
).scale(0.6)

self.outline = VGroup(
self.envelope_body.copy().set_fill(opacity=0.2),
self.envelope_flap.copy().set_fill(opacity=0.2)
)
self.envelope_body.next_to(self.commiter, LEFT)
self.envelope_body_closed.next_to(self.commiter, LEFT)
self.outline.next_to(self.commiter, LEFT)
self.outline_closed.next_to(self.commiter, LEFT)
self.envelope_flap.next_to(self.envelope_body, UP, buff= 0)
self.envelope_flap_closed.next_to(self.envelope_body_closed, UP, buff = -1)
self.message.next_to(self.commiter, RIGHT, buff = 0.1)
self.lock = ImageMobject("data/images/Locked@2x.png").scale(0.25).next_to(self.message, RIGHT, buff = 0.1)

def animate_in(self, scene):
self.new_subsection(scene, "envelope", "data/sound/e4/slide2-1.mp3")
scene.play(Write(self.title))
scene.play(FadeIn(self.commiter))
scene.play(Write(self.commiter_label))

scene.play(FadeIn(self.envelope_body_closed, self.envelope_flap_closed, self.outline_closed))
scene.wait(1.5)
scene.play(FadeIn(self.envelope_body_closed, self.envelope_flap_closed))
scene.wait(2)
scene.play(FadeIn(self.lock))
scene.play(Transform(VGroup(self.envelope_body_closed, self.envelope_flap_closed, self.outline_closed) ,VGroup(self.envelope_body, self.envelope_flap, self.outline)))
secret_message = Group(self.lock, self.message)
secret_message.generate_target()
secret_message.target.next_to(self.commiter, LEFT)
scene.play(MoveToTarget(secret_message))
scene.play(Transform(self.envelope_flap_closed, self.envelope_flap))
scene.play(FadeOut(secret_message))
scene.wait(1)
scene.play(Transform(VGroup(self.envelope_body, self.envelope_flap), VGroup(self.envelope_body_closed, self.envelope_flap_closed)))

self.tex.scale(0.8).next_to(self.commiter, RIGHT, buff = 1)
scene.play(Write(self.tex))

self.new_subsection(scene, "hiding", "data/sound/e4/slide2-1a.mp3")
scene.wait(0.2)
scene.wait(0.7)
scene.play(Indicate(self.tex[0][1:7], color = HIGHLIGHT_COLOR))
scene.wait(2)

self.new_subsection(scene, "binding", "data/sound/e4/slide2-1b.mp3")
scene.wait(1.2)
scene.play(Indicate(self.tex[0][8:15], color = HIGHLIGHT_COLOR))
scene.wait(4)
scene.play(Indicate(self.lock, color = HIGHLIGHT_COLOR))
scene.wait(3)

self.new_subsection(scene, "polynomial commitments", "data/sound/e4/slide2-2.mp3")
scene.play(FadeOut(self.envelope_body_closed, self.envelope_flap_closed), FadeOut(self.tex))
scene.play(Write(self.chart.ax), Write(self.chart.graph), Write(self.chart.labels))
scene.wait(1)

self.new_subsection(scene, "committer creates a commitment", "data/sound/e4/slide2-3.mp3")
scene.play(FadeIn(self.verifier))
scene.play(Write(self.verifier_label))
scene.wait(1)
scene.play(Indicate(self.chart.graph, color = HIGHLIGHT_COLOR))

scene.play(Indicate(self.chart.graph, color = HIGHLIGHT_COLOR))
self.outline.next_to(self.commiter, LEFT+DOWN)
self.outline_closed.next_to(self.commiter, LEFT+DOWN)
self.envelope_body.next_to(self.commiter, LEFT+DOWN)
self.envelope_body_closed.next_to(self.commiter, LEFT+DOWN)
self.envelope_flap.next_to(self.commiter, LEFT+DOWN)
self.envelope_flap_closed.next_to(self.commiter, LEFT+DOWN)
scene.wait(2)
scene.play(FadeIn(self.envelope_body, self.envelope_flap))
scene.wait(1)
scene.play(Write(self.commitment))
scene.wait(1.5)
scene.play(Indicate(self.commitment[1], color = HIGHLIGHT_COLOR))
scene.play(Create(self.p_tau))
scene.wait(1.5)
scene.play(Indicate(self.commitment[3], color = HIGHLIGHT_COLOR))
self.images = Group(self.commiter, self.commiter_label, self.verifier, self.verifier_label)
self.images.generate_target()
self.images.target.shift(UP*1.5)
scene.play(MoveToTarget(self.images), run_time=2)
scene.play(FadeIn(self.trusted_setup))
scene.play(TransformMatchingShapes(self.trusted_setup, self.trusted_setup1))
scene.wait(2)
scene.wait(1)
scene.play(TransformMatchingShapes(self.trusted_setup1, self.trusted_setup2))
scene.wait(1.5)
scene.wait(1)
scene.play(Indicate(self.trusted_setup2[3], color = HIGHLIGHT_COLOR))
scene.wait(1.5)
scene.wait(1)
scene.play(Indicate(self.trusted_setup2[1], color = HIGHLIGHT_COLOR))
self.new_subsection(scene, "committer creates a commitment", "data/sound/e4/slide2-3.mp3")

scene.play(Create(self.p_tau))
scene.wait(2)
scene.play(Indicate(self.p_tau[1], color = HIGHLIGHT_COLOR))
scene.play(Create(self.commitment))
scene.wait(1)
scene.play(FadeOut(self.trusted_setup2))
self.images.generate_target()
self.images.target.shift(DOWN*1.5)
scene.play(MoveToTarget(self.images), run_time=2)

self.new_subsection(scene, "commitment is sent", "data/sound/e4/slide2-4.mp3")
scene.play(TransformMatchingShapes(self.commitment.copy(), self.commitment_copy))
self.commitment_copy.generate_target()
self.commitment_copy.target.next_to(self.commiter, LEFT+DOWN, buff = 0.4)
scene.play(MoveToTarget(self.commitment_copy))
scene.play(Transform(self.envelope_flap, self.envelope_flap_closed))

commitment_sent = VGroup(self.commitment_copy, self.envelope_body_closed, self.envelope_flap_closed, self.outline_closed)
commitment_sent.generate_target()
commitment_sent.target.next_to(self.verifier, RIGHT)
scene.play(MoveToTarget(commitment_sent))

self.new_subsection(scene, "validate the commitment", "data/sound/e4/slide2-5.mp3")

self.new_subsection(scene, "open the commitment", "data/sound/e4/slide2-6.mp3")
scene.play(Transform(self.envelope_flap_closed, self.envelope_flap))
self.commitment_copy.generate_target()
self.commitment_copy.target.shift(UP*1.5)
scene.play(MoveToTarget(self.commitment_copy))

self.new_subsection(scene, "opening", "data/sound/e4/slide3-7.mp3")
scene.play(Create(self.p.dot))
scene.play(Write(self.p.label))
scene.play(FadeOut(self.commitment, self.trusted_setup2))

self.images.generate_target()
self.images.target.shift(DOWN*1.5)
scene.play(MoveToTarget(self.images), run_time=2)
scene.play(TransformMatchingShapes(self.p.label.copy(), self.opening))
scene.play(FadeOut(commitment_sent))


self.new_subsection(scene, "committer proves that he knows the polynomial", "data/sound/e4/slide2-7.mp3")

Expand Down

0 comments on commit 709eca8

Please sign in to comment.