#NEWLINE# def time_it_all( repetitions = 1000 ) : #NEWLINE# #INDENT# import time #NEWLINE# print ( ( 'Timings of operations (%s repetitions)' % repetitions ) ) #NEWLINE# t0 = time . clock ( ) #NEWLINE# for _ in range ( repetitions ) : #NEWLINE# #INDENT# i = 0 #NEWLINE# #UNINDENT# T = ( time . clock ( ) - t0 ) #NEWLINE# print ( ( '%.3f ms\tIdle' % ( ( 1000 * T ) / repetitions ) ) ) #NEWLINE# t0 = time . clock ( ) #NEWLINE# for _ in range ( repetitions ) : #NEWLINE# #INDENT# params = cred_setup ( ) #NEWLINE# #UNINDENT# T = ( time . clock ( ) - t0 ) #NEWLINE# print ( ( '%.3f ms\tCredential Group Setup' % ( ( 1000 * T ) / repetitions ) ) ) #NEWLINE# ( G , _ , _ , o ) = params #NEWLINE# public_attr = [ o . random ( ) , o . random ( ) ] #NEWLINE# private_attr = [ o . random ( ) , o . random ( ) ] #NEWLINE# n = ( len ( public_attr ) + len ( private_attr ) ) #NEWLINE# t0 = time . clock ( ) #NEWLINE# for _ in range ( repetitions ) : #NEWLINE# #INDENT# ( ipub , isec ) = cred_CredKeyge ( params , n ) #NEWLINE# #UNINDENT# T = ( time . clock ( ) - t0 ) #NEWLINE# print ( ( '%.3f ms\tCredential Key generation' % ( ( 1000 * T ) / repetitions ) ) ) #NEWLINE# t0 = time . clock ( ) #NEWLINE# for _ in range ( repetitions ) : #NEWLINE# #INDENT# keypair = cred_UserKeyge ( params ) #NEWLINE# #UNINDENT# T = ( time . clock ( ) - t0 ) #NEWLINE# print ( ( '%.3f ms\tUser Key generation' % ( ( 1000 * T ) / repetitions ) ) ) #NEWLINE# t0 = time . clock ( ) #NEWLINE# for _ in range ( repetitions ) : #NEWLINE# #INDENT# ( pub , EGenc , sig ) = cred_secret_issue_user ( params , keypair , private_attr ) #NEWLINE# #UNINDENT# T = ( time . clock ( ) - t0 ) #NEWLINE# print ( ( '%.3f ms\tUser Key generation (proof)' % ( ( 1000 * T ) / repetitions ) ) ) #NEWLINE# if __debug__ : #NEWLINE# #INDENT# _check_enc ( params , keypair , EGenc , private_attr ) #NEWLINE# #UNINDENT# t0 = time . clock ( ) #NEWLINE# for _ in range ( repetitions ) : #NEWLINE# #INDENT# if ( not cred_secret_issue_user_check ( params , pub , EGenc , sig ) ) : #NEWLINE# #INDENT# raise Exception ( 'User key generation invalid' ) #NEWLINE# #UNINDENT# #UNINDENT# T = ( time . clock ( ) - t0 ) #NEWLINE# print ( ( '%.3f ms\tUser Key generation (verification)' % ( ( 1000 * T ) / repetitions ) ) ) #NEWLINE# t0 = time . clock ( ) #NEWLINE# for _ in range ( repetitions ) : #NEWLINE# #INDENT# ( u , EncE , sig ) = cred_secret_issue ( params , pub , EGenc , ipub , isec , public_attr ) #NEWLINE# #UNINDENT# T = ( time . clock ( ) - t0 ) #NEWLINE# print ( ( '%.3f ms\tCredential issuing' % ( ( 1000 * T ) / repetitions ) ) ) #NEWLINE# if __debug__ : #NEWLINE# #INDENT# _internal_ckeck ( keypair , u , EncE , isec , ( public_attr + private_attr ) ) #NEWLINE# #UNINDENT# t0 = time . clock ( ) #NEWLINE# for _ in range ( repetitions ) : #NEWLINE# #INDENT# mac = cred_secret_issue_user_decrypt ( params , keypair , u , EncE , ipub , public_attr , EGenc , sig ) #NEWLINE# #UNINDENT# T = ( time . clock ( ) - t0 ) #NEWLINE# print ( ( '%.3f ms\tCredential decryption & verification' % ( ( 1000 * T ) / repetitions ) ) ) #NEWLINE# t0 = time . clock ( ) #NEWLINE# for _ in range ( repetitions ) : #NEWLINE# #INDENT# ( creds , sig ) = cred_show ( params , ipub , mac , sig , ( public_attr + private_attr ) ) #NEWLINE# #UNINDENT# T = ( time . clock ( ) - t0 ) #NEWLINE# print ( ( '%.3f ms\tCredential Show (proof)' % ( ( 1000 * T ) / repetitions ) ) ) #NEWLINE# t0 = time . clock ( ) #NEWLINE# for _ in range ( repetitions ) : #NEWLINE# #INDENT# if ( not cred_show_check ( params , ipub , isec , creds , sig ) ) : #NEWLINE# #INDENT# raise Exception ( 'Credential show failed.' ) #NEWLINE# #UNINDENT# #UNINDENT# T = ( time . clock ( ) - t0 ) #NEWLINE# print ( ( '%.3f ms\tCredential Show (verification)' % ( ( 1000 * T ) / repetitions ) ) )