Would something like this be a reasonable way to implement the double ratchet with libsodium? The sodium port that I'm using is quite limited and does not offer a kdf.
Here is a link to the libsodium documentation page regarding the scalar multiplication.
What crypto_scalarmult_base / crypto_scalarmult does is: "compute a shared secret given a user's secret key and another user's public key".
// random key shared between parties during the initial handshake
const preKey = "yez6GrvuVl3zihPwHf9wiXUv93CSkXHBQhPs6e0YLxg="
// compute the first chain key based on the shared pre key
const chain1 = sodium.crypto_scalarmult_base(preKey)
// compute the actual message key, since chain has just started,
// use the pre key as the "public key" and chain1 key as
// the "secret key" for the multiplication
const key1 = sodium.crypto_scalarmult(chain1, preKey)
const cipher1 = encrypt_message(key1)
// compute the next chain2 key based on the previous chain1 key
const chain2 = sodium.crypto_scalarmult_base(chain1)
// compute the next message key based on the chain2 key,
// used as the "secret key" and the chain1 key used as
// the "public key" for the multiplication
const key2 = sodium.crypto_scalarmult(chain2, chain1)
const cipher2 = encrypt_message(key2)
const chain3 = sodium.crypto_scalarmult_base(chain2)
const key3 = sodium.crypto_scalarmult(chain3, chain2)
const cipher3 = encrypt_message(key3)
// and so on ....
From what I understand, scalarmult is not backtrackable and breaking key2 would not allow you to calculate key1 nor key3.
So my question is - is an implementation like this reasonable or a total disaster?