It's not going to get used.
It's not going to get used.
It's not going to get used.
It's not going to get used.
It's not going to get used.
It's not going to get used.
It's not going to get used.
It's not going to get used.
Hey everybody and welcome to Chapter 2 of Programming Bitcoin.
So while we're waiting for our co-host Portland Hoddle to join, make sure that you get everything
ready for today's lesson.
So you're going to have your book open and your Jupiter notebook running and you're also
going to have Portland slides open as well that he made for us for today and those are up
And I have added him as a co-host.
Please accept the co-host position.
I heard we're talking about elliptical curves today.
We are elliptical curves baby.
That reminds me of that, what is that cardio machine that used to be really popular?
I don't know if people still do that.
I always think of that elliptical machine thing whenever people talk about elliptical
At the gym, you know, it's like next to the cardio and it was popular for a while.
So yeah, we're talking about elliptic curve, not cryptography, but we're talking about building
blocks that we will use to build elliptic curve cryptography.
So next week we're going to talk about cryptography, but this week we're just talking
So I definitely had to brush up on a lot of math that I have not used since high school
Like I haven't really thought about derivatives or calculus or any of this in a very, very,
When was the last time that you used derivatives?
Last time I used derivatives, I like actually went through and like did your d over dx style
I mean, for me it hasn't, for me it hasn't been since college.
It's been since college as well.
I'm pretty sure like I've done derivatives implicitly in code before, like, oh, the rate
of change of this, but I haven't actually sat down and like done the equation other
than sometimes we'll have Wolfram alpha or another service do it for me, which I'm
sorry to say, yeah, I can still do them.
And the nice part was doing this chapter, the actually a lot of it seemed to come back
And then also if Jimmy Song mentions in chapter two that you don't actually have to know
the calculus or derivatives to do this stuff.
And the reason why is because he doesn't that kind of an interesting way.
He actually gives you the solution to the entire equation first and then he'll go
into the proof afterwards.
So you can he'll show you like, OK, this is how to get the slope at this point.
And he'll just like literally give you the derived formula for that.
And that's really nice because that means you can just put it right into code without
having to do that higher level mathematics.
But at the same time, he does go through down below that section and he literally goes
through the entire proof of how you get the slope and how you kind of find that
third point on the curve.
Yeah, so I think for me, like.
I've been studying this topic for a while and I already knew about elliptic curves and how
to do point addition, but there are a few things that I never really understood until
I went through this chapter.
And so one of the things I never understood was why you flip the result over the
freaking y axis, the flipping.
I just always thought, OK, we do this thing.
No earthly idea why I just got to accept it as a fact of life.
And now I understand the flipping and I'm so happy, so, so, so happy.
So let's just kind of go over just a very brief overview of what we're going to be
talking about today, elliptic curves.
So elliptic curves are curves that follow the equation y squared equals x cubed plus
a x plus b where a and b are constants.
Now, in the case of Bitcoin, those constants are going to be zero and seven
respectively. So we're going to talk about elliptic curves.
We can plot points onto the curve.
But what we actually want to do today is define math operations on points on this
curve. And so what I said last week when we talked about finite fields and when we
defined math operators across finite fields was imagine that you just took
acid and you landed in Wonderland and up is down and down is up and left is right
It's not exactly the math that you learned as a kid.
It's not necessarily super hard math.
And so when we define addition over elliptic curves, it's not regular addition.
Like we do with regular numbers, it's point addition.
And so it's kind of like we're doing addition in Wonderland.
It's made up math that works for elliptic curves.
But again, it's just made up to work on elliptic curves.
It's not regular, real addition.
It's addition such that we have some of the properties that we're used to addition
having. And we'll talk about those, the identity property, the communitivity
property, the associativity property, the invertibility property.
But again, it's like it's like a duck, like it kind of looks like a duck.
It kind of quacks like a duck.
It kind of has duck feathers, but it's not it's not a duck that we're used to.
This duck is like it has weird technicolor feathers because we're on acid
and we're in Wonderland and the duck is ducking, but it's a weird, a weird duck.
So we're going to define addition in particular.
And addition has these kind of funny corner cases where, you know, in most cases,
you're adding two points together and we have a formula that gives us,
for all intents and purposes, that weird addition that we're trying to define.
But then there's a few exceptions, things we got to look out for that are
corner cases where we might have a few things we need to define specifically.
So that said, what I suggested to everybody for today
was that you actually go through the chapter before the lecture.
And for anyone that did that right on, like congrats to you,
because you're going to get so much more from today if you've already read the chapter.
If you haven't already read the chapter, just be sure to read it before next Sunday
when we delve into elliptic curve cryptography, which is going to be really cool.
You're going to finally see, oh, this is why we're learning all this weird math.
This is why we learned finite fields.
This is why we learned elliptic curves.
We're pulling it all together to do something really extraordinary with it.
So that said, I'm leaving these episodes up on Twitter for a limited time only.
I'm not going to let them persist, but I'm giving you like about a week or so
to review the lectures or if you can't make it for whatever reason,
if you're not in the same time zone or country as us,
you have a few days to catch up, but they're not going to be left up.
So make sure that you are as up to date as possible.
You'll have about a week or so to get caught up.
So yeah, huge like pat on the back to everybody that has gone through the chapter.
They've gone through the Jupyter Notebook.
And after we talk about elliptic curves, we're going to take questions
and be sure to ask questions.
If you have any questions with Jupyter Notebook or Git or GitHub
or any of the DevOps stuff or anything at all,
be sure to ask those questions so you don't fall behind.
So yeah, Portland, what do you think about this chapter just kind of overall?
Like would you agree that it is a weird flavor of math that is similar
but certainly not the same to what we're used to?
Yeah, so the interesting thing about the math applied in this chapter
is normally when you add points together.
For example, you have like a slope and you add these two
or so you have two points, you make a slope out of it.
You can just kind of like add things together directly.
And because you're doing math on a curve and everything has to exist on a curve,
the result must be on the curve.
Suddenly, you have to kind of skew what you define as addition, right?
And so addition no longer is just like any two points on the XY.
It's a point on this curve that is in the XY space
that satisfies the condition of the curve.
And so you kind of have to wrap your head around that.
And then what comes along with that is along with the operation of just purely addition,
Well, I don't mean this in a bad way,
but like there are a couple of corner cases that you got to deal with.
And one of them, for example, you'll see at the end,
the answer is literally just hard code it.
Like literally just make a just return the infinity.
But yeah, so you have to kind of like to make this math work in a special way,
and that's what this chapter is all about.
So yeah, it was a really excellent way to really make your mind work.
It took a second, but once I started getting into it,
I was like, all this makes perfect sense.
And the diagrams and basically graphics Jimmy Song uses,
especially there's one in the middle that shows the associative property.
And that one right there, like just watching like picture one and picture two,
like if you get anything from this chapter,
those are the two pictures, just like look at those until your brain gets it.
And once your brain gets that, boom, like the whole thing makes sense.
Because if you just follow it, like in a linear order,
you'll get to that point where Jimmy Song starts defining addition.
And he's like, okay, so you just add the two things together
and you find like the slope and it ends up at a point on the curve.
And then you just like take that thing and then you just flip it.
You just invert it along the X axis or Y axis.
And then that's just how it is.
But once you go through those diagrams, it makes it very clear
that that's exactly why you take that resultant and then you flip it.
So the flipping is probably one of the more important things
you can get out of this chapter.
So that diagram with the flipping are my own opinion, probably the big ones.
The flipping for me was the mind equals blown moment of, oh my gosh,
I love those aha moments for myself.
They're so joyful and so exciting.
So one thing I will say is that we did this weird type of math over finite fields.
We're about to do some weird math with elliptic curves,
but we're doing elliptic curves today over an infinite plane.
It stretches out to infinity in every direction.
So what's going to be fun next week is to combine finite fields and elliptic curves
to define an elliptic curve over a finite field.
So that all said, we have these equations.
We have Y squared equals X cubed plus AX plus B.
And you can pop that bad boy onto a graph and then you can plot points onto that graph.
But when you want to start doing things like add point A to point B,
how can you define point addition with elliptic curves?
So the bottom line is we want addition to have some certain properties.
Like we described, one of those properties is going to be the commutative property of
And we learned this when we were little kids where A plus B is the same as B plus A.
So we want to make sure that when we add two points,
we get the same result when we add A plus B and B plus A.
We want to make sure that we have the rule of associativity.
And what that means is when we're adding three points together, let's say A, B, and C,
we want to make sure that the order in which we add those points does not change the result.
In other words, we want A plus B plus C to have the same answer as if we were to add B
plus C plus A, whereby we added the B plus C part first.
And of course, we know with regular numbers, one plus two plus three is the same as
We want to make sure that's the same also for points on an elliptic curve.
And so in order to make all of these properties fit,
we are going to define what we call point addition across elliptic curves.
But like I said before, we're just making this up.
Some guy just made this up.
Some guy was just like, okay, there's this elliptic curve.
I'm going to define what I'm calling addition.
But you're suspending your disbelief a little bit because it's not
the regular addition that we learned when we were little kids.
We have some points on the curve.
We want to define A plus B, whereby A and B are two different points.
So let's start with the case whereby A and B are not the same points on the curve.
So how do we define point addition?
Well, we take point A and point B, and we just draw a straight line through those points.
And so this brought me back to pre-algebra.
So Portland, do you remember when we were little kids,
how we learned to find a straight line between two points?
There was a slope equation because we're finding what we're calling the slope
of the line between two points.
Do you remember learning that when you were a kid?
I have to brush up on all of this.
But when we were kids, we learned that we had two points.
And those points have coordinates, right, x, y, and then x2, y2.
So all you do is you just take those coordinates and you subtract them.
So y2 minus y1 divided by x2 minus x1, that gives you the slope of the line.
And from there, you have a straight line.
And you find where that straight line intersects in a third point on the elliptic curve.
So that's going to give you a third point.
Now, here's where it gets even stranger.
You take that point, and because elliptic curves are symmetrical over the y-axis,
meaning for any one given x-coordinate, you're going to have a positive and a negative y.
So you're going to invert that third point over the y-axis.
So if the third point that intersects with the slope that you just calculated is positive,
you're going to invert it to make it negative.
If it happens to be negative, you're going to invert it to make it positive.
And for as long as I've known anything about elliptic curves, I've known this to be true,
but I just accepted it as some detail that I couldn't fully explain why was the case.
I just knew that we did it.
And today, I finally actually learned for the first time why we invert that point.
So should we talk about why we invert that point?
Well, here's why we invert that point.
The reason we invert that point is we want the commutative property of addition
and the associativity property of addition to hold true for point addition.
Now, if we didn't invert that point over the y-axis, what would happen?
A plus B plus C would not equal B plus C plus A.
Those would be two completely different points on the curve
that would have no real relation to one another.
They wouldn't be anywhere near one another at all.
So that property of associativity would have been broken.
And if we don't want that property to be broken,
we have to invert the point over the y-axis.
So what I would suggest you all do is take three points, A plus B plus C.
Go through what it would look like to add A plus B plus C
without inverting the point.
And then add B plus C plus A and see where that lands.
Just go through that exercise on your own
and see how far off those two points are.
See how they are nowhere near one another.
Now go through the same process whereby you invert the result
and see just like magic how they're the same freaking point,
which is to say that rule of associativity has not been broken.
And like Portland said, the flippening,
this has been the most exciting point for me
in my journey of understanding elliptic curves.
Oh, Portland actually is not on stage.
I've been asking him questions and he hasn't been responding
and that would explain why he's not responding.
So Portland, I requested you to come back up and co-host.
Hey, Portland, anything to add about what we've said so far about point addition?
Any points you'd like to make?
Yes, points I'd like to make is there's kind of a few simple things
And one is how did the curve end up being mirrored
along the basically x-axis, right? Or the y-axis.
So that, and the reason why it's flipped
is because of the fact that the first part of it is y-squared.
So it's not a cubic equation.
But as soon as you put that y-squared in front,
it suddenly becomes symmetrical across itself.
So that is one really nice property.
And then the second thing I thought that was pretty interesting
about this kind of math was the addition is nonlinear.
So as you're like adding points, sometimes like the point
It can be like adding two together.
And then sometimes you'll add two points
and it'll be in between them.
Yeah, it's just interesting to see how it's just not,
it's nonlinear in terms of the way.
So when you, yeah, when you say nonlinear,
what that means is you have two points
and it's kind of just from looking at those points,
it's pretty hard to determine where the result
of the addition is going to be.
They could kind of be almost anywhere on the graph,
given two points on the curve,
the results of the addition of those two points.
And I think this to me really foreshadows
why we're going to be using elliptic curves in Bitcoin.
To me this is foreshadowing why elliptic curves
are being used for cryptography
because it's hard to predict
where these operations are going to take us.
Those are the only two things.
There are some other points as well in terms of the property.
There's the inversibility property.
And so when I said that you're going to be taking acid
and going to Wonderland, this is what I mean.
So addition's not addition.
Zero is the quote, point at infinity.
And this is where you get that invertibility property.
So this was something that I never really fully understood.
I always just thought it was a strange thing
that cryptographers would say about elliptic curve math.
That you have zero on this graph somewhere
but it's the point of infinity.
I never really truly understood what that means.
But I would say my working understanding
is that it's a point on the graph
that you can't really see.
And you're kind of just imagining
that it's like way, way, way far kind of off the map somewhere.
How do you sort of visualize that point at infinity
or that identity point or that zero point?
I just associate it as zero.
In terms of its actual representation,
that's actually something I still struggle with.
What does it actually mean?
I see, for example, that it's used
but I still don't understand conceptually exactly what it is.
And I apologize for not putting that piece together.
It's like we're in Wonderland and things are weird.
And so you kind of have to suspend your disbelief a little bit.
Okay, it's the zero point
but it's not really zero.
It's zero such that in regular math,
when you add zero to a number,
you get that same number back out of that equation.
But this is a curve, right?
So we're not actually using zero.
We're finding some point such that a point on the curve
plus the quote identity point
will yield that same point on the curve, right?
Because any number plus zero should yield the same number.
But because we're having to suspend our disbelief
because we're in Wonderland,
because we took acid and things were strange,
It's the identity point or the point at infinity.
And so I've had to, again, suspend my disbelief
and just imagine that this point is just far away off somewhere
And it's, again, just this corner case
that we're defining the properties of this point
that doesn't actually really even exist on the curve.
It's just kind of like in our code, for example,
we have some if else statements to define some weird edge cases.
I think the point at infinity is just going to be one of them.
It's just a weird, weird corner case.
And because you can't really define infinity in Python,
what we've done in the code is we've just set the point at infinity
to be none with a capital N.
And because this point isn't really a real point on the curve,
it's just this kind of strange construct,
we always have to define those edge cases separately in the code.
We're always checking to see, like, is this the identity point?
And if it is, we're going to maybe do something
a little different with the result.
And we can check that in Python simply by saying,
is its x coordinate none?
Is its y coordinate none?
Oh, that's that weird point.
I didn't turn this point differently.
And if we're getting this weird point at infinity
or this identity point, well, if we're adding it to a point,
then we're just going to return that point.
You literally just hard code that into your program.
Just because I want to hopefully cement my visualization
So I've been treating it as basically like a zero operator
for all intents and purposes.
Because that's kind of the way it works.
But visualizing it, where would this thing actually be on?
Like, would it be to the left side, to the right side?
Or where does this thing exist?
And how is it infinitely far out?
Yeah, that's a good question.
So I think when you add a point to another point,
that point, those points are on the curve, right?
So you're kind of imagining that the point is
But I'm just kind of imagining that it's like far off.
To where my eyes can't see.
So is this the infinity point per se?
Is it literally just a point created
or a part of the definition of what is elliptic curve math
to satisfy this condition?
Like it doesn't actually exist in any real form.
This is a construct that we've created
so that we can satisfy the conditions of this.
Okay, that makes more sense.
That's why it's so freaking weird.
It's an extra point on the curve that satisfies these conditions,
This is where the acid comes into play.
When I say it's imaginary,
I don't mean it's imaginary as in an imaginary number.
I mean, it's like we imagined it.
We're imagining it because we're in one.
It's a point with a bunch of interesting properties,
It's different than all other points, essentially.
Because when you add it to anything,
you literally just take the other side
and just basically use that again.
Yeah, so we talked about this weird point at infinity,
which we sometimes call zero.
We sometimes call the identity point.
That satisfies the invertibility property of elliptic curves.
So that satisfies kind of two things here.
The identity, which is to say any number plus zero is itself,
as well as the invertibility property of addition.
So the point at identity were used
in a number of different places.
We talked about any number plus zero is itself,
but also any number plus the inverse of that number
So if I take negative two plus two, I should get zero.
If I take negative 10 plus 10, I should get zero.
If I take negative a million plus a million, I should get zero.
But in elliptic curve math,
if I were to add a point on the curve
plus its inverse on the curve,
and everything is flipped over that y-axis.
there's going to be two points
with two different y-coordinates.
If I take those two points with the same x
I want to get the identity point.
that there's this point on the curve somewhere.
but we're kind of defining it as a corner case.
And in Python, we're just literally defining a case
whereby two points that have the same x
but different y's when you add them together,
you get that point at infinity.
And in Python, we're simply just defining
just none as its x and none as its y.
but if we didn't define these corner cases,
we wouldn't be able to do the things
that we want our math to do.
We wouldn't be able to invert points
and have them yield the quote zero or identity point.
We wouldn't be able to add zero
or the identity point to a number
where I think we use the point at infinity as well.
So I think this part is one of the weirdest parts.
I think finding two points on the curve,
drawing a line through them,
finding where it intersects on the elliptic curve,
flipping that across the y-axis.
I don't think that part's that weird.
I think actually, if I go back a few years ago
to when I first learned this,
I thought it was really weird.
I think it's just become more normal to me
because I see it quite often.
But I do think that definitely
that identity point is super weird.
So Portland, are you able to talk?
I think you switch your devices or something.
I think Portland's switching over his devices.
Okay, so we talked about point addition
and the different properties we want addition to have.
We can code that in Python.
And the way that we code that in Python
is first we define a point.
A point has an x-coordinate, a y-coordinate.
It also has an a and a b.
The a and a b are going to be the arguments
that define the elliptic curve itself, right?
Because y squared equals x cubed plus ax plus b.
So in other words, when we're adding points
we need to make sure that those two points
The points aren't on the same curve,
which is to say the a and b
of those two points aren't the same.
We can't add those points together.
We cannot define addition between two points
that are not on the same elliptic curve.
So if the points are not on the same curve,
we're just going to return an error, actually.
Just an error saying, hey, lady,
these points are not on the same curve.
I don't know how to add points
that aren't on the same curve.
Now, if the points are on the same curve
and they're not equal to one another,
then we have an equation that we can use.
I mentioned that we find these slope,
and let me add Portland back up
because he's kind of coming and going.
Hey, Portland, you're back.
I'm going to add you as a co-host.
Okay, so the first case that Jimmy Song defines
is point addition where the two points
do not have the same x-coordinate.
Because remember, we talked about
how if they have the same x-coordinate,
you get that weird identity point.
So we're going to come to that one later.
But we're first going to implement in Python
point addition where the x-coordinates are not the same.
And we're on the same curve.
You got to be on the same curve, okay?
So if those points are not the same,
he goes through what the formula is
and then he derives that formula
is in fact the correct formula to use.
So what do you think, Portland?
like why this formula is selected?
Or should we just kind of do some hand waving
and say, just don't worry about it.
I think we can dive into it.
I think we should start with
the easy portion first about it.
Kind of this is just the way you do it.
And then we can go into the actual why it works.
I think the easy part for me
Because I remember doing that as a kid.
One second, bring up the slide.
And if you have your book open,
Sorry, my browser crashed.
I'm assuming where X1 is not equal to X2,
Because that's the first case
that we defined in our class
in Python for point addition.
So I figured we'd start there.
So essentially, it's just you're
even in calculus for derivatives,
essentially, it's just a slope of a line.
you use a derived equation
that is explained in the proof down below
at how they arrive at that.
And you basically plug in the power squared
minus the X minus the other X as well.
So that is the second point's X.
And then you're able to solve for that X.
And then you plug it in to solve for Y
Yeah, I think that is the simple form of it.
And then, yeah, they do have the proof as well.
Yeah, so I think the first part,
the Y2 minus Y1 over X2 minus X1,
that's the slope of the line,
a straight line that you draw
So for any two points that you have,
there's always going to be a straight line
that intersects through both of them.
And we learned how to find the quote,
slope of that straight line
in pre-algebra when we were kids.
And then once we have the slope,
we can actually plug that equation
into the elliptic curve equation.
We can substitute X and Y
when we have the slope of the straight line
and plug that into the graph
for the elliptic curve line.
So why are we plugging the straight line
into the elliptic curved line?
That's because we're looking for values of X and Y
that satisfy both equations.
Okay, we want to find all the points
that are true for both the straight line
and the elliptic curve line.
And we're actually going to get
There's not just going to be one X and Y
that satisfied both of those equations.
It's going to actually be three,
in most cases, not all cases,
there's going to be three intersections.
Now, the cool thing is we already know
are two of the intersections, A and B.
We want to find the third set of X, Y coordinates.
That's the third intersection, C.
So because we have these equations
of the straight line and the curved line,
and because we have the first two sets
for the first two points,
we can plug those points into the equation as well
to get the third set of coordinates,
And you can go through this proof
and you can see exactly why the formula is as it is.
And the formula ends up being pretty simple.
It's just the third point
on the intersection of those two lines
is going to be S squared,
The second X is the X for point B.
And then the third Y coordinate
is just going to be the slope
times the first X coordinate,
That's actually the third X coordinate.
And so the equations are really simple.
And Jimmy Song goes through
where the equations come from.
So when I actually wrote this in Python,
it was just a really simple equation
And boom, it's bits out the result
of that point addition now.
And the point addition does take into it a fact
that we are inverting the result
over the Y axis as always.
Okay, so I don't know anything else to say about that.
I think it's pretty straightforward.
Yeah, I think in essence,
just I think the most important thing
to connect here is the actual mathematics,
which is what we just described
and how it relates to those lines
or even in the book, right?
one of these things through,
You know two of the points
and it'll cross the curve
So you're just finding that last point
where you have two things you know
and you're solving for a third.
I was talking to the point at infinity
way out there where no one could hear.
contemplate the concept of infinity.
So what I was saying was very simply,
we just defined point addition
for the case whereby the two X coordinates
that you're adding together
It's pretty straightforward.
There's other going to be cases
that we're going to also define.
that I think we want to define
is going to be where we're adding
And if you add a point to itself,
what that means is the X coordinate
and the Y coordinate are both equal.
And this is really important.
This is so freaking important
Oh my God, because in Bitcoin,
Adding points to themselves.
This have just needless to say
this happens a lot in Bitcoin.
So get excited for applying
this to Bitcoin next week.
So the case whereby point one
how to do addition with that.
Because when we defined point addition
for two points that weren't the same,
we found where they intersected
on the curve when we drew
between those two points.
But what line are we going to draw
when the points are the same?
the slope of the line that we draw
to find where it intersects?
Okay, so this prompted me
to go back to calculus and say,
what the heck is a tangent?
What the heck is a tangent?
Do you want to take a stab
Like, how would you define a tangent?
No, I don't think I know off the top
of my head what a tangent is.
Well, I see where you're trying
because like, usually we kind of
in the way that you described,
which is a line that touches
a curve at a single point
and doesn't cross at that point.
Like, that's the way that
you were essentially describing it.
But where it gets a little weird
it does intersect the line,
the elliptic curve line later,
the slope of the tangent.
that's where it gets a little weird.
Oh, I think that's actually just fine.
I just was actually just trying
to define the actual like,
how do you come up with this angle
on the point that you have,
you basically find that tangent line
until it hits something, correct?
Unless it is the last special case.
So you find the tangent point
and we learned how to do this as kids.
was something we learned.
I think we learned it in calculus.
That would be, did we learn it?
We learned it in trigonometry.
of actually defining formulas
I think what it's defining
is the slope of the curve at that point.
So you have a point on the curve
and you draw this tangent line,
which is a straight line,
and there's a cool formula
and we call that the tangent.
And you do this using derivatives.
So I haven't used derivatives in a while.
Like, it's been a minute.
I mean, it comes back to me, of course,
that I've been using this really
But it brought me back to remembering
how to derive in calculus.
So we're going to just use
the same elliptic curve equation
which is y squared plus x cubed
with a and b being constants.
And we can take the derivative
we get the slope of the tangent curve.
And the slip of the tangent curve
is 3x squared plus a divided by 2y.
what I would say is to use Bitcoin
an applied cryptographer,
about being an applied cryptographer
is as an applied cryptographer,
you can just take the equations
that an actual cryptographer
and you can just use them in the code.
You don't really have to know.
You don't have to really know
you can literally just be like,
okay, there's a cryptographer
why we're using these equations.
I'm going to just let them
and I'm going to do my job
or an applied cryptographer
and just take those equations
and implement them in code.
And as an applied cryptographer,
exactly why those equations
even why the heck we're doing
point addition over elliptic curves.
than I do figured it out.
Okay, so we find the slope
with the slope that we calculated
is going to intersect the curve
whereby we take the point
and we flip it across the y-axis.
because we always do this
and you just write it in code.
It's like one line of code
that we are flippening it
There's one little optimization
that Jimmy Song mentioned
share the same x-coordinate
in the second to last step
He literally just did 2x1.
because that's the same point
and that in the previous step
was you actually did x1 minus x2.
because when I was implementing
I thought we're not really
because they're the same.
So you could have easily said x2
Use whichever one you want.
Yeah, you can use whichever one you want
because they're literally the same.
Is there anything else to say
where they do the actual derivative
of what's actually happening.
you do not need to understand this
to implement these functions
to build your Bitcoin library.
Yeah, that's such a good point.
And so if anyone's feeling
like discouraged or annoyed
by the fact that there's calculus here
and there's algebra and geometry.
because like Portland said,
to be able to write Bitcoin applications.
I'd say the average Bitcoin programmer
doesn't really understand
where this math comes from.
And that's probably a good thing
we leave that to the experts.
We leave that to the cryptographers.
And we'll just do what we do best,
That's the way I see it anyway.
to become a cryptographer.
No, I mean like, of course,
I want to understand this
to the highest degree possible.
I live in a real world with real time
everywhere I look, right?
or I could spend several days
deep diving into why somebody did
And several years given here.
Well, at least somebody took years to do it.
They can tell you how you need
to find it out in a week.
But yeah, you're technically correct.
It could be you don't know
how long it's going to take you, right?
You wouldn't be able to build anything
because yeah, Portland, you're a builder.
You're always building cool Bitcoin stuff.
You wouldn't be able to do any of that.
If you truly wanted to understand
cryptography to the extent
I'm not really going to build anything,
who was a Bitcoin programmer
that he understood cryptography.
He understands how to implement it.
He probably pretty much understands
pretty well like why it was designed
for different cryptographic primitives.
But what frustrated him was that
although even though he could understand
why those choices were made,
he didn't feel that he could invent
new cryptographic primitives.
And that frustrated him so much
that he went back to school
Now, if that's his passion in life,
of course, that's the right path for him.
But I'm saying this to say
that if you go into a PhD program
and you're devoting your life
to being able to invent new cryptography,
then you're not going to have the bandwidth
to be able to do cool Bitcoin stuff
like write Bitcoin applications.
So you kind of have to...
that they're mutually exclusive,
a little bit of a distraction
to just say I'm going to dive
so deep into this rabbit hole
that you might not realize
If I'm correct, though...
Peter Woolley, though, right?
with the latest transport encryption,
Is that applied cryptography?
Did he create new methods
I thought Peter Weller was...
an applied cryptographer.
if someone's an applied cryptographer,
it's not taking away at all
Like, I'm an applied cryptographer
in that I can apply cryptography
We all are at this point.
I want to jump back to...
the optimization that was made
That Jimmy Song made as well.
And that was in the section
where he describes, okay,
the negation case, right?
So if you have the same X,
And in the way it's implemented,
just return none and none.
And then it made me think like,
why is he able just to go,
oh, I don't care what the other Ys,
as long as they're not equal.
that both Ys exist on the curve anyways,
is on the other side of the curve
Because there's another case...
And I actually went through
the same question, my own mind.
And the reason why you check
for both coordinates X and Y
is because there's another case
whereby the X's are the same
and the Y's are also the same.
where you draw the tangent
on the slope for that point
and find where it intersects.
So that's the reason why.
But then you're bringing up
You're bringing up yet a third case,
which is the case whereby
someone has defined a point
that's not actually on the curve.
I was just like, how did you just go
and just go, oh, yeah, it's fine.
And it's because he's assuming
because of the way the class
So when you actually define the point,
it makes sure that your point
that aren't on the curve there.
So, yeah, that's why he's able
just to completely not actually check
if they are on the curve again
because it's already been defined.
Sorry, that actually made more sense
So we defined point addition
for the case whereby X1, Y1, X2, Y2
where the X's are the same
but the Y's are different.
And that's kind of a weird case
whereby we return the point at infinity.
And the reason we do that
is because we want this invertability
property to hold for point addition
whereby if you take a number
say number two and negative two,
We don't really have zero.
We have this weird identity point.
we're just going to literally
hard code this in Python.
You're just literally going to
okay, if the X's are the same
but the Y's are different,
That's the point at infinity.
It's a little strange, but it works.
So those are the cases we've defined.
We do have yet one additional case
and that is the case where
the tangent line is vertical.
where the Y coordinate is zero.
And so that tangent slope
a vertical line going up and down.
And you handle this in a special case
and you literally just check
then you're going to just return none,
which is the point at infinity.
So lots of weird kind of cases here,
but I'd say the case that we use the most
you're adding a point to itself.
get really, really fun for Bitcoin
we love adding points to themselves
and we'll see why next week.
So I feel like that gets us
pretty much through the whole chapter.
What have we not covered?
I actually had an observation just now.
So I'm looking at this code, right?
So we just went over this section
but the Y's are not equal.
And you return none, none, right?
Because basically they're flipped.
You're on the other side of the curve.
But the same thing actually is true
of that last point as well,
the one with the vertical tangent line
because the X's would technically be equal.
Both are essentially zero.
And then the Y's are also equal,
but you again return none, none.
So is there any case where X equals X
that you don't return the zero point
when adding them together?
And that is when the X's are equal
I apologize for forgetting that case.
No, that's okay because that's okay
because the last case is again,
just a weird edge case whereby there's
this weird exception that you're adding a point to itself.
And usually when you add a point to itself,
you find its tangent and then see
where that tangent intersects the elliptic curve.
But in this weird exception where Y is zero,
that tangent does not intersect the curve anywhere
because it just goes up and down.
And so because it doesn't intersect anywhere,
we're imagining that there's this other point out there
somewhere just on the edge of the world,
And we're imagining that this is a real point
that's on the curve, but it's not.
And we're just defining it in Python as being none.
Its X coordinate is none.
Its Y coordinate is none.
Like I said, we're on acid.
Okay. So just go with it.
If you ever meet the guy or woman who invented this,
we'll just be like, what the fuck were you on?
Like you were on something.
So I think we covered everything.
I think this might be a good time for us
to say some kind of concluding words about the chapter
and then invite people to have any questions
or comments they might want to share.
Those questions or comments can be about the chapter.
They can also be about Git or GitHub
or Jupyter Notebook or even Python.
And the questions can also be,
after we get through the elliptic curve stuff,
if you have any residual questions about finite field math,
now would be a good time to bring those up as well
so that we will be all caught up for next week,
which is chapter three, elliptic curve cryptography,
where we're taking the elliptic curve
and we're plotting it over a finite field.
And when I'm talking about Alice in Wonderland on acid,
this is where you're really going to go on an acid trip
because that elliptic curve plotted over the real numbers
is going to look very, very, very different
for the elliptic curve plotted over a finite field.
It's actually pretty beautiful, the combination of these two
and how you take this really nice, smooth thing
and then you turn it into complete chaos and security
But I was going to ask my question real quick
is you mentioned earlier that Bitcoin uses a lot
What is that used for frequently in Bitcoin, I guess?
Yeah, and I don't want to get too far ahead of myself,
but the reason I'll say that is because
when we start to define other math operators,
such as multiplication, for example,
the math operators are weird, right?
So we can't really multiply two points,
but we can take a point and we can add it to itself
So that's why I said in Bitcoin,
you're going to see this thing where you're taking a point
and adding it to itself over and over and over and over again.
You're going to see this happen a lot.
So just kind of visualizing that in my head real quick.
So let's say you're doing seven times a point.
You're going to basically add that point to itself
like seven times because this is pretty non-linear.
Does that mean that each resultant becomes
like more and more random compared to the original?
Yes, it's bouncing all over the place.
Every time you add it to yourself,
the result is just shooting across Wonderland.
Because it's like you said, Portland,
Because regular multiplication,
you see like this nice slope.
And then with this, it's just going to go...
Okay, time for questions from everybody else.
That was my grand question.
I guess concluding thoughts real quick?
Yeah, just because the addition is not linear,
the result can just be almost anywhere on the graph.
And it's not intuitive where it's going to end up.
So I'd say my concluding thought is,
again, my explosive moment was the understanding
of why the flippening happens
to enforce the associative property of addition.
That was really exciting for me,
getting to go back to calculus
to remember how to define and compute tangents.
And then also, I think for me,
the most fun that I've had is writing this code in Python.
Because I have not really a Python person.
I don't have anything against Python.
It's just not a language that I've really needed to use
And it's kind of a pleasure to see
just how easy it is to code in Python
and how all of this crazy math
you can just write in a single line of code.
I'd say those are my takeaways.
I'd just say, nonetheless,
literally Python combined with Jupyter notebooks
is so incredibly easy to work with.
It feels like you're writing in an actual notebook,
but you have the power of multiplying
just exponents and stuff instantly.
But yeah, I guess my takeaway,
again, the flippening would be the first kind of big point.
When you add things together,
you flip it on the y-axis before you're finished
Sorry, I get that backwards sometimes.
But the second thing I would say
that if you take anything away from this,
it would be understanding that by adding things
the rules created for addition
aren't meant to look like what we have in normal
It's meant to just give you another point on the curve.
And as such, when they say addition,
they're just creating rules to make sure
that everything fits to give you a result on the curve.
The reason why we have these special edge cases
is so that set of things is complete under all conditions.
As you add anything from just any x-value,
So it's just a way of defining something.
It's not necessarily meant to look like
the addition you're used to using.
So yeah, just let your mind just let it loose
and just try not to apply traditional mathematics
Otherwise, that will become very difficult.
It's just something that was invented
to define this operation on elliptic curves.
Some guy literally just made it up.
It's made up math to give us something
that looks kind of like a duck.
It quacks kind of like a duck,
but also kind of weirdly has a weird duck feathers.
But it's duck-like enough such that we can call it addition.
But it's just literally made up by some guy.
So be prepared to suspend your disbelief.
Portland about Jupyter Notebooks with Python,
is if you actually define bash commands
also in your Jupyter Notebook,
and then you can execute them within the notebook itself.
And I was doing that with Bitcoin D.
And oh my gosh, it is fun.
You can call on Bitcoin CLI from the Jupyter Notebook.
And you can check to see if your work is lining up
with what Bitcoin is happening.
Wait, so you could just...
Because we're not really...
So we're defining our own Bitcoin library.
We're writing our own Bitcoin library from scratch.
So we don't actually need Bitcoin D.
But what's cool is you can execute the Bitcoin CLI commands
within the Jupyter Notebook.
And as you're going through this book,
you can check to make sure that your work is correct.
You can check it against the actual Bitcoin core
reference implementation itself.
So if you like create a transaction
in Jupyter Notebooks using Python,
you can call the Bitcoin CLI
to literally validate that transaction.
I haven't gotten that far with Jupyter Notebooks.
I pretty much coded Python
with just them and command line,
like not this Jupyter Notebook thing.
This book actually introduced me to Jupyter Notebooks.
And I'm a big fan so far.
But okay, yeah, I look forward to that.
And I saw one of the comments from captain,
hashtag BTC says he's been writing code for decades.
C, C++, C sharp, JS, et cetera,
So I am learning two new things,
both building your own Bitcoin library
and Python at the same time.
So should we, let's open up the floor for questions.
Go ahead and raise your hand
if you have a question or comment
about anything we've gone over.
And again, that can also include
GitHub and Jupyter Notebooks and Python.
Now that said, I mentioned this last week,
I'm going to say it again.
If you come to all of these sessions
and you go through the exercises in Python,
in your Jupyter Notebook,
and you actually make sure
that you implement all of the code yourself,
if you take that repository
and submit it to Portland and I
at the end of this bootcamp,
you will receive a certificate
of completion that we will issue
on the Bitcoin blockchain itself.
And that's going to, I think,
It's going to mean something to me.
If I see that you did this
and I'm looking to hire somebody for a job,
you're going to be that much more
than somebody who did not.
It's also good for yourself
You will understand a lot more
and just in general programming.
And especially if you haven't
integrating Python with Bitcoin
is really actually an amazing use of Python
just because of the number library includes.
you are very responsibly embedding
this data into the time chain
using an op return and just a merkle hash, right?
That instead of just inscribing
it's a very small representation.
So it's a point of contention,
which is why I'm proud to say that,
yes, you're going to have
your certificate of completion
issued on the Bitcoin blockchain.
I know this is a huge point
because we are currently witnessing
a culture war between the inscribors
of the Bitcoin blockchain.
were very, very, very respectful wishes to say
that every single certificate
is going to be rolled into a primitive
that's used in computer science
which is used not only in this application,
We see Merkle trees all over the place.
what you can do is you can take
a bunch of distinct pieces of data
and you can hash them all with one another
and only have to provide the root hash,
which is only going to be 32 bytes
as well as a Merkle proof of inclusion
or sometimes just a Merkle proof
is made its way into that Merkle tree.
Now, the proof of inclusion
but it doesn't have to go on chain.
I'm going to provide that to y'all off chain.
So you're going to get your data,
your Merkle proof of inclusion.
You're going to get that off chain.
And all that's going on chain
So if 10,000 people take this class
and we issue 10,000 certificates,
we're still only going to inscribe,
So don't cancel this, okay?
It's only 16 bytes for me,
16 bytes for Portland, total.
I would say that I would hope
that 10,000 people do do this,
but I just thought of another way
you could technically do it,
basically hash of the proof of completion
as a pay to witness script
hash redeemed script in the out point.
So you just have every completed person
gets their own out point.
But no, we're not doing that.
Right, but we're doing just the one.
We're doing just the one.
is if we give you the Merkle proof of inclusion
the data, which is to say,
Portland Hoddle completed this course.
So he's going to get his own.
D++ completed this course.
That's the data that's getting hashed.
The proof of inclusion proves
that we're in the Merkle tree
goes on the Bitcoin blockchain.
So if I give you all three
it's going to be up to you
to write the code that validates
Yeah, that'll be a cool exercise.
I think for the participants.
OK, I see we have one person
I'm going to add them as a speaker.
Portland, I've added you as a co-host.
I don't know if you're able to.
I'm not going to chance it.
I've had a stable connection
I see Topher is in the audience.
when he joined us last week,
He loves that chapter is great.
Like it's not more than this one did.
Like this chapter is really cool.
that basically the P minus one factor
and you invert these things to divide.
I mean, when we talked about
you're just kind of defining an operator
that's kind of like addition.
whereby we defined these operators
that were not really the operators
Wonderland versions and division
in particular gets really weird
because you can't really divide
by the multiplicative inverse.
So OK, we're going to just do that.
And again, some guy just decided
that that's how we define addition.
And so we're going with it.
So OK, captain, did you have
anything to add about today's session?
I just wanted to first say thank you
because like this is the perfect timing
So like hearing your voices
Oh, I'm interested in talking about
like how the process of how you're
going to like issue these certificates
but not today or maybe on not online.
Portland or is it Mr. Hoddle?
It can be anything really,
but Portland Hoddle is typically
so I'm just going to keep talking.
But you can clarify that later.
I would like to translate the script.
Like I want to invite some
that can take this with me.
So like if I can have the
I don't want to have to like
copy and paste the whole thing.
If I can have like a copy of it,
I'll make the translation.
I can just share a Google link to that
because it's done on Google talks
or I'll just post it in my GitHub
repository along with the other ones
So along with the chapter,
I just dump all the images of these.
What language are you going
to be translating over to?
I guess my first one is going
then I can easily do whatever I want,
but I'm just I have local friends.
So I'm gonna do Nepalese first.
So yeah, it's gonna be fun.
Yeah, you mentioned audio visual learning.
We all have our different learning styles.
And if you're just listening to the spaces
and you don't have anything to look at,
you might be a little confused.
I would definitely suggest
having a book in front of you
and permanent slides in front of you,
having your Jupiter notebook open
so that you have something visually
Last week, I was kind of toying
with the idea of streaming
I think I'm just gonna hopefully
It's up to y'all to make sure
that you have the right visual
materials prepared for yourself.
how to make it work on Twitch,
if we're gonna do some live coding,
yeah, just have like your laptop
What's up, Brian Sandwich?
Ma'am, I am a Reuben, not a sandwich.
going through elliptic curves
or are you a veteran to the curve?
No, I am a curved newbie.
But I was gonna ask you guys,
where is this course that you guys
Yeah, so what we're doing
Jimmy Song's programming Bitcoin book
how to program Bitcoin from scratch.
So you're not gonna be using libraries
that implement the cryptography for you
or libraries that construct transactions for you.
You're writing all of that yourself in Python.
we went through finite fields.
This week, we're going through elliptic curves.
It might not make a lot of sense to folks
why we're talking about finite fields,
but you're gonna find out next week
in elliptic curve cryptography.
So Brian, what we're doing
is we're going through a chapter a week
And for folks who are following along
with their Jupiter notebooks,
and actually going through the exercises
and implementing this library themselves
if they get through the entire book,
they are going to receive a certificate
of completion from Portland and I
saying that you completed
but I just had a thought.
Do you have like a schedule?
I think you might not be able
I think she can't hear you.
do you think I should create
a copy of all of the examples
that Jimmy Song has in his book
so that people can maybe even attempt
to solve them without having
or find a copy somewhere?
Because like just like what
somebody needs to complete
a very well defined set of things
What they need to complete
is the exercises in the Jupiter.
And that's going to be available
all in his repository on GitHub.
So if you click on my page,
D plus plus on my Twitter
and you click on the Jimmy Song
programming Bitcoin link,
to Jimmy Song's GitHub repository.
what you can do is you can either
clone it to your local host
to your GitHub either way
and you are going to be able
to run a Jupiter notebook
once you've installed some dependencies.
From there, you're going to go
and you're going to flesh out
in that Jupiter notebook.
And all of those exercises,
is he's written the tests,
the functional tests in Python first
and you have to go through
and write the classes and methods
that fulfill and satisfy those tests.
So this is like test first development
who follow a test first development.
I'm just going to take a stab at this
and I think I've done this in the past.
It's defined as basically
you write the tests first,
like your expected outputs and solutions
and then you build the code
to achieve those results second.
Yeah, which is what we're doing
It's like the tests are first
so then we got to make sure
Side note, I actually haven't been,
I do have Jimmy Song's repository forked
to write the Jupiter notebook myself
from scratch with each one,
like literally not using templates.
Yeah, so you've been going through
like a little extra work on your part
I have not been doing that
because there's a few things in here.
Like some of the class definitions
he already provides for us,
for example, the point class,
he's already fleshed out some of that.
So he's fleshed out the constructor,
he's fleshed out the equal operator
that overrides the existing equal operator
in Python and then I've just gone in
and I've fleshed out the ones
like not equals, for example.
So yeah, I think if you're doing
where you're writing everything,
you're going to get probably even more
And the equals operator as well
is a little interesting too
I really kind of come to the conclusion
that most of these things
he's just basically writing
to make sure all the members
of that class are equal to each other.
are exactly the same so far at least.
Oh, sorry to take the floor, Brian.
No, I was looking at the code too.
Brian, I was going to say
you should totally go through
I'll help you along, Brian, if you want.
I've been having a lot of fun doing this.
I think I literally had a start on GitHub
and I've been meaning to get through it.
Do all the things through it, Brian.
That's the thing is like,
It's like how many people
sitting on their shelf getting dusty
and someday they're going to finish it.
you've all been waiting for.
And if you're just joining us
for the first time today,
because the first chapter,
because there's a lot of diagrams
and it's not too late to get caught up.
But what I would say is don't wait
until we're like halfway through the course
because I'm not going to keep
all the material up on my Twitter forever.
So you're saying there's digital scarcity
There's digital scarcity.
This is you got to kind of be here.
You had to be there, man.
You had to be there, bro.
Topor, do you want to say anything
I see you're in the audience lurking.
Anyone else have any questions?
that no one has no questions.
Like I'm getting a little suspicious
cryptography is literally
like fucking Chinese even to me.
And I'm literally sitting here
like I was listening to you guys.
I'm literally here like Googling
JPT stuff to try to understand this
and it's still like black magic.
I don't know if you've been here
but you just imagine that
you're like halfway through.
Well, OK, what I said was
You've just hit Wonderland
and everything is super weird.
Math just got really weird.
That's elliptic curve photography.
what we do got the coding part.
Hey, Captain, do you mind?
Do you mind just stepping down
Because I think you're not
And I apologize, Captain.
I didn't mean to talk over,
do you have like a specific question
or something that you wish
was more clear about today's topic?
I'm so trying to understand it
that it's like I don't even know
what's the right question to ask.
So I guess let's start with
how about how exactly is like.
Sec P 256 K one specifically
derive public keys, correct?
So here's the thing, Brian.
about this for two weeks now
public private key cryptography.
We haven't talked even about
looks like over a finite field.
All we've done is just looked
into what is a finite field?
What is finite field math,
how do we define math operators
and what is an elliptic curve?
We've talked about point addition,
which is where you take two points
and you find a third point
that's also on the curve.
So if you're feeling overwhelmed,
that you're way far ahead
of what we've even covered.
No, no, so I guess it's just
I guess it's just kind of more
of the way like I learned.
are kind of going from it
or like a bottom off perspective.
I work more from like a top down.
Like here's the final thing
and then like I deconstruct it
So yeah, that's probably why I'm lost.
I think all that we really described
like the shape it does, right?
it just basically is like this bend
and it's got this little thing
and it goes down the other side as well.
And then we defined basically
how you can take two dots
But why I guess like what's the point?
Obviously I know it's using cryptography,
but I'm trying to understand like
Like how does this help me?
Have you ever heard of key tweaking?
I've heard the term, yes.
Okay, so when you tweak a key in Bitcoin,
what you're essentially doing
is point addition over elliptic curves.
So that's one example of like why.
I'm literally adding a random number.
I'm literally just adding
a random number that's on this curve.
so that you have points on the curve
and you can add them together
And we do this a lot in Bitcoin.
I'm just giving an example of key tweaking
because it's something you may have heard.
And it's an example of like
why the hell do we do this?
and then we do it, yeah, we do it
with public and private keys.
how to derive public keys
and we derive public keys
by using point addition also.
please correct me if I'm wrong here,
you can really gain from this
is the fact that the addition
on these curves is nonlinear.
I think that is one of the bigger things
And then I think next week
we'll go over how it applies
once all of a sudden you apply
just massive number, so, or equation.
So when you say a finite field,
do you just mean any two values
between an x and y coordinate?
Yeah, so in the first chapter,
we defined finite fields.
I didn't know you were doing this, sorry.
Yeah, it's just a set of number.
It's just a set of numbers.
So like 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.
there's 11 numbers in that field.
And then we define the math operators
across that field such that
the result of those operations
are also within the field.
And you can go back and listen
to our recording from last week
and then go through that chapter
and then go through the exercises
to kind of help you understand.
And again, kind of like we talked
about being in Wonderland,
the operators that you define
are kind of weird plus and minus
and multiplication and division.
They have their similarities
to their regular operators
but they're also a little strange
that are within that field.
there are some weird properties
I don't know if your Twitter
was kind of bugging out today.
So if you're not able to talk,
maybe drop down and come back.
Brian, in terms of the first chapter
basically how things just wrap around.
So if you have a finite field
the numbers 0 through 11 in that
and you can just go around
and then once you add over that,
you just you just wrap it around
again and again and again.
And the math in that is extremely,
it's pretty simple overall.
It's like addition, subtraction,
multiplication, you can get that
but division is incredibly like
it's not incredibly difficult,
but if you walk down the right path,
you it'll hit right away.
But yeah, just finding that way
to get there to that conclusion.
Yeah, just follow the book
I kind of walk you through it.
and how you can essentially do division
through multiplication of things
So but yeah, division is the one part
that actually really matters.
Is your Twitter still bugging out?
Hey, I saw that you had a riddle for us.
that shows itself here in chapter two.
And yeah, so that's my riddle.
Oh man, that's the thing is like
we haven't really combined
the two chapters together
because we're doing that next week,
but I'm trying to think what.
modular arithmetic in chapter two.
So Portland, are you thinking?
Very slow processor here though.
We're not using finite fields.
Well, maybe I'm jumping ahead a little bit
you do use modular arithmetic,
but that's that's in the next chapter.
you're talking about chapters
one and two though Topher, right?
because in the finished code
when you're done writing the library,
it is involved in chapter two.
But I guess you don't have to involve it yet.
for doing point addition.
Yeah, over finite fields.
do you want to just tell us the answer
or do you want to keep us guessing?
Well, yeah, so the Portland
But yeah, so there's this theorem
called Fermat's Little Theorem
And it's what you use to do division
And you will be using it again
in order to do point addition as well
that's required in that operation.
Oh, now I'm pretty stoked.
So when you wrote your library
for Taproot, did you use this book
as a reference and just go through
and rewrite everything in JavaScript?
Yeah, and now that I'm looking at the code
and then there's the Jupyter Notebook
you will have built a library
with number fields, finite fields.
And so when you do the point arithmetic,
do they make you also use finite fields?
Next week, we're going to combine
that we've learned thus far
because right now we're just
the elliptic curve over real numbers.
We're just getting numbers as the results.
or modulus happening at all.
It's just here are your three points,
you got back out from this.
Topher has already cheated.
He's already moved ahead.
I guess Boatface, welcome to the stage.
I just have a quick question
to clarify what we talked about today
and this is probably going back
but I can't really do graphs.
But here when we're adding these points,
like let's say p1 and p2,
which is x1 or the coordinates x1 and y1
and the coordinates x2 and y2.
are we just simply taking the first x1
and then that makes up the addition c
in the case of the first a
when you're adding two points,
you're going to plot them
and you can do this visually
and then you're going to draw
between those two points a and b.
There's always going to be
and we learned this in pre-algebra
like before we did it algebra
and calculus and all that stuff.
You can draw a straight line
is when you draw that straight line
it's going to intersect the curve
is really going to be helpful.
It's probably not going to make sense.
didn't ask my question correctly.
and I see what I'm trying to
what is supposed to happen
but I want to be able to prove it
So if you try to plug those numbers in
and say x1 plus x2 equals x3,
So I can't add the coordinates?
Well, you can't add the coordinates directly
because you would just get
another point out in space.
It wouldn't be on the curve.
So instead, you have to do this process
So if you have one point another,
you find the slope of it.
And then essentially what you're doing
is you're then drawing a line
at the rate of that slope
and then use this special equation
that is outlined in Jimmy Song's book
or you could actually read through
Basically, it'll tell you
with the third point on the curve.
obviously don't match up right.
And so I guess the answer is
maybe just get a calculator
It's more than a calculator.
that Boatface's hypothesis
And it's a great hypothesis
to try to prove or disprove
because the hypothesis is,
okay, we have x1, y1, x2, y2.
is going to be the sum of x1 and x2.
And so I'm going to look...
With the zero point, it will be,
but let's define two points.
This is from a Jupiter notebook,
the first point is going to be
So the x is two, the y is five.
The second point is going to be
So let's just forget the y's
for now and look at the x's.
We're going to prove or disprove
So x1 is two, x2 is negative one.
What is two plus negative one?
What is two plus negative one?
So I'm going to add these two points
meaning I'm going to plot them
find where the third intersection
point is if I draw a straight line
Now the result that I get
is three comma negative seven.
You can kind of go through yourself
if we have these linear properties
with elliptic curve point addition.
When you add two points together,
the result could be almost anywhere
from a cryptographic standpoint.
And I think it's a great question
You know, sometimes in math class,
and you're listening for hours
That's like kind of two weeks
in a row that's happened.
When you do that total turn
and flip to the other axis,
so far from what we've seen,
that's not really like a formula
so much as an interesting thing
that's going to become relevant later, right?
It is defined in the formula.
when we've been defining point addition,
flipping over the results.
I guess my question is like
the flipping over of the result
ends up in these mathematical oddities
But like there's no reason
to flip other than to prove
and that's the flippening.
So when we're defining point addition,
we want it to satisfy properties
that we generally think of
when we think of addition
because it's not actual addition, right?
It's like it's this addition-like operation
that we're defining over elliptic curves.
we took acid, we're in Wonderland,
we're trying to figure out
You can't really add them,
but we can come up with a way
that's kind of similar to addition.
that we want to be true of addition
is a property that's called associativity.
when you were a little kid,
a plus b plus c is the same thing
Like the order in which you add stuff
should not change the result.
is the same thing as 2 plus 3 plus 1.
Those should always be the same with addition.
then something's not right
with that addition operator.
I think all the other three properties
even if you don't flip the x-axis over that, right?
But it's associativity property
But all the other properties
also still are satisfied by flipping it.
that last property as well.
So hence adding the flipping,
flippening is really just a construct
that all four of these boxes were ticked, right?
Because it's unintuitive though.
at the commutative property of addition,
even if you don't do the flippening.
So you don't need the flippening for that.
But for the associativity property,
you do need the flippening.
what I did was I went through
these three points, a, b, and c.
of which points I'm adding first?
I'm going to add points a and b,
and then I'm going to add point c.
I'm going to add points b and c first,
and then I'm going to add point a later.
And when I change the order
in which I'm adding those points,
if I don't do the flippening,
completely different results.
They're both on the elliptic curve,
Then no matter what order
I add these numbers together,
I still get the same results.
does that suggest that you could
out of order like a plus c
You wouldn't be able to do that.
Like you just flip is sort of inherent
anytime you add, you flip,
you flip anytime you add two numbers
because so they're in parentheses,
You're supposed to add one set first,
then apply the next operator,
that next addition to that.
So it's going to flip twice,
if I'm correct in that set.
Two additions, two flippenings,
three additions, three flippenings,
four additions, four flippenings.
I know this is marinating for you,
but you mentioned you had an aha
I'm wondering when that happened.
like eyeballing these coordinates
and trying to add them up
and like they're not adding up.
I wouldn't say you're wasting your time.
I'd say that you're testing
a hypothesis and they're proving
Literally just open up a Python shell
and just start like I think it's in.
It's a lot easier to read the code
and understand what's happening
the math formula into lines.
I think Jimmy Song's GitHub repository
has an example that you can basically
run from the Jupyter Notebook
I would have to double check though
Yeah, there's a lot of examples
for all the examples and exercises
that have different properties
like points where the x and y's
points where the x and y's are the same,
points where the x's are the same
or the y's are different, et cetera.
And we're going through all those cases.
Speaking of Jupyter Notebooks,
I've discovered that is very fun.
I actually hosted my Jupyter Notebook
instance in a Docker container
And what that was interesting
is because now I have access
from every device in my house
or even I broke it out to the web too
so that I'm able to access it.
to every time I installed on a new computer,
You can run it as like a service
on a host, even a Raspberry Pi.
followed by the port number.
Let's bring up Post Capone.
What is going on with the sandwiches?
I feel like I'm a bit out.
So we're doing sandwiches
Post Capone, are you following
programming Bitcoin with us?
quite a million times in my life
but I'm really excited about
I'm really excited about buying
I'm sure they're going to
actually sell it in science
and we're going to sell it in science.
I'm in a public space, yeah.
What I was saying is that
I've used Jimmy Song's book
and I just tuned in to this space
but I absolutely follow in it.
Well, be sure to go through
because I would love for you
to actually get that certificate
It's that carrot in front of the stick
to actually finish this course
And I know post you obviously
know a whole lot about Bitcoin
and have been using this book
But you know it hits different
when you really like exhaust
It's so, so, so satisfying.
with Andreas Antonopoulos
and he has his own programming book
as in-depth as this book does.
and actually implementing it yourself.
Okay, Brian Portland Topher post
I have some work to complete
thank you so much for hosting
I know that as Brian said
but if you can ask questions
DM me or I'll ask questions
get Jimmy Song's Jupyter Notebook
and just start learning from that
because though you will learn a lot
actively applying yourself
and really kind of doing things
with this above listening
will be the key to success
and understanding more about Bitcoin
and I think also the nice part too
two fundamental building blocks
so you have elliptic curves
and you have finite fields
I think things accelerate
in terms of the fundness really quick
so getting out of just kind of boring math
into more of the actual programming
and how to apply this to Bitcoin
and like the question everybody
how does it make the private keys
so I look forward to that.
This the first two chapters
I think are probably the most dry
because we haven't really done
and we're going to start doing Bitcoin stuff
and we're going to start learning
how to build our own Bitcoin transactions
and how freaking cool is that.
is this an attack on Bitcoin?
I think everything is lately right?
Learning how to use Bitcoin
well thank you so much for joining
Quick question, I'm sorry
I just had a question probably to buy it.
The Jupyter Notebook, is it on the GitHub?
So you're going to fork or clone the GitHub
and then you're going to run
the Jupyter Notebook on your local host
and what that's going to do
is it's going to run a server
that will allow you to run the Notebook
Now Portland being the DevOps engineer
that he is, decided to containerize it
to all of his devices everywhere.
Seriously how do you do that, how?
Somebody else has already done the hard work
and I just literally took the repo
and followed the instructions
which were about five lines
but here's why it's just saying
having the Dockerized version
if you have a host that is constantly on
because you don't ever have to start up
You don't ever have to type in Jupyter
or whatever to get it started.
I've never even typed in Jupyter Notebook
I just go to the website.
It's literally hosted 24 seven
I just type in my password
I have access to all my Jupyter Notebooks.
I can just start running things right away.
I don't have to basically
don't have to do extra steps.
So I just want to add things
that give men feeling the power
is not running Jupyter Notebook command.
Jupyter Notebooks are by far
and away the greatest feature
and I'll never forgive for it.
Okay okay why is Docker cancer?
Extra execution environment baggage.
Owned by a fucking company.
The company thing doesn't bother me.
I think that Docker is a really,
of an open source corporation
that's done like tremendously good
So like I would apply Docker as an entity
to like the end of the earth.
I think they've done an amazing job.
Dude just switch over to Nick already.
Come on Portland you know.
I just don't want to Dockerize everything.
I just want to build shit.
I just want to download it and build it.
I just don't want to do it.
do you just download it and just
That's I guess I would say that
everything has a time and place right.
Like the best tool for the job.
And no not everything needs to be
But in cases where I literally
can clone somebody's repository
and then get a Jupyter Notebook server
I don't need massive performance.
I need to run Jimmy Song's notebooks
and I also want an environment
to do fun stuff in another example
where Docker works pretty good
So if I just install everything locally
everything else is exposed.
It's all in its own little container.
I actually run my own email server
and I literally just did it
There's Docker mail server
and I'm just saying like it's
and somebody's already got
kind of that golden sample
and you just want to plug in
your own like magic keywords
or magic variables to make it go.
And that's what I did with the email server.
Every Docker maxis and mix
OS maxis it just hasn't fact.
I just haven't taken the time
No I just haven't taken the time
but just right now I have learned.
No I think for commercial
I think Docker is a really amazing tool.
The problem is that a lot of us
commercial environment solutions
and we don't want to deal
The biggest overhead for Docker
in terms of just getting stuff done
because have you tried debugging
You're going to have a bad time.
So but yeah in terms of getting things
basically something you basically
debugged already it's good to go
and just basically containerizing it
so anybody that knows that type
and Docker compose up can do it.
That's a time and place for everything.
And yes Nix is probably better
I just haven't learned it yet.
Hey I actually don't know
if I even agree with that one.
Okay there's also pot man
and some other things too right.
Do Nix match any virtual environment
or is it just Docker specifically?
It's any virtual environment.
So does that include Python?
Wait you don't like virtual environments?
Dude it's a it's a crutch.
because Python has dog shit
Okay I use virtual environments all the time
and I'm very very happy with them
Oh yeah no they they definitely work
I don't even really have a V.
Like everything's a fucking V and V.
So no this course is just going
to be Python and Bitcoin.
Layer one we're not going to talk
about Rust and we're not going to
We got to do what we got to do.
actually like programming
and Bitcoin core like contributing
to those to the Bitcoin core
just constructing transactions
and Bitcoin scripts and stuff like that.
I just want to figure I want to
figure out how to fucking
that's going to be bigger
I know that he's already up
He figured out how to do covenants
which like if we're tracking
what he's doing right now,
it should be like something
along the lines of like three
or four times the current
the script is fucking hilarious.
like 40 times over and over.
Meds will literally implement
op cats instead of going to therapy.
Is it that that's the underlying
problem with that therapy?
basically the amount of data
and the processing burden
sandwiches are for a break.
Oh, I think it's reasonable.
I haven't still gotten a clear
answer why it was taken away
other than the implications
First off, we don't know.
Like objectively, we don't have
But I think the strongest
assumption and the most common
that weren't in use, right?
If you aren't using this,
we're turning it off, right?
kind of a hair trigger response
So, like, I think it's fair
to say, like, a lot of people
might want to say, like, oh, well,
Satoshi's original design.
a couple of different times
that, like, we should support
pipes and stuff like this.
you know, this conservative
not having the expressive mess.
Like, fast forward 14 years
or whatever, 13 and a half years.
And we're having this conversation
some or any of these op codes?
In terms of reactivation,
what method would be used?
into doing that functionality?
Because I think that would be
hard fork according to any node
on the network right now.
Okay, so op cat in particular
I think it's op success 128
to activate it as an op-not,
that it was previously in.
And the original Stoshe client
But there had been hard forks.
hard forks in the release
of the initial Stoshe client
So like that theory breaks down.
Thank you so much for hosting.
Okay, we'll see you next week
elliptic curve cryptography
where we combine elliptic curves
What do you guys want to do?
Does somebody want to open up
where we continue talking
I'll open up one via you.
Yeah, go ahead and open up
nerding out about Bitcoin tech.
and learned about elliptic curves,
I'm so happy that you came.
And I can't really talk about-
Elliptic curve cryptography.