Facility for clearing CFrags.

pull/249/head
jMyles 2019-08-08 11:37:22 -07:00 committed by David Núñez
parent 3193d1541d
commit b89decb8c1
2 changed files with 15 additions and 0 deletions

View File

@ -121,3 +121,15 @@ def test_capsule_length(prepared_capsule, kfrags):
assert len(capsule) == counter
cfrag = pre.reencrypt(kfrag, capsule)
capsule.attach_cfrag(cfrag)
def test_capsule_clear(prepared_capsule, kfrags):
capsule = prepared_capsule
for counter, kfrag in enumerate(kfrags):
assert len(capsule) == counter
cfrag = pre.reencrypt(kfrag, capsule)
capsule.attach_cfrag(cfrag)
capsule.clear_cfrags()
assert len(capsule) == 0

View File

@ -176,6 +176,9 @@ class Capsule:
error_msg = "CFrag is not correct and cannot be attached to the Capsule"
raise UmbralCorrectnessError(error_msg, [cfrag])
def clear_cfrags(self):
self._attached_cfrags = set()
def first_cfrag(self):
try:
return list(self._attached_cfrags)[0]