public SenderMessageKey RemoveSenderMessageKey(uint iteration) { LinkedList <SenderKeyStateStructure.Types.SenderMessageKey> keys = new LinkedList <SenderKeyStateStructure.Types.SenderMessageKey>(senderKeyStateStructure.SenderMessageKeysList); IEnumerator <SenderKeyStateStructure.Types.SenderMessageKey> iterator = keys.GetEnumerator(); // iterator(); SenderKeyStateStructure.Types.SenderMessageKey result = null; while (iterator.MoveNext()) // hastNext { SenderKeyStateStructure.Types.SenderMessageKey senderMessageKey = iterator.Current; // next(); if (senderMessageKey.Iteration == iteration) //senderMessageKey.getIteration() { result = senderMessageKey; keys.Remove(senderMessageKey); //iterator.remove(); break; } } this.senderKeyStateStructure = this.senderKeyStateStructure.ToBuilder() .ClearSenderMessageKeys() //.AddAllSenderMessageKeys(keys) .AddRangeSenderMessageKeys(keys) .Build(); if (result != null) { return(new SenderMessageKey(result.Iteration, result.Seed.ToByteArray())); } else { return(null); } }
private SenderKeyState(uint id, uint iteration, byte[] chainKey, ECPublicKey signatureKeyPublic, May <ECPrivateKey> signatureKeyPrivate) { SenderKeyStateStructure.Types.SenderChainKey senderChainKeyStructure = SenderKeyStateStructure.Types.SenderChainKey.CreateBuilder() .SetIteration(iteration) .SetSeed(ByteString.CopyFrom(chainKey)) .Build(); SenderKeyStateStructure.Types.SenderSigningKey.Builder signingKeyStructure = SenderKeyStateStructure.Types.SenderSigningKey.CreateBuilder() .SetPublic(ByteString.CopyFrom(signatureKeyPublic.Serialize())); if (signatureKeyPrivate.HasValue) { signingKeyStructure.SetPrivate(ByteString.CopyFrom(signatureKeyPrivate.ForceGetValue().Serialize())); } this.senderKeyStateStructure = SenderKeyStateStructure.CreateBuilder() .SetSenderKeyId(id) .SetSenderChainKey(senderChainKeyStructure) .SetSenderSigningKey(signingKeyStructure) .Build(); }
private SenderKeyState(uint id, uint iteration, byte[] chainKey, ECPublicKey signatureKeyPublic, May<ECPrivateKey> signatureKeyPrivate) { SenderKeyStateStructure.Types.SenderChainKey senderChainKeyStructure = SenderKeyStateStructure.Types.SenderChainKey.CreateBuilder() .SetIteration(iteration) .SetSeed(ByteString.CopyFrom(chainKey)) .Build(); SenderKeyStateStructure.Types.SenderSigningKey.Builder signingKeyStructure = SenderKeyStateStructure.Types.SenderSigningKey.CreateBuilder() .SetPublic(ByteString.CopyFrom(signatureKeyPublic.serialize())); if (signatureKeyPrivate.HasValue) { signingKeyStructure.SetPrivate(ByteString.CopyFrom(signatureKeyPrivate.ForceGetValue().serialize())); } this.senderKeyStateStructure = SenderKeyStateStructure.CreateBuilder() .SetSenderKeyId(id) .SetSenderChainKey(senderChainKeyStructure) .SetSenderSigningKey(signingKeyStructure) .Build(); }
private SenderKeyState(uint id, uint iteration, byte[] chainKey, IEcPublicKey signatureKeyPublic, May <IEcPrivateKey> signatureKeyPrivate) { SenderKeyStateStructure.Types.SenderChainKey senderChainKeyStructure = new SenderKeyStateStructure.Types.SenderChainKey { Iteration = iteration, Seed = ByteString.CopyFrom(chainKey) }; SenderKeyStateStructure.Types.SenderSigningKey signingKeyStructure = new SenderKeyStateStructure.Types.SenderSigningKey { Public = ByteString.CopyFrom(signatureKeyPublic.Serialize()) }; if (signatureKeyPrivate.HasValue) { signingKeyStructure.Private = ByteString.CopyFrom(signatureKeyPrivate.ForceGetValue().Serialize()); } _senderKeyStateStructure = new SenderKeyStateStructure { SenderKeyId = id, SenderChainKey = senderChainKeyStructure, SenderSigningKey = signingKeyStructure }; }
public void SetSenderChainKey(SenderChainKey chainKey) { SenderKeyStateStructure.Types.SenderChainKey senderChainKeyStructure = SenderKeyStateStructure.Types.SenderChainKey.CreateBuilder() .SetIteration(chainKey.GetIteration()) .SetSeed(ByteString.CopyFrom(chainKey.GetSeed())) .Build(); this.senderKeyStateStructure = senderKeyStateStructure.ToBuilder() .SetSenderChainKey(senderChainKeyStructure) .Build(); }
public void addSenderMessageKey(SenderMessageKey senderMessageKey) { SenderKeyStateStructure.Types.SenderMessageKey senderMessageKeyStructure = SenderKeyStateStructure.Types.SenderMessageKey.CreateBuilder() .SetIteration(senderMessageKey.getIteration()) .SetSeed(ByteString.CopyFrom(senderMessageKey.getSeed())) .Build(); this.senderKeyStateStructure = this.senderKeyStateStructure.ToBuilder() .AddSenderMessageKeys(senderMessageKeyStructure) .Build(); }
public void setSenderChainKey(SenderChainKey chainKey) { SenderKeyStateStructure.Types.SenderChainKey senderChainKeyStructure = SenderKeyStateStructure.Types.SenderChainKey.CreateBuilder() .SetIteration(chainKey.getIteration()) .SetSeed(ByteString.CopyFrom(chainKey.getSeed())) .Build(); this.senderKeyStateStructure = senderKeyStateStructure.ToBuilder() .SetSenderChainKey(senderChainKeyStructure) .Build(); }
public void AddSenderMessageKey(SenderMessageKey senderMessageKey) { SenderKeyStateStructure.Types.SenderMessageKey senderMessageKeyStructure = SenderKeyStateStructure.Types.SenderMessageKey.CreateBuilder() .SetIteration(senderMessageKey.GetIteration()) .SetSeed(ByteString.CopyFrom(senderMessageKey.GetSeed())) .Build(); SenderKeyStateStructure.Builder builder = this.senderKeyStateStructure.ToBuilder(); builder.AddSenderMessageKeys(senderMessageKeyStructure); if (builder.SenderMessageKeysList.Count > MAX_MESSAGE_KEYS) { builder.SenderMessageKeysList.RemoveAt(0); } this.senderKeyStateStructure = builder.Build(); }
public SenderKeyState(SenderKeyStateStructure senderKeyStateStructure) { this.senderKeyStateStructure = senderKeyStateStructure; }
public SenderMessageKey removeSenderMessageKey(uint iteration) { LinkedList<SenderKeyStateStructure.Types.SenderMessageKey> keys = new LinkedList<SenderKeyStateStructure.Types.SenderMessageKey>(senderKeyStateStructure.SenderMessageKeysList); IEnumerator<SenderKeyStateStructure.Types.SenderMessageKey> iterator = keys.GetEnumerator(); // iterator(); SenderKeyStateStructure.Types.SenderMessageKey result = null; while (iterator.MoveNext()) // hastNext { SenderKeyStateStructure.Types.SenderMessageKey senderMessageKey = iterator.Current; // next(); if (senderMessageKey.Iteration == iteration) //senderMessageKey.getIteration() { result = senderMessageKey; keys.Remove(senderMessageKey); //iterator.remove(); break; } } this.senderKeyStateStructure = this.senderKeyStateStructure.ToBuilder() .ClearSenderMessageKeys() //.AddAllSenderMessageKeys(keys) .AddRangeSenderMessageKeys(keys) .Build(); if (result != null) { return new SenderMessageKey(result.Iteration, result.Seed.ToByteArray()); } else { return null; } }
public void addSenderMessageKey(SenderMessageKey senderMessageKey) { SenderKeyStateStructure.Types.SenderMessageKey senderMessageKeyStructure = SenderKeyStateStructure.Types.SenderMessageKey.CreateBuilder() .SetIteration(senderMessageKey.getIteration()) .SetSeed(ByteString.CopyFrom(senderMessageKey.getSeed())) .Build(); SenderKeyStateStructure.Builder builder = this.senderKeyStateStructure.ToBuilder(); builder.AddSenderMessageKeys(senderMessageKeyStructure); if (builder.SenderMessageKeysList.Count > MAX_MESSAGE_KEYS) { builder.SenderMessageKeysList.RemoveAt(0); } this.senderKeyStateStructure = builder.Build(); }