def ring_test(): os.system("sudo mn -c") filename = ctime() network = "ring" host1 = "h1" host2 = "h2" switch1 = "s1" switch2 = "s2" net = startup(ring()) testing(net, filename, host1, host2, switch1, switch2, network) net.stop()
from kuju import Kuju from ruut import Ruut from kolmnurk import Kolmnurk from ring import ring kuju = Kuju() ruut = Ruut(2) kolmnurk = Kolmnurk(4, 2) ring = ring(5) print("Kuju pindala" + str(kuju.pindala)) print("Ruudu pindala" + str(ruut.pindala())) print("Kolmnurga pindala" + str(kolmnurk.pindala())) print("Ringi pindala" + str(ring.pindala())) print(kuju) print(ring) print(kolmnurk)
############################## # msg = 'hello' # f = open('message','wb') # f.write(msg) #### READ THE FILE TO SIGN ### f = open(filename,'rb') msg1 = f.read() ################################# # ring signature object r = ring(pubs) # sign the messages s1 = r.sign(msg1,z) # save the signature to file f = open('sigs/' + filename[7:] + '-sig','w') # now verify just using public keys id = sys.argv[1] id = id.replace("https://www.facebook.com/", "") id = id.replace("http://www.facebook.com/", "") response = urllib2.urlopen('http://mahan.webfactional.com/pub-keys/' + id) html = response.read()
size = len(sys.argv)-2 pubs = range(size) # name of file to verify signature against filename = sys.argv[len(sys.argv)-1] print 'filename: ', filename print 'reading signature...' # read the signature from file sigfilename = sys.argv[1] f = open(sigfilename,'r') ids, pubs, sig = pickle.load(f) ################################### f = open(filename,'rb') msg3 = f.read() ############################ # now verify just using public keys s = ring(pubs) print (s.verify(msg3,sig)) if s.verify(msg3,sig): print "file was signed by one of the following: ", ids
import os,hashlib,random,Crypto.PublicKey.RSA from ring import ring print('weak') # number of participants in ring signature size = 4 # two messages to sign msg1,msg2 = 'hello','world!' # ring signature object r = ring(map(lambda _:Crypto.PublicKey.RSA.generate(1024, os.urandom),range(size))) # test every combination of signing and verifying for i in range(size): s1,s2 = r.sign(msg1,i),r.sign(msg2,i) x = (r.verify(msg1,s1) and r.verify(msg2,s2) and not r.verify(msg1,s2)) print(x) print() # signing test # make 2 RSA keys key1 = Crypto.PublicKey.RSA.generate(1024, os.urandom) key2 = Crypto.PublicKey.RSA.generate(1024, os.urandom) # make a ring signature r = ring([key1, key2]) # write private key to file x = key1.exportKey() print (x)