44import time , tai64n
55from pyblake2 import blake2b
66
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+
742_SIX_MONTH_IN_SECONDS = 15778463
843
944'''
1247[X] Public/Private keypair for central reserve
1348[X] Public/Private keypair for mint
1449[X] Signature data from central reserve signing
15-
1650'''
1751
1852KEYPAIR__CENTRAL_RESERVE = ed25519 .create_keypair ()
4983#[X] Nonce (UINT32)
5084SN_NONCE = os .urandom (4 ) #4 bytes = uint32
5185#[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!"'
5387#[/] The SigNote's Serial Number (BLAKE2b 64-byte Hash of Initial Data)
5488
5589def sn__generate_init ():
90+ out = []
91+
5692 #Version Header
57- out = [struct .pack ( "!2sI " , 'SN' , 1 )]
93+ out + = [struct .pack ( "!2sH " , 'SN' , 1 )]
5894 # Start init section
59- out += [struct .pack ( "!BBH" , 0 , 0 , 256 )]
95+ out += [struct .pack ( "!BBH" , 0 , 0 , 248 )]
6096
6197 # [ISO][SQNUM] = 128 bits
6298 out += [SN__ISOCODE , SN__SQNUMBER ]
@@ -82,3 +118,8 @@ def sn__generate_init():
82118print len (snote ['data' ])
83119print "SIGNATURE:" , snote ['signature' ]
84120print repr (snote ['data' ])
121+
122+ print _SN_SECTION_INIT .parse ( snote ['data' ] )
123+
124+
125+
0 commit comments