4
4
import time , tai64n
5
5
from pyblake2 import blake2b
6
6
7
+ from construct import Struct , Const , Int8ub , Bytes , Int16ub
8
+
9
+ _SN_VERSION = Struct (
10
+ "magic" / Const (b"SN" )
11
+ , "version" / Const (1 , Int16ub )
12
+ )
13
+
14
+ _SN_SECTION_HEADER = Struct (
15
+ "type" / Int8ub
16
+ ,"flags" / Int8ub
17
+ ,"length" / Int16ub
18
+ );
19
+
20
+ _SN_SECTION_INIT = Struct (
21
+ "version" / _SN_VERSION
22
+ ,"header" / Struct (
23
+ "type" / Int8ub
24
+ ,"flags" / Int8ub
25
+ ,"length" / Const (248 , Int16ub )
26
+ )
27
+ ,"isocode" / Bytes (3 )
28
+ ,"seqnum" / Bytes (13 )
29
+ #SN__DENOMINATION_FLAGS, SN__DENOMINATION, SN__DECIMALPLACE
30
+ ,"denomination_flags" / Int8ub
31
+ ,"denomination" / Int16ub
32
+ ,"decimalplace" / Int8ub
33
+ #SN__MINT_PK, SN__MINT_PK_CRSIG
34
+ ,"mint_pk" / Bytes (32 )
35
+ ,"mint_pk_crsig" / Bytes (64 )
36
+ #nonce, hashkey
37
+ ,"nonce" / Bytes (4 )
38
+ ,"hashkey" / Bytes (64 )
39
+ ,"signature" / Bytes (64 )
40
+ );
41
+
7
42
_SIX_MONTH_IN_SECONDS = 15778463
8
43
9
44
'''
12
47
[X] Public/Private keypair for central reserve
13
48
[X] Public/Private keypair for mint
14
49
[X] Signature data from central reserve signing
15
-
16
50
'''
17
51
18
52
KEYPAIR__CENTRAL_RESERVE = ed25519 .create_keypair ()
49
83
#[X] Nonce (UINT32)
50
84
SN_NONCE = os .urandom (4 ) #4 bytes = uint32
51
85
#[X] SigNote Hash Key String (64-Bytes) (Ex: "In God We Trust. Copyright The United States Federal Reserve")
52
- SN_HASHKEY = " Bill Gates never said that 640K ought to be enough for anybody!!"
86
+ SN_HASHKEY = ' Bill Gates has never said " 640K ought to be enough for anybody!"'
53
87
#[/] The SigNote's Serial Number (BLAKE2b 64-byte Hash of Initial Data)
54
88
55
89
def sn__generate_init ():
90
+ out = []
91
+
56
92
#Version Header
57
- out = [struct .pack ( "!2sI " , 'SN' , 1 )]
93
+ out + = [struct .pack ( "!2sH " , 'SN' , 1 )]
58
94
# Start init section
59
- out += [struct .pack ( "!BBH" , 0 , 0 , 256 )]
95
+ out += [struct .pack ( "!BBH" , 0 , 0 , 248 )]
60
96
61
97
# [ISO][SQNUM] = 128 bits
62
98
out += [SN__ISOCODE , SN__SQNUMBER ]
@@ -82,3 +118,8 @@ def sn__generate_init():
82
118
print len (snote ['data' ])
83
119
print "SIGNATURE:" , snote ['signature' ]
84
120
print repr (snote ['data' ])
121
+
122
+ print _SN_SECTION_INIT .parse ( snote ['data' ] )
123
+
124
+
125
+
0 commit comments