Skip to main content
Pre-HTLC allows to create efficient atomic swaps but the user has to make 2 interactions for each swap (1 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.
This way we keep all the advantages of HTLC, but delegate the secret management to the dapp. As long as the user does not clear the cache the dapp can crete newer and newer secrets. And if the cache is cleared than the user can sign the message again and get the initial key, after that the secret can be recovered as the other parameters used to derive the key are publicly stored in the blockchain.

Passkey Sign-in

Instead of using User’s wallet for the initial key generation, we can directly generate key from user’s passkey.

Implementation: TODO