ccf 7.0.0.dev4__py3-none-any.whl → 7.0.0.dev5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ccf/ledger_viz.py CHANGED
@@ -4,11 +4,29 @@
4
4
  import ccf.ledger
5
5
  import argparse
6
6
  import os
7
- from stringcolor import cs # type: ignore
8
7
  import json
9
8
  from typing import Optional
10
9
 
11
10
 
11
+ COLORS = {
12
+ "Black": 40,
13
+ "Red": 41,
14
+ "Green": 42,
15
+ "Yellow": 43,
16
+ "Blue": 44,
17
+ "Magenta": 45,
18
+ "Cyan": 46,
19
+ "White": 47,
20
+ "Grey": 100,
21
+ }
22
+
23
+
24
+ def cs(s: str, background_colour: Optional[str] = None) -> str:
25
+ if background_colour is not None and background_colour in COLORS:
26
+ return f"\033[{COLORS[background_colour]}m{s}\033[0m"
27
+ return s
28
+
29
+
12
30
  class Liner:
13
31
  _line = ""
14
32
  _len = 0
@@ -19,8 +37,8 @@ class Liner:
19
37
  self._line = ""
20
38
  self._len = 0
21
39
 
22
- def append(self, s: str, colour: str, background_colour: Optional[str] = None):
23
- self._line += cs(s, colour, background_colour)
40
+ def append(self, s: str, background_colour: Optional[str] = None):
41
+ self._line += cs(s, background_colour)
24
42
  self._len += len(s)
25
43
  if self._len >= self.MAX_LENGTH:
26
44
  self.flush()
@@ -28,17 +46,16 @@ class Liner:
28
46
 
29
47
  class DefaultLiner(Liner):
30
48
  _bg_colour_mapping = {
31
- "New Service": "White",
32
- "Recovering Service": "Grey",
33
- "Service Open": "Magenta",
34
- "Governance": "Red",
49
+ "New Service": "Black",
50
+ "Recovering Service": "Red",
51
+ "Service Open": "White",
52
+ "Governance": "Yellow",
35
53
  "Signature": "Green",
36
- "Internal": "Orange",
54
+ "Internal": "Magenta",
37
55
  "User Public": "Blue",
38
- "User Private": "DarkBlue",
56
+ "User Private": "Cyan",
39
57
  }
40
58
  _last_view = None
41
- _fg_colour = "Black"
42
59
 
43
60
  @staticmethod
44
61
  def view_to_char(view):
@@ -69,27 +86,20 @@ class DefaultLiner(Liner):
69
86
  if self.write_views:
70
87
  char = "‾" if not view_change else self.view_to_char(view)
71
88
 
72
- fg_colour = self._fg_colour
73
89
  bg_colour = self._bg_colour_mapping[category]
74
- self.append(char, fg_colour, bg_colour)
90
+ self.append(char, bg_colour)
75
91
 
76
92
  def help(self):
77
93
  print(
78
94
  " | ".join(
79
95
  [
80
- f"{category} {cs(' ', 'White', bg_colour)}"
96
+ f"{category} {cs(' ', bg_colour)}"
81
97
  for category, bg_colour in self._bg_colour_mapping.items()
82
98
  ]
83
99
  )
84
100
  )
85
101
  if self.write_views:
86
- print(
87
- " ".join(
88
- [
89
- f"Start of view 3: {cs(self.view_to_char(3), self._fg_colour, 'DarkGrey')}"
90
- ]
91
- )
92
- )
102
+ print(" ".join([f"Start of view 3: {cs(self.view_to_char(3), 'Grey')}"]))
93
103
  print()
94
104
 
95
105
 
ccf/read_ledger.py CHANGED
@@ -9,8 +9,6 @@ import argparse
9
9
  from datetime import datetime
10
10
  from enum import Enum, auto
11
11
 
12
- from loguru import logger as LOG
13
-
14
12
 
15
13
  class PrintMode(Enum):
16
14
  Quiet = auto()
@@ -93,9 +91,9 @@ def print_key(key, table_name, tables_format_rules, indent_s, is_removed=False):
93
91
  k = find_rule(tables_format_rules, table_name)["key"](key)
94
92
 
95
93
  if is_removed:
96
- LOG.error(f"{indent_s}Removed {k}")
94
+ print(f"{indent_s}Removed {k}")
97
95
  else:
98
- LOG.info(f"{indent_s}{k}:")
96
+ print(f"{indent_s}{k}:")
99
97
 
100
98
 
101
99
  def counted_string(string, name):
@@ -113,22 +111,20 @@ def dump_entry(entry, table_filter, tables_format_rules):
113
111
  private_table_size = entry.get_private_domain_size()
114
112
  if private_table_size and table_filter is None:
115
113
  if not printed_tx_header:
116
- LOG.success(tx_header)
114
+ print(tx_header)
117
115
  printed_tx_header = True
118
116
 
119
- LOG.error(f"{indent(2)}-- private: {private_table_size} bytes")
117
+ print(f"{indent(2)}-- private: {private_table_size} bytes")
120
118
 
121
119
  for table_name, records in public_tables.items():
122
120
  if table_filter is not None and not table_filter.match(table_name):
123
121
  continue
124
122
 
125
123
  if not printed_tx_header:
126
- LOG.success(tx_header)
124
+ print(tx_header)
127
125
  printed_tx_header = True
128
126
 
129
- LOG.warning(
130
- f'{indent(4)}table "{table_name}" ({counted_string(records, "write")}):'
131
- )
127
+ print(f'{indent(4)}table "{table_name}" ({counted_string(records, "write")}):')
132
128
  key_indent = indent(6)
133
129
  value_indent = indent(8)
134
130
  for key, value in records.items():
@@ -142,7 +138,7 @@ def dump_entry(entry, table_filter, tables_format_rules):
142
138
  pass
143
139
  finally:
144
140
  print_key(key, table_name, tables_format_rules, key_indent)
145
- LOG.info(f"{value_indent}{value}")
141
+ print(f"{value_indent}{value}")
146
142
  else:
147
143
  print_key(
148
144
  key, table_name, tables_format_rules, key_indent, is_removed=True
@@ -171,7 +167,7 @@ def run(
171
167
  if is_snapshot:
172
168
  snapshot_file = paths[0]
173
169
  with ccf.ledger.Snapshot(snapshot_file) as snapshot:
174
- LOG.info(
170
+ print(
175
171
  f"Reading snapshot from {snapshot_file} ({'' if snapshot.is_committed() else 'un'}committed)"
176
172
  )
177
173
  dump_entry(snapshot, table_filter, tables_format_rules)
@@ -187,12 +183,12 @@ def run(
187
183
  read_recovery_files=read_recovery_files,
188
184
  )
189
185
 
190
- LOG.info(f"Reading ledger from {ledger_paths}")
191
- LOG.info(f"Contains {counted_string(ledger, 'chunk')}")
186
+ print(f"Reading ledger from {ledger_paths}")
187
+ print(f"Contains {counted_string(ledger, 'chunk')}")
192
188
 
193
189
  try:
194
190
  for chunk in ledger:
195
- LOG.info(
191
+ print(
196
192
  f"chunk {chunk.filename()} ({'' if chunk.is_committed() else 'un'}committed)"
197
193
  )
198
194
  for transaction in chunk:
@@ -208,28 +204,22 @@ def run(
208
204
  if validator:
209
205
  validator.add_transaction(transaction)
210
206
  except Exception as e:
211
- LOG.exception(f"Error parsing ledger: {e}")
207
+ print(f"Error parsing ledger: {e}")
212
208
  has_error = True
213
209
  else:
214
- LOG.success("Ledger verification complete")
210
+ print("Ledger verification complete")
215
211
  has_error = False
216
212
  finally:
217
213
  if not validator:
218
- LOG.warning("Skipped ledger integrity verification")
214
+ print("Skipped ledger integrity verification")
219
215
  else:
220
- LOG.info(
216
+ print(
221
217
  f"Found {validator.signature_count} signatures, and verified until {validator.last_verified_txid()}"
222
218
  )
223
219
  return not has_error
224
220
 
225
221
 
226
222
  def main():
227
- LOG.remove()
228
- LOG.add(
229
- sys.stdout,
230
- format="<level>{message}</level>",
231
- )
232
-
233
223
  parser = argparse.ArgumentParser(
234
224
  description="Read CCF ledger or snapshot",
235
225
  formatter_class=argparse.ArgumentDefaultsHelpFormatter,
ccf/split_ledger.py CHANGED
@@ -6,8 +6,6 @@ import argparse
6
6
  import os
7
7
  from typing import BinaryIO, List
8
8
 
9
- from loguru import logger as LOG
10
-
11
9
  DEFAULT_OUTPUT_DIR_NAME = "split_ledger"
12
10
  TEMPORARY_LEDGER_FILE_NAME = "ledger.tmp"
13
11
 
@@ -58,7 +56,7 @@ def close_ledger_file(
58
56
  ledger_file.name,
59
57
  os.path.join(os.path.dirname(ledger_file.name), final_file_name),
60
58
  )
61
- LOG.info(f"Wrote new ledger file: {final_file_name} (complete: {complete_file})")
59
+ print(f"Wrote new ledger file: {final_file_name} (complete: {complete_file})")
62
60
 
63
61
 
64
62
  def run(args_):
@@ -92,10 +90,10 @@ def run(args_):
92
90
  ledger_file_input = ccf.ledger.LedgerChunk(args.path)
93
91
  is_input_file_complete = ledger_file_input.is_complete()
94
92
  is_input_file_committed = ledger_file_input.is_committed()
95
- LOG.info(
93
+ print(
96
94
  f"Splitting ledger file {args.path} (complete: {is_input_file_complete}/committed: {is_input_file_committed}) at seqno {args.seqno}"
97
95
  )
98
- LOG.info(f"Output directory: {args.output_dir}")
96
+ print(f"Output directory: {args.output_dir}")
99
97
 
100
98
  output_file = None
101
99
  found_target_seqno = False
@@ -130,7 +128,7 @@ def run(args_):
130
128
  looking_for_following_signature = True
131
129
  continue
132
130
 
133
- LOG.debug(f"Found target seqno {args.seqno}")
131
+ print(f"Found target seqno {args.seqno}")
134
132
  found_target_seqno = True
135
133
  close_ledger_file(
136
134
  output_file,
@@ -178,10 +176,4 @@ def run(args_):
178
176
 
179
177
 
180
178
  def main():
181
- LOG.remove()
182
- LOG.add(
183
- sys.stdout,
184
- format="<level>{message}</level>",
185
- )
186
-
187
179
  run(sys.argv[1:])
@@ -6,8 +6,6 @@ import sys
6
6
  import json
7
7
  import argparse
8
8
 
9
- from loguru import logger as LOG
10
-
11
9
 
12
10
  def counted_string(string, name):
13
11
  return f"{len(string)} {name}{'s' * bool(len(string) != 1)}"
@@ -39,12 +37,12 @@ def run(paths, uncommitted=False):
39
37
  read_recovery_files=True,
40
38
  )
41
39
 
42
- LOG.info(f"Reading ledger from {ledger_paths}")
43
- LOG.info(f"Contains {counted_string(ledger, 'chunk')}")
40
+ print(f"Reading ledger from {ledger_paths}")
41
+ print(f"Contains {counted_string(ledger, 'chunk')}")
44
42
  try:
45
43
  previous_historical_ledger_entry = None
46
44
  for chunk in ledger:
47
- LOG.info(
45
+ print(
48
46
  f"chunk {chunk.filename()} ({'' if chunk.is_committed() else 'un'}committed)"
49
47
  )
50
48
  for transaction in chunk:
@@ -64,22 +62,19 @@ def run(paths, uncommitted=False):
64
62
  "txid": txid,
65
63
  "entry": json.loads(value.decode("utf-8")),
66
64
  }
67
- LOG.info(json.dumps(entry))
65
+ print(json.dumps(entry))
68
66
  historical_secrets_invariant(
69
67
  entry, previous_historical_ledger_entry
70
68
  )
71
69
  previous_historical_ledger_entry = entry
72
70
 
73
71
  except Exception as e:
74
- LOG.exception(f"Error parsing ledger: {e}")
72
+ print(f"Error parsing ledger: {e}")
75
73
  return False
76
74
  return True
77
75
 
78
76
 
79
77
  def main():
80
- LOG.remove()
81
- LOG.add(sys.stdout, format="<level>{message}</level>")
82
-
83
78
  parser = argparse.ArgumentParser(
84
79
  description="Verify that the ledger's secrets are valid",
85
80
  formatter_class=argparse.ArgumentDefaultsHelpFormatter,
@@ -1,21 +1,19 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ccf
3
- Version: 7.0.0.dev4
3
+ Version: 7.0.0.dev5
4
4
  Summary: Set of tools and utilities for the Confidential Consortium Framework (CCF)
5
5
  Author-email: CCF Team <CCF-Sec@microsoft.com>
6
6
  Project-URL: Homepage, https://github.com/microsoft/ccf
7
7
  Project-URL: Issues, https://github.com/microsoft/ccf/issues
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: License :: OSI Approved :: Apache Software License
10
- Requires-Python: >=3.8
10
+ Requires-Python: >=3.12
11
11
  Description-Content-Type: text/markdown
12
12
  License-File: LICENSE
13
- Requires-Dist: loguru==0.*,>=0.5
14
- Requires-Dist: cryptography<47,>=44
15
- Requires-Dist: string-color==1.*,>=1.2.1
16
- Requires-Dist: cwt==3.*,>=3.1.0
13
+ Requires-Dist: cryptography<47,>=46
14
+ Requires-Dist: cwt<4,>=3.2.0
17
15
  Requires-Dist: setuptools<81,>=74
18
- Requires-Dist: packaging<26,>=24
16
+ Requires-Dist: packaging<26,>=25
19
17
  Dynamic: license-file
20
18
 
21
19
  # CCF Python
@@ -3,19 +3,19 @@ ccf/_versionifier.py,sha256=17vUCXFp_VixNCuhBmMS9SCM74JnHR1OIZnMQSspSs4,2951
3
3
  ccf/cose.py,sha256=hueXb_gvswxRkDAcUacmSIdkfqAFegZIWkA66M4yKVk,14950
4
4
  ccf/ledger.py,sha256=X6ljpGPB8HJ6eAw9F3KkEz_meJpMbPALSr0Fbn6R_cg,42240
5
5
  ccf/ledger_code.py,sha256=_malocCXly7TdBwBt8ldY6_yNfFwvyCb5Zkp8T4t9fg,3859
6
- ccf/ledger_viz.py,sha256=l1p2wKgLDayxquVa9-yzsMcLx9vvygCV8EZ_PrVpvMg,6430
6
+ ccf/ledger_viz.py,sha256=D7eTZVry8mNkAdPuJq0aaP2iy4zAj4xbkoV7kilYUT4,6525
7
7
  ccf/merkletree.py,sha256=JHUnGYYHJfi18YUNGiHmNCa1AwmCAwLAN3ias5j61ws,2931
8
8
  ccf/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- ccf/read_ledger.py,sha256=UzmEKAMS2GJmwuaenKBJbkBDZIWeCa9xcXdpZB51SEg,9370
9
+ ccf/read_ledger.py,sha256=ih_wk6_71SS37a4inLTYLdkZZ6-rDrqgB864t780nME,9147
10
10
  ccf/receipt.py,sha256=dySVvy-IqvsB8pj5uooIokbQR853vpT7uC0TQ-IWIQk,2765
11
- ccf/split_ledger.py,sha256=wspNZUFPMSvMgGxmwP3QuSbx7QDzTjrC6ecFFJSp14o,5900
11
+ ccf/split_ledger.py,sha256=kUxGMUx6taBm6os_r1eay4Q0JXpgw8nJs7gcc1ZoJd0,5753
12
12
  ccf/tx_id.py,sha256=E7XJyUoJ-a8h7Fp36zNQdhSYdyuNdFV-r_aXhoWl1ks,736
13
- ccf/verify_ledger_secrets_chain.py,sha256=_UDc4wNro2mNUVbErDkhl24jLeJC0Vr-kECeZEdeHME,3590
14
- ccf-7.0.0.dev4.data/scripts/keygenerator.sh,sha256=r9i8rURcDUPU8c9NKkxrjweU1qU09Hv3SWc3IFQ648A,2391
15
- ccf-7.0.0.dev4.data/scripts/submit_recovery_share.sh,sha256=v1L_PjduUASCVYjOJiG7lDwtcSwQPOd3G2CY9ipSUXU,3289
16
- ccf-7.0.0.dev4.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
17
- ccf-7.0.0.dev4.dist-info/METADATA,sha256=yppnqWwmlb_lb6yLX4KPgvdUutc8c7s6KJVrHVGAj2Q,991
18
- ccf-7.0.0.dev4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
- ccf-7.0.0.dev4.dist-info/entry_points.txt,sha256=3hbXI2LSOY06QitxM8GQqT9NwY7rCp1RtSU9gGG20A4,365
20
- ccf-7.0.0.dev4.dist-info/top_level.txt,sha256=I0tWtkKe6KRqXt0nIp8W-ln8j431-vDBb39bQGKkL9Q,4
21
- ccf-7.0.0.dev4.dist-info/RECORD,,
13
+ ccf/verify_ledger_secrets_chain.py,sha256=FC0Vil6IcHdZbFhh6c2tVjbFLMTHf8D59bF4sxLqgWQ,3459
14
+ ccf-7.0.0.dev5.data/scripts/keygenerator.sh,sha256=r9i8rURcDUPU8c9NKkxrjweU1qU09Hv3SWc3IFQ648A,2391
15
+ ccf-7.0.0.dev5.data/scripts/submit_recovery_share.sh,sha256=v1L_PjduUASCVYjOJiG7lDwtcSwQPOd3G2CY9ipSUXU,3289
16
+ ccf-7.0.0.dev5.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
17
+ ccf-7.0.0.dev5.dist-info/METADATA,sha256=Xv4SVhXHJlaN7h1RLDgACV50QQi-huyGF7ymU1PxUBw,915
18
+ ccf-7.0.0.dev5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
+ ccf-7.0.0.dev5.dist-info/entry_points.txt,sha256=3hbXI2LSOY06QitxM8GQqT9NwY7rCp1RtSU9gGG20A4,365
20
+ ccf-7.0.0.dev5.dist-info/top_level.txt,sha256=I0tWtkKe6KRqXt0nIp8W-ln8j431-vDBb39bQGKkL9Q,4
21
+ ccf-7.0.0.dev5.dist-info/RECORD,,