commit() + 1 add_lock()).
An Ideal atomic swap would have only one interaction.
This ” ideal swap” is possible if we leave the secret generation to the user, but this is not an option.
Our secret generation from the wallet approach offers a way to have N+1 interactions for N swaps.
The idea is to create one reproducible secret for the user and then generate new secrets for each swap. In some senss this is a sign-in for the user.
Sign In
1
User Sign
The users signs the message
I am using Train.2
Cache Key
The dapp calls a HKDF to derive an initial key from the signature, and keeps the key in the cache.
Wallet HTLC Flow
1
Create secret
Dapp derives a secret from the initial key,source chain, destination chain, and the timelock of the swap using HKDF.
2
User Lock
User locks the funds using the hash of that secret.
3
Solver Lock
Solver locks the funds using the same Hashlock.
4
Secret Reveal
Dapp reveals the secret.
5
Funds Unlock
Solver unlocks both of the funds.