last-before-sharing
This commit is contained in:
		
							
								
								
									
										8
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
				
			|||||||
 | 
					doc/protocol.aux
 | 
				
			||||||
 | 
					doc/protocol.fdb_latexmk
 | 
				
			||||||
 | 
					doc/protocol.fls
 | 
				
			||||||
 | 
					doc/protocol.log
 | 
				
			||||||
 | 
					doc/protocol.pdf
 | 
				
			||||||
 | 
					doc/protocol.synctex.gz
 | 
				
			||||||
 | 
					out/doc/general_deployment/general_deployment.png
 | 
				
			||||||
 | 
					out/doc/server_deployment/server_deployment.png
 | 
				
			||||||
							
								
								
									
										21
									
								
								doc/general_deployment.puml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								doc/general_deployment.puml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					@startuml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cloud net as "Network"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					component mapp as "Mobile Application"
 | 
				
			||||||
 | 
					component capp as "CLI Application"
 | 
				
			||||||
 | 
					component dapp as "Desktop Application"
 | 
				
			||||||
 | 
					component proxy1 as "Http Web Service Proxy"
 | 
				
			||||||
 | 
					component proxy2 as "Http Web Service Proxy"
 | 
				
			||||||
 | 
					component ws1 as "Company 1 Web Services" #LightGray
 | 
				
			||||||
 | 
					component ws2 as "Company 2 Web Client" #LightGray
 | 
				
			||||||
 | 
					component srv1 as "Server"
 | 
				
			||||||
 | 
					net -- srv1
 | 
				
			||||||
 | 
					net -- mapp
 | 
				
			||||||
 | 
					net -- capp
 | 
				
			||||||
 | 
					net -- dapp
 | 
				
			||||||
 | 
					net -- proxy1
 | 
				
			||||||
 | 
					net -- proxy2
 | 
				
			||||||
 | 
					ws1 -- proxy1
 | 
				
			||||||
 | 
					ws2 -- proxy2
 | 
				
			||||||
 | 
					ws2 ..> ws1
 | 
				
			||||||
@@ -120,7 +120,7 @@ The Ekp is used to cypher your conversation.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
\subsection{Conversation lookup}
 | 
					\subsection{Conversation lookup}
 | 
				
			||||||
A contact conversation Lookup Key Pair(Lkp) is also associated with your conversation. The Lkp public key is used to identify your conversation on a server.
 | 
					A contact conversation Lookup Key Pair(Lkp) is also associated with your conversation. The Lkp public key is used to identify your conversation on a server.
 | 
				
			||||||
the private key allows you to sign your tequest and prove the server that you are the legitimate recipient for a message.
 | 
					the private key allows you to sign your request and prove the server that you are the legitimate recipient for a message.
 | 
				
			||||||
This Lkp can be changed anytime by it's owner and the new public key will be sent along the last message. 
 | 
					This Lkp can be changed anytime by it's owner and the new public key will be sent along the last message. 
 | 
				
			||||||
The Lkp and the Ekp are only changed, once the change has beeen acknowledged by your contact.
 | 
					The Lkp and the Ekp are only changed, once the change has beeen acknowledged by your contact.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										36
									
								
								doc/server_deployment.puml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								doc/server_deployment.puml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
				
			|||||||
 | 
					@startuml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cloud Network
 | 
				
			||||||
 | 
					component lb as "Load Balancer"
 | 
				
			||||||
 | 
					component http1 as "HTTP Server"
 | 
				
			||||||
 | 
					component http2 as "HTTP Server"
 | 
				
			||||||
 | 
					component ws1 as "Websocket Server"
 | 
				
			||||||
 | 
					component ws2 as "Websocket Server"
 | 
				
			||||||
 | 
					component ws3 as "Websocket Server"
 | 
				
			||||||
 | 
					component ws4 as "..."
 | 
				
			||||||
 | 
					database q as "Message Queue"
 | 
				
			||||||
 | 
					component d1 as "Message Dispatcher"
 | 
				
			||||||
 | 
					component d2 as "Message Dispatcher"
 | 
				
			||||||
 | 
					component d3 as "Message Dispatcher"
 | 
				
			||||||
 | 
					component d4 as "Message Dispatcher"
 | 
				
			||||||
 | 
					component d5 as "..."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					lb -- http1
 | 
				
			||||||
 | 
					lb -- http2
 | 
				
			||||||
 | 
					lb -- ws1
 | 
				
			||||||
 | 
					lb -- ws2
 | 
				
			||||||
 | 
					lb -- ws3
 | 
				
			||||||
 | 
					lb -- ws4
 | 
				
			||||||
 | 
					http1 -- q 
 | 
				
			||||||
 | 
					http2 -- q
 | 
				
			||||||
 | 
					ws1 -- q
 | 
				
			||||||
 | 
					ws2 -- q
 | 
				
			||||||
 | 
					ws3 -- q
 | 
				
			||||||
 | 
					q -- d1
 | 
				
			||||||
 | 
					q -- d2
 | 
				
			||||||
 | 
					q -- d3
 | 
				
			||||||
 | 
					q -- d4
 | 
				
			||||||
 | 
					q -- d5
 | 
				
			||||||
 | 
					Network -- lb
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@enduml
 | 
				
			||||||
@@ -35,7 +35,7 @@ func TestEndToEnd(t *testing.T) {
 | 
				
			|||||||
		//
 | 
							//
 | 
				
			||||||
		// Simulate peer invitation response : generate the friend's keypair
 | 
							// Simulate peer invitation response : generate the friend's keypair
 | 
				
			||||||
		fmt.Println("Simulating first friend answer...")
 | 
							fmt.Println("Simulating first friend answer...")
 | 
				
			||||||
		var receivedContact Contact
 | 
							var receivedContact ContactCard
 | 
				
			||||||
		firstFriendContactKp := NewKeyPair()
 | 
							firstFriendContactKp := NewKeyPair()
 | 
				
			||||||
		firstFriendEncryptionKp := NewKeyPair()
 | 
							firstFriendEncryptionKp := NewKeyPair()
 | 
				
			||||||
		firstFriendLookupKp := NewKeyPair()
 | 
							firstFriendLookupKp := NewKeyPair()
 | 
				
			||||||
@@ -48,7 +48,7 @@ func TestEndToEnd(t *testing.T) {
 | 
				
			|||||||
		for _, srv := range friendsMessageServers.Servers {
 | 
							for _, srv := range friendsMessageServers.Servers {
 | 
				
			||||||
			receivedContact.PullServers = append(receivedContact.PullServers, srv.ServerData)
 | 
								receivedContact.PullServers = append(receivedContact.PullServers, srv.ServerData)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		// End simulating concact invitation response
 | 
							// End simulating contact invitation response
 | 
				
			||||||
		//
 | 
							//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//
 | 
							//
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								https.go
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								https.go
									
									
									
									
									
								
							@@ -25,13 +25,9 @@ func (https *Https) Send(msg []byte) ([]byte, error) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (https *Https) Start(callback *func() []InternalMessage) {
 | 
					func (https *Https) Start(callback *func() []InternalMessage) {
 | 
				
			||||||
	for {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (https *Https) Stop() {
 | 
					func (https *Https) Stop() {
 | 
				
			||||||
	for {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,9 +28,9 @@ func CreateIdentity(nickname string) *Identity {
 | 
				
			|||||||
	return &id
 | 
						return &id
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (id *Identity) InvitePeer(myName string, contactName string, messageServerIdxs []int) (*Peer, *Contact) {
 | 
					func (id *Identity) InvitePeer(myName string, contactName string, messageServerIdxs []int) (*Peer, *ContactCard) {
 | 
				
			||||||
	var peer Peer
 | 
						var peer Peer
 | 
				
			||||||
	var myContactCard Contact
 | 
						var myContactCard ContactCard
 | 
				
			||||||
	peer.Me = NewKeyPair()
 | 
						peer.Me = NewKeyPair()
 | 
				
			||||||
	peer.EncryptionKp = NewKeyPair()
 | 
						peer.EncryptionKp = NewKeyPair()
 | 
				
			||||||
	peer.LookupKp = NewKeyPair()
 | 
						peer.LookupKp = NewKeyPair()
 | 
				
			||||||
@@ -48,7 +48,7 @@ func (id *Identity) InvitePeer(myName string, contactName string, messageServerI
 | 
				
			|||||||
	return &id.Peers[len(id.Peers)-1], &myContactCard
 | 
						return &id.Peers[len(id.Peers)-1], &myContactCard
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (*Identity) FinalizeInvitation(peer *Peer, receivedContact *Contact) {
 | 
					func (*Identity) FinalizeInvitation(peer *Peer, receivedContact *ContactCard) {
 | 
				
			||||||
	peer.Contact = *receivedContact
 | 
						peer.Contact = *receivedContact
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										
											BIN
										
									
								
								invitation.png
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								invitation.png
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 530 B  | 
							
								
								
									
										0
									
								
								messages.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								messages.json
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										1191
									
								
								messages.pb.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1191
									
								
								messages.pb.go
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										17
									
								
								pb/messages.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								pb/messages.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					from socket import MsgFlag
 | 
				
			||||||
 | 
					import protoparser
 | 
				
			||||||
 | 
					import json
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def parseMessage(pb, parent):
 | 
				
			||||||
 | 
					    if hasattr(pb, 'messages'):
 | 
				
			||||||
 | 
					        for msg in pb.messages:
 | 
				
			||||||
 | 
					            print(pb.messages)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pb = protoparser.parse_from_file("pb/messages.proto")
 | 
				
			||||||
 | 
					#print(json.dumps(pb))
 | 
				
			||||||
 | 
					print(json.dumps(pb.messages))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					with open('messages.json', 'w') as f:
 | 
				
			||||||
 | 
					    f.write(pb)
 | 
				
			||||||
							
								
								
									
										14
									
								
								peer.go
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								peer.go
									
									
									
									
									
								
							@@ -16,7 +16,7 @@ import (
 | 
				
			|||||||
	"github.com/makiuchi-d/gozxing/qrcode"
 | 
						"github.com/makiuchi-d/gozxing/qrcode"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Contact struct {
 | 
					type ContactCard struct {
 | 
				
			||||||
	Name                string   `json:"name,omitempty"`
 | 
						Name                string   `json:"name,omitempty"`
 | 
				
			||||||
	ContactPublicKey    string   `json:"contact_public_key,omitempty"`
 | 
						ContactPublicKey    string   `json:"contact_public_key,omitempty"`
 | 
				
			||||||
	EncryptionPublicKey string   `json:"encryption_public_key,omitempty"`
 | 
						EncryptionPublicKey string   `json:"encryption_public_key,omitempty"`
 | 
				
			||||||
@@ -27,7 +27,7 @@ type Contact struct {
 | 
				
			|||||||
type Peer struct {
 | 
					type Peer struct {
 | 
				
			||||||
	Name                string            `json:"name,omitempty"`
 | 
						Name                string            `json:"name,omitempty"`
 | 
				
			||||||
	Me                  KeyPair           `json:"me,omitempty"`
 | 
						Me                  KeyPair           `json:"me,omitempty"`
 | 
				
			||||||
	Contact             Contact           `json:"contact,omitempty"`
 | 
						Contact             ContactCard       `json:"contact,omitempty"`
 | 
				
			||||||
	Visible             bool              `json:"visible,omitempty"`
 | 
						Visible             bool              `json:"visible,omitempty"`
 | 
				
			||||||
	VisiblePassword     string            `json:"visible_password,omitempty"`
 | 
						VisiblePassword     string            `json:"visible_password,omitempty"`
 | 
				
			||||||
	PasswordType        string            `json:"password_type,omitempty"`
 | 
						PasswordType        string            `json:"password_type,omitempty"`
 | 
				
			||||||
@@ -46,7 +46,7 @@ type PeerList []Peer
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
type Group struct {
 | 
					type Group struct {
 | 
				
			||||||
	Name    string        `json:"name,omitempty"`
 | 
						Name    string        `json:"name,omitempty"`
 | 
				
			||||||
	Members []Contact `json:"members,omitempty"`
 | 
						Members []ContactCard `json:"members,omitempty"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (pl *PeerList) GetFromPublicKey(publickey string) *Peer {
 | 
					func (pl *PeerList) GetFromPublicKey(publickey string) *Peer {
 | 
				
			||||||
@@ -81,7 +81,7 @@ func (peer *Peer) SendText(text string) {
 | 
				
			|||||||
	fmt.Println(im.MessageData.Destination)
 | 
						fmt.Println(im.MessageData.Destination)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (contact *Contact) WritePng(filename string) {
 | 
					func (contact *ContactCard) WritePng(filename string) {
 | 
				
			||||||
	jsonContact, _ := json.Marshal(contact)
 | 
						jsonContact, _ := json.Marshal(contact)
 | 
				
			||||||
	//imgdata := base64.StdEncoding.EncodeToString(jsonContact)
 | 
						//imgdata := base64.StdEncoding.EncodeToString(jsonContact)
 | 
				
			||||||
	size := int(math.Sqrt(float64(len(jsonContact))/3)) + 1
 | 
						size := int(math.Sqrt(float64(len(jsonContact))/3)) + 1
 | 
				
			||||||
@@ -120,7 +120,7 @@ func (contact *Contact) WritePng(filename string) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (contact *Contact) WriteQr(filename string) {
 | 
					func (contact *ContactCard) WriteQr(filename string) {
 | 
				
			||||||
	jsonContact, _ := json.Marshal(contact)
 | 
						jsonContact, _ := json.Marshal(contact)
 | 
				
			||||||
	qwriter := qrcode.NewQRCodeWriter()
 | 
						qwriter := qrcode.NewQRCodeWriter()
 | 
				
			||||||
	code, err := qwriter.Encode(string(jsonContact), gozxing.BarcodeFormat_QR_CODE, 512, 512, nil)
 | 
						code, err := qwriter.Encode(string(jsonContact), gozxing.BarcodeFormat_QR_CODE, 512, 512, nil)
 | 
				
			||||||
@@ -136,8 +136,8 @@ func (contact *Contact) WriteQr(filename string) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func ReadQr(fielname string) Contact {
 | 
					func ReadQr(fielname string) ContactCard {
 | 
				
			||||||
	var contact Contact
 | 
						var contact ContactCard
 | 
				
			||||||
	// open and decode image file
 | 
						// open and decode image file
 | 
				
			||||||
	file, _ := os.Open("qrcode.jpg")
 | 
						file, _ := os.Open("qrcode.jpg")
 | 
				
			||||||
	img, _, _ := image.Decode(file)
 | 
						img, _, _ := image.Decode(file)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user