Difference between revisions of "MpOTR/algorithm dump"

(Created page with "===Example of an Algorithm in Wiki=== {{algorithm-begin|name=LargestNumber}} Input: A list of numbers ''L''. Output: The largest number in the list ''L''. ''largest'...")
 
Line 1: Line 1:
===Example of an Algorithm in Wiki===
 
{{algorithm-begin|name=LargestNumber}}
 
  Input: A list of numbers ''L''.
 
  Output: The largest number in the list ''L''.
 
 
  ''largest'' ← null
 
  '''for each''' ''item'' '''in''' "L"', '''do'''
 
    '''if''' ''item'' > ''largest'', '''then'''
 
      ''largest'' ← ''item''
 
  '''return''' ''largest''
 
{{algorithm-end}}
 
 
===mpOTR algorithms===
 
 
====Chatroom setup====
 
====Chatroom setup====
 
<!--alg_chat_setup-->
 
<!--alg_chat_setup-->
 
{{algorithm-begin|name=Chat Initiator Init}}
 
{{algorithm-begin|name=Chat Initiator Init}}
  Input: ''newRoomName'', ''participantNick''
+
  Input: <math>newRoomName</math>, <math>participantNick</math>
   Global ''myId := 1''
+
   Global <math>myId := 1</math>
   Global ''Nick_{myId} := participantNick''
+
   Global <math>Nick_{myId} := participantNick</math>
   Global ''roomName := newRoomName''
+
   Global <math>roomName := newRoomName</math>
   Global ''x_{myId}, y_{myId} :='' '''Call''' '''Generate Initial Paramters'''(''myId'')
+
   Global <math>x_{myId}, y_{myId} :=</math> '''Call''' '''Generate Initial Paramters'''(<math>myId</math>)
   Global ''signatureKey_{myId} := (x_{myId},y_{myId})''
+
   Global <math>signatureKey_{myId} := (x_{myId},y_{myId})</math>
   ''participantList := [Nick_{myId}]''
+
   <math>participantList := [Nick_{myId}]</math>
   ''ephemeralPublicPointList := [y_{myId}, y_{other}]''
+
   <math>ephemeralPublicPointList := [y_{myId}, y_{other}]</math>
 
{{algorithm-end}}
 
{{algorithm-end}}
  
  
 
{{algorithm-begin|name=Verify Verifier Generate Init Key}}
 
{{algorithm-begin|name=Verify Verifier Generate Init Key}}
  Input: ''schnorrRandomPoint_{other''
+
  Input: <math>schnorrRandomPoint_{other</math>
 
   '''Call''' '''Verify Verifiers'''()
 
   '''Call''' '''Verify Verifiers'''()
   Global ''sessionKey := SHA-512(x_{myId}y_{other}, sessionId)''
+
   Global <math>sessionKey := SHA-512(x_{myId}y_{other}, sessionId)</math>
   ''toBeSigned := SHA-512(SHA-512(sessionId||SHA-512(y_1, v_1)||SHA-512(y_2,v_2)))''
+
   <math>toBeSigned := SHA-512(SHA-512(sessionId||SHA-512(y_1, v_1)||SHA-512(y_2,v_2)))</math>
   '''Call''' '''Sign Session and Send'''(''toBeSigned'')
+
   '''Call''' '''Sign Session and Send'''(<math>toBeSigned</math>)
 
{{algorithm-end}}
 
{{algorithm-end}}
  
Line 40: Line 27:
 
<!--alg_join-->
 
<!--alg_join-->
 
{{algorithm-begin|name=Join}}
 
{{algorithm-begin|name=Join}}
  Input: ''newRoomName'', ''Nickname_{myId''
+
  Input: <math>newRoomName</math>, <math>Nickname_{myId</math>
   Global ''myId := participantId''
+
   Global <math>myId := participantId</math>
   Global ''roomName := newRoomName''
+
   Global <math>roomName := newRoomName</math>
   ''x_{myId}, y_{myId} := '''''Call''' '''Generate Initial Paramters'''(Participant ID ''myId'')
+
   <math>x_{myId}, y_{myId} := </math>'''Call''' '''Generate Initial Paramters'''(Participant ID <math>myId</math>)
   Global ''signatureKey_{myId} := (x_{myId},y_{myId})''
+
   Global <math>signatureKey_{myId} := (x_{myId},y_{myId})</math>
   '''Call''' '''Broadcast'''(``:3mpCat:3Join:3'', ''myId'', ''Nickname_{myId'')
+
   '''Call''' '''Broadcast'''(``:3mpCat:3Join:3'', <math>myId</math>, <math>Nickname_{myId</math>)
   Global ''participantList, ephemeralPublicPointList :='' '''Call''' '''Receive'''()
+
   Global <math>participantList, ephemeralPublicPointList :=</math> '''Call''' '''Receive'''()
   Global ''sessionId := '' '''Call''' '''Compute Session Id'''(''roomName'', ''participantList'', ''ephemeralPublicPointList'')
+
   Global <math>sessionId := </math> '''Call''' '''Compute Session Id'''(<math>roomName</math>, <math>participantList</math>, <math>ephemeralPublicPointList</math>)
 
   '''Call''' '''Sign and Send Key Confirmation and Shares'''()
 
   '''Call''' '''Sign and Send Key Confirmation and Shares'''()
 
   '''Call''' '''Wait On Receive'''(``:3mpCat:3KeyConfirmationShare:3'')
 
   '''Call''' '''Wait On Receive'''(``:3mpCat:3KeyConfirmationShare:3'')
   Global ''keyShareList, keyConfirmationList, signatureList :='' '''Call''' '''Receive'''()
+
   Global <math>keyShareList, keyConfirmationList, signatureList :=</math> '''Call''' '''Receive'''()
   '''Call''' '''Verify Key Confirmations and Signatures'''(''keyConfirmationList'', ''signatureList'')
+
   '''Call''' '''Verify Key Confirmations and Signatures'''(<math>keyConfirmationList</math>, <math>signatureList</math>)
 
   '''Call''' '''Update Session Key'''()
 
   '''Call''' '''Update Session Key'''()
 
{{algorithm-end}}
 
{{algorithm-end}}
Line 57: Line 44:
  
 
{{algorithm-begin|name=Receive Session Digest}}
 
{{algorithm-begin|name=Receive Session Digest}}
  Input: ''currentSessionHistoryDigest''
+
  Input: <math>currentSessionHistoryDigest</math>
   Global ''sessionDigest := currentSessionHistoryDigest''
+
   Global <math>sessionDigest := currentSessionHistoryDigest</math>
 
{{algorithm-end}}
 
{{algorithm-end}}
  
Line 68: Line 55:
 
{{algorithm-begin|name=Accept}}
 
{{algorithm-begin|name=Accept}}
 
  Input: newParticipant
 
  Input: newParticipant
   '''Call''' '''Broadcast'''(``:3mpCat:3Join:3'', ''myId'', ''Nickname_{myId'')
+
   '''Call''' '''Broadcast'''(``:3mpCat:3Join:3'', <math>myId</math>, <math>Nickname_{myId</math>)
 
   '''Call''' '''Wait On Receive'''(``:3mpCat:3Join:3'')
 
   '''Call''' '''Wait On Receive'''(``:3mpCat:3Join:3'')
   Global ''nick_{NewParticipant}'', ''ephemeralPublicPoint_{NewParticipant} := '' '''Call''' '''Receive'''()
+
   Global <math>nick_{NewParticipant}</math>, <math>ephemeralPublicPoint_{NewParticipant} := </math> '''Call''' '''Receive'''()
   '''Call''' '''Update Lists'''(''nick_{NewParticipant'')
+
   '''Call''' '''Update Lists'''(<math>nick_{NewParticipant</math>)
   Global ''sessionId := '' '''Call''' '''Compute Session Id'''(''roomName'', ''participantList'', ''ephemeralPublicPointList'')
+
   Global <math>sessionId := </math> '''Call''' '''Compute Session Id'''(<math>roomName</math>, <math>participantList</math>, <math>ephemeralPublicPointList</math>)
 
   '''Call''' '''Sign and Send Key Confirmation and Shares'''()
 
   '''Call''' '''Sign and Send Key Confirmation and Shares'''()
 
   '''Call''' '''Wait On Receive'''(``:3mpCat:3KeyConfirmationShare:3'')
 
   '''Call''' '''Wait On Receive'''(``:3mpCat:3KeyConfirmationShare:3'')
   Global ''keyShareList, keyConfirmationList, signatureList :='' '''Call''' '''Receive'''()
+
   Global <math>keyShareList, keyConfirmationList, signatureList :=</math> '''Call''' '''Receive'''()
   '''Call''' '''Verify Key Confirmations and Signatures'''(''keyConfirmationList'', ''signatureList'')
+
   '''Call''' '''Verify Key Confirmations and Signatures'''(<math>keyConfirmationList</math>, <math>signatureList</math>)
 
   '''Call''' '''Update Session Key'''()
 
   '''Call''' '''Update Session Key'''()
   '''Call''' '''Send'''(''sessionDigest'')
+
   '''Call''' '''Send'''(<math>sessionDigest</math>)
 
{{algorithm-end}}
 
{{algorithm-end}}
  
Line 85: Line 72:
 
<!--alg_farewell-->
 
<!--alg_farewell-->
 
{{algorithm-begin|name=Shrink on Leave}}
 
{{algorithm-begin|name=Shrink on Leave}}
  Input: ''leaverId''
+
  Input: <math>leaverId</math>
   Remove ''leaverId'' from ''participantIdList''
+
   Remove <math>leaverId</math> from <math>participantIdList</math>
   Global ''sessionId :='' '''Call''' '''Compute Session Id'''()
+
   Global <math>sessionId :=</math> '''Call''' '''Compute Session Id'''()
   \If{''|participantList| > 1''}
+
   \If{<math>|participantList| > 1</math>}
 
   '''Call''' '''Sign and Send Key Shares'''()
 
   '''Call''' '''Sign and Send Key Shares'''()
 
   '''Call''' '''Wait On Receive'''(``:3mpCat:3KeyShare:3'')
 
   '''Call''' '''Wait On Receive'''(``:3mpCat:3KeyShare:3'')
   ''keyShareList'' := Receive{}
+
   <math>keyShareList</math> := Receive{}
   '''Call''' '''Update Session Key'''(''keyShareList'')
+
   '''Call''' '''Update Session Key'''(<math>keyShareList</math>)
 
{{algorithm-end}}
 
{{algorithm-end}}
  
Line 98: Line 85:
 
{{algorithm-begin|name=Sign and Send Key Shares}}
 
{{algorithm-begin|name=Sign and Send Key Shares}}
 
  Input:  
 
  Input:  
   Global ''z_{myId -1, myId} := SHA-512(k_{myId,myId-1}, sessionId)''
+
   Global <math>z_{myId -1, myId} := SHA-512(k_{myId,myId-1}, sessionId)</math>
   Global ''z_{myId, myId+1} := SHA-512(k_{myId,myId+1}, sessionId)''
+
   Global <math>z_{myId, myId+1} := SHA-512(k_{myId,myId+1}, sessionId)</math>
   ''keyShare_{myId} := z_{myId -1, myId} \oplus z_{myId, myId+1}''
+
   <math>keyShare_{myId} := z_{myId -1, myId} \oplus z_{myId, myId+1}</math>
   ''originAuthSignature :='' '''Call''' '''ED25519Sign'''(''SignatureKey'', ''sessionId'' || ''z_{myId'')
+
   <math>originAuthSignature :=</math> '''Call''' '''ED25519Sign'''(<math>SignatureKey</math>, <math>sessionId</math> || <math>z_{myId</math>)
   '''Call''' '''Broadcast'''(``:3mpCat:3KeyShare:3'', ''myId'', ''keyShare_{myId'')
+
   '''Call''' '''Broadcast'''(``:3mpCat:3KeyShare:3'', <math>myId</math>, <math>keyShare_{myId</math>)
 
{{algorithm-end}}
 
{{algorithm-end}}
  
Line 110: Line 97:
 
{{algorithm-begin|name=Send}}
 
{{algorithm-begin|name=Send}}
 
  Input: Message
 
  Input: Message
  ''keyShareMessage'' = '''Call''' '''NewKeyShareMessage'''(MetaMessage)
+
  <math>keyShareMessage</math> = '''Call''' '''NewKeyShareMessage'''(MetaMessage)
  ''cryptMessage'' := '''Call''' '''AES CTR Encrypt'''(''sessionKey'',''message | keyShareMessage'')
+
  <math>cryptMessage</math> := '''Call''' '''AES CTR Encrypt'''(<math>sessionKey</math>,<math>message | keyShareMessage</math>)
  ''originAuthSignature'' := '''Call''' '''ED25519Sign'''(''SignatureKey'', ''sessionId'' || ''cryptMetatMessage'')
+
  <math>originAuthSignature</math> := '''Call''' '''ED25519Sign'''(<math>SignatureKey</math>, <math>sessionId</math> || <math>cryptMetatMessage</math>)
  ''sessionDigest'' := '''Call''' '''Compute Session Digest'''(''lastMessage'')
+
  <math>sessionDigest</math> := '''Call''' '''Compute Session Digest'''(<math>lastMessage</math>)
  '''Call''' '''Broadcast'''(``:3mpCat:3'', ''sessionId'', ''cryptMessage'', ''sessionDigest'', ''originAuthSignature'',``:3'')
+
  '''Call''' '''Broadcast'''(``:3mpCat:3'', <math>sessionId</math>, <math>cryptMessage</math>, <math>sessionDigest</math>, <math>originAuthSignature</math>,``:3'')
 
{{algorithm-end}}
 
{{algorithm-end}}
  
Line 121: Line 108:
 
<!--alg_recv-->
 
<!--alg_recv-->
 
{{algorithm-begin|name=Receive}}
 
{{algorithm-begin|name=Receive}}
  Input: ''sender'', ''encryptedMessage'', ''originAuthSignature'', ''sessionDigest''
+
  Input: <math>sender</math>, <math>encryptedMessage</math>, <math>originAuthSignature</math>, <math>sessionDigest</math>
  ''v := '' '''Call''' '''ED25519VerifySignature'''(''ephemeralPublicKeyList[Sender]'', ''sessionId || encryptedMessage'', ''originAuthSignature'')
+
  <math>v := </math> '''Call''' '''ED25519VerifySignature'''(<math>ephemeralPublicKeyList[Sender]</math>, <math>sessionId || encryptedMessage</math>, <math>originAuthSignature</math>)
  '''Call''' '''Assert'''(''v'')
+
  '''Call''' '''Assert'''(<math>v</math>)
  ''message, keyShareMessage :='' '''Call''' '''AES CTR Decrypt'''(''sessionKey'', ''encryptedMessage'')
+
  <math>message, keyShareMessage :=</math> '''Call''' '''AES CTR Decrypt'''(<math>sessionKey</math>, <math>encryptedMessage</math>)
  ''isMetaMessage = '''''Call''' '''UpdateNewKeyStatus'''(''keyShareMessage'')
+
  <math>isMetaMessage = </math>'''Call''' '''UpdateNewKeyStatus'''(<math>keyShareMessage</math>)
  '''Call''' '''Verify Digests'''(''sessionDiges'')
+
  '''Call''' '''Verify Digests'''(<math>sessionDiges</math>)
  '''Return'''{''isMetaMessage, message''}
+
  '''Return'''{<math>isMetaMessage, message</math>}
 
{{algorithm-end}}
 
{{algorithm-end}}
  
Line 140: Line 127:
  
 
{{algorithm-begin|name=Generate Initial Paramters}}
 
{{algorithm-begin|name=Generate Initial Paramters}}
  Input: ''myId''
+
  Input: <math>myId</math>
   ''signaturePrivateKey := '' '''Call''' '''RandomBits'''(256)
+
   <math>signaturePrivateKey := </math> '''Call''' '''RandomBits'''(256)
   ''x_{myId} :='' '''Call''' '''Ed25519 Scalar'''(''signaturePrivateKey''))
+
   <math>x_{myId} :=</math> '''Call''' '''Ed25519 Scalar'''(<math>signaturePrivateKey</math>))
   ''y_{myId} := x_{myId}P''
+
   <math>y_{myId} := x_{myId}P</math>
   '''Return''' ''x,y''
+
   '''Return''' <math>x,y</math>
 
{{algorithm-end}}
 
{{algorithm-end}}
  
  
 
{{algorithm-begin|name=Verify Key Confirmation and Signatures}}
 
{{algorithm-begin|name=Verify Key Confirmation and Signatures}}
  Input: ''signatureList'', ''keyConfirmationList''
+
  Input: <math>signatureList</math>, <math>keyConfirmationList</math>
   '''For each''' ''participant \in participantList''}, '''do'''
+
   '''For each''' <math>participant \in participantList</math>}, '''do'''
     \If{''keyConfirmationList[participant][myId] \neq SHA-512(k_{myId,participant}, U_{myId})''}
+
     \If{<math>keyConfirmationList[participant][myId] \neq SHA-512(k_{myId,participant}, U_{myId})</math>}
 
       '''Call''' '''Halt'''()
 
       '''Call''' '''Halt'''()
       ' \If{'''Call''' '''ED25519VerifySignature'''(''ephemeralPublicKeyList[particicpant]'', ''sessionId ||keyShares[myId]'', ''originAuthSignature'')'
+
       ' \If{'''Call''' '''ED25519VerifySignature'''(<math>ephemeralPublicKeyList[particicpant]</math>, <math>sessionId ||keyShares[myId]</math>, <math>originAuthSignature</math>)'
 
       '''Call''' '''Halt'''()
 
       '''Call''' '''Halt'''()
 
{{algorithm-end}}
 
{{algorithm-end}}
Line 159: Line 146:
  
 
{{algorithm-begin|name=Compute Session Id}}
 
{{algorithm-begin|name=Compute Session Id}}
  Input: ''participantList'', ''ephemeralPublicPointList''
+
  Input: <math>participantList</math>, <math>ephemeralPublicPointList</math>
   '''Return''' ''SHA-512(roomeName, zip(participantList, ephemeralPublicPointList))'' # ''zip([a,b],[c,d]):=[(a,c),(b,d)]''
+
   '''Return''' <math>SHA-512(roomeName, zip(participantList, ephemeralPublicPointList))</math> # <math>zip([a,b],[c,d]):=[(a,c),(b,d)]</math>
 
{{algorithm-end}}
 
{{algorithm-end}}
  
  
 
{{algorithm-begin|name=Verify Signatures}}
 
{{algorithm-begin|name=Verify Signatures}}
  Input: ''longPublicList'',''schnorrRandomPointList'',  
+
  Input: <math>longPublicList</math>,<math>schnorrRandomPointList</math>,  
 
{{algorithm-end}}
 
{{algorithm-end}}
  
  
 
{{algorithm-begin|name=Sign and Send Key Confirmation and Share}}
 
{{algorithm-begin|name=Sign and Send Key Confirmation and Share}}
  Input: ''schnorrRandomPointList''
+
  Input: <math>schnorrRandomPointList</math>
  '''For each''' ''participant \in participantList'', '''do'''
+
  '''For each''' <math>participant \in participantList</math>, '''do'''
     ''k_{myId, participant} := H(g^{lp_{myId}}LP_{participant}y_{participant}^{x_{myId}})'' # Triple DH
+
     <math>k_{myId, participant} := H(g^{lp_{myId}}LP_{participant}y_{participant}^{x_{myId}})</math> # Triple DH
     ''kc_{myId} := kc_{myId} | H(k_{myId,participant}, U_{participant})''
+
     <math>kc_{myId} := kc_{myId} | H(k_{myId,participant}, U_{participant})</math>
  
  
   Global ''z_{myId -1, myId} := SHA-512(k_{myId,myId-1}, sessionId)''
+
   Global <math>z_{myId -1, myId} := SHA-512(k_{myId,myId-1}, sessionId)</math>
   Global ''z_{myId, myId+1} := SHA-512(k_{myId,myId+1}, sessionId)''
+
   Global <math>z_{myId, myId+1} := SHA-512(k_{myId,myId+1}, sessionId)</math>
   ''keyShare_{myId} := z_{myId -1, myId} \oplus z_{myId, myId+1}''
+
   <math>keyShare_{myId} := z_{myId -1, myId} \oplus z_{myId, myId+1}</math>
  
  
     ''originAuthSignature :='' '''Call''' '''ED25519Sign'''(''SignatureKey'', ''sessionId'' || ''z_{myId'')
+
     <math>originAuthSignature :=</math> '''Call''' '''ED25519Sign'''(<math>SignatureKey</math>, <math>sessionId</math> || <math>z_{myId</math>)
   '''Call''' '''Broadcast'''(``:3mpCat:3KeyConfirmationAndShare:3'', ''myId'', ''keyShare_{myId'')
+
   '''Call''' '''Broadcast'''(``:3mpCat:3KeyConfirmationAndShare:3'', <math>myId</math>, <math>keyShare_{myId</math>)
 
{{algorithm-end}}
 
{{algorithm-end}}
  
  
 
{{algorithm-begin|name=Update Session Key}}
 
{{algorithm-begin|name=Update Session Key}}
  Input: ''keyShareList''
+
  Input: <math>keyShareList</math>
  ''i := myId''
+
  <math>i := myId</math>
'''For each''' ''{j \in [i,...,i+n-1]}''}, '''do'''
+
'''For each''' <math>{j \in [i,...,i+n-1]}</math>}, '''do'''
   ''z_{j,j+1} := z_{j-1,j} \oplus keyShareListe[j+1]''
+
   <math>z_{j,j+1} := z_{j-1,j} \oplus keyShareListe[j+1]</math>
  # recovered ''z_{i-1,i}'' should be equal to its original value
+
  # recovered <math>z_{i-1,i}</math> should be equal to its original value
  Global ''sessionKey := SHA-512(z_{j,j+1} | j \in [1...n])''
+
  Global <math>sessionKey := SHA-512(z_{j,j+1} | j \in [1...n])</math>
 
{{algorithm-end}}
 
{{algorithm-end}}
  
  
 
{{algorithm-begin|name=Sign Params Update Session Key}}
 
{{algorithm-begin|name=Sign Params Update Session Key}}
  Input: ''toBeSigned'', ''signatureList'', ''keyShareList''
+
  Input: <math>toBeSigned</math>, <math>signatureList</math>, <math>keyShareList</math>
 
  '''Call''' '''Update Session Key'''()
 
  '''Call''' '''Update Session Key'''()
  ''toBeSigned := SHA-512(sessionId, ||SHA-512(verifierList, ephemeralPublicPointList, keyShareList)))''
+
  <math>toBeSigned := SHA-512(sessionId, ||SHA-512(verifierList, ephemeralPublicPointList, keyShareList)))</math>
  ''signature_{myId} := '''''Call''' '''Sign Session and Send'''(''toBeSigned'')
+
  <math>signature_{myId} := </math>'''Call''' '''Sign Session and Send'''(<math>toBeSigned</math>)
  '''Call''' '''Broadcast'''(``:3mpCat:3SignedSessionParameters:3'',''signature_{myId'')
+
  '''Call''' '''Broadcast'''(``:3mpCat:3SignedSessionParameters:3'',<math>signature_{myId</math>)
 
{{algorithm-end}}
 
{{algorithm-end}}
  
  
 
{{algorithm-begin|name=ComputeSessionDigest}}
 
{{algorithm-begin|name=ComputeSessionDigest}}
  Input: ''lastMessage''
+
  Input: <math>lastMessage</math>
'''For each''' ''message'' in Messages Received from ''lastDigestedMessage''+1 till ''lastMessage''}, '''do'''
+
'''For each''' <math>message</math> in Messages Received from <math>lastDigestedMessage</math>+1 till <math>lastMessage</math>}, '''do'''
  ''sesionDigest :='' '''Call''' '''SHA-512'''(''sessionDigest'', ''message'')
+
  <math>sesionDigest :=</math> '''Call''' '''SHA-512'''(<math>sessionDigest</math>, <math>message</math>)
  '''Call''' '''LRU Cache Store Digest'''(''sessionDigest'', ''message'')
+
  '''Call''' '''LRU Cache Store Digest'''(<math>sessionDigest</math>, <math>message</math>)
  '''Return''' ''sessionDigest'',''lastMessageId''
+
  '''Return''' <math>sessionDigest</math>,<math>lastMessageId</math>
 
{{algorithm-end}}
 
{{algorithm-end}}

Revision as of 10:33, 27 July 2014

Chatroom setup

Procedure Chat Initiator Init
Input: newRoomName, participantNick
  Global myId:=1
  Global Nick_{{myId}}:=participantNick
  Global roomName:=newRoomName
  Global x_{{myId}},y_{{myId}}:= Call Generate Initial Paramters(myId)
  Global signatureKey_{{myId}}:=(x_{{myId}},y_{{myId}})
  participantList:=[Nick_{{myId}}]
  ephemeralPublicPointList:=[y_{{myId}},y_{{other}}]


Procedure Verify Verifier Generate Init Key
Input: Failed to parse (syntax error): schnorrRandomPoint_{other
  Call Verify Verifiers()
  Global sessionKey:=SHA-512(x_{{myId}}y_{{other}},sessionId)
  toBeSigned:=SHA-512(SHA-512(sessionId||SHA-512(y_{1},v_{1})||SHA-512(y_{2},v_{2})))
  Call Sign Session and Send(toBeSigned)



Join

Procedure Join
Input: newRoomName, Failed to parse (syntax error): Nickname_{myId
  Global myId:=participantId
  Global roomName:=newRoomName
  x_{{myId}},y_{{myId}}:=Call Generate Initial Paramters(Participant ID myId)
  Global signatureKey_{{myId}}:=(x_{{myId}},y_{{myId}})
  Call Broadcast(``:3mpCat:3Join:3, myId, Failed to parse (syntax error): Nickname_{myId

)

  Global participantList,ephemeralPublicPointList:= Call Receive()
  Global sessionId:= Call Compute Session Id(roomName, participantList, ephemeralPublicPointList)
  Call Sign and Send Key Confirmation and Shares()
  Call Wait On Receive(``:3mpCat:3KeyConfirmationShare:3)
  Global keyShareList,keyConfirmationList,signatureList:= Call Receive()
  Call Verify Key Confirmations and Signatures(keyConfirmationList, signatureList)
  Call Update Session Key()


Procedure Receive Session Digest
Input: currentSessionHistoryDigest
  Global sessionDigest:=currentSessionHistoryDigest



Protocol for other participants already in the chat to accept the newcomer

Procedure Accept
Input: newParticipant
  Call Broadcast(``:3mpCat:3Join:3, myId, Failed to parse (syntax error): Nickname_{myId

)

  Call Wait On Receive(``:3mpCat:3Join:3)
  Global nick_{{NewParticipant}}, ephemeralPublicPoint_{{NewParticipant}}:= Call Receive()
  Call Update Lists(Failed to parse (syntax error): nick_{NewParticipant

)

  Global sessionId:= Call Compute Session Id(roomName, participantList, ephemeralPublicPointList)
  Call Sign and Send Key Confirmation and Shares()
  Call Wait On Receive(``:3mpCat:3KeyConfirmationShare:3)
  Global keyShareList,keyConfirmationList,signatureList:= Call Receive()
  Call Verify Key Confirmations and Signatures(keyConfirmationList, signatureList)
  Call Update Session Key()
  Call Send(sessionDigest)


Farewell

Procedure Shrink on Leave
Input: leaverId
  Remove leaverId from participantIdList
  Global sessionId:= Call Compute Session Id()
 \If{|participantList|>1}
  Call Sign and Send Key Shares()
  Call Wait On Receive(``:3mpCat:3KeyShare:3)
  keyShareList := Receive{}
  Call Update Session Key(keyShareList)


Procedure Sign and Send Key Shares
Input: 
  Global z_{{myId-1,myId}}:=SHA-512(k_{{myId,myId-1}},sessionId)
  Global z_{{myId,myId+1}}:=SHA-512(k_{{myId,myId+1}},sessionId)
  keyShare_{{myId}}:=z_{{myId-1,myId}}\oplus z_{{myId,myId+1}}
  originAuthSignature:= Call ED25519Sign(SignatureKey, sessionId || Failed to parse (syntax error): z_{myId

)

  Call Broadcast(``:3mpCat:3KeyShare:3, myId, Failed to parse (syntax error): keyShare_{myId

)


Send

Procedure Send
Input: Message
keyShareMessage = Call NewKeyShareMessage(MetaMessage)
cryptMessage := Call AES CTR Encrypt(sessionKey,message|keyShareMessage)
originAuthSignature := Call ED25519Sign(SignatureKey, sessionId || cryptMetatMessage)
sessionDigest := Call Compute Session Digest(lastMessage)
Call Broadcast(``:3mpCat:3, sessionId, cryptMessage, sessionDigest, originAuthSignature,``:3)


Recieve

Procedure Receive
Input: sender, encryptedMessage, originAuthSignature, sessionDigest
v:= Call ED25519VerifySignature(ephemeralPublicKeyList[Sender], sessionId||encryptedMessage, originAuthSignature)
Call Assert(v)
message,keyShareMessage:= Call AES CTR Decrypt(sessionKey, encryptedMessage)
isMetaMessage=Call UpdateNewKeyStatus(keyShareMessage)
Call Verify Digests(sessionDiges)
Return{isMetaMessage,message}


\subsection{Common functions}


Common functions used by other procedures in different stages

Procedure Generate Initial Paramters
Input: myId
  signaturePrivateKey:= Call RandomBits(256)
  x_{{myId}}:= Call Ed25519 Scalar(signaturePrivateKey))
  y_{{myId}}:=x_{{myId}}P
 Return x,y


Procedure Verify Key Confirmation and Signatures
Input: signatureList, keyConfirmationList
  For each participant\in participantList}, do
    \If{keyConfirmationList[participant][myId]\neq SHA-512(k_{{myId,participant}},U_{{myId}})}
      Call Halt()
     ' \If{Call ED25519VerifySignature(ephemeralPublicKeyList[particicpant], sessionId||keyShares[myId], originAuthSignature)'
      Call Halt()


Procedure Compute Session Id
Input: participantList, ephemeralPublicPointList
  Return SHA-512(roomeName,zip(participantList,ephemeralPublicPointList)) # zip([a,b],[c,d]):=[(a,c),(b,d)]


Procedure Verify Signatures
Input: longPublicList,schnorrRandomPointList, 


Procedure Sign and Send Key Confirmation and Share
Input: schnorrRandomPointList
For each participant\in participantList, do
    k_{{myId,participant}}:=H(g^{{lp_{{myId}}}}LP_{{participant}}y_{{participant}}^{{x_{{myId}}}}) # Triple DH
    kc_{{myId}}:=kc_{{myId}}|H(k_{{myId,participant}},U_{{participant}})


  Global z_{{myId-1,myId}}:=SHA-512(k_{{myId,myId-1}},sessionId)
  Global z_{{myId,myId+1}}:=SHA-512(k_{{myId,myId+1}},sessionId)
  keyShare_{{myId}}:=z_{{myId-1,myId}}\oplus z_{{myId,myId+1}}


    originAuthSignature:= Call ED25519Sign(SignatureKey, sessionId || Failed to parse (syntax error): z_{myId

)

  Call Broadcast(``:3mpCat:3KeyConfirmationAndShare:3, myId, Failed to parse (syntax error): keyShare_{myId

)


Procedure Update Session Key
Input: keyShareList
i:=myId

For each {j\in [i,...,i+n-1]}}, do

  z_{{j,j+1}}:=z_{{j-1,j}}\oplus keyShareListe[j+1]
# recovered z_{{i-1,i}} should be equal to its original value
Global sessionKey:=SHA-512(z_{{j,j+1}}|j\in [1...n])


Procedure Sign Params Update Session Key
Input: toBeSigned, signatureList, keyShareList
Call Update Session Key()
toBeSigned:=SHA-512(sessionId,||SHA-512(verifierList,ephemeralPublicPointList,keyShareList)))
signature_{{myId}}:=Call Sign Session and Send(toBeSigned)
Call Broadcast(``:3mpCat:3SignedSessionParameters:3,Failed to parse (syntax error): signature_{myId

)


Procedure ComputeSessionDigest
Input: lastMessage

For each message in Messages Received from lastDigestedMessage+1 till lastMessage}, do

sesionDigest:= Call SHA-512(sessionDigest, message)
Call LRU Cache Store Digest(sessionDigest, message)
Return sessionDigest,lastMessageId