예제 #1
0
 def create_keypair(self, nonce):
     self.pk = ecdaa.ecdaa_member_public_key_FP256BN()
     self.sk = ecdaa.ecdaa_member_secret_key_FP256BN()
     ret = ecdaa.ecdaa_member_key_pair_FP256BN_generate(
         ecdaa.pointer(self.pk), ecdaa.pointer(self.sk), nonce, len(nonce),
         ecdaa.pointer(self.prng))
     if 0 != ret:
         raise JoinException('error creating join request: ' + str(ret))
예제 #2
0
    def process_join_response(self, cred, cred_sig):
        ret = ecdaa.ecdaa_credential_FP256BN_validate(ecdaa.pointer(cred),
                                                      ecdaa.pointer(cred_sig),
                                                      ecdaa.pointer(self.pk),
                                                      ecdaa.pointer(self.gpk))
        if 0 != ret:
            raise JoinException('credential signature is invalid: ' + str(ret))

        self.cred = cred
예제 #3
0
 def create_group(self):
     self.ipk = ecdaa.ecdaa_issuer_public_key_FP256BN()
     self.isk = ecdaa.ecdaa_issuer_secret_key_FP256BN()
     ret = ecdaa.ecdaa_issuer_key_pair_FP256BN_generate(
         ecdaa.pointer(self.ipk), ecdaa.pointer(self.isk),
         ecdaa.pointer(self.prng))
     if 0 != ret:
         raise CreationException('error creating issuer key-pair: ' +
                                 str(ret))
예제 #4
0
def verify(gpk, message, signature, revocations, basename):
    print('verifying \'' + message + '\' of length ' + str(len(message)))
    ret = ecdaa.ecdaa_signature_FP256BN_verify(ecdaa.pointer(signature),
                                               ecdaa.pointer(gpk),
                                               ecdaa.pointer(revocations),
                                               message, len(message), basename,
                                               len(basename))

    return ret
예제 #5
0
    def sign(self, message, basename):
        signature = ecdaa.ecdaa_signature_FP256BN()
        print('signing \'' + message + '\' of length ' + str(len(message)))
        ret = ecdaa.ecdaa_signature_FP256BN_sign(ecdaa.pointer(signature),
                                                 message, len(message),
                                                 basename, len(basename),
                                                 ecdaa.pointer(self.sk),
                                                 ecdaa.pointer(self.cred),
                                                 ecdaa.pointer(self.prng))
        if 0 != ret:
            raise SignException('error creating signature: ' + str(ret))

        return signature
예제 #6
0
    def __init__(self, gpk):
        self.gpk = gpk

        self.prng = ecdaa.ecdaa_prng()
        ret = ecdaa.ecdaa_prng_init(ecdaa.pointer(self.prng))
        if 0 != ret:
            raise PRNGException('error initializing prng: ' + str(ret))
예제 #7
0
    def process_join_request(self, member_pk, nonce):
        cred = ecdaa.ecdaa_credential_FP256BN()
        cred_sig = ecdaa.ecdaa_credential_FP256BN_signature()
        ret = ecdaa.ecdaa_member_public_key_FP256BN_validate(
            ecdaa.pointer(member_pk), nonce, len(nonce))
        if 0 != ret:
            raise JoinException('member public key is invalid: ' + str(ret))

        ret = ecdaa.ecdaa_credential_FP256BN_generate(ecdaa.pointer(cred),
                                                      ecdaa.pointer(cred_sig),
                                                      ecdaa.pointer(self.isk),
                                                      ecdaa.pointer(member_pk),
                                                      ecdaa.pointer(self.prng))
        if 0 != ret:
            raise JoinException('error processing join request: ' + str(ret))

        return (cred, cred_sig)