Skip to content

Commit

Permalink
added discrete elliptic chart
Browse files Browse the repository at this point in the history
  • Loading branch information
martawleklinska committed Aug 17, 2024
1 parent d1c4216 commit a3b7d77
Show file tree
Hide file tree
Showing 34 changed files with 119 additions and 105 deletions.
Binary file modified data/sound/e4/slide2-0.mp3
Binary file not shown.
Binary file modified data/sound/e4/slide2-1.mp3
Binary file not shown.
Binary file modified data/sound/e4/slide2-2.mp3
Binary file not shown.
Binary file modified data/sound/e4/slide2-3.mp3
Binary file not shown.
Binary file modified data/sound/e4/slide3-0.mp3
Binary file not shown.
Binary file modified data/sound/e4/slide3-1.mp3
Binary file not shown.
Binary file modified data/sound/e4/slide3-2.mp3
Binary file not shown.
Binary file modified data/sound/e4/slide3-3.mp3
Binary file not shown.
Binary file modified data/sound/e4/slide3-4.mp3
Binary file not shown.
Binary file modified data/sound/e4/slide3-5.mp3
Binary file not shown.
Binary file removed data/sound/e4/slide3-6.mp3
Binary file not shown.
Binary file removed data/sound/e4/slide3-7.mp3
Binary file not shown.
Binary file modified data/sound/e4/slide4-0.mp3
Binary file not shown.
Binary file modified data/sound/e4/slide4-1.mp3
Binary file not shown.
Binary file modified data/sound/e4/slide4-2.mp3
Binary file not shown.
Binary file modified data/sound/e4/slide4-3.mp3
Binary file not shown.
Binary file modified data/sound/e4/slide4-4.mp3
Binary file not shown.
Binary file modified data/sound/e4/slide4-5.mp3
Binary file not shown.
Binary file modified data/sound/e4/slide4-6.mp3
Binary file not shown.
Binary file modified data/sound/e4/slide4-7.mp3
Binary file not shown.
File renamed without changes.
File renamed without changes.
Binary file added data/sound/e4/slide5-0.mp3
Binary file not shown.
Binary file added data/sound/e4/slide5-1.mp3
Binary file not shown.
Binary file added data/sound/e4/slide5-2.mp3
Binary file not shown.
Binary file added data/sound/e4/slide5-3.mp3
Binary file not shown.
Binary file added data/sound/e4/slide5-4.mp3
Binary file not shown.
Binary file added data/sound/e4/slide5-5.mp3
Binary file not shown.
Binary file added data/sound/e4/slide5-6.mp3
Binary file not shown.
Binary file added data/sound/e4/slide5-7.mp3
Binary file not shown.
7 changes: 3 additions & 4 deletions zkmarek/video/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
# from zkmarek.video.slides.episode4.PCS import PolynomialCommitment
# 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.poly_commitment import PolynomialCommitment
from zkmarek.video.slides.e4.e3_reference import Episode3Reference


Expand Down Expand Up @@ -173,9 +173,8 @@
Episode3Reference(),
TitleSlide("Polynomials", sound="data/sound/e4/slide0-4.mp3", wait_time=5),
Polynomials(),
TitleSlide("Commitments", wait_time=1.5),
Commitment(),
# PolynomialCommitment(),
TitleSlide("Commitments", sound="data/sound/e4/slide2-0.mp3", wait_time=1.5),
PolynomialCommitment(),
Proof1(),
Proof2(),
# Verkle(),
Expand Down
105 changes: 9 additions & 96 deletions zkmarek/video/slides/e4/commitment.py
Original file line number Diff line number Diff line change
@@ -1,106 +1,19 @@
from manim import LEFT, RIGHT, FadeIn, ImageMobject, Text, DOWN, UP, Write, MathTex, Brace, MoveToTarget, FadeOut, Indicate, Arrow, AddTextLetterByLetter, ReplacementTransform, ValueTracker, Create, TransformMatchingShapes
from manim import Create, Rectangle

from zkmarek.video.constant import SECONDARY_COLOR, PRIMARY_FONT, PRIMARY_COLOR
from zkmarek.video.constant import 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

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

def construct(self):
self.title = Text("Commitment", color = PRIMARY_COLOR, font = PRIMARY_FONT, font_size=80).to_edge(UP)
self.verifier = ImageMobject("data/images/person.png").shift(RIGHT*3)
self.commiter = ImageMobject("data/images/person_blue.png").shift(LEFT*3)

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)

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).shift(DOWN*0.4)

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

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.opening = MathTex(r"p(z) = y", color = SECONDARY_COLOR).shift(2*UP)

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

def animate_in(self, scene):
self.new_subsection(scene, "intro", "data/sound/e4/slide2-0.mp3")
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(AddTextLetterByLetter(self.message), run_time=2.5)

self.new_subsection(scene, "what is commitment", "data/sound/e4/slide2-2.mp3")
# scene.wait(1.5)
scene.play(ReplacementTransform(self.message, self.commitment))
scene.wait(1.5)
scene.play(Indicate(self.commitment[1], color = PRIMARY_COLOR))
scene.play(Indicate(self.commitment[3], color = PRIMARY_COLOR))



self.new_subsection(scene, "what is verifiers job", "data/sound/e4/slide2-3.mp3")
self.commiter.generate_target()
self.commiter.target.to_edge(LEFT)
self.rectangle = Rectangle(height=3, width=5, color = PRIMARY_COLOR)

self.verifier.generate_target()
self.verifier.target.to_edge(RIGHT)

self.commiter_label.generate_target()
self.commiter_label.target.to_edge(LEFT)

self.verifier_label.generate_target()
self.verifier_label.target.to_edge(RIGHT)

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*2)
scene.play(MoveToTarget(self.commitment))

self.arrow = Arrow(start=self.polynomial.get_top(), end=self.chart.graph.get_bottom(), color =PRIMARY_COLOR)
scene.play(Write(self.chart.ax), Write(self.chart.graph), Write(self.chart.labels))
scene.wait(2)
scene.play(Indicate(self.commitment[1], color = PRIMARY_COLOR))
scene.wait(1)
scene.play(Create(self.p_tau))

self.new_subsection(scene, "opening", "data/sound/e4/slide2-4.mp3")
scene.wait(1.5)

scene.play(Create(self.p.dot))
scene.play(Write(self.p.label))
scene.play(FadeOut(self.commitment))
scene.wait(2)
scene.play(TransformMatchingShapes(self.p.label.copy(), self.opening))

self.new_subsection(scene, "kzg", "data/sound/e4/slide2-5.mp3")
scene.play(Write(self.polynomial))
scene.play(Write(self.arrow))
scene.wait(5.5)

def animate_out(self, scene):
scene.play(FadeOut(self.commiter, self.verifier, self.commiter_label, self.verifier_label, self.opening, self.chart))
def animate_in(self, scene):
self.new_subsection(scene, "envelope", "data/sound/e4/slide2-1.mp3")
scene.play(Create(self.rectangle))

self.new_subsection(scene, "another party", "data/sound/e4/slide2-3.mp3")
104 changes: 104 additions & 0 deletions zkmarek/video/slides/e4/poly_commitment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
from manim import LEFT, RIGHT, FadeIn, ImageMobject, Text, DOWN, UP, Write, MathTex, Brace, MoveToTarget, FadeOut, Indicate, Arrow, AddTextLetterByLetter, ReplacementTransform, ValueTracker, Create, TransformMatchingShapes

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 PolynomialCommitment(SlideBase):
chart: Chart

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

def construct(self):
self.title = Text("Commitment", color = PRIMARY_COLOR, font = PRIMARY_FONT, font_size=80).to_edge(UP)
self.verifier = ImageMobject("data/images/person.png").shift(RIGHT*3)
self.commiter = ImageMobject("data/images/person_blue.png").shift(LEFT*3)

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)

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).next_to(self.chart, UP, buff = 0.2)
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.8).to_edge(LEFT)

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

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.opening = MathTex(r"p(z) = y", color = SECONDARY_COLOR).shift(2*UP)

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

def animate_in(self, scene):
self.new_subsection(scene, "intro", "data/sound/e4/slide3-1.mp3")
scene.wait(1.5)
scene.play(FadeIn(self.commiter))
scene.play(Write(self.commiter_label))
scene.play(Write(self.chart.ax), Write(self.chart.graph), Write(self.chart.labels))
scene.wait(2)
scene.play(FadeIn(self.verifier))
scene.wait(0.5)
scene.play(Write(self.verifier_label))

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


self.new_subsection(scene, "what is commitment", "data/sound/e4/slide3-3.mp3")
scene.wait(1.5)
scene.play(Indicate(self.commitment[1], color = PRIMARY_COLOR))
scene.play(Indicate(self.commitment[3], color = PRIMARY_COLOR))



self.new_subsection(scene, "what is verifiers job", "data/sound/e4/slide3-4.mp3")
self.commiter.generate_target()
self.commiter.target.to_edge(LEFT)

self.verifier.generate_target()
self.verifier.target.to_edge(RIGHT)

self.commiter_label.generate_target()
self.commiter_label.target.to_edge(LEFT)

self.verifier_label.generate_target()
self.verifier_label.target.to_edge(RIGHT)

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*2)
scene.play(MoveToTarget(self.commitment))

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

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

self.new_subsection(scene, "opening", "data/sound/e4/slide3-5.mp3")
scene.wait(1.5)

scene.play(Create(self.p.dot))
scene.play(Write(self.p.label))
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))
scene.wait(5.5)

def animate_out(self, scene):
scene.play(FadeOut(self.commiter, self.verifier, self.commiter_label, self.verifier_label, self.opening, self.chart))

8 changes: 3 additions & 5 deletions zkmarek/video/slides/e4/polynomials.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from zkmarek.video.slides.episode4.discreete_polynomial_chart import DiscreetePolynomialChart
from zkmarek.crypto.field_element import FieldElement
def poly(x):
return 4 * x ** 3 - 8 * x **2 + 17 * x + 30
return 4 * x * x * x - 8 * x * x - 17 * x + 30

class Polynomials(SlideBase):

Expand Down Expand Up @@ -57,11 +57,11 @@ def construct(self):

self.p3_23 = ValueTracker(3)
a3_23 = Curve.from_x(self.p3_23.get_value())
self.p3 = DotOnCurve(self.chart.ax, "(3,-12)", a3_23)
self.p3 = DotOnCurve(self.chart.ax, "(3, 15)", a3_23)

self.poly_point1 = MathTex("P(1) = 9", color = PRIMARY_COLOR).to_edge(RIGHT)
self.poly_point2 = MathTex("P(2) = -4", color = PRIMARY_COLOR).next_to(self.poly_point1, DOWN)
self.poly_point3 = MathTex("P(3) = -12", color = PRIMARY_COLOR).next_to(self.poly_point2, DOWN)
self.poly_point3 = MathTex("P(3) = 15", color = PRIMARY_COLOR).next_to(self.poly_point2, DOWN)

self.p25 = ValueTracker(-2)
a25 = Curve.from_x(self.p25.get_value())
Expand All @@ -86,7 +86,6 @@ def construct(self):
points = ValueTracker(point_value)
a = Curve.from_x(points.get_value())
self.point.append(DotOnCurve(self.chart.ax, "", a))
self.z = FieldElement(1, 5)


def animate_in(self, scene):
Expand Down Expand Up @@ -210,7 +209,6 @@ def animate_in(self, scene):
self.new_subsection(scene, "finite fields", "data/sound/e4/slide1-6.mp3")
self.chart1.gen_points()
scene.play(FadeIn(self.chart))
self.chart1.add_xaxis_label(self.z.value, r"z")

self.new_subsection(scene, "example of finite field", "data/sound/e4/slide1-7.mp3")

Expand Down

0 comments on commit a3b7d77

Please sign in to comment.