예제 #1
0
    print('\n\t\033[93m \033[1m [Real Transcript] \033[0m')
    for i in t_real:
        print(i)

    if t_ideal == t_real:
        print("\033[92m[Distinguisher] They're the same\033[0m")
    else:
        print("\033[91m[Distinguisher] They're different\033[0m")


if __name__ == '__main__':
    print('\n\t\t\033[93m [IDEAL WORLD] \033[0m\n')
    t1 = execWrappedUC(128,
                       env_equivocation,
                       [('F_bracha', Syn_Bracha_Functionality)],
                       wrappedPartyWrapper('F_bracha'),
                       Syn_FWrapper,
                       brachaSimulator(Broken_Bracha_Protocol),
                       poly=Polynomial([100, 2, 3, 4, 5, 6, 7]))

    print('\n\t\t\033[93m [REAL WORLD] \033[0m\n')
    t2 = execWrappedUC(128,
                       env_equivocation, [('F_chan', Syn_Channel)],
                       wrappedProtocolWrapper(Broken_Bracha_Protocol),
                       Syn_FWrapper,
                       DummyWrappedAdversary,
                       poly=Polynomial([100, 2, 3, 4, 5, 6, 7]))

    distinguisher(t1, t2)
예제 #2
0
    def __init__(self, k, bits, crupt, sid, pid, channels, pump, prot, poly, importargs):
        self.parties = sid[1]
        self.delta = sid[2]

        # Track idx in queue for each party's output
        self.pid_to_queue = {}
        # whether input was provided to the functionality
        self.dealer_input = None
        self.total_extra_delay_added = 0
        self.log = logging.getLogger("\033[1mRBC_Simulator\033[0m")
   
        self.party_output_value = None
        self.expect_output = False
        
        SynWrapperSimulator.__init__(self, k, bits, crupt, sid, pid, channels, pump, prot, poly, importargs)

        # Spawn UC experiment of real world (local to the simulator)
        self.sim_channels,static,_pump = createWrappedUC(k, [('F_chan',Syn_Channel)], wrappedProtocolWrapper(prot), Syn_FWrapper, DummyWrappedAdversary, poly, importargs={'ctx': self.ctx, 'impflag':False})

        # Forward the same 'sid' to the simulation 
        # TODO forward crupt parties as well
        # TODO so far the comm.py enforces cruption in the simulation as well
        # TODO possibly wait to do the `static.write` below until execuc.py
        #   tells us who the crupted parties are
        self.sim_sid = (sid[0]+' simulation', sid[1], sid[2])
        self.sim_pump = _pump
        static.write( (('sid', self.sim_sid), ('crupt', *[x for x in self.crupt])) )
    
        self.handlers.update(
        {
            self.sim_channels['p2z']: self.sim_party_msg,
            self.sim_channels['a2z']: self.sim_adv_msg,
            self.sim_channels['f2z']: self.sim_func_msg,
            self.sim_channels['w2z']: self.sim_wrapper_msg,
        })


        print('\n<><><><>\nSimulator channel w2a: {}\n<><><><>\n'.format(self.channels['w2a'].i))
예제 #3
0
    else:
        print("\033[91m[Distinguisher] They're different\033[0m")


from uc.itm import ProtocolWrapper, WrappedProtocolWrapper, WrappedPartyWrapper, wrappedPartyWrapper, wrappedProtocolWrapper
from uc.adversary import DummyWrappedAdversary
from uc.syn_ours import Syn_FWrapper, Syn_Channel
from prot_bracha import Syn_Bracha_Protocol
from f_bracha import RBC_Simulator, Syn_Bracha_Functionality, brachaSimulator
from uc.execuc import execWrappedUC

if __name__ == '__main__':
    print('\n\t\t\033[93m [IDEAL WORLD] \033[0m\n')
    print('env1 type', type(env1))
    t1 = execWrappedUC(128,
                       env1, [('F_bracha', Syn_Bracha_Functionality)],
                       wrappedPartyWrapper('F_bracha'),
                       Syn_FWrapper,
                       brachaSimulator(Syn_Bracha_Protocol),
                       poly=Polynomial([100, 2, 3, 4, 5, 6]))

    print('\n\t\t\033[93m [REAL WORLD] \033[0m\n')
    t2 = execWrappedUC(128,
                       env1, [('F_chan', Syn_Channel)],
                       wrappedProtocolWrapper(Syn_Bracha_Protocol),
                       Syn_FWrapper,
                       DummyWrappedAdversary,
                       poly=Polynomial([100, 2, 3, 4, 5, 6, 7]))

    distinguisher(t1, t2)