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: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
====Chatroom setup==== | ====Chatroom setup==== | ||
<!--alg_chat_setup--> | <!--alg_chat_setup--> | ||
{{algorithm-begin|name=Chat Initiator Init}} | {{algorithm-begin|name=Chat Initiator Init}} | ||
− | Input: | + | Input: <math>newRoomName</math>, <math>participantNick</math> |
− | Global | + | Global <math>myId := 1</math> |
− | Global | + | Global <math>Nick_{myId} := participantNick</math> |
− | Global | + | Global <math>roomName := newRoomName</math> |
− | Global | + | Global <math>x_{myId}, y_{myId} :=</math> '''Call''' '''Generate Initial Paramters'''(<math>myId</math>) |
− | Global | + | Global <math>signatureKey_{myId} := (x_{myId},y_{myId})</math> |
− | + | <math>participantList := [Nick_{myId}]</math> | |
− | + | <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: | + | Input: <math>schnorrRandomPoint_{other</math> |
'''Call''' '''Verify Verifiers'''() | '''Call''' '''Verify Verifiers'''() | ||
− | Global | + | Global <math>sessionKey := SHA-512(x_{myId}y_{other}, sessionId)</math> |
− | + | <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'''( | + | '''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: | + | Input: <math>newRoomName</math>, <math>Nickname_{myId</math> |
− | Global | + | Global <math>myId := participantId</math> |
− | Global | + | Global <math>roomName := newRoomName</math> |
− | + | <math>x_{myId}, y_{myId} := </math>'''Call''' '''Generate Initial Paramters'''(Participant ID <math>myId</math>) | |
− | Global | + | Global <math>signatureKey_{myId} := (x_{myId},y_{myId})</math> |
− | '''Call''' '''Broadcast'''(``:3mpCat:3Join:3'', | + | '''Call''' '''Broadcast'''(``:3mpCat:3Join:3'', <math>myId</math>, <math>Nickname_{myId</math>) |
− | Global | + | Global <math>participantList, ephemeralPublicPointList :=</math> '''Call''' '''Receive'''() |
− | Global | + | 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 | + | Global <math>keyShareList, keyConfirmationList, signatureList :=</math> '''Call''' '''Receive'''() |
− | '''Call''' '''Verify Key Confirmations and Signatures'''( | + | '''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: | + | Input: <math>currentSessionHistoryDigest</math> |
− | Global | + | 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'', | + | '''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 | + | Global <math>nick_{NewParticipant}</math>, <math>ephemeralPublicPoint_{NewParticipant} := </math> '''Call''' '''Receive'''() |
− | '''Call''' '''Update Lists'''( | + | '''Call''' '''Update Lists'''(<math>nick_{NewParticipant</math>) |
− | Global | + | 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 | + | Global <math>keyShareList, keyConfirmationList, signatureList :=</math> '''Call''' '''Receive'''() |
− | '''Call''' '''Verify Key Confirmations and Signatures'''( | + | '''Call''' '''Verify Key Confirmations and Signatures'''(<math>keyConfirmationList</math>, <math>signatureList</math>) |
'''Call''' '''Update Session Key'''() | '''Call''' '''Update Session Key'''() | ||
− | '''Call''' '''Send'''( | + | '''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: | + | Input: <math>leaverId</math> |
− | Remove | + | Remove <math>leaverId</math> from <math>participantIdList</math> |
− | Global | + | Global <math>sessionId :=</math> '''Call''' '''Compute Session Id'''() |
− | \If{ | + | \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'') | ||
− | + | <math>keyShareList</math> := Receive{} | |
− | '''Call''' '''Update Session Key'''( | + | '''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 | + | Global <math>z_{myId -1, myId} := SHA-512(k_{myId,myId-1}, sessionId)</math> |
− | Global | + | Global <math>z_{myId, myId+1} := SHA-512(k_{myId,myId+1}, sessionId)</math> |
− | + | <math>keyShare_{myId} := z_{myId -1, myId} \oplus z_{myId, myId+1}</math> | |
− | + | <math>originAuthSignature :=</math> '''Call''' '''ED25519Sign'''(<math>SignatureKey</math>, <math>sessionId</math> || <math>z_{myId</math>) | |
− | '''Call''' '''Broadcast'''(``:3mpCat:3KeyShare:3'', | + | '''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 | ||
− | + | <math>keyShareMessage</math> = '''Call''' '''NewKeyShareMessage'''(MetaMessage) | |
− | + | <math>cryptMessage</math> := '''Call''' '''AES CTR Encrypt'''(<math>sessionKey</math>,<math>message | keyShareMessage</math>) | |
− | + | <math>originAuthSignature</math> := '''Call''' '''ED25519Sign'''(<math>SignatureKey</math>, <math>sessionId</math> || <math>cryptMetatMessage</math>) | |
− | + | <math>sessionDigest</math> := '''Call''' '''Compute Session Digest'''(<math>lastMessage</math>) | |
− | '''Call''' '''Broadcast'''(``:3mpCat: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: | + | Input: <math>sender</math>, <math>encryptedMessage</math>, <math>originAuthSignature</math>, <math>sessionDigest</math> |
− | + | <math>v := </math> '''Call''' '''ED25519VerifySignature'''(<math>ephemeralPublicKeyList[Sender]</math>, <math>sessionId || encryptedMessage</math>, <math>originAuthSignature</math>) | |
− | '''Call''' '''Assert'''( | + | '''Call''' '''Assert'''(<math>v</math>) |
− | + | <math>message, keyShareMessage :=</math> '''Call''' '''AES CTR Decrypt'''(<math>sessionKey</math>, <math>encryptedMessage</math>) | |
− | + | <math>isMetaMessage = </math>'''Call''' '''UpdateNewKeyStatus'''(<math>keyShareMessage</math>) | |
− | '''Call''' '''Verify Digests'''( | + | '''Call''' '''Verify Digests'''(<math>sessionDiges</math>) |
− | '''Return'''{ | + | '''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: | + | Input: <math>myId</math> |
− | + | <math>signaturePrivateKey := </math> '''Call''' '''RandomBits'''(256) | |
− | + | <math>x_{myId} :=</math> '''Call''' '''Ed25519 Scalar'''(<math>signaturePrivateKey</math>)) | |
− | + | <math>y_{myId} := x_{myId}P</math> | |
− | '''Return''' | + | '''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: | + | Input: <math>signatureList</math>, <math>keyConfirmationList</math> |
− | '''For each''' | + | '''For each''' <math>participant \in participantList</math>}, '''do''' |
− | \If{ | + | \If{<math>keyConfirmationList[participant][myId] \neq SHA-512(k_{myId,participant}, U_{myId})</math>} |
'''Call''' '''Halt'''() | '''Call''' '''Halt'''() | ||
− | ' \If{'''Call''' '''ED25519VerifySignature'''( | + | ' \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: | + | Input: <math>participantList</math>, <math>ephemeralPublicPointList</math> |
− | '''Return''' | + | '''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: | + | 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: | + | Input: <math>schnorrRandomPointList</math> |
− | '''For each''' | + | '''For each''' <math>participant \in participantList</math>, '''do''' |
− | + | <math>k_{myId, participant} := H(g^{lp_{myId}}LP_{participant}y_{participant}^{x_{myId}})</math> # Triple DH | |
− | + | <math>kc_{myId} := kc_{myId} | H(k_{myId,participant}, U_{participant})</math> | |
− | Global | + | Global <math>z_{myId -1, myId} := SHA-512(k_{myId,myId-1}, sessionId)</math> |
− | Global | + | Global <math>z_{myId, myId+1} := SHA-512(k_{myId,myId+1}, sessionId)</math> |
− | + | <math>keyShare_{myId} := z_{myId -1, myId} \oplus z_{myId, myId+1}</math> | |
− | + | <math>originAuthSignature :=</math> '''Call''' '''ED25519Sign'''(<math>SignatureKey</math>, <math>sessionId</math> || <math>z_{myId</math>) | |
− | '''Call''' '''Broadcast'''(``:3mpCat:3KeyConfirmationAndShare:3'', | + | '''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: | + | Input: <math>keyShareList</math> |
− | + | <math>i := myId</math> | |
− | '''For each''' | + | '''For each''' <math>{j \in [i,...,i+n-1]}</math>}, '''do''' |
− | + | <math>z_{j,j+1} := z_{j-1,j} \oplus keyShareListe[j+1]</math> | |
− | # recovered | + | # recovered <math>z_{i-1,i}</math> should be equal to its original value |
− | Global | + | 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: | + | Input: <math>toBeSigned</math>, <math>signatureList</math>, <math>keyShareList</math> |
'''Call''' '''Update Session Key'''() | '''Call''' '''Update Session Key'''() | ||
− | + | <math>toBeSigned := SHA-512(sessionId, ||SHA-512(verifierList, ephemeralPublicPointList, keyShareList)))</math> | |
− | + | <math>signature_{myId} := </math>'''Call''' '''Sign Session and Send'''(<math>toBeSigned</math>) | |
− | '''Call''' '''Broadcast'''(``:3mpCat:3SignedSessionParameters:3'', | + | '''Call''' '''Broadcast'''(``:3mpCat:3SignedSessionParameters:3'',<math>signature_{myId</math>) |
{{algorithm-end}} | {{algorithm-end}} | ||
{{algorithm-begin|name=ComputeSessionDigest}} | {{algorithm-begin|name=ComputeSessionDigest}} | ||
− | Input: | + | Input: <math>lastMessage</math> |
− | '''For each''' | + | '''For each''' <math>message</math> in Messages Received from <math>lastDigestedMessage</math>+1 till <math>lastMessage</math>}, '''do''' |
− | + | <math>sesionDigest :=</math> '''Call''' '''SHA-512'''(<math>sessionDigest</math>, <math>message</math>) | |
− | '''Call''' '''LRU Cache Store Digest'''( | + | '''Call''' '''LRU Cache Store Digest'''(<math>sessionDigest</math>, <math>message</math>) |
− | '''Return''' | + | '''Return''' <math>sessionDigest</math>,<math>lastMessageId</math> |
{{algorithm-end}} | {{algorithm-end}} |
Revision as of 10:33, 27 July 2014
Contents
Chatroom setup
Procedure Chat Initiator Init Input: , Global Global Global Global Call Generate Initial Paramters() Global
Procedure Verify Verifier Generate Init Key Input: Failed to parse (syntax error): schnorrRandomPoint_{other
Call Verify Verifiers() Global Call Sign Session and Send()
Join
Procedure Join Input: , Failed to parse (syntax error): Nickname_{myId
Global Global Call Generate Initial Paramters(Participant ID ) Global Call Broadcast(``:3mpCat:3Join:3, , Failed to parse (syntax error): Nickname_{myId
)
Global Call Receive() Global Call Compute Session Id(, , ) Call Sign and Send Key Confirmation and Shares() Call Wait On Receive(``:3mpCat:3KeyConfirmationShare:3) Global Call Receive() Call Verify Key Confirmations and Signatures(, ) Call 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 Call Broadcast(``:3mpCat:3Join:3, , Failed to parse (syntax error): Nickname_{myId
)
Call Wait On Receive(``:3mpCat:3Join:3) Global , Call Receive() Call Update Lists(Failed to parse (syntax error): nick_{NewParticipant
)
Global Call Compute Session Id(, , ) Call Sign and Send Key Confirmation and Shares() Call Wait On Receive(``:3mpCat:3KeyConfirmationShare:3) Global Call Receive() Call Verify Key Confirmations and Signatures(, ) Call Update Session Key() Call Send()
Farewell
Procedure Shrink on Leave Input: Remove from Global Call Compute Session Id() \If{} Call Sign and Send Key Shares() Call Wait On Receive(``:3mpCat:3KeyShare:3) := Receive{} Call Update Session Key()
Procedure Sign and Send Key Shares Input: Global Global Call ED25519Sign(, || Failed to parse (syntax error): z_{myId
)
Call Broadcast(``:3mpCat:3KeyShare:3, , Failed to parse (syntax error): keyShare_{myId
)
Send
Procedure Send Input: Message = Call NewKeyShareMessage(MetaMessage) := Call AES CTR Encrypt(,) := Call ED25519Sign(, || ) := Call Compute Session Digest() Call Broadcast(``:3mpCat:3, , , , ,``:3)
Recieve
Procedure Receive Input: , , , Call ED25519VerifySignature(, , ) Call Assert() Call AES CTR Decrypt(, ) Call UpdateNewKeyStatus() Call Verify Digests() Return{}
\subsection{Common functions}
Common functions used by other procedures in different stages
Procedure Generate Initial Paramters Input: Call RandomBits(256) Call Ed25519 Scalar()) Return
Procedure Verify Key Confirmation and Signatures Input: , For each }, do \If{} Call Halt() ' \If{Call ED25519VerifySignature(, , )' Call 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
Call ED25519Sign(, || Failed to parse (syntax error): z_{myId
)
Call Broadcast(``:3mpCat:3KeyConfirmationAndShare:3, , Failed to parse (syntax error): keyShare_{myId
)
Procedure Update Session Key Input:
For each }, do
# recovered should be equal to its original value Global
Procedure Sign Params Update Session Key Input: , , Call Update Session Key() Call Sign Session and Send() Call Broadcast(``:3mpCat:3SignedSessionParameters:3,Failed to parse (syntax error): signature_{myId
)
Procedure ComputeSessionDigest Input:
For each in Messages Received from +1 till }, do
Call SHA-512(, ) Call LRU Cache Store Digest(, ) Return ,