示例#1
0
 def test_nonTransitiveConvert(self):
     self.addMember()
     sig1 = groupsig.sign(b"Hello, World1!", self.memkeys[0], self.grpkey)
     sig2 = groupsig.sign(b"Hello, World2!", self.memkeys[0], self.grpkey)
     b = groupsig.verify(sig1, b"Hello, World1!", self.grpkey)
     self.assertTrue(b)
     b = groupsig.verify(sig2, b"Hello, World2!", self.grpkey)
     self.assertTrue(b)
     bkey = bldkey.bldkey_random(self.code, self.grpkey)
     out = groupsig.blind(self.grpkey, sig1, "Hello, World1!", bkey)
     bsig1 = out["bsig"]
     out = groupsig.blind(self.grpkey, sig2, "Hello, World2!", bkey)
     bsig2 = out["bsig"]
     bkey_pub = bldkey.bldkey_import(constants.GL19_CODE,
                                     bldkey.bldkey_export_pub(bkey))
     csigs1 = groupsig.convert([bsig1],
                               self.grpkey,
                               bkey_pub,
                               mgrkey=self.cnvkey)
     csigs2 = groupsig.convert([bsig2],
                               self.grpkey,
                               bkey_pub,
                               mgrkey=self.cnvkey)
     nym1 = groupsig.unblind(csigs1[0], bkey)
     nym2 = groupsig.unblind(csigs2[0], bkey)
     self.assertNotEqual(nym1['nym'], nym2['nym'])
示例#2
0
 def test_bldkeyExportImportPub(self):
     bldkey_str = bldkey.bldkey_export_pub(self.bldkey)
     bkey = bldkey.bldkey_import(self.code, bldkey_str)
     # This is quite useless, as import returns an exception if the FFI
     # method returns ffi.NULL. Maybe implementing a cmp function for
     # bld keys would be good for testing this (and also in general?)
     self.assertIsNot(ffi.NULL, bkey)
示例#3
0
import sys

from pygroupsig import groupsig
from pygroupsig import bldkey
from pygroupsig import blindsig
from pygroupsig import constants

if len(sys.argv) != 4:
    print("Usage: $python blind.py <bldkey str> <csig1 str> <csig2 str>")
    sys.exit()

groupsig.init(constants.GL19_CODE, 0)

# Import blinding key
bsk = bldkey.bldkey_import(constants.GL19_CODE, sys.argv[1])

# Import converted signatures
csig1 = blindsig.blindsig_import(constants.GL19_CODE, sys.argv[2])
csig2 = blindsig.blindsig_import(constants.GL19_CODE, sys.argv[3])

# Unblind
nym1 = groupsig.unblind(csig1, bsk)
nym2 = groupsig.unblind(csig2, bsk)

print("Sig1:\n\tNym: %s\n\tMessage: %s" % (nym1['nym'], nym1['msg']))
print("Sig2:\n\tNym: %s\n\tMessage: %s" % (nym2['nym'], nym2['msg']))