-
Notifications
You must be signed in to change notification settings - Fork 2
/
shares.py
60 lines (44 loc) · 1.36 KB
/
shares.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 3 16:01:43 2018
@author: jordi
"""
import rlp
from rlp.sedes import binary, CountableList, big_endian_int
from utils import address, sha3
class Share(rlp.Serializable):
fields = [
('source', address),
('signature', binary),
('block_number', big_endian_int)
#Reserved in case we have to sign the shares
# ('v', big_endian_int),
# ('r', big_endian_int),
# ('s', big_endian_int),
]
def __init__ (self, source, signature, block_number):
self.source = source
self.signature = signature
self.block_number = block_number
@property
def hash(self):
return sha3(rlp.encode(self))
class Dkg_Share(rlp.Serializable):
fields = [
('source', address),
('to', address),
('secret_share_contrib', binary),
('verif_vector', CountableList(binary))
#Reserved in case we have to sign the shares
# ('v', big_endian_int),
# ('r', big_endian_int),
# ('s', big_endian_int),
]
def __init__ (self, source, to, secret_share_contrib, verif_vector):
self.source = source
self.to = to
self.secret_share_contrib = secret_share_contrib
self.verif_vector = verif_vector
@property
def hash(self):
return sha3(rlp.encode(self))