Пример #1
0
        print x, y, z
    else:
        print %s
ret = Valid("print 1")
"""%(x)
if __name__ == "__main__":
    code = map(ex, xrange(20)) 
    m = mast.Mast("compile", "print 1")
    n = m
    for i, c in enumerate(code):
        if i%10000 == 0:
            print '.'
        for i in xrange(100):
            n.addBr(c)
        n = n.addBr(c)
    mt = mast.MerkleTreeList(m.children)
    orig_len = float(len("".join(code))*101)
    print "original length", orig_len
    pr = n.generateFullProofUpward(m.hash())
    code, _script = mast.toScript(pr, m.hash())
    together = enc("".join(map(chr,code+_script)))
    comp_len = len(str(pr))
    pct_comp = 1 - comp_len/orig_len
    print sim.merkleVerifyExec(None, m.hash(), [pr], 10)
    print script.run("".join(map(chr,code+_script)))
    print orig_len
    print "compression length", comp_len
    print "compression length for blockchain ready version", len(together)
    print "compression percentage", pct_comp
    print "compression percentage for blockchain version", 1-len(together)/orig_len
Пример #2
0
    code2, _script = mast.toScript(proof, m.hash())
    together = enc("".join(map(chr,code2+_script)))
    print "Blockchain compatible Proof is:"
    print together


    c = crypto.hashable(ex%60)
    dec.getcontext().prec = 30
    compressed_size = dec.Decimal(len(str(proof)))

    initial_size = dec.Decimal(N*sum(map(len,code)))
    print "Compression achieved for %d branches"%N
    rate = dec.Decimal(1) - (compressed_size / initial_size)
    print rate
    print "%s %%" %rate

    rate = dec.Decimal(1) - (dec.Decimal(len(together)) / initial_size)
    print rate
    print "%s %%" %rate
    raw_input("Continue:")
    assert mast.upwardProve(proof, mh, True)
    raw_input("Continue:")
    script.run("".join(map(chr, code2+_script)))