Difference between revisions of "MpOTR/algorithm dump"
Line 1: | Line 1: | ||
====Chatroom setup==== | ====Chatroom setup==== | ||
<!--alg_chat_setup--> | <!--alg_chat_setup--> | ||
− | {{algorithm-begin|name= | + | {{algorithm-begin|name=Chatroom Init}} |
Input: <math>newRoomName</math>, <math>participantNick</math> | Input: <math>newRoomName</math>, <math>participantNick</math> | ||
Global <math>myId := 1</math> | Global <math>myId := 1</math> | ||
Global <math>Nick_{myId} := participantNick</math> | Global <math>Nick_{myId} := participantNick</math> | ||
Global <math>roomName := newRoomName</math> | Global <math>roomName := newRoomName</math> | ||
− | Global <math>x_{myId}, y_{myId} :=</math> | + | Global <math>x_{myId}, y_{myId} :=</math> <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Generate Initial Paramters</span>'''(<math>myId</math>) |
Global <math>signatureKey_{myId} := (x_{myId},y_{myId})</math> | Global <math>signatureKey_{myId} := (x_{myId},y_{myId})</math> | ||
<math>participantList := [Nick_{myId}]</math> | <math>participantList := [Nick_{myId}]</math> | ||
Line 14: | Line 14: | ||
{{algorithm-begin|name=Verify Verifier Generate Init Key}} | {{algorithm-begin|name=Verify Verifier Generate Init Key}} | ||
− | Input: <math>schnorrRandomPoint_{other</math> | + | Input: <math>schnorrRandomPoint_{other}</math>, <math>Hv_{other}</math>, <math>v_{other}</math>, <math>y_{other}</math>, <math>Nick_{other}</math> |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Verify Verifiers</span>'''() | |
− | Global <math>sessionKey := | + | Global <math>sessionKey := Hash(x_{myId}y_{other}, sessionId)</math> |
− | <math>toBeSigned := | + | <math>toBeSigned := Hash(Hash(sessionId||Hash(y_1, v_1)||Hash(y_2,v_2)))</math> |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Sign Session and Send</span>'''(<math>toBeSigned</math>) | |
{{algorithm-end}} | {{algorithm-end}} | ||
Line 27: | Line 27: | ||
<!--alg_join--> | <!--alg_join--> | ||
{{algorithm-begin|name=Join}} | {{algorithm-begin|name=Join}} | ||
− | Input: <math>newRoomName</math>, <math>Nickname_{myId</math> | + | Input: <math>newRoomName</math>, <math>Nickname_{myId}</math>, <math>participantId</math> |
Global <math>myId := participantId</math> | Global <math>myId := participantId</math> | ||
Global <math>roomName := newRoomName</math> | Global <math>roomName := newRoomName</math> | ||
− | <math>x_{myId}, y_{myId} := </math> | + | <math>x_{myId}, y_{myId} := </math><span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Generate Initial Paramters</span>'''(Participant ID <math>myId</math>) |
Global <math>signatureKey_{myId} := (x_{myId},y_{myId})</math> | Global <math>signatureKey_{myId} := (x_{myId},y_{myId})</math> | ||
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Broadcast</span>'''(":3mpCat:3Join:3", <math>myId</math>, <math>Nickname_{myId}</math>, <math>y_{myId}</math>) | |
− | Global <math>participantList, ephemeralPublicPointList :=</math> | + | Global <math>participantList, ephemeralPublicPointList :=</math> <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Receive</span>'''() |
− | Global <math>sessionId := </math> | + | Global <math>sessionId := </math> <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Compute Session Id</span>'''(<math>roomName</math>, <math>participantList</math>, <math>ephemeralPublicPointList</math>) |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Sign and Send Key Confirmation and Shares</span>'''() | |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Wait On Receive</span>'''(":3mpCat:3KeyConfirmationShare:3") | |
− | Global <math>keyShareList, keyConfirmationList, signatureList :=</math> | + | Global <math>keyShareList, keyConfirmationList, signatureList :=</math> <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Receive</span>'''() |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Verify Key Confirmations and Signatures</span>'''(<math>keyConfirmationList</math>, <math>signatureList</math>) | |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Update Session Key</span>'''() | |
{{algorithm-end}} | {{algorithm-end}} | ||
Line 55: | Line 55: | ||
{{algorithm-begin|name=Accept}} | {{algorithm-begin|name=Accept}} | ||
Input: newParticipant | Input: newParticipant | ||
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Broadcast</span>'''(":3mpCat:3Join:3", <math>myId</math>, <math>Nickname_{myId}</math>, <math>y_{myId}</math>) | |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Wait On Receive</span>'''(":3mpCat:3Join:3") | |
− | Global <math>nick_{NewParticipant}</math>, <math>ephemeralPublicPoint_{NewParticipant} := </math> | + | Global <math>nick_{NewParticipant}</math>, <math>ephemeralPublicPoint_{NewParticipant} := </math> <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Receive</span>'''() |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Update Lists</span>'''(<math>nick_{NewParticipant}</math>, <math>ephemeralPublicPoint_{NewParticipant}</math>) | |
− | Global <math>sessionId := </math> | + | Global <math>sessionId := </math> <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Compute Session Id</span>'''(<math>roomName</math>, <math>participantList</math>, <math>ephemeralPublicPointList</math>) |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Sign and Send Key Confirmation and Shares</span>'''() | |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Wait On Receive</span>'''(":3mpCat:3KeyConfirmationShare:3") | |
− | Global <math>keyShareList, keyConfirmationList, signatureList :=</math> | + | Global <math>keyShareList, keyConfirmationList, signatureList :=</math> <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Receive</span>'''() |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Verify Key Confirmations and Signatures</span>'''(<math>keyConfirmationList</math>, <math>signatureList</math>) | |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Update Session Key</span>'''() | |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Send</span>'''(<math>sessionDigest</math>) | |
{{algorithm-end}} | {{algorithm-end}} | ||
Line 74: | Line 74: | ||
Input: <math>leaverId</math> | Input: <math>leaverId</math> | ||
Remove <math>leaverId</math> from <math>participantIdList</math> | Remove <math>leaverId</math> from <math>participantIdList</math> | ||
− | Global <math>sessionId :=</math> | + | Global <math>sessionId :=</math> <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Compute Session Id</span>'''() |
− | + | '''If'''<math>|participantList| > 1</math>''', then''' | |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Sign and Send Key Shares</span>'''() | |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Wait On Receive</span>'''(":3mpCat:3KeyShare:3") | |
<math>keyShareList</math> := Receive{} | <math>keyShareList</math> := Receive{} | ||
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Update Session Key</span>'''(<math>keyShareList</math>) | |
{{algorithm-end}} | {{algorithm-end}} | ||
Line 85: | Line 85: | ||
{{algorithm-begin|name=Sign and Send Key Shares}} | {{algorithm-begin|name=Sign and Send Key Shares}} | ||
Input: | Input: | ||
− | Global <math>z_{myId -1, myId} := | + | Global <math>z_{myId -1, myId} := Hash(k_{myId,myId-1}, sessionId)</math> |
− | Global <math>z_{myId, myId+1} := | + | Global <math>z_{myId, myId+1} := Hash(k_{myId,myId+1}, sessionId)</math> |
<math>keyShare_{myId} := z_{myId -1, myId} \oplus z_{myId, myId+1}</math> | <math>keyShare_{myId} := z_{myId -1, myId} \oplus z_{myId, myId+1}</math> | ||
− | <math>originAuthSignature :=</math> | + | <math>originAuthSignature :=</math> <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''ED25519Sign</span>'''(<math>SignatureKey</math>, <math>sessionId</math> || <math>z_{myId}</math>) |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Broadcast</span>'''(":3mpCat:3KeyShare:3", <math>myId</math>, <math>keyShare_{myId}</math>, <math>originAuthSignature</math>) | |
{{algorithm-end}} | {{algorithm-end}} | ||
Line 96: | Line 96: | ||
<!--alg_send--> | <!--alg_send--> | ||
{{algorithm-begin|name=Send}} | {{algorithm-begin|name=Send}} | ||
− | Input: Message | + | Input: Message}{MetaMessage, message |
− | <math>keyShareMessage</math> = | + | <math>keyShareMessage</math> = <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''NewKeyShareMessage</span>'''(MetaMessage) |
− | <math>cryptMessage</math> := | + | <math>cryptMessage</math> := <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''AES CTR Encrypt</span>'''(<math>sessionKey</math>,<math>message | keyShareMessage</math>) |
− | <math>originAuthSignature</math> := | + | <math>originAuthSignature</math> := <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''ED25519Sign</span>'''(<math>SignatureKey</math>, <math>sessionId</math> || <math>cryptMetatMessage</math>) |
− | <math>sessionDigest</math> := | + | <math>sessionDigest</math> := <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Compute Session Digest</span>'''(<math>lastMessage</math>) |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Broadcast</span>'''(":3mpCat:3", <math>sessionId</math>, <math>cryptMessage</math>, <math>sessionDigest</math>, <math>originAuthSignature</math>,":3") | |
{{algorithm-end}} | {{algorithm-end}} | ||
Line 109: | Line 109: | ||
{{algorithm-begin|name=Receive}} | {{algorithm-begin|name=Receive}} | ||
Input: <math>sender</math>, <math>encryptedMessage</math>, <math>originAuthSignature</math>, <math>sessionDigest</math> | Input: <math>sender</math>, <math>encryptedMessage</math>, <math>originAuthSignature</math>, <math>sessionDigest</math> | ||
− | <math>v := </math> | + | <math>v := </math> <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''ED25519VerifySignature</span>'''(<math>ephemeralPublicKeyList[Sender]</math>, <math>sessionId || encryptedMessage</math>, <math>originAuthSignature</math>) |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Assert</span>'''(<math>v</math>) | |
− | <math>message, keyShareMessage :=</math> | + | <math>message, keyShareMessage :=</math> <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''AES CTR Decrypt</span>'''(<math>sessionKey</math>, <math>encryptedMessage</math>) |
− | <math>isMetaMessage = </math> | + | <math>isMetaMessage = </math><span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''UpdateNewKeyStatus</span>'''(<math>keyShareMessage</math>) |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Verify Digests</span>'''(<math>sessionDiges</math>) | |
'''Return'''{<math>isMetaMessage, message</math>} | '''Return'''{<math>isMetaMessage, message</math>} | ||
{{algorithm-end}} | {{algorithm-end}} | ||
Line 128: | Line 128: | ||
{{algorithm-begin|name=Generate Initial Paramters}} | {{algorithm-begin|name=Generate Initial Paramters}} | ||
Input: <math>myId</math> | Input: <math>myId</math> | ||
− | <math>signaturePrivateKey := </math> | + | <math>signaturePrivateKey := </math> <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''RandomBits</span>'''(256) |
− | <math>x_{myId} :=</math> | + | <math>x_{myId} :=</math> <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Ed25519 Scalar</span>'''(<math>signaturePrivateKey</math>)) |
<math>y_{myId} := x_{myId}P</math> | <math>y_{myId} := x_{myId}P</math> | ||
'''Return''' <math>x,y</math> | '''Return''' <math>x,y</math> | ||
Line 138: | Line 138: | ||
Input: <math>signatureList</math>, <math>keyConfirmationList</math> | Input: <math>signatureList</math>, <math>keyConfirmationList</math> | ||
'''For each''' <math>participant \in participantList</math>}, '''do''' | '''For each''' <math>participant \in participantList</math>}, '''do''' | ||
− | \If{<math>keyConfirmationList[participant][myId] \neq | + | \If{<math>keyConfirmationList[participant][myId] \neq Hash(k_{myId,participant}, U_{myId})</math>} |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Halt</span>'''() | |
− | ' \If{ | + | ' \If{<span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''ED25519VerifySignature</span>'''(<math>ephemeralPublicKeyList[particicpant]</math>, <math>sessionId ||keyShares[myId]</math>, <math>originAuthSignature</math>)' |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Halt</span>'''() | |
{{algorithm-end}} | {{algorithm-end}} | ||
Line 147: | Line 147: | ||
{{algorithm-begin|name=Compute Session Id}} | {{algorithm-begin|name=Compute Session Id}} | ||
Input: <math>participantList</math>, <math>ephemeralPublicPointList</math> | Input: <math>participantList</math>, <math>ephemeralPublicPointList</math> | ||
− | '''Return''' <math> | + | '''Return''' <math>Hash(roomeName, zip(participantList, ephemeralPublicPointList))</math> # <math>zip([a,b],[c,d]):=[(a,c),(b,d)]</math> |
{{algorithm-end}} | {{algorithm-end}} | ||
Line 163: | Line 163: | ||
− | Global <math>z_{myId -1, myId} := | + | Global <math>z_{myId -1, myId} := Hash(k_{myId,myId-1}, sessionId)</math> |
− | Global <math>z_{myId, myId+1} := | + | Global <math>z_{myId, myId+1} := Hash(k_{myId,myId+1}, sessionId)</math> |
<math>keyShare_{myId} := z_{myId -1, myId} \oplus z_{myId, myId+1}</math> | <math>keyShare_{myId} := z_{myId -1, myId} \oplus z_{myId, myId+1}</math> | ||
− | <math>originAuthSignature :=</math> | + | <math>originAuthSignature :=</math> <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''ED25519Sign</span>'''(<math>SignatureKey</math>, <math>sessionId</math> || <math>z_{myId}</math>) |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Broadcast</span>'''(":3mpCat:3KeyConfirmationAndShare:3", <math>myId</math>, <math>keyShare_{myId}</math>, <math>originAuthSignature</math>, <math>kc_{myId}</math>) | |
{{algorithm-end}} | {{algorithm-end}} | ||
Line 179: | Line 179: | ||
<math>z_{j,j+1} := z_{j-1,j} \oplus keyShareListe[j+1]</math> | <math>z_{j,j+1} := z_{j-1,j} \oplus keyShareListe[j+1]</math> | ||
# recovered <math>z_{i-1,i}</math> should be equal to its original value | # recovered <math>z_{i-1,i}</math> should be equal to its original value | ||
− | Global <math>sessionKey := | + | Global <math>sessionKey := Hash(z_{j,j+1} | j \in [1...n])</math> |
{{algorithm-end}} | {{algorithm-end}} | ||
Line 185: | Line 185: | ||
{{algorithm-begin|name=Sign Params Update Session Key}} | {{algorithm-begin|name=Sign Params Update Session Key}} | ||
Input: <math>toBeSigned</math>, <math>signatureList</math>, <math>keyShareList</math> | Input: <math>toBeSigned</math>, <math>signatureList</math>, <math>keyShareList</math> | ||
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Update Session Key</span>'''() | |
− | <math>toBeSigned := | + | <math>toBeSigned := Hash(sessionId, ||Hash(verifierList, ephemeralPublicPointList, keyShareList)))</math> |
− | <math>signature_{myId} := </math> | + | <math>signature_{myId} := </math><span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Sign Session and Send</span>'''(<math>toBeSigned</math>) |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Broadcast</span>'''(":3mpCat:3SignedSessionParameters:3",<math>signature_{myId}</math>) | |
{{algorithm-end}} | {{algorithm-end}} | ||
Line 195: | Line 195: | ||
Input: <math>lastMessage</math> | Input: <math>lastMessage</math> | ||
'''For each''' <math>message</math> in Messages Received from <math>lastDigestedMessage</math>+1 till <math>lastMessage</math>}, '''do''' | '''For each''' <math>message</math> in Messages Received from <math>lastDigestedMessage</math>+1 till <math>lastMessage</math>}, '''do''' | ||
− | <math>sesionDigest :=</math> ''' | + | <math>sesionDigest :=</math> <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''Hash</span>'''(<math>sessionDigest</math>, <math>message</math>) |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;"> '''LRU Cache Store Digest</span>'''(<math>sessionDigest</math>, <math>message</math>) | |
'''Return''' <math>sessionDigest</math>,<math>lastMessageId</math> | '''Return''' <math>sessionDigest</math>,<math>lastMessageId</math> | ||
{{algorithm-end}} | {{algorithm-end}} |
Revision as of 18:56, 28 July 2014
Contents
Chatroom setup
Procedure Chatroom Init
Input: ,
Global
Global
Global
Global Generate Initial Paramters()
Global
Procedure Verify Verifier Generate Init Key Input: , , , , Verify Verifiers() Global Sign Session and Send()
Join
Procedure Join Input: , , Global Global Generate Initial Paramters(Participant ID ) Global Broadcast(":3mpCat:3Join:3", , , ) Global Receive() Global Compute Session Id(, , ) Sign and Send Key Confirmation and Shares() Wait On Receive(":3mpCat:3KeyConfirmationShare:3") Global Receive() Verify Key Confirmations and Signatures(, ) Update Session Key()
Procedure Receive Session Digest Input: Global
Protocol for other participants already in the chat to accept the newcomer
Procedure Accept Input: newParticipant Broadcast(":3mpCat:3Join:3", , , ) Wait On Receive(":3mpCat:3Join:3") Global , Receive() Update Lists(, ) Global Compute Session Id(, , ) Sign and Send Key Confirmation and Shares() Wait On Receive(":3mpCat:3KeyConfirmationShare:3") Global Receive() Verify Key Confirmations and Signatures(, ) Update Session Key() Send()
Farewell
Procedure Shrink on Leave Input: Remove from Global Compute Session Id() If, then Sign and Send Key Shares() Wait On Receive(":3mpCat:3KeyShare:3") := Receive{} Update Session Key()
Procedure Sign and Send Key Shares Input: Global Global ED25519Sign(, || ) Broadcast(":3mpCat:3KeyShare:3", , , )
Send
Procedure Send Input: Message}{MetaMessage, message = NewKeyShareMessage(MetaMessage) := AES CTR Encrypt(,) := ED25519Sign(, || ) := Compute Session Digest() Broadcast(":3mpCat:3", , , , ,":3")
Recieve
Procedure Receive Input: , , , ED25519VerifySignature(, , ) Assert() AES CTR Decrypt(, ) UpdateNewKeyStatus() Verify Digests() Return{}
\subsection{Common functions}
Common functions used by other procedures in different stages
Procedure Generate Initial Paramters Input: RandomBits(256) Ed25519 Scalar()) Return
Procedure Verify Key Confirmation and Signatures Input: , For each }, do \If{} Halt() ' \If{ ED25519VerifySignature(, , )' Halt()
Procedure Compute Session Id Input: , Return #
Procedure Verify Signatures Input: ,,
Procedure Sign and Send Key Confirmation and Share Input: For each , do # Triple DH
Global Global
ED25519Sign(, || ) Broadcast(":3mpCat:3KeyConfirmationAndShare:3", , , , )
Procedure Update Session Key Input:
For each }, do
# recovered should be equal to its original value Global
Procedure Sign Params Update Session Key Input: , , Update Session Key() Sign Session and Send() Broadcast(":3mpCat:3SignedSessionParameters:3",)
Procedure ComputeSessionDigest Input:
For each in Messages Received from +1 till }, do
Hash(, ) LRU Cache Store Digest(, ) Return ,