Skip to content

Commit

Permalink
Debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
tfn18001 committed Apr 22, 2022
1 parent 7a8b425 commit 760ce92
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 41 deletions.
6 changes: 3 additions & 3 deletions CTng/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"program": "${workspaceRoot}/ctng.go",
"args": [
"gossiper",
"config/test/gossiper_pub_config.json",
"config/test/gossiper_priv_config.json",
"config/test/localhost:8081.crypto.json"
"testData/gossiperNetworkTest/gossiper_pub_config.json",
"testData/gossiperNetworkTest/1/gossiper_priv_config.json",
"testData/gossiperNetworkTest/1/gossiperCrypto.json"
],
},
{
Expand Down
5 changes: 5 additions & 0 deletions CTng/crypto/crypto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ func TestRSAFunctionality(T *testing.T) {
// Verify the signature
err = RSAVerify([]byte(msg), sig, &pub)
confirmNil(T, err)
sigstr := sig.String()
sig2, err := RSASigFromString(sigstr)
confirmNil(T, err)
err = RSAVerify([]byte(msg), sig2, &pub)
confirmNil(T, err)
}

// This test verifies that CTng IDs can be sorted,
Expand Down
2 changes: 1 addition & 1 deletion CTng/gossip/gossiper.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func SendToOwner(c *GossiperContext, obj Gossip_object) {
fmt.Println(err)
}
// Send the gossip object to the owner.
resp, postErr := c.Client.Post("http://"+c.Config.Owner_URL+"/recieve-gossip", "application/json", bytes.NewBuffer(msg))
resp, postErr := c.Client.Post("http://"+c.Config.Owner_URL+"/monitor/recieve-gossip", "application/json", bytes.NewBuffer(msg))
if postErr != nil {
fmt.Errorf("Error sending object to owner: " + postErr.Error())
} else {
Expand Down
2 changes: 1 addition & 1 deletion CTng/gossip/process_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func ProcessInvalidObject(obj Gossip_object, e error) {
func ProcessAccusation(c *GossiperContext, acc Gossip_object) {
pom, shouldGossip, err := Process_Accusation(acc, c.Accusations, c.Config.Crypto)
if err != nil {
fmt.Println(util.RED, err, util.RESET)
fmt.Println(util.RED+err.Error(), util.RESET)
} else {
fmt.Println(util.YELLOW+"Processed accusation against", acc.Payload[0], util.RESET)
}
Expand Down
6 changes: 4 additions & 2 deletions CTng/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ func QueryLoggers(c *MonitorContext) {
// Get today's STH from logger.

// Get today's date in format YYYY-MM-DD
var today = time.Now().UTC().Format(time.RFC3339)[0:10]
// (Used when querying individual days)
// var today = time.Now().UTC().Format(time.RFC3339)[0:10]

sthResp, err := http.Get(PROTOCOL + logger + "/ctng/v1/get-sth/" + today)
sthResp, err := http.Get(PROTOCOL + logger + "/ctng/v2/get-sth/")
if err != nil {
log.Println(err)
AccuseEntity(c, logger)
Expand Down Expand Up @@ -108,6 +109,7 @@ func AccuseEntity(c *MonitorContext, Accused string) {
Timestamp: gossip.GetCurrentTimestamp(),
Payload: payloadarray,
}
// c.HasAccused[Accused] = true
Send_to_gossiper(c, accusation)
}

Expand Down
8 changes: 4 additions & 4 deletions CTng/monitor/monitor_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ func Process_valid_object(c *MonitorContext, g gossip.Gossip_object) {
//if the valid object is from the logger in the monitor config logger URL list
//This handles the STHS
if IsLogger(c, g.Signer) && g.Type == gossip.STH {
sig_frag, err := c.Config.Crypto.ThresholdSign(g.Payload[0])
if err != nil {
fmt.Println(err.Error())
}
Send_to_gossiper(c, g)
f := func() {
sig_frag, err := c.Config.Crypto.ThresholdSign(g.Payload[0])
if err != nil {
fmt.Println(err.Error())
}
pom_err := Check_entity_pom(c, g.Signer)
//if there is no conflicting information/PoM send the Threshold signed version to the gossiper
if pom_err == nil {
Expand Down
6 changes: 5 additions & 1 deletion CTng/monitor/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ type MonitorContext struct {
// TODO: Utilize Storage directory: A folder for the files of each MMD.
// Folder should be set to the current MMD "Period" String upon initialization.
StorageDirectory string
Client *http.Client

// The below could be used to prevent a Monitor from sending duplicate Accusations,
// should be reset each MMD
// HasAccused map[string]bool
Client *http.Client
}

func (c *MonitorContext) SaveStorage() error {
Expand Down
4 changes: 3 additions & 1 deletion CTng/server/Monitor_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ func handleMonitorRequests(c *monitor.MonitorContext) {
gorillaRouter := mux.NewRouter().StrictSlash(true)

// POST functions
gorillaRouter.HandleFunc("/gossip/push-data", bindMonitorContext(c, handle_gossip)).Methods("POST")
gorillaRouter.HandleFunc("/monitor/recieve-gossip", bindMonitorContext(c, handle_gossip)).Methods("POST")

// For Relying party poms
gorillaRouter.HandleFunc("/submit-pom", bindMonitorContext(c, receivePOM)).Methods("POST")

// GET functions
Expand Down
56 changes: 28 additions & 28 deletions CTng/testData/gossiperNetworkTest/2/gossiperCrypto.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,35 @@
"SignScheme": "rsa",
"ThresholdScheme": "bls",
"SignaturePublicMap": {
"localhost:8080": {
"N": 20010196815470022435868905546915542860705680635042118881171554384873360580244876659820408674639799454365129107628151822842814014262950419073898510010981594641035086504257248790238888439086631001997378363682363649099418615134106203086740252932938343000798251735033433522209722248620071309719516673957669499458841781052026977221612793822280506590749048919212266395854934215745868879850674191875785897998003681752950538090419315688634180383729788626474282822226656747955463503023336781235249715040718221916236198718891202818058724534673409638175978839512694597475925538323738577620893665506531948712974237575045737965311,
"E": 65537
"localhost:8080": {
"N": 20010196815470022435868905546915542860705680635042118881171554384873360580244876659820408674639799454365129107628151822842814014262950419073898510010981594641035086504257248790238888439086631001997378363682363649099418615134106203086740252932938343000798251735033433522209722248620071309719516673957669499458841781052026977221612793822280506590749048919212266395854934215745868879850674191875785897998003681752950538090419315688634180383729788626474282822226656747955463503023336781235249715040718221916236198718891202818058724534673409638175978839512694597475925538323738577620893665506531948712974237575045737965311,
"E": 65537
},
"localhost:8081": {
"N": 22265317011700522186802456786678770643614324758714289255366329473626820590704823030230709608569934849445128778973670182901273925362727087112386107828649513607503206659592242794253072737305046532022516417769962902581173567574629331815032230625669004629271769700216264625443049242186857838259226595755938522540722239659051932103732143495921325866791010607252799898001370251402795373929951111945751613309366505589950915121161149775316829765086040643092125277724807859054045292672284769539144903037563155174269482106591349804364324893328199033235538200908465565871591090163269866631899714466007734874765165044802148613793,
"E": 65537
},
"localhost:8082": {
"N": 19961204460921970503300579932065442183645901848003098839019840608612510606744670277660742197745067670158187113667360856515584353515791304548070716309414461316220600935375489383120099160064817439719415902943820794665241725627889562060378471958187509325469849393188140617578102910884520136838069065887723925729684883813492565953538132502043914701499993681261363156482327556839897647330135993330072249632471079215888643818436138705734435028527258777628764880153174996193051793668825514755740441960639930479164113231672170913400912950274759989310855802034482553318362443126979161238299959487315504417699897708696009650909,
"E": 65537
},
"localhost:8083": {
"N": 26870715517835529425253494973837486554496693058315934126353937263363499330261461485381262361113673081045161641304624376693732542037023595854601835682220975198910217245209668094613672833815786326127005311157989476454093892694012764622280038969283716141665044760770506720659886883854701543635236232491317419343190653278291941405059974182460907553633517556368444698741137203102270437715594036760316321980916496316137000145286669820908390058207507839701654880194090835221584921965515435462057528401736347863468050447674086524622139153323903175166279073909777002658168965380565632801085646035534739531953512614548345415337,
"E": 65537
},
"localhost:9000": {
"N": 21807808817028069521693981025854627766849100907464628031386389529795793140445452403979568400586301388102303005688782597096478795543494617476262626637251939091457219474844544584944694111795327351162485025615396615156332890111445956553729344912738727208120229178581403780883051005207097866108991379098981205093118647139047092214048380759204440914928346690315813577955415022365974040592290311683131513649330794291316838007320668201086717296546111828165980835726696797314928836964283576233301855572522559548630195787917554335560790396850488199331707061308922415163250057868060445529850753103153976841020361249662478352377,
"E": 65537
},
"localhost:9001": {
"N": 23252973551340935183125964301239394441268751011208146732992808020417063643722798116442608594279677205628615159796637042351236895510183530067421586578520622761961327937601077936607208585910560962764238731254814969375357028226260361691859503574268216691949008213953884839053600853903979504862782260745247938279459295671742467758276923319951606178695777588680957056514003518072749213888863320971271934432550756175972781344678001820332694558433506149685765145751895391937311845198206021246778714450986559172352984358941313079975500433800828535054555138262203102926122738137575483960219776073243032678302367325287435201381,
"E": 65537
},
"localhost:9002": {
"N": 20028649974874227033360914359590766678527711517531636997713603474008908788659881072754993703433185955779617335557947288171124892464864232545291605031424352674054323768598060610599281281539072954580390937994894319035538689968791373798820944766502542768153531189979514749140151783915919768722020901389133722554527607979186909863026840800319528623758670965878003072462079597023515002126915829370037330794543912057953039966473482799333260960689543682741483394536974500771002815055637466302437703527466497406576505348945381874007559705058294342241838471511807556669238624256963671945475465519079937531652829531772652319583,
"E": 65537
}
},
"localhost:8081": {
"N": 22265317011700522186802456786678770643614324758714289255366329473626820590704823030230709608569934849445128778973670182901273925362727087112386107828649513607503206659592242794253072737305046532022516417769962902581173567574629331815032230625669004629271769700216264625443049242186857838259226595755938522540722239659051932103732143495921325866791010607252799898001370251402795373929951111945751613309366505589950915121161149775316829765086040643092125277724807859054045292672284769539144903037563155174269482106591349804364324893328199033235538200908465565871591090163269866631899714466007734874765165044802148613793,
"E": 65537
},
"localhost:8082": {
"N": 19961204460921970503300579932065442183645901848003098839019840608612510606744670277660742197745067670158187113667360856515584353515791304548070716309414461316220600935375489383120099160064817439719415902943820794665241725627889562060378471958187509325469849393188140617578102910884520136838069065887723925729684883813492565953538132502043914701499993681261363156482327556839897647330135993330072249632471079215888643818436138705734435028527258777628764880153174996193051793668825514755740441960639930479164113231672170913400912950274759989310855802034482553318362443126979161238299959487315504417699897708696009650909,
"E": 65537
},
"localhost:8083": {
"N": 26870715517835529425253494973837486554496693058315934126353937263363499330261461485381262361113673081045161641304624376693732542037023595854601835682220975198910217245209668094613672833815786326127005311157989476454093892694012764622280038969283716141665044760770506720659886883854701543635236232491317419343190653278291941405059974182460907553633517556368444698741137203102270437715594036760316321980916496316137000145286669820908390058207507839701654880194090835221584921965515435462057528401736347863468050447674086524622139153323903175166279073909777002658168965380565632801085646035534739531953512614548345415337,
"E": 65537
},
"localhost:9000": {
"N": 21807808817028069521693981025854627766849100907464628031386389529795793140445452403979568400586301388102303005688782597096478795543494617476262626637251939091457219474844544584944694111795327351162485025615396615156332890111445956553729344912738727208120229178581403780883051005207097866108991379098981205093118647139047092214048380759204440914928346690315813577955415022365974040592290311683131513649330794291316838007320668201086717296546111828165980835726696797314928836964283576233301855572522559548630195787917554335560790396850488199331707061308922415163250057868060445529850753103153976841020361249662478352377,
"E": 65537
},
"localhost:9001": {
"N": 23252973551340935183125964301239394441268751011208146732992808020417063643722798116442608594279677205628615159796637042351236895510183530067421586578520622761961327937601077936607208585910560962764238731254814969375357028226260361691859503574268216691949008213953884839053600853903979504862782260745247938279459295671742467758276923319951606178695777588680957056514003518072749213888863320971271934432550756175972781344678001820332694558433506149685765145751895391937311845198206021246778714450986559172352984358941313079975500433800828535054555138262203102926122738137575483960219776073243032678302367325287435201381,
"E": 65537
},
"localhost:9002": {
"N": 20028649974874227033360914359590766678527711517531636997713603474008908788659881072754993703433185955779617335557947288171124892464864232545291605031424352674054323768598060610599281281539072954580390937994894319035538689968791373798820944766502542768153531189979514749140151783915919768722020901389133722554527607979186909863026840800319528623758670965878003072462079597023515002126915829370037330794543912057953039966473482799333260960689543682741483394536974500771002815055637466302437703527466497406576505348945381874007559705058294342241838471511807556669238624256963671945475465519079937531652829531772652319583,
"E": 65537
}
},
"RSAPrivateKey": {
"N": 22265317011700522186802456786678770643614324758714289255366329473626820590704823030230709608569934849445128778973670182901273925362727087112386107828649513607503206659592242794253072737305046532022516417769962902581173567574629331815032230625669004629271769700216264625443049242186857838259226595755938522540722239659051932103732143495921325866791010607252799898001370251402795373929951111945751613309366505589950915121161149775316829765086040643092125277724807859054045292672284769539144903037563155174269482106591349804364324893328199033235538200908465565871591090163269866631899714466007734874765165044802148613793,
"E": 65537,
Expand Down

0 comments on commit 760ce92

Please sign in to comment.