Each party application sends a signed message and public key to the network to initiate the process.
So in your example Party A has the Private key for address A
And in your example Party B has the Private key for address B
Party “A” receives the private key to party “B”s wallet from the network.
Party “B” receives the private key to party “A”s wallet from the network.
So in your example Party A has the Private key for address A and B now also knows the Private Key for address A
And in your example Party B has the Private key for address B and A now also knows the Private Key for address B
Sharing Private Keys seems like a bad choice! Party A still has control over address A after it has been "handed over" to B so A could just clear the address after a successful wallet swap.
No - Party A and Party B have a special "wallet" that is created to communicate with the coin network.
So lets call the token on the blockchain that runs the wallet swap x
BTC we will call y
ETH we will call z
So party A wants to sell Y for Z
Party B wants to buy Y for Z
Party A creates a wallet for X and has a public and private key for X
Party B creates a wallet for X and has a public and private key for X
Party A uses the "create address" function from his X wallet app (it sends a small fee)
The X network creates the public and private key and give the AY public address to A but retains the AY private key on the X network
Party B uses the "create address" function from his X wallet app (it sends a small fee)
The X network creates the public and private key and give the BZ public address to B but retains the BZ private key on the X network
Party A funds the AY address and using the X wallet app sends a small fee to create a sale order.
Party B "buys the order" (by sending a small fee and message on the X network) and funds his BZ wallet accordingly.
The X network checks the balance of the AY and BZ wallets and sends a message to the X wallet app for the users to confirm manually.
Each user check the relevant blockchain and either accepts or rejects the sale. (small fee for the message)
The sale can be rejected by either party until both have accepted the sale.
Once accepted the X network disconnects the ability to trade on the AY and BZ wallets and the BZ key is provided to A and the AY key is provided to B
If at any stage a party cancels a offer or sale the party that cancels it is given the key to their wallet.
So if A cancels their sale of AY they send a small fee message to the X network. The network disconnects the ability to use the wallet and issues the AY key to A.
B can either cancel their wallet or list the BZ for sale for a small fee.
Every Message sent by the x wallet costs a small fee. So there are no % of trade fees - just communication fees.
The X network stores the keys to the other coin wallets and provides them to A or B depending on whether a trade takes place.
The AY and BZ key are encrypted on the X network by both the key of the owners wallet and by the network itself. So neither the owner of the funds - nor the network has access to.
So A who owns wallet AY has the private key generated and stored on the X network. Encrypted by both AX and XX.
So B who owns wallet BZ has the private key generated and stored on the X network. Encrypted by both BX and XX.
Only when a trade is completed the AX key is used to unlock the AY private key and released to B by the X network
If the trade is cancelled by A the AX key is used to unlock the AY private key and released to A by the X network
While it may seem unusual to have a fee for each step - a micro fee would not affect users and can pay for the network miners.
Since the network only stores the private key in encrypted form and the fee is paid for the message rather than the size of the sale there is no record of buyer or seller. The size of the transfer will not be known. Because the buyer and seller are exchanging wallets the buyer and seller cannot be easily matched.
Since the buyer and the seller are able to import the private key into their wallet (or a wallet built into the X wallet app) any withdrawal will not match times of when the messages are sent to conduct the swap.
This means i can fill the whole block with just one transaction and one small fee ?
Doesn't sound very resilient against spam attacks..
The transaction only provides the key to the correct recipient. It doesn't transfer any value. So block size is not relevant.
A sale on the X network will only transfer the ownership of the AY key to B and the BZ key to A
Neither party will have had access to the key but they will have had full control over the key.
Only the AX wallet can determine whether to swap or retrieve the AY private key - but it is safely stored on the X network by encrypting it with its own encryption XX and from the AX wallet.
Only the BX wallet can determine whether to swap or retrieve the BZ private key - but it is safely stored on the X network by encrypting it with its own encryption XX and from the BX wallet.
The X network - apart from transferring its own tokens - does not transfer coin values - it only stores, swaps or releases the private keys of the other coins.
B receives a AY wallet that is funded by A but the AY private key is securely generated and kept by the X network until the deal is completed.
This is a theoretical model - that could work with funded and unfunded Y and Z wallets.
Hedging using WalletSwap
A bond in X could be paid by A and B that if within a certain period of time the wallet is not funded the bond is released to the counterparty.
This would allow A to list 0.1 BTC (Y) for a certain price in ETH (Z) without yet funding the AY wallet in BTC but pay a bond in X that gets released to B if the sale does not take place withing a certain set time.
Likewise this would allow B to buy 0.1 BTC (Y) for a certain price in ETH (Z) without yet funding the BZ wallet in BTC but pay a bond in X that gets released to A if the sale does not take place withing a certain set time.