From 65207c9fde20c18a4e68ac4118d916126c5456ed Mon Sep 17 00:00:00 2001 From: Jie Date: Mon, 18 Apr 2022 21:15:44 -0400 Subject: [PATCH] Deleted unused files --- CTng/IO/CRV.go | 52 ---------- CTng/IO/HandleSTHs.go | 40 -------- CTng/IO/IO_config.go | 14 --- CTng/IO/IO_test.go | 47 --------- CTng/IO/Readme.md | 18 ---- CTng/IO/Testing_json/CRV_read_test.json.gz | Bin 49 -> 0 bytes CTng/IO/Testing_json/CRV_write_test.json.gz | Bin 49 -> 0 bytes CTng/IO/Testing_json/Read_sth_test.json | 20 ---- CTng/IO/Testing_json/Write_sth_test.json | 20 ---- .../IO/Testing_json/accusation_read_test.json | 14 --- .../Testing_json/accusation_write_test.json | 28 ------ .../pom_accusation_read_test.json | 12 --- .../pom_accusation_write_test.json | 12 --- .../Testing_json/pom_conflicts_read_test.json | 23 ----- .../pom_conflicts_write_test.json | 18 ---- CTng/IO/Testinglog.txt | 26 ----- CTng/IO/accusation.go | 35 ------- CTng/IO/pom_accusation.go | 34 ------- CTng/IO/pom_conflicts.go | 49 ---------- CTng/PoM/Gossiper_Process_Accusation_List.go | 92 ------------------ CTng/PoM/PoM_test.txt | 46 --------- CTng/PoM/Readme.md | 6 -- CTng/PoM/Testing log.txt | 32 ------ 23 files changed, 638 deletions(-) delete mode 100644 CTng/IO/CRV.go delete mode 100644 CTng/IO/HandleSTHs.go delete mode 100644 CTng/IO/IO_config.go delete mode 100644 CTng/IO/IO_test.go delete mode 100644 CTng/IO/Readme.md delete mode 100644 CTng/IO/Testing_json/CRV_read_test.json.gz delete mode 100644 CTng/IO/Testing_json/CRV_write_test.json.gz delete mode 100644 CTng/IO/Testing_json/Read_sth_test.json delete mode 100644 CTng/IO/Testing_json/Write_sth_test.json delete mode 100644 CTng/IO/Testing_json/accusation_read_test.json delete mode 100644 CTng/IO/Testing_json/accusation_write_test.json delete mode 100644 CTng/IO/Testing_json/pom_accusation_read_test.json delete mode 100644 CTng/IO/Testing_json/pom_accusation_write_test.json delete mode 100644 CTng/IO/Testing_json/pom_conflicts_read_test.json delete mode 100644 CTng/IO/Testing_json/pom_conflicts_write_test.json delete mode 100644 CTng/IO/Testinglog.txt delete mode 100644 CTng/IO/accusation.go delete mode 100644 CTng/IO/pom_accusation.go delete mode 100644 CTng/IO/pom_conflicts.go delete mode 100644 CTng/PoM/Gossiper_Process_Accusation_List.go delete mode 100644 CTng/PoM/PoM_test.txt delete mode 100644 CTng/PoM/Readme.md delete mode 100644 CTng/PoM/Testing log.txt diff --git a/CTng/IO/CRV.go b/CTng/IO/CRV.go deleted file mode 100644 index bde604e..0000000 --- a/CTng/IO/CRV.go +++ /dev/null @@ -1,52 +0,0 @@ -package IO - -import ( - "bytes" - "compress/gzip" - "fmt" - "io/ioutil" - "log" -) - -type crv struct { - CRV []byte `json:"crv"` -} - -type crv_delta struct { - CRV_delta []byte -} - -func Write_jsongz(filename string, data crv) { - var fileGZ bytes.Buffer - zipper := gzip.NewWriter(&fileGZ) - - _, err := zipper.Write(data.CRV) - if err != nil { - log.Fatalf("zipper.Write ERROR: %+v", err) - } - zipper.Close() - //fmt.Println(bytes.NewBuffer(fileGZ.Bytes())) - err = ioutil.WriteFile(filename, fileGZ.Bytes(), 0644) - if err != nil { - fmt.Printf("WriteFileGZ ERROR: %+v", err) - } -} -func Read_jsongz(filename string) crv { - rzip, err := ioutil.ReadFile(filename) - if err != nil { - log.Fatal("ioutil.ReadFile", err) - } - //fmt.Println(bytes.NewBuffer(rzip)) - r, err := gzip.NewReader(bytes.NewBuffer(rzip)) - if err != nil { - log.Fatal("gzip.NewReader", err) - } - defer r.Close() - var crv_1 crv - crv_1.CRV, err = ioutil.ReadAll(r) - if err != nil { - log.Fatal("IO.Reader", err) - } - fmt.Println(bytes.NewBuffer(crv_1.CRV)) - return crv_1 -} diff --git a/CTng/IO/HandleSTHs.go b/CTng/IO/HandleSTHs.go deleted file mode 100644 index 70db661..0000000 --- a/CTng/IO/HandleSTHs.go +++ /dev/null @@ -1,40 +0,0 @@ -package IO - -import ( - "CTng/util" - "encoding/json" - "fmt" -) - -type Sths struct { - Sths []sth `json:"sths"` -} - -type sth struct { - Pre_timestamp string `json:"pre_timestamp"` - Timestamp string `json:"timestamp"` - Number_MMD_periods int `json:"number_MMD_periods"` - Sequence_number int `json:"sequence_number"` - Head string `json:"head"` - Log_signature string `json:"log_signature"` -} - -func Readsth(filename string) (Sths, error) { - // we initialize our sths - var sths Sths - byteValue, err := util.ReadByte(filename) - if err != nil { - return sths, err - } - // we unmarshal our byteArray which contains our - // jsonFile's content into 'sths' which we defined above - json.Unmarshal(byteValue, &sths) - // initialize ts pre-timestamp and timestamp arrays - fmt.Println("The number of sths contained in this json file: ", len(sths.Sths)) - fmt.Println("Reading finished successfully") - return sths, nil -} - -func WriteSTH(filename string, data Sths) { - util.WriteData(filename, data) -} diff --git a/CTng/IO/IO_config.go b/CTng/IO/IO_config.go deleted file mode 100644 index ea87eff..0000000 --- a/CTng/IO/IO_config.go +++ /dev/null @@ -1,14 +0,0 @@ -package IO - -type IOinterface interface { - Readsth(string) (Sths, error) - Writesth(string) - Read_accusations(string) (accusations, error) - Write_accusations(string, accusations) - //Pom01 is Pom due to conflicting information - Read_Pom01(string) (Pom01DB, error) - Write_Pom01(string, Pom01DB) - //Pom02 is Pom due to enough number of accusations - Read_Pom02(string) (Pom02DB, error) - Write_Pom02(string, Pom02DB) -} diff --git a/CTng/IO/IO_test.go b/CTng/IO/IO_test.go deleted file mode 100644 index a73ace0..0000000 --- a/CTng/IO/IO_test.go +++ /dev/null @@ -1,47 +0,0 @@ -package IO - -import ( - "testing" -) - -func TestHandleSths(t *testing.T) { - print("Handle Sths test start\n") - sths_to_write, err := Readsth("Testing_json/Read_sth_test.json") - if err != nil { - t.Errorf("%s", err) - } - WriteSTH("Testing_json/Write_sth_test.json", sths_to_write) -} - -func TestPom_conflicts(t *testing.T) { - print("\n PoM Due to conflicts test start\n") - poms_to_write, err := ReadPom01("Testing_json/pom_conflicts_read_test.json") - if err != nil { - t.Errorf("%s", err) - } - WritePom01("Testing_json/pom_conflicts_write_test.json", poms_to_write) -} - -func TestPom_accusation(t *testing.T) { - print("\n PoM due to accusations test start\n") - poms_to_write, err := ReadPom02("Testing_json/pom_accusation_read_test.json") - if err != nil { - t.Errorf("%s", err) - } - WritePom02("Testing_json/pom_accusation_write_test.json", poms_to_write) -} - -func TestAccusations(t *testing.T) { - print("\n Accusation test start\n") - accusations_to_write, err := Read_accusations("Testing_json/accusation_read_test.json") - if err != nil { - t.Errorf("%s", err) - } - Write_accusations("Testing_json/accusation_write_test.json", accusations_to_write) -} - -func TestCRV(t *testing.T) { - print("\n CRV test start\n") - CRV_to_write := Read_jsongz("Testing_json/CRV_Read_test.json.gz") - Write_jsongz("Testing_json/CRV_Write_test.json.gz", CRV_to_write) -} diff --git a/CTng/IO/Readme.md b/CTng/IO/Readme.md deleted file mode 100644 index d9026fd..0000000 --- a/CTng/IO/Readme.md +++ /dev/null @@ -1,18 +0,0 @@ -Json files for testing are located in Testing_json folder - -IO_test covers the testing functions for all go files in this folder - -IO.go contains 2 functions: - a generic read function that reads from a json file and returns a ByteArray - a generic write functions that take a struct and (the targeted) file path as input - - Note: The purpose of the generic read/write function is to make code more compact, it is not designed for use cases - - Function Use Cases (both read and write): - 1) HandleSths - 2) Accusations (mainly for emergency cases when the server needs to go offline, and the number of the accusations at that exact moment didn't reach the threshold for genrating POM) - 3) POM generated due to enough number of Accusaations - 4) POM generated due to conflicting information - 5) CRV - - Specific Use Case in presented in IO_test.go, sample files are in Testing_json folder diff --git a/CTng/IO/Testing_json/CRV_read_test.json.gz b/CTng/IO/Testing_json/CRV_read_test.json.gz deleted file mode 100644 index d702de9a9b33b97955569311f107a7926de78fef..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 49 zcmb2|=3oGW|Et2h^t6I61sWL`7#J08Dlutba25z#_4Fwd3j@Rd|4siNMJoVR0sv#x B5D5SP diff --git a/CTng/IO/Testing_json/CRV_write_test.json.gz b/CTng/IO/Testing_json/CRV_write_test.json.gz deleted file mode 100644 index d702de9a9b33b97955569311f107a7926de78fef..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 49 zcmb2|=3oGW|Et2h^t6I61sWL`7#J08Dlutba25z#_4Fwd3j@Rd|4siNMJoVR0sv#x B5D5SP diff --git a/CTng/IO/Testing_json/Read_sth_test.json b/CTng/IO/Testing_json/Read_sth_test.json deleted file mode 100644 index 9bcdf98..0000000 --- a/CTng/IO/Testing_json/Read_sth_test.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "Sths": [ - { - "pre_timestamp": "2022-02-16T21:26:00.0562729-05:00", - "timestamp": "2022-02-16T21:26:29.9550592-05:00", - "number_MMD_periods": 2, - "sequence_number": 1, - "head": "PEM_Base64_certificate_placeholder", - "log_signature": "Threshold_signiture_placeholder" - }, - { - "pre_timestamp": "2022-02-16T21:27:02.0103228-05:00", - "timestamp": "2022-02-16T21:27:21.2408456-05:00", - "number_MMD_periods": 3, - "sequence_number": 1, - "head": "PEM_Base64_certificate_placeholder", - "log_signature": "Threshold_signiture_placeholder" - } - ] - } \ No newline at end of file diff --git a/CTng/IO/Testing_json/Write_sth_test.json b/CTng/IO/Testing_json/Write_sth_test.json deleted file mode 100644 index 58ab0f4..0000000 --- a/CTng/IO/Testing_json/Write_sth_test.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "sths": [ - { - "pre_timestamp": "2022-02-16T21:26:00.0562729-05:00", - "timestamp": "2022-02-16T21:26:29.9550592-05:00", - "number_MMD_periods": 2, - "sequence_number": 1, - "head": "PEM_Base64_certificate_placeholder", - "log_signature": "Threshold_signiture_placeholder" - }, - { - "pre_timestamp": "2022-02-16T21:27:02.0103228-05:00", - "timestamp": "2022-02-16T21:27:21.2408456-05:00", - "number_MMD_periods": 3, - "sequence_number": 1, - "head": "PEM_Base64_certificate_placeholder", - "log_signature": "Threshold_signiture_placeholder" - } - ] - } \ No newline at end of file diff --git a/CTng/IO/Testing_json/accusation_read_test.json b/CTng/IO/Testing_json/accusation_read_test.json deleted file mode 100644 index 317fbbb..0000000 --- a/CTng/IO/Testing_json/accusation_read_test.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "accusations": [ - {"accusers":["monitor_DNS_placeholder_01","monitor_DNS_placeholder_02"], - "entity_DN": "logger_DNS_placeholder_01", - "num_acc": 2, - "partial_sigs":["parital_sigs_01","parital_sigs_02"] - }, - {"accusers":["monitor_DNS_placeholder_03","monitor_DNS_placeholder_04"], - "entity_DN": "logger_DNS_placeholder_02", - "num_acc": 2, - "partial_sigs":["parital_sigs_01","parital_sigs_02"] - } - ] - } \ No newline at end of file diff --git a/CTng/IO/Testing_json/accusation_write_test.json b/CTng/IO/Testing_json/accusation_write_test.json deleted file mode 100644 index 6bb56c1..0000000 --- a/CTng/IO/Testing_json/accusation_write_test.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "accusations": [ - { - "accusers": [ - "monitor_DNS_placeholder_01", - "monitor_DNS_placeholder_02" - ], - "entity_DN": "logger_DNS_placeholder_01", - "num_acc": 2, - "partial_sigs": [ - "parital_sigs_01", - "parital_sigs_02" - ] - }, - { - "accusers": [ - "monitor_DNS_placeholder_03", - "monitor_DNS_placeholder_04" - ], - "entity_DN": "logger_DNS_placeholder_02", - "num_acc": 2, - "partial_sigs": [ - "parital_sigs_01", - "parital_sigs_02" - ] - } - ] - } \ No newline at end of file diff --git a/CTng/IO/Testing_json/pom_accusation_read_test.json b/CTng/IO/Testing_json/pom_accusation_read_test.json deleted file mode 100644 index 78d8ffb..0000000 --- a/CTng/IO/Testing_json/pom_accusation_read_test.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "pom02s": [ - { - "entity_DN": "logger_DNS_placeholder_01", - "signature_TH": "Threshold_signiture_placeholder_01" - }, - { - "entity_DN": "logger_DNS_placeholder_02", - "signature_TH": "Threshold_signiture_placeholder_02" - } - ] - } \ No newline at end of file diff --git a/CTng/IO/Testing_json/pom_accusation_write_test.json b/CTng/IO/Testing_json/pom_accusation_write_test.json deleted file mode 100644 index e0bdb23..0000000 --- a/CTng/IO/Testing_json/pom_accusation_write_test.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "pom02s": [ - { - "entity_DN": "logger_DNS_placeholder_01", - "signature_TH": "Threshold_signiture_placeholder_01" - }, - { - "entity_DN": "logger_DNS_placeholder_02", - "signature_TH": "Threshold_signiture_placeholder_02" - } - ] - } \ No newline at end of file diff --git a/CTng/IO/Testing_json/pom_conflicts_read_test.json b/CTng/IO/Testing_json/pom_conflicts_read_test.json deleted file mode 100644 index 3a803a8..0000000 --- a/CTng/IO/Testing_json/pom_conflicts_read_test.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "poms": [ - { - "entity": "logger", - "obj_1": { - "application": "URL_placeholder", - "type_data" :301, - "signer" : "8.8.8.8", - "signature": "signiture_placeholder", - "timestamp": "2022-02-16T21:27:02.0103228-05:00", - "payload":"Gossip_data_place_holder_something" - }, - "obj_2": { - "application": "URL_placeholder", - "type_data" :301, - "signer" : "8.8.8.8", - "signature": "signiture_placeholder", - "timestamp": "2022-02-16T21:27:02.0103228-05:00", - "payload":"Gossip_data_place_holder_something_different" - } - } - ] -} \ No newline at end of file diff --git a/CTng/IO/Testing_json/pom_conflicts_write_test.json b/CTng/IO/Testing_json/pom_conflicts_write_test.json deleted file mode 100644 index 0f74e62..0000000 --- a/CTng/IO/Testing_json/pom_conflicts_write_test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "poms": [ - { - "application": "", - "type": "", - "signer": "", - "signature": [ - "", - "" - ], - "timestamp": "", - "payload": [ - "", - "" - ] - } - ] - } \ No newline at end of file diff --git a/CTng/IO/Testinglog.txt b/CTng/IO/Testinglog.txt deleted file mode 100644 index 2db4943..0000000 --- a/CTng/IO/Testinglog.txt +++ /dev/null @@ -1,26 +0,0 @@ -PS C:\Users\12702\SDP\SDP--PKI-CyberSec-\CTng\IO> go test -Handle Sths test start -The number of sths contained in this json file: 2 -Reading finished successfully - - PoM Due to conflicts test start -Number of PoMs Fetched: 1 -The payload of the first gossip object from the Poms[0] is Gossip_data_place_holder_something -The payload of the second gossip object from the Poms[0] is Gossip_data_place_holder_something_different -Reading finished successfully - - PoM due to accusations test start -Total number of PoMs in this json file is: 2 -The Domain name of the first accused entity is: logger_DNS_placeholder_01 -Reading finished successfully - - Accusation test start -Total number of entities accuseds in this json file is: 2 -Total number of accusers are: 2 -Reading finished successfully - - CRV test start -{"crv","00022B9A000000010001"} - -PASS -ok CTng/IO 0.237s \ No newline at end of file diff --git a/CTng/IO/accusation.go b/CTng/IO/accusation.go deleted file mode 100644 index dd9e2ef..0000000 --- a/CTng/IO/accusation.go +++ /dev/null @@ -1,35 +0,0 @@ -package IO - -import ( - "CTng/util" - "encoding/json" - "fmt" -) - -type accusations struct { - Accusations []accusation `json:"accusations"` -} - -type accusation struct { - Accusers []string `json:"accusers"` - Entity_DN string `json:"entity_DN"` - Num_acc int `json:"num_acc"` - Partial_sigs []string `json:"partial_sigs"` -} - -func Read_accusations(filename string) (accusations, error) { - var accs accusations - byteValue, err := util.ReadByte(filename) - if err != nil { - return accs, err - } - json.Unmarshal(byteValue, &accs) - println("Total number of entities accuseds in this json file is: ", len(accs.Accusations)) - println("Total number of accusers are: ", len(accs.Accusations[0].Accusers)) - fmt.Println("Reading finished successfully") - return accs, nil -} - -func Write_accusations(filename string, data accusations) { - util.WriteData(filename, data) -} diff --git a/CTng/IO/pom_accusation.go b/CTng/IO/pom_accusation.go deleted file mode 100644 index c75c0fe..0000000 --- a/CTng/IO/pom_accusation.go +++ /dev/null @@ -1,34 +0,0 @@ -package IO - -// This file handles the PoM generated due to enough number of accusations -import ( - "CTng/util" - "encoding/json" - "fmt" -) - -type Pom02DB struct { - Pom02s []Pom02 `json:"pom02s"` -} - -type Pom02 struct { - Entity_DN string `json:"entity_DN"` - Signature_TH string `json:"signature_TH"` -} - -func ReadPom02(filename string) (Pom02DB, error) { - var poms Pom02DB - byteValue, err := util.ReadByte(filename) - if err != nil { - return poms, err - } - json.Unmarshal(byteValue, &poms) - println("Total number of PoMs in this json file is: ", len(poms.Pom02s)) - println("The Domain name of the first accused entity is: ", poms.Pom02s[0].Entity_DN) - fmt.Println("Reading finished successfully") - return poms, nil -} - -func WritePom02(filename string, data Pom02DB) { - util.WriteData(filename, data) -} diff --git a/CTng/IO/pom_conflicts.go b/CTng/IO/pom_conflicts.go deleted file mode 100644 index b37cc71..0000000 --- a/CTng/IO/pom_conflicts.go +++ /dev/null @@ -1,49 +0,0 @@ -package IO - -// This file handles the PoM generated due to conflicting information -import ( - "CTng/gossip" - "CTng/util" - "encoding/json" - "fmt" -) - -type Pom01DB struct { - Pom01s []Pom01 `json:"poms"` -} - -type Pom01 gossip.Gossip_object - -func ReadPom01(filename string) (Pom01DB, error) { - var poms Pom01DB - byteValue, err := util.ReadByte(filename) - if err != nil { - return poms, err - } - json.Unmarshal(byteValue, &poms) - var length = len(poms.Pom01s) - println("Number of PoMs Fetched: ", length) - println("The payload of the first gossip object from the Poms[0] is ", poms.Pom01s[0].Payload[0]) - println("The payload of the second gossip object from the Poms[0] is ", poms.Pom01s[0].Payload[1]) - /* - ts1 := make([]time.Time, length+1) - ts2 := make([]time.Time, length+1) - for i := 0; i < len(poms.Pom01s); i++ { - //convert the time to make it more readable, convert it to golang standard - ts1[i], err = time.Parse(time.RFC3339, poms.Pom01s[i].Obj_1.Timestamp) - if err != nil { - fmt.Println(err) - } - ts2[i], err = time.Parse(time.RFC3339, poms.Pom01s[i].Obj_2.Timestamp) - if err != nil { - fmt.Println(err) - } - } - */ - fmt.Println("Reading finished successfully") - return poms, nil -} - -func WritePom01(filename string, data Pom01DB) { - util.WriteData(filename, data) -} diff --git a/CTng/PoM/Gossiper_Process_Accusation_List.go b/CTng/PoM/Gossiper_Process_Accusation_List.go deleted file mode 100644 index a9756b2..0000000 --- a/CTng/PoM/Gossiper_Process_Accusation_List.go +++ /dev/null @@ -1,92 +0,0 @@ -package POM - -// import ( -// "CTng/IO" -// "CTng/crypto" -// "CTng/gossip" -// "errors" -// "fmt" -// ) - -// // This file is only for reference: Do not update it, use the mapping verison in Gossiper_Process_Accusation.go! - -// type AccusationDBList []EntityAccusations - -// //The Process_accusation Function returns 3 value -// //IO.PoM02: PoM due to enough number of accusations. The IO version can be write to json file directly (post-conversion) -// //bool: whether the gossiper should gossip this recently received accusation to other gossipers true indicates yes -// //error: error messages - -// //AccusationDB is passed as a pointer and will be modifed after the function - -// func Process_Accusation_List(new_acc gossip.Gossip_object, accs *AccusationDBList, c *crypto.CryptoConfig) (IO.Pom02, bool, error) { -// fmt.Println("The length of the accusation list before processing is: ", len(*accs)) -// //check if the accused entity has been accused by others already (if yes, it is already in the accusations data structure) -// for i := 0; i < len(*accs); i++ { -// if new_acc.Payload[0] == (*accs)[i].Entity_URL { -// //check if the accusation is a duplicate (from an existing accuser) -// for _, x := range (*accs)[i].Accusers { -// if x == new_acc.Signer { -// fmt.Println("The length of the accusation list after processing is: ", len(*accs)) -// fmt.Println("The accusation is a duplicate.") -// return IO.Pom02{}, false, errors.New("This is a duplicate accusation") -// } -// } -// //update the number of accusations and the list of accusers -// (*accs)[i].Accusers = append((*accs)[i].Accusers, new_acc.Signer) -// (*accs)[i].Num_acc++ -// p_sig, errp := crypto.SigFragmentFromString(new_acc.Signature[0]) -// if errp != nil { -// fmt.Println("partial sig conversion error (from string)") -// } -// (*accs)[i].Partial_sigs = append((*accs)[i].Partial_sigs, p_sig) -// fmt.Println("Accusation number and list of accusers updated.") -// fmt.Println("The length of the accusation list after processing is: ", len(*accs)) -// //Case1: PoM has already been generated, no need to generate again -// if (*accs)[i].PoM_status == true { -// return IO.Pom02{}, false, errors.New("There exists an PoM against this accused entity already.") -// } -// PoM_TH_accs := generate_accusation_pom_from_accused_entity((*accs)[i], c) -// //if new_pom is generated successfully, verify it -// err := verify_accusation_pom(PoM_TH_accs, c) -// if err == nil { -// //Case2: PoM is generated successfully, -// //set the PoM_status to true, -// //return the updated accusationsDB, -// //the generated PoM, and true (we still want to gossip the accusation to other gossipers) -// if err_pom == nil && PoM_TH_accs.Entity_DN != "" && (*accs)[i].PoM_status == false { -// sig_string, converr := PoM_TH_accs.Signature_TH.String() -// if converr != nil { -// fmt.Println(converr) -// } -// new_pom02 := IO.Pom02{ -// Entity_DN: PoM_TH_accs.Entity_DN, -// Signature_TH: sig_string, -// } -// (*accs)[i].PoM_status = true -// return new_pom02, true, nil -// } -// } else { -// //case3: PoM verification failed -// //we don't want to gossip this accusation to others -// return IO.Pom02{}, false, err -// } -// } -// } -// //if the for loop above went through, that means the accused entity is accused the 1st time -// q_sig, errq := crypto.SigFragmentFromString(new_acc.Signature[0]) -// if errq != nil { -// fmt.Println("partial sig conversion error (from string)") -// } -// new_entity := EntityAccusations{ -// Accusers: []string{new_acc.Signer}, -// Entity_URL: new_acc.Payload[0], -// Num_acc: 1, -// Partial_sigs: []crypto.SigFragment{q_sig}, -// PoM_status: false, -// } -// *accs = append(*accs, new_entity) -// fmt.Println("The length of the accusation list after processing is: ", len(*accs)) -// fmt.Println("New accused entity registered") -// return IO.Pom02{}, true, nil -// } diff --git a/CTng/PoM/PoM_test.txt b/CTng/PoM/PoM_test.txt deleted file mode 100644 index eb52763..0000000 --- a/CTng/PoM/PoM_test.txt +++ /dev/null @@ -1,46 +0,0 @@ -package POM - -import ( - "CTng/crypto" - "testing" -) - -func TestAccusationUpdates(t *testing.T) { - println("test start\n") - var accs AccusationDB - var cp1 Accusation - var cp2 Accusation - var cp3 Accusation - var cp4 Accusation - cp1.Accuser = "monitor_01_DNS_place_holder" - cp1.Entity_URL = "logger_01_DNS_place_holder" - cp1.Partial_sig = crypto.SigFragment{} - cp2.Accuser = "monitor_02_DNS_place_holder" - cp2.Entity_URL = "logger_02_DNS_place_holder" - cp2.Partial_sig = crypto.SigFragment{} - cp3.Accuser = "monitor_01_DNS_place_holder" - cp3.Entity_URL = "logger_02_DNS_place_holder" - cp3.Partial_sig = crypto.SigFragment{} - cp4.Accuser = "monitor_02_DNS_place_holder" - cp4.Entity_URL = "logger_01_DNS_place_holder" - cp4.Partial_sig = crypto.SigFragment{} - println("data structures initialized") - accs = process_Accusation(cp1, accs) - accs = process_Accusation(cp1, accs) - accs = process_Accusation(cp2, accs) - accs = process_Accusation(cp3, accs) - println("Accsuation processing went through") - println("_______________________________________") - println("start listing accused entities and the number of accusations") - for i := 0; i < len(accs); i++ { - println("\nThe accused entity DNS is: ", accs[i].Entity_URL) - println("The total number of accusations is", accs[i].Num_acc) - for j := 0; j < len(accs[i].Accusers); j++ { - print("Accusers No.", j+1, "is ") - println(accs[i].Accusers[j]) - // print("Partial sigature No.", j+1, "is ") - // println(accs[i].Partial_sigs[j]) - } - } - -} diff --git a/CTng/PoM/Readme.md b/CTng/PoM/Readme.md deleted file mode 100644 index 2054385..0000000 --- a/CTng/PoM/Readme.md +++ /dev/null @@ -1,6 +0,0 @@ -The Process_accusation Function returns 3 value - IO.PoM02: PoM due to enough number of accusations. The IO version can be write to json file directly (post-conversion) - bool: whether the gossiper should gossip this recently received accusation to other gossipers true indicates yes - error: error messages - -AccusationDB is passed as a pointer and will be modifed after the function diff --git a/CTng/PoM/Testing log.txt b/CTng/PoM/Testing log.txt deleted file mode 100644 index fbe40a0..0000000 --- a/CTng/PoM/Testing log.txt +++ /dev/null @@ -1,32 +0,0 @@ -test start - -data structures initialized -The length of the accusation list before processing is: 0 -The length of the accusation list after processing is: 1 -New accused entity registered -The length of the accusation list before processing is: 1 -The length of the accusation list after processing is: 1 -The accusation is a duplicate. -The length of the accusation list before processing is: 1 -The length of the accusation list after processing is: 2 -New accused entity registered -The length of the accusation list before processing is: 2 -Accusation number and list of accusers updated. -The length of the accusation list after processing is: 2 -Accsuation processing went through -_______________________________________ -start listing accused entities and the number of accusations - -The accused entity DNS is: logger_01_DNS_place_holder -The total number of accusations is 1 -Accusers No. 1 is monitor_01_DNS_place_holder -Partial sigature No. 1 is monitor_01_partial_sig - -The accused entity DNS is: logger_02_DNS_place_holder -The total number of accusations is 2 -Accusers No. 1 is monitor_02_DNS_place_holder -Partial sigature No. 1 is monitor_02_partial_sig -Accusers No. 2 is monitor_01_DNS_place_holder -Partial sigature No. 2 is monitor_01_partial_sig -PASS -ok CTng/PoM 0.182s \ No newline at end of file