Atomic swaps are based on Hashed Time-Lock Contracts (HTLC), which utilize the following basic mechanisms:
• Multi-signatures: transactions can be signed by two (or more) parties, thus having the parties that signed verify and be accountable for the multi-signature transaction (also referred to as multi-sig in Bitcoin parlance).
• Hash-locks: a cryptographic lock that can be unlocked by revealing a secret s whose hash H(s) is equal to the value h configured in the lock.
• Time-locks: a time-based condition that prevents a transaction’s or smart contract’s assets from being redeemed (or refunded) until a specific time interval has elapsed. The interval can be relative to the time the transaction is published on the blockchain or can be absolute time.
• Basic scripting: this is required to indicate that a transaction can be unlocked (or committed) only if multiple conditions are satisfied, e.g., both the secret to unlock a hashlock is revealed or the time specified by the timelock has elapsed and a particular signature is provided. Hashlocks can be used to link transactions on two blockchains. Both locks are constructed using the same hash function and are configured with the same hash, hence they can be unlocked using the same secret: opening one hashlock reveals the secret which can be used to open the hashlock on the other chain.