Ok. I'm going to make a whole lot of questions, and some of them might seem strange, but I skipped many posts of the huge NXT thread...so I appreciate your patience :-)
1. What does "AM" stand for? Asset Management?
2. Why 2-3 multisig transactions? Is there support for M-N multisig transactions, where 2>M>N, at least in the RPC API of dogecoind or in {Bit,Lite}coind?
Can you explain the general workflow, and the input/outputs of each computer in the workflow?
After the wallet addresses are linked to account, everything is designed to be transparent. just send coin to the deposit address and it appears in the AE. just transfer from AE to original issuer (or gateway ID) and it appears in the coin wallet.
Let's say I have some Doge's. I talk to the input server. I assume that the "Input Server" will be the one that hosts a web site or an API server, right? So I'm given a DOGE M-N multisig address, in which I should deposit the coins. This address has been generated with all the N private keys coming from the N Trusted Gateways. I also give my NXT account, in which I want my assets transferred to.
I deposit the doge's in the address. The trusted gateways coordinate together, M of them sign the transaction and withdraw the DOGE's into a private address. Then some (how many?) "DOGENXT" assets are created, and given back to the user to his NXT account.
Are the above right so far?
1. AM means Arbitrary Message, it is really a way to publish data on the blockchain. I check the first four bytes for the GATEWAY_SIG code and if it matches, assume it is a data packet for the gateway. All communications to the gateway are via the blockchain.
2. I wanted to do 4 of 5, but the current bitcoin network treats anything over 3 signers as a non-standard transaction and few of the miners will propagate it. For dogecoind, it simply gags on anything over 3.
The only way you can talk to the gateway is by using a sendMessage NXT API
http://wiki.nxtcrypto.org/wiki/Nxt_API#Arbitrary_Message_System_Operations The data needs to be a gateway_AM data structure. The C code has char *AM_get_coindeposit_address(int timestamp,int gatewayid,char *nxtaddr,char *withdrawaddr,char *userpubkey)
This shows exactly how to create and send a request to bind NXTaddr with DOGE withdrawal addr. It will then publish a corresponding AM with the deposit address. The C code loops scanning all AM's for the gateway signature and when it finds the one with the deposit address, it terminates.
Now there are two completely separate processes, deposit and withdraw.
Deposit
1. user sends DOGE to the address returned by gateway in the AM data
2. the selected gateway (each gateway has different deposit address) detects the deposit and transfers the amount to the shared multisig acct and at the same time issues the corresponding amount of DOGE and milliDOGE assets. Amount is rounded to nearest .001 and TXFEE is subtracted
Withdraw
1. user transfers DOGE or milliDOGE asset to the gateway (or DOGE asset issuer)
2. the selected gateway notices the withdraw request and posts an AM with the details
3. all three gateways process the withdraw request and add it to an internal queue
4. All withdraws are put into a single global queue for all withdraws to avoid any parallel changes to balances
5. the three servers agree on which withdraw request to process and generate a rawtransaction to satisfy it
6. all three servers compare their rawtransaction with the other servers and if it is IDENTICAL to the byte, the selected server signs a rawtransaction that was already signed by one of the other gateways and broadcasts it to DOGE network and also sends an AM to the NXT blockchain that the withdraw was completed
7. all three servers mark the withdraw request as completed and go on to the next on in the queue
So, quite a lot of stuff happening behind the scenes, but as far as the user is concerned, the DOGE deposit address is directly linked to the NXT AE and the NXT AE "transfer" link is directly connected to their DOGE wallet registered as the withdraw address.
I designed this to be the easiest to use gateway out of all the gateways that are out there, but one that is more secure.
James
P.S. If you point out that the above does not match the picture, you got me. I just thought the pic was cool and it is something that might or might not get done in a parallel project