public void TestI2PLeaseSet() { var destinfo = new I2PDestinationInfo(I2PSigningKey.SigningKeyTypes.EdDSA_SHA512_Ed25519); var dest = destinfo.Destination; var leases = Enumerable.Range(1, 8).Select(i => new I2PLease(new I2PIdentHash(true), new I2PTunnelId())); var ls = new I2PLeaseSet(dest, leases, new I2PLeaseInfo(destinfo)); Assert.IsTrue(ls.VerifySignature(dest.SigningPublicKey)); var ls2 = new I2PLeaseSet(new BufRefLen(ls.ToByteArray())); Assert.IsTrue(ls2.VerifySignature(dest.SigningPublicKey)); var ls3 = new I2PLeaseSet(ls2.Destination, ls2.Leases, new I2PLeaseInfo(destinfo)); Assert.IsTrue(ls3.VerifySignature(dest.SigningPublicKey)); Assert.IsTrue(new BufLen(ls.ToByteArray()) == new BufLen(ls3.ToByteArray())); }
public void AddLeaseSet(I2PLeaseSet leaseset) { if (!leaseset.VerifySignature(leaseset.Destination.SigningPublicKey)) { Logging.LogWarning($"LeaseSet {0} signature verification failed."); return; } if (LeaseSets.TryGetValue(leaseset.Destination.IdentHash, out var extls)) { if (extls.EndOfLife > leaseset.EndOfLife) { return; } } LeaseSets[leaseset.Destination.IdentHash] = leaseset; if (LeaseSetUpdates != null) { ThreadPool.QueueUserWorkItem(a => LeaseSetUpdates(leaseset)); } }