Пример #1
0
def test():
  h.load_file("stdgui.hoc")
  #h.cvode_active(1)
  h('create soma[5]')

  h.tstop=.2
  ecg_setup()
  ecg_init()
  h.run()
  ecg_final()
Пример #2
0
 def _format_index_page(self, page):
     ret = []
     ret.append(
         "<header> logical page: {:s} | physical page: {:s} | count: {:s}".
         format(h(page.logical_page_number), h(page.physical_page_number),
                h(page.key_count)))
     for i in xrange(page.key_count):
         key = page.get_key(i)
         ret.append(" | {{ {key:s} | <child_{i:s}> {child:s} }}".format(
             key=key.human_format, i=h(i), child=h(page.get_child(i))))
     return "".join(ret)
Пример #3
0
 def _format_index_page(self, page):
     ret = []
     ret.append("<header> logical page: {:s} | physical page: {:s} | count: {:s}".format(
         h(page.logical_page_number),
         h(page.physical_page_number),
         h(page.key_count)))
     for i in xrange(page.key_count):
         key = page.get_key(i)
         ret.append(" | {{ {key:s} | <child_{i:s}> {child:s} }}".format(
             key=key.human_format,
             i=h(i),
             child=h(page.get_child(i))))
     return "".join(ret)
Пример #4
0
def verify(S, merch_ans, z, n, e, a_id):
    xi = []
    yi = []
    print(z)
    for i in range(len(z)):
        if z[i] == 1:
            yi += [merch_ans[i][0]]
            xi += [common.h(merch_ans[i][1], merch_ans[i][2])]
        else:
            xi += [merch_ans[i][0]]
            yi += [common.h(merch_ans[i][1], merch_ans[i][2])]
    f_prod = numpy.prod(list(map(lambda v: common.f(v[0], v[1]), zip(xi, yi))))
    print("h(x) signed:\t{}".format((f_prod % n) % n))
    print("decrypt:\t{}".format((S**e) % n))
    return (f_prod % n) % n == (S**e) % n
Пример #5
0
    def _graph_index_page_rec(self, page):
        print("  \"node{:s}\" [".format(h(page.logical_page_number)))
        print("     label = \"{:s}\"".format(self._format_index_page(page)))
        print("     shape = \"record\"")
        print("  ];")

        key_count = page.key_count
        for i in xrange(key_count + 1):
            child_page_number = page.get_child(i)
            if not is_index_page_number_valid(child_page_number):
                continue
            child_page = self._cim.logical_index_store.get_page(
                child_page_number)
            self._graph_index_page_rec(child_page)

        for i in xrange(key_count):
            child_page_number = page.get_child(i)
            if not is_index_page_number_valid(child_page_number):
                continue
            print("  \"node{num:s}\":child_{i:s} -> \"node{child:s}\"".format(
                num=h(page.logical_page_number),
                i=h(i),
                child=h(child_page_number)))
        # last entry has two links, to both less and greater children nodes
        final_child_index = page.get_child(key_count)
        if is_index_page_number_valid(final_child_index):
            print("  \"node{num:s}\":child_{i:s} -> \"node{child:s}\"".format(
                num=h(page.logical_page_number),
                i=h(key_count - 1),
                child=h(final_child_index)))
Пример #6
0
    def _graph_index_page_rec(self, page):
        print("  \"node{:s}\" [".format(h(page.logical_page_number)))
        print("     label = \"{:s}\"".format(self._format_index_page(page)))
        print("     shape = \"record\"")
        print("  ];")

        key_count = page.key_count
        for i in xrange(key_count + 1):
            child_page_number = page.get_child(i)
            if not is_index_page_number_valid(child_page_number):
                continue
            child_page = self._cim.logical_index_store.get_page(child_page_number)
            self._graph_index_page_rec(child_page)

        for i in xrange(key_count):
            child_page_number = page.get_child(i)
            if not is_index_page_number_valid(child_page_number):
                continue
            print("  \"node{num:s}\":child_{i:s} -> \"node{child:s}\"".format(
                num=h(page.logical_page_number),
                i=h(i),
                child=h(child_page_number)))
        # last entry has two links, to both less and greater children nodes
        final_child_index = page.get_child(key_count)
        if is_index_page_number_valid(final_child_index):
            print("  \"node{num:s}\":child_{i:s} -> \"node{child:s}\"".format(
                num=h(page.logical_page_number),
                i=h(key_count - 1),
                child=h(final_child_index)))
Пример #7
0
    def verify(self):
        xi = []
        yi = []
        for i in range(len(self.z)):
            if self.z[i] == 0:
                xi.append(self.z_answer[i][0])
                yi.append(common.h(self.z_answer[i][1], self.z_answer[i][2]))
            else:
                xi.append(common.h(self.z_answer[i][1], self.z_answer[i][2]))
                yi.append(self.z_answer[i][0])

        #This is done merchant!
        f_prod = numpy.prod(
            list(map(lambda v: common.f(v[0], v[1]), zip(xi, yi))))

        hx = f_prod % self.n
        dec_hx = (self.serial**self.e) % self.n

        print("Done by merchant! h(x) signed:\t{}".format(hx))
        print("Done by merchant! decrypt:\t{}".format(dec_hx))
        return hx == dec_hx