Exemplo n.º 1
0
    def lrs_sign(self, msg):
        """Sign for LRS."""
        ltp_array = sendrecv(self.server_addr, [Constants.GET_LTP_ARRAY])
        ltp_idx = ltp_array.index(self.pub_key)

        # modify stp_array to prevent duplicate voting
        ltp_array.append(msg_hash(msg, sha1))

        return lrs.sign(msg, self.pri_key, ltp_idx, ltp_array)
Exemplo n.º 2
0
    def lrs_sign(self, msg):
        """Sign for LRS."""
        generator = sendrecv(self.server_addr, [Constants.GET_GENERATOR])
        stp_array = sendrecv(self.server_addr, [Constants.GET_STP_ARRAY])
        stp = powm(generator, self.pri_key)
        stp_idx = stp_array.index(stp)

        # modify stp_array to prevent duplicate voting
        stp_array.append(msg_hash(msg, sha1))

        return lrs.sign(msg, self.pri_key, stp_idx, stp_array, g=generator)
Exemplo n.º 3
0
# get the public keys for all ids in anon set
pubkeys = range(setsize)
for i in range(setsize):
	key = getpub(anonset[i])
	pubkeys[i] = key
	print key

	
# get LRS signature
# add private key to list of pub keys
pos = random.StrongRandom().randint(0,len(pubkeys))
L = pubkeys[:pos]+[comppub]+pubkeys[pos:]
# message to sign

f = open('ogst.pdf','rb')
msg1 = f.read()
m = msg1
print verify(sign(m,L,comppriv,pos),m)
print










Exemplo n.º 4
0
print z

"""
# get LRS signature
# add private key to list of pub keys
pos = random.StrongRandom().randint(0,len(pubkeys))
L = pubkeys[:pos]+[comppub]+pubkeys[pos:]
anonset = anonset[:pos]+[id]+anonset[pos:]
print anonset
"""
# message to sign

f = open(filename,'rb')
m = f.read()
# get the signature
s1 = sign(m,pubs,comppriv,z)
print verify(s1,m,pubs)
print

# save the signature to file
f = open('sigs/' + filename[7:] + '.sig','w')
# save the list of facebook ids, their corresponding public keys, and the signature
pickle.dump([ids,pubs,s1],f)