Let's say we have a group of users, authenticated by a server that providers the service, communicating on a secure channel (e.g. over HTTPS/TLS) and each user has a corresponding curve25519 key pair. Each user keeps a database of public keys of the other users but it needs first to verify that the other users actually own the claimed public key.
Can I use libsodium to verify the ownership of the keys? Let's say the flow of verifying the ownership of the key (or let's call it authentication) works as follows:
The claimant sends the verifier its public key.
The verifier generates a long random binary challenge (let's say 128 or 256 bits) and encrypts it with the sealed box method
crypto_box_seal()
as illustrated in https://libsodium.gitbook.io/doc/public-key_cryptography/sealed_boxes and keeps the plaintext challenge in some private database.The claimant receives the encrypted challenge and decrypts it with
crypto_box_seal_open()
and sends the verifier back the plaintext answerThe verifier checks the received answer and compares it with the expected answer stored in its database. If they do match then the public key really belongs to the claimant and it gets stored in the verifier's database.
Is is this flow correct? Can it be shorter since curve25519 keys are usually implemented only for encryption and not signing purposes? So users can just upload the signature of their own public keys in step no. 2 and thus we can skip the additional request from the verifier to the claimant in step no. 3?
(nonce || your PK || her PK)
. $\endgroup$ – Frank Denis Dec 13 '19 at 16:59crypto_box_seal_open()
and waits for the decrypted answer for verification. $\endgroup$ – Kri Noe Dec 13 '19 at 17:05