jimmysong / programmingbitcoin

Repository for the book
Other
1.75k stars 656 forks source link

Chapter 02 coding for infinity point feedback #225

Open jwhendy opened 3 years ago

jwhendy commented 3 years ago

Not really an issue, but was working through the examples and noticed this combination of implementation choices:

I was initially thinking I could break this by trying Point(None, y) or Point(x, None), but get an error as it skips the infinity point check and tries to validate that the point is on the curve:

TypeError: unsupported operand type(s) for ** or pow(): 'NoneType' and 'int'

So, for more of a python best practice question, why do something like raising a value error if the point isn't on a curve but allow this edge case to fail via a math operator error? I presume not checking if the point is actually on the curve could fail later due to calculating the slope of a point not actually on the curve, for example, but we deal with it explicitly up front.

Anyway, since this repo exists, thought I'd document the feedback. Loving the book so far!