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'...") |
(→Common functions used by other procedures in different stages) |
||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
====Chatroom setup==== | ====Chatroom setup==== | ||
<!--alg_chat_setup--> | <!--alg_chat_setup--> | ||
− | {{algorithm-begin|name= | + | {{algorithm-begin|name=Chatroom Init}} |
− | Input: | + | Input: <math>newRoomName</math>, <math>participantNick</math> |
− | + | '''global''' <math>myId := 1</math> | |
− | + | '''global''' <math>Nick_{myId} := participantNick</math> | |
− | + | '''global''' <math>roomName := newRoomName</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> | |
− | + | <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>, <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 := Hash(x_{myId}y_{other}, sessionId)</math> | |
− | + | <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}} | ||
− | |||
− | |||
− | |||
====Join==== | ====Join==== | ||
<!--alg_join--> | <!--alg_join--> | ||
{{algorithm-begin|name=Join}} | {{algorithm-begin|name=Join}} | ||
− | Input: | + | Input: <math>newRoomName</math>, <math>Nickname_{myId}</math>, <math>participantId</math> |
− | + | '''global''' <math>myId := participantId</math> | |
− | + | '''global''' <math>roomName := newRoomName</math> | |
− | + | <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> | |
− | + | <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> <span style="font-family: serif; font-size: larger; font-variant:small-caps;">'''Receive</span>'''() | |
− | + | '''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> <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}} | ||
{{algorithm-begin|name=Receive Session Digest}} | {{algorithm-begin|name=Receive Session Digest}} | ||
− | Input: '' | + | Input: <math>currentSessionHistoryDigest</math> |
− | + | '''global''' <math>sessionDigest := currentSessionHistoryDigest</math> | |
{{algorithm-end}} | {{algorithm-end}} | ||
+ | ====Protocol for other participants already in the chat to accept the newcomer==== | ||
− | |||
− | |||
− | |||
<!--alg_accept--> | <!--alg_accept--> | ||
{{algorithm-begin|name=Accept}} | {{algorithm-begin|name=Accept}} | ||
− | Input: newParticipant | + | Input: <math>newParticipant</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>) | |
− | + | <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> <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> <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> <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 85: | Line 67: | ||
<!--alg_farewell--> | <!--alg_farewell--> | ||
{{algorithm-begin|name=Shrink on Leave}} | {{algorithm-begin|name=Shrink on Leave}} | ||
− | Input: | + | Input: <math>leaverId</math> |
− | + | '''remove''' <math>leaverId</math> from <math>participantIdList</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> := <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 Session Key</span>'''(<math>keyShareList</math>) | |
{{algorithm-end}} | {{algorithm-end}} | ||
Line 98: | Line 80: | ||
{{algorithm-begin|name=Sign and Send Key Shares}} | {{algorithm-begin|name=Sign and Send Key Shares}} | ||
Input: | Input: | ||
− | + | '''global''' <math>z_{myId -1, myId} := Hash(k_{myId,myId-1}, sessionId)</math> | |
− | + | '''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>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>) # we can send this encrypted but leaving person can read it, hence theoretically it is the same as sending it unencrypted. | |
{{algorithm-end}} | {{algorithm-end}} | ||
− | |||
====Send==== | ====Send==== | ||
<!--alg_send--> | <!--alg_send--> | ||
{{algorithm-begin|name=Send}} | {{algorithm-begin|name=Send}} | ||
− | Input: | + | Input: <math>metaMessage</math>, <math>message</math> |
− | + | <math>keyShareMessage</math> = <span style="font-family: serif; font-size: larger; font-variant:small-caps;">'''NewKeyShareMessage</span>'''(<math>metaMessage</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> := <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> := <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}} | ||
− | |||
====Recieve==== | ====Recieve==== | ||
<!--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> <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>) or '''return''' Reject | |
− | + | <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><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>} # isMetaMessage is true if the message is purely meta message and there is nothing to display | |
{{algorithm-end}} | {{algorithm-end}} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
====Common functions used by other procedures in different stages==== | ====Common functions used by other procedures in different stages==== | ||
<!--alg_comm--> | <!--alg_comm--> | ||
− | |||
− | |||
{{algorithm-begin|name=Generate Initial Paramters}} | {{algorithm-begin|name=Generate Initial Paramters}} | ||
− | Input: | + | Input: <math>myId</math> |
− | + | <math>signaturePrivateKey := </math> <span style="font-family: serif; font-size: larger; font-variant:small-caps;">'''RandomBits</span>'''(256) | |
− | + | <math>x_{myId} :=</math> <span style="font-family: serif; font-size: larger; font-variant:small-caps;">'''Ed25519 Scalar</span>'''(<math>signaturePrivateKey</math>)) #{This is both Diffie-Hellman secret and ephemeral signature private key} | |
− | + | <math>y_{myId} := x_{myId}P</math> | |
− | + | '''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''' <math>participant \in participantList</math>, '''do''' |
− | + | '''if''' <math>keyConfirmationList[participant][myId] \neq Hash(k_{myId,participant} , U_{myId} )</math>''', then''' | |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;">'''Halt</span>'''() | |
− | + | '''else''' '''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>) = Fail ''', then''' | |
− | + | <span style="font-family: serif; font-size: larger; font-variant:small-caps;">'''Halt</span>'''() | |
{{algorithm-end}} | {{algorithm-end}} | ||
{{algorithm-begin|name=Compute Session Id}} | {{algorithm-begin|name=Compute Session Id}} | ||
− | Input: | + | Input: <math>participantList</math>, <math>ephemeralPublicPointList</math> |
− | ''' | + | '''return''' <math>Hash(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>, |
+ | # standard signature verification | ||
{{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''' <math>participant \in participantList</math>, '''do''' | |
− | + | <math>k_{myId, participant} := Hash(x_{myId}LP_{participant} |lp_{myId}y_{participant} | x_{myId}y_{participant})</math> # Triple DH | |
− | + | <math>kc_{myId} := kc_{myId} | Hash(k_{myId,participant}, U_{participant})</math> | |
+ | '''global''' <math>z_{myId -1, myId} := Hash(k_{myId,myId-1}, sessionId)</math> | ||
+ | '''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>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-begin|name=Update Session Key}} | |
− | + | Input: <math>keyShareList</math> | |
− | + | <math>i := myId</math> | |
+ | '''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 <math>z_{i-1,i}</math> should be equal to its original value | ||
+ | '''global''' <math>sessionKey := Hash(z_{j,j+1} | j \in [1...n])</math> | ||
+ | {{algorithm-end}} | ||
− | + | {{algorithm-begin|name=Sign Params Update Session Key}} | |
− | ''' | + | 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 := Hash(sessionId, ||Hash(verifierList, ephemeralPublicPointList, keyShareList)))</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}} | ||
− | {{algorithm-begin|name= | + | {{algorithm-begin|name=ComputeSessionDigest}} |
− | Input: | + | Input: <math>lastMessage</math> |
− | + | '''for each''' <math>message</math> in Messages Received from <math>lastDigestedMessage</math>+1 till <math>lastMessage</math>, '''do''' | |
− | ''' | + | <math>sesionDigest := Hass(sessionDigest, 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> | |
− | + | ||
{{algorithm-end}} | {{algorithm-end}} | ||
− | {{algorithm-begin|name= | + | {{algorithm-begin|name=NewKeyShareMessage}} |
− | Input: | + | Input: <math>metaMessage</math> |
− | + | # Based on metaMessage Determines what type of keyshare needs to be send (Ephemeral point or Group key share) and returen it. | |
− | + | ||
− | + | ||
− | + | ||
{{algorithm-end}} | {{algorithm-end}} | ||
− | {{algorithm-begin|name= | + | {{algorithm-begin|name=UpdateNewKeyStatus}} |
− | Input: | + | Input: <math>keyShareMessage</math> |
− | + | # Update the table of which participant has sent its new ephemeral point or its new group key share | |
− | + | {{algorithm-end}} | |
− | + | ||
− | + | ||
+ | {{algorithm-begin|name=Hash}} | ||
+ | Input: <math>message</math> | ||
+ | '''return''' <span style="font-family: serif; font-size: larger; font-variant:small-caps;">'''SHA-512</span>'''(<math>message</math>) | ||
{{algorithm-end}} | {{algorithm-end}} |
Latest revision as of 20:40, 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() 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: 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", , , ) # we can send this encrypted but leaving person can read it, hence theoretically it is the same as sending it unencrypted.
Send
Procedure Send Input: , = NewKeyShareMessage() := AES CTR Encrypt(,) := ED25519Sign(, || ) := Compute Session Digest() Broadcast(":3mpCat:3", , , , ,":3")
Recieve
Procedure Receive Input: , , , ED25519VerifySignature(, , ) Assert() or return Reject AES CTR Decrypt(, ){} UpdateNewKeyStatus() Verify Digests() return{} # isMetaMessage is true if the message is purely meta message and there is nothing to display
Common functions used by other procedures in different stages
Procedure Generate Initial Paramters Input: RandomBits(256) Ed25519 Scalar()) #{This is both Diffie-Hellman secret and ephemeral signature private key} return
Procedure Verify Key Confirmation and Signatures Input: , for each , do if , then Halt() else if ED25519VerifySignature(, , ) = Fail , then Halt()
Procedure Compute Session Id Input: , return #
Procedure Verify Signatures Input: ,, # standard signature verification
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
LRU Cache Store Digest(, )
return ,
Procedure NewKeyShareMessage Input: # Based on metaMessage Determines what type of keyshare needs to be send (Ephemeral point or Group key share) and returen it.
Procedure UpdateNewKeyStatus Input: # Update the table of which participant has sent its new ephemeral point or its new group key share
Procedure Hash
Input:
return SHA-512()