Exemplo n.º 1
0
 def fak_stat(ansamble_of_sig):
     print(mode)
     sig_len = len(ansamble_of_sig[0])
     if len(ansamble_of_sig) > 0:
         asnsam_fak_list = auto_corel_all(ansamble_of_sig, mode)
         printFullStat(asnsam_fak_list, 1, sig_len - 1, True)
         printFullStat(asnsam_fak_list, 1, sig_len - 1)
Exemplo n.º 2
0
def test_cross_correl(source_sig, ansamble_of_sig):
    sig1_ = copy.deepcopy(source_sig)
    ansamble_of_pereodic_cross_corel_list = modules.arr_procedures.corel_source_and_rest(
        sig1_, ansamble_of_sig, "PFVK")
    print("\nPFVK")
    cal.printFullStat(ansamble_of_pereodic_cross_corel_list, 0,
                      len(source_sig), True)
    cal.printFullStat(ansamble_of_pereodic_cross_corel_list, 0,
                      len(source_sig))
Exemplo n.º 3
0
 def fvk_stat(ansamble_of_sig):
     print(mode)
     sig_len = len(ansamble_of_sig[0])
     if len(ansamble_of_sig) > 0:
         pair_list = getPair([i for i in range(0, len(ansamble_of_sig))])
         # cross_correl_btwn_pairs you can use anothe method correl_source_and_rest
         fvk_sig_list = cross_corel_btwn_pairs(ansamble_of_sig, mode)
         printFullStat(fvk_sig_list, 0, sig_len, True, list_of_num=pair_list)
         printFullStat(fvk_sig_list, 0, sig_len, list_of_num=pair_list)
Exemplo n.º 4
0
def test_cross_correl (source_sig, ansamble_of_sig):
    sig1_ = copy.deepcopy(source_sig)
    ansamble_of_pereodic_cross_corel_list = corel_source_and_rest(sig1_, ansamble_of_sig, "PFVK")
    print("\nPFVK")
    printFullStat(ansamble_of_pereodic_cross_corel_list, 0, len(source_sig), True)
    printFullStat(ansamble_of_pereodic_cross_corel_list, 0, len(source_sig))

    ansamble_of_apereodic_cross_corel_list = corel_source_and_rest(sig1_, ansamble_of_sig, "AFVK")
    print("\nAFVK")
    printFullStat(ansamble_of_apereodic_cross_corel_list, 0, len(source_sig), True)
    printFullStat(ansamble_of_apereodic_cross_corel_list, 0, len(source_sig))
Exemplo n.º 5
0
    # print(len(only_decimated_signals))
    # asnsam_pfak_list = cal.auto_corel_all(only_decimated_signals, "PFAK")
    # cal.printFullStat(asnsam_pfak_list, 1, 256 - 1, True)
    # cal.printFullStat(asnsam_pfak_list, 1, 256 - 1)
    pfak_function = modules.arr_procedures.ansamble_correlation('PFAK')
    afak_function = modules.arr_procedures.ansamble_correlation('AFAK')
    pfvk_function = modules.arr_procedures.ansamble_correlation('PFVK')
    afvk_function = modules.arr_procedures.ansamble_correlation('AFVK')

    pfak_function(only_decimated_signals[1:10])
    afak_function(only_decimated_signals[1:10])
    pfvk_function(only_decimated_signals[1:10])
    afvk_function(only_decimated_signals[1:10])


if __name__ == '__main__':
    # Generating random sequence with 256 el
    cs = CryptoSignal(256)
    source_sig = cs.generateDefRandomSeq(32)

    #Source signal calculate PFAK, AFAK
    pfak_list, afak_list = test_auto_correl(source_sig, len(source_sig))

    cal.printFullStat([pfak_list], 1, len(source_sig) - 1, True)

    # Getting singals created with decimation method
    decimations = modules.arr_procedures.getDecimation(source_sig)
    test_stat_correl(decimations)

    #For each decimation signal calculate PFAK AFAK
Exemplo n.º 6
0
    # Decimated signals without first sig(because its the same as source)
    b = list()
    for item in decimation_signals:
        # we only need signals so use 0th pos
        b.append(item[0])
    b.pop(0)

    # cal.printPair(d)

    print("\nDecimation: ", decimation_signals)

    ansamble_of_pereodic_cross_corel_list = modules.arr_procedures.corel_source_and_rest(
        sig1_, b, "PFVK")
    print("\nPFVK")
    cal.printFullStat(ansamble_of_pereodic_cross_corel_list, 0, p, True)
    cal.printFullStat(ansamble_of_pereodic_cross_corel_list, 0, p)

    ansamble_of_apereodic_cross_corel_list = modules.arr_procedures.corel_source_and_rest(
        sig1_, b, "AFVK")
    print("\nAFVK")
    cal.printFullStat(ansamble_of_apereodic_cross_corel_list, 0, p, True)
    cal.printFullStat(ansamble_of_apereodic_cross_corel_list, 0, p)

    ansamble_of_pereodic_auto_corel_list = modules.arr_procedures.corel_source_and_rest(
        sig1_, b, "PFAK")
    print("\nPFAK")
    cal.printFullStat(ansamble_of_pereodic_auto_corel_list, 1, p - 1, True)
    cal.printFullStat(ansamble_of_pereodic_auto_corel_list, 1, p - 1)

    ansamble_of_apereodic_auto_corel_list = modules.arr_procedures.corel_source_and_rest(
Exemplo n.º 7
0
    # printing hadamar signals
    print("HADAMAR")
    print(hadamar_sig_list)
    # for i in range(0, len(hadamar_sig_list)):
    #   print(i + 1, ") ", list(hadamar_sig_list[i]))

    # printing generated cryptographic signals
    print("\nCRYPTOSIG")
    print_sig_in_list(crypto_sig_ansam)

    # counting numbers of cryptographic signals
    sig_num = [i for i in range(0, len(crypto_sig_ansam))]

    print("\nPFAK CRYPTOGRAPHIC SIGNALS")
    asnsam_pfak_list = modules.arr_procedures.auto_corel_all(crypto_sig_ansam, "PFAK")
    cal.printFullStat(asnsam_pfak_list, 1, p - 1, True, sig_num)
    cal.printFullStat(asnsam_pfak_list, 1, p - 1, list_of_num=sig_num)

    pair_list_cryptosig = cal.getPair([i for i in range(0, len(crypto_sig_ansam))])
    print("\nPFVK CRYPTOGRAPHIC SIGNALS")
    pfvk_cryptosig_list = modules.arr_procedures.cross_corel_btwn_pairs(crypto_sig_ansam, "PFVK")
    cal.printFullStat(pfvk_cryptosig_list, 0, p, True, list_of_num=pair_list_cryptosig )
    cal.printFullStat(pfvk_cryptosig_list, 0, p, list_of_num=pair_list_cryptosig)


    dersig, combinations = derivativeSigALL(crypto_sig_ansam, hadamar_sig_list)
    # print(dersig)
    print(combinations)

    pair_list_derivative = cal.getPair([i for i in range(0,len(dersig))])
    #print(pair_list)
Exemplo n.º 8
0
import numpy as np
from modules import calculations as cal

import math

if __name__ == "__main__":
    p = 64
    h = Hadamar(p)
    hadamar_sig_list = h.getHadamMatrix()
    for i in range(p - 50, p):
        print(i, ") ", hadamar_sig_list[i].tolist())

    hadamar_pfvk_list = modules.arr_procedures.cross_corel_btwn_pairs(
        hadamar_sig_list[p - 10:p].tolist(), "PFVK")

    cal.printFullStat(hadamar_pfvk_list, 0, p)
    cal.printFullStat(hadamar_pfvk_list, 0, p, True)

    # calculation with formula
    a = [
        0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
        0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
        0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0
    ]

    print(kurtosis(a) / math.sqrt(p))

    moment4 = moment(a, moment=4)
    print("Moment4 = ", moment4)
    var = np.var(a)
    print("D^2 = ", var)
Exemplo n.º 9
0
    cs = CryptoSignal(p)
    # sig1 = cs.generateRandomSeq()
    # print(sig1)
    # print("AFAK",cal.getCorellation(sig1,sig1,True))

    # pfak rmax = 4 L =16
    # sig2 = cs.generateDefRandomSeq(4)
    # print(sig2)
    # print("PFAK",cal.getCorellation(sig2, sig2))

    # sig3 = cs.generateDefRandomSeq2(2)
    # print(sig3)
    # print("PFAK",cal.getCorellation(sig3, sig3))

    # generete asnsamble of signals with defined Rmax
    ansam = cs.genereteAnsambleOfCryptoSig(5, 140)
    print(ansam)

    # getting all pfvks
    asnsam_pfvk_list = modules.arr_procedures.cross_corel_btwn_pairs(
        ansam, "PFVK")
    # calculate stat for pfaks
    cal.printFullStat(asnsam_pfvk_list, 0, p, True)
    cal.printFullStat(asnsam_pfvk_list, 0, p)

    # for sig in ansam:
    #  print(sig)
    #  pfak_list = cal.getCorellation(sig,sig)
    #   print("PFAK",pfak_list)
    #   cal.printFullStat(pfak_list,1,255,True)