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

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

by 류정필, 송재준
November 2019
Beginner to intermediate
408 pages
9h 29m
Korean
Hanbit Media, Inc.
Content preview from 밑바닥부터 시작하는 비트코인
1
유한체
39
1.3.1
파이썬으로 유한체 코딩하기
파이썬으로 유한체 원소를 표현하기 위해서 먼저 유한체 원소
1
개를 표현하는 클래스를 정의
하겠습니다. 의미에 맞게 해당 클래스 이름은
FieldElement
로 하겠습니다.
클래스는 유한체
F
prime
에 있는 원소를 나타냅니다. 클래스의 기본 뼈대는 아래와 같습니다.
class FieldElement:
def __init__(self, num, prime):
if num >= prime or num < 0:
error = 'Num {} not in field range 0 to {}'.format(
num, prime - 1)
raise ValueError(error)
self.num = num
self.prime = prime
def __repr__(self):
return 'FieldElement_{}({})'.format(self.prime, self.num)
def __eq__(self, other):
if other is None:
return False
return self.num == other.num and self.prime == other.prime
먼저
num
prime
을 인수로 받은 후
num
값이 경곗값을 포함하여
0
prime
-
1
이 값인지 조사합니다.
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