Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
71cfd9aa
Unverified
Commit
71cfd9aa
authored
4 years ago
by
Sydney Anne Erickson
Browse files
Options
Downloads
Patches
Plain Diff
removeFact
parent
4adb5fe8
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
network/message/parse/firstMessagePart_test.go
+34
-0
34 additions, 0 deletions
network/message/parse/firstMessagePart_test.go
ud/manager.go
+5
-5
5 additions, 5 deletions
ud/manager.go
ud/remove.go
+49
-14
49 additions, 14 deletions
ud/remove.go
ud/remove_test.go
+74
-0
74 additions, 0 deletions
ud/remove_test.go
with
162 additions
and
19 deletions
network/message/parse/firstMessagePart_test.go
0 → 100644
+
34
−
0
View file @
71cfd9aa
package
parse
import
(
"bytes"
"gitlab.com/elixxir/client/interfaces/message"
"testing"
"time"
)
func
TestnewFirstMessagePart
(
t
*
testing
.
T
)
{
now
:=
time
.
Now
()
fmp
:=
newFirstMessagePart
(
message
.
Text
,
uint32
(
6
),
uint8
(
2
),
now
,
[]
byte
{
't'
,
'e'
,
's'
,
't'
,
'i'
,
'n'
,
'g'
})
if
fmp
.
GetType
()
!=
message
.
Text
{
}
if
fmp
.
GetNumParts
()
!=
uint8
(
2
)
{
}
recorded_now
,
err
:=
fmp
.
GetTimestamp
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
recorded_now
!=
now
{
}
if
!
bytes
.
Equal
(
fmp
.
Bytes
(),
[]
byte
{
't'
,
'e'
,
's'
,
't'
,
'i'
,
'n'
,
'g'
})
{
}
}
This diff is collapsed.
Click to expand it.
ud/manager.go
+
5
−
5
View file @
71cfd9aa
...
@@ -3,11 +3,11 @@ package ud
...
@@ -3,11 +3,11 @@ package ud
import
(
import
(
"gitlab.com/elixxir/comms/client"
"gitlab.com/elixxir/comms/client"
"gitlab.com/xx_network/comms/connect"
"gitlab.com/xx_network/comms/connect"
"gitlab.com/xx_network/crypto/signature/rsa"
)
)
type
Manager
struct
{
type
Manager
struct
{
comms
*
client
.
Comms
comms
*
client
.
Comms
host
*
connect
.
Host
host
*
connect
.
Host
privKey
*
privKey
*
rsa
.
PrivateKey
}
}
This diff is collapsed.
Click to expand it.
ud/remove.go
+
49
−
14
View file @
71cfd9aa
package
ud
package
ud
import
(
import
(
"crypto/rand"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes/any"
"gitlab.com/elixxir/client/interfaces/contact"
"gitlab.com/elixxir/client/interfaces/contact"
"gitlab.com/elixxir/comms/client"
"gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/elixxir/crypto/hash"
"gitlab.com/xx_network/comms/connect"
"gitlab.com/xx_network/comms/connect"
"gitlab.com/xx_network/comms/messages"
"gitlab.com/xx_network/comms/messages"
"gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/xx_network/crypto/signature/rsa"
)
)
type
removeFactComms
interface
{
type
removeFactComms
interface
{
SendDeleteMessage
(
host
*
connect
.
Host
,
message
*
messages
.
AuthenticatedMessage
)
(
*
messages
.
Ack
,
error
)
SendDeleteMessage
(
host
*
connect
.
Host
,
message
*
messages
.
AuthenticatedMessage
)
(
*
messages
.
Ack
,
error
)
}
}
...
@@ -17,19 +20,51 @@ func (m *Manager)RemoveFact(fact contact.Fact)error{
...
@@ -17,19 +20,51 @@ func (m *Manager)RemoveFact(fact contact.Fact)error{
return
m
.
removeFact
(
fact
,
m
.
comms
)
return
m
.
removeFact
(
fact
,
m
.
comms
)
}
}
func
(
m
*
Manager
)
removeFact
(
fact
contact
.
Fact
,
SendDeleteMessage
removeFactComms
)
error
{
func
(
m
*
Manager
)
removeFact
(
fact
contact
.
Fact
,
rFC
removeFactComms
)
error
{
//digest the fact
// Construct the message to send
fact
.
Stringify
()
// Convert our Fact to a mixmessages Fact for sending
//sign the fact
mmFact
:=
mixmessages
.
Fact
{
rsa
.
Sign
()
Fact
:
fact
.
Fact
,
FactType
:
uint32
(
fact
.
T
),
}
//constuct the message
// Sign the fact
signedFact
,
err
:=
rsa
.
Sign
(
rand
.
Reader
,
m
.
privKey
,
hash
.
CMixHash
,
mmFact
.
Digest
(),
rsa
.
NewDefaultOptions
())
if
err
!=
nil
{
return
err
}
// Create our Fact Removal Request message data
remFactMsg
:=
mixmessages
.
FactRemovalRequest
{
UID
:
m
.
host
.
GetId
()
.
Marshal
(),
RemovalData
:
&
mmFact
,
}
//send the message
// Marshal it to bytes for sending over the wire
remFactMsgMarshalled
,
err
:=
proto
.
Marshal
(
&
remFactMsg
)
if
err
!=
nil
{
return
err
}
//return the error
// Convert our marshalled Fact Removal Request to an Any
// object for sending in an authed message
remFactMsgAny
:=
any
.
Any
{
TypeUrl
:
"gitlab.com/elixxir/client/interfaces/contact.Fact"
,
Value
:
remFactMsgMarshalled
,
}
// Create our AuthenticatedMessage so we can send the data over
msg
:=
messages
.
AuthenticatedMessage
{
ID
:
nil
,
Signature
:
signedFact
,
Token
:
nil
,
Client
:
nil
,
Message
:
&
remFactMsgAny
,
}
// Send the message
_
,
err
=
rFC
.
SendDeleteMessage
(
m
.
host
,
&
msg
)
// Return the error
return
err
}
}
This diff is collapsed.
Click to expand it.
ud/remove_test.go
0 → 100644
+
74
−
0
View file @
71cfd9aa
package
ud
import
(
"gitlab.com/elixxir/client/interfaces/contact"
"gitlab.com/elixxir/comms/client"
"gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/xx_network/comms/connect"
"gitlab.com/xx_network/comms/messages"
"gitlab.com/xx_network/crypto/csprng"
"gitlab.com/xx_network/crypto/large"
"gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/xx_network/primitives/id"
"testing"
)
var
genericGroup
=
cyclic
.
NewGroup
(
large
.
NewIntFromString
(
"9DB6FB5951B66BB6FE1E140F1D2CE5502374161FD6538DF1648218642F0B5C48"
+
"C8F7A41AADFA187324B87674FA1822B00F1ECF8136943D7C55757264E5A1A44F"
+
"FE012E9936E00C1D3E9310B01C7D179805D3058B2A9F4BB6F9716BFE6117C6B5"
+
"B3CC4D9BE341104AD4A80AD6C94E005F4B993E14F091EB51743BF33050C38DE2"
+
"35567E1B34C3D6A5C0CEAA1A0F368213C3D19843D0B4B09DCB9FC72D39C8DE41"
+
"F1BF14D4BB4563CA28371621CAD3324B6A2D392145BEBFAC748805236F5CA2FE"
+
"92B871CD8F9C36D3292B5509CA8CAA77A2ADFC7BFD77DDA6F71125A7456FEA15"
+
"3E433256A2261C6A06ED3693797E7995FAD5AABBCFBE3EDA2741E375404AE25B"
,
16
),
large
.
NewIntFromString
(
"5C7FF6B06F8F143FE8288433493E4769C4D988ACE5BE25A0E24809670716C613"
+
"D7B0CEE6932F8FAA7C44D2CB24523DA53FBE4F6EC3595892D1AA58C4328A06C4"
+
"6A15662E7EAA703A1DECF8BBB2D05DBE2EB956C142A338661D10461C0D135472"
+
"085057F3494309FFA73C611F78B32ADBB5740C361C9F35BE90997DB2014E2EF5"
+
"AA61782F52ABEB8BD6432C4DD097BC5423B285DAFB60DC364E8161F4A2A35ACA"
+
"3A10B1C4D203CC76A470A33AFDCBDD92959859ABD8B56E1725252D78EAC66E71"
+
"BA9AE3F1DD2487199874393CD4D832186800654760E1E34C09E4D155179F9EC0"
+
"DC4473F996BDCE6EED1CABED8B6F116F7AD9CF505DF0F998E34AB27514B0FFE7"
,
16
))
type
testRFC
struct
{}
func
(
rFC
*
testRFC
)
SendDeleteMessage
(
host
*
connect
.
Host
,
message
*
messages
.
AuthenticatedMessage
)
(
*
messages
.
Ack
,
error
)
{
return
&
messages
.
Ack
{},
nil
}
func
TestRemoveFact
(
t
*
testing
.
T
)
{
c
,
err
:=
client
.
NewClientComms
(
&
id
.
DummyUser
,
nil
,
nil
,
nil
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
h
,
err
:=
connect
.
NewHost
(
&
id
.
DummyUser
,
"address"
,
nil
,
connect
.
GetDefaultHostParams
())
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
rng
:=
csprng
.
NewSystemRNG
()
cpk
,
err
:=
rsa
.
GenerateKey
(
rng
,
256
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
m
:=
Manager
{
comms
:
c
,
host
:
h
,
privKey
:
cpk
,
}
f
:=
contact
.
Fact
{
Fact
:
"testing"
,
T
:
2
,
}
trfc
:=
testRFC
{}
err
=
m
.
removeFact
(
f
,
&
trfc
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment