Skip to Content
밑바닥부터 시작하는 비트코인
book

밑바닥부터 시작하는 비트코인

by 류정필, 송재준
November 2019
Beginner to intermediate
408 pages
9h 29m
Korean
Hanbit Media, Inc.
Content preview from 밑바닥부터 시작하는 비트코인
3
타원곡선 암호
101
3.9
스칼라 곱셈 코딩하기
[연습문제
3
.
5
]에서 다루고자 했던 것은 다음과 같습니다.
>>> from ecc import FieldElement, Point
>>> prime = 223
>>> a = FieldElement(0, prime)
>>> b = FieldElement(7, prime)
>>> x = FieldElement(15, prime)
>>> y = FieldElement(86, prime)
>>> p = Point(x, y, a, b)
>>> print(7*p)
Point(infinity)
스칼라 곱셈은
int
형의 수와
Point
클래스형 객체의 곱셈 연산입니다. 파이썬에서 이런 목적
에 안성맞춤인
__
rmul
__
메서드가 있습니다.
3
스칼라 곱셈을 스칼라 값만큼 그대로 더하는 방
식으로 구현한
__
rmul
__
코드는 다음과 같습니다.
class Point:
...
def __rmul__(self, coefficient):
product = self.__class__(None, None, self.a, self.b)
for _ in range(coefficient):
product += self
return product
product
를 무한원점으로 초기화합니다. 점덧셈이므로 무한원점은
0
에 해당합니다.
coefficient ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

밑바닥부터 시작하는 딥러닝

밑바닥부터 시작하는 딥러닝

사이토 고키
실리콘밸리 리더십

실리콘밸리 리더십

김정혜, 마이클 롭

Publisher Resources

ISBN: 9791162248294