public async Task <ProtocolTransactionResponse> CreateTransaction(List <SignedItem> items, ChaosProtocolSettings settings) { var id = TxIdHelper.GenerateId(); var revealItem = new RevealItem() { Type = UserType.Validator, Seed = random.NextLong().ToString(), Nonce = DateTime.UtcNow.Ticks.ToString(), PubKey = keySecret.PublicAddress.ToLowerInvariant() }; revealItem.Sign = cryptoService.SignMessage(revealItem.ToString(), keySecret.PrivateKey); await storage.Add(revealItem.Sign, revealItem); var commitItem = revealItem.ToCommitItem(); items.Add(new SignedItem() { Type = commitItem.Type, Nonce = commitItem.Nonce, PubKey = commitItem.PubKey, Sign = commitItem.Sign, }); var tx = new ProtocolTransactionResponse() { Id = id, Signer = keySecret.PublicAddress.ToLowerInvariant(), Items = items }; await AddAnchors(tx); await storage.Add(id, tx); return(tx); }
public async Task <CommitItem> Commit(string salt) { var revealItem = new RevealItem() { Type = UserType.Validator, Seed = random.NextLong().ToString(), Nonce = salt ?? DateTime.UtcNow.Ticks.ToString(), PubKey = keySecret.PublicAddress.ToLowerInvariant() }; revealItem.Sign = cryptoService.SignMessage(revealItem.ToString(), keySecret.PrivateKey); await storage.Add(revealItem.Sign, revealItem); return(revealItem.ToCommitItem()); }