from core.services.crypto.TicketCustomer import TicketCustomer """ We are making both an unblinded and blinded commitment pair. unblinded = saving it to disk, for later blinded = sending to the server """ def make_ONE_commitment_pair( profile_object: TicketCustomer, which_ticket: int ) -> str | None: # First, make the original unblinded commitment. it's saved inside the profile object: did_unblinded_save = profile_object.make_unblinded_commitment(which_ticket) # that `profile_object` object is holding the unblinded commitment, # so it can be directly used to blind it (without having to serialize then deserialize it). # Then BLIND it, so it can be sent to the billing server: blind_commitment = profile_object.blind_commitment(which_ticket) # we need to make sure we actually saved the data, # because it's the only way to unblind it later: if did_unblinded_save == False or blind_commitment == False: return None # assuming we got it, else: # we are initially only sending to the server the blinded data, return blind_commitment def make_ALL_commitments(how_many_profiles_to_make: int) -> list | None: # Setup the entire class object of "profile_object" for using all these other functions, profile_object = TicketCustomer() # setup loop: which_ticket = 0 list_of_all_blinded_data = [] failed_to_save = [] # loop up to the number of profiles requested: while which_ticket < how_many_profiles_to_make: which_ticket = which_ticket + 1 # for each profile, make the commitment data, blinded_string = make_ONE_commitment_pair(profile_object, which_ticket) if blinded_string is None: second_try = make_ONE_commitment_pair(profile_object, which_ticket) if second_try is None: failed_to_save.append(which_ticket) profile_object.reset() pass # and add only the BLIND commitment to the list, to submit to the server after paying: list_of_all_blinded_data.append(blinded_string) # wipe the object's data, but without reloading the code: profile_object.reset() # Summary: # We SAVED to disk all the unblind commtiments and blinding factors for later. # If more than one of them failed to save, then we are abandoning this entire loop. how_many_failed_to_save = len(failed_to_save) if how_many_failed_to_save > 1: return None # But we are sending to the SERVER only the BLIND commitments, return list_of_all_blinded_data