ECAlgorithms.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Math.EC.Endo;
  5. using BestHTTP.SecureProtocol.Org.BouncyCastle.Math.EC.Multiplier;
  6. using BestHTTP.SecureProtocol.Org.BouncyCastle.Math.Field;
  7. using BestHTTP.SecureProtocol.Org.BouncyCastle.Math.Raw;
  8. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Math.EC
  9. {
  10. public class ECAlgorithms
  11. {
  12. public static bool IsF2mCurve(ECCurve c)
  13. {
  14. return IsF2mField(c.Field);
  15. }
  16. public static bool IsF2mField(IFiniteField field)
  17. {
  18. return field.Dimension > 1 && field.Characteristic.Equals(BigInteger.Two)
  19. && field is IPolynomialExtensionField;
  20. }
  21. public static bool IsFpCurve(ECCurve c)
  22. {
  23. return IsFpField(c.Field);
  24. }
  25. public static bool IsFpField(IFiniteField field)
  26. {
  27. return field.Dimension == 1;
  28. }
  29. public static ECPoint SumOfMultiplies(ECPoint[] ps, BigInteger[] ks)
  30. {
  31. if (ps == null || ks == null || ps.Length != ks.Length || ps.Length < 1)
  32. throw new ArgumentException("point and scalar arrays should be non-null, and of equal, non-zero, length");
  33. int count = ps.Length;
  34. switch (count)
  35. {
  36. case 1:
  37. return ps[0].Multiply(ks[0]);
  38. case 2:
  39. return SumOfTwoMultiplies(ps[0], ks[0], ps[1], ks[1]);
  40. default:
  41. break;
  42. }
  43. ECPoint p = ps[0];
  44. ECCurve c = p.Curve;
  45. ECPoint[] imported = new ECPoint[count];
  46. imported[0] = p;
  47. for (int i = 1; i < count; ++i)
  48. {
  49. imported[i] = ImportPoint(c, ps[i]);
  50. }
  51. GlvEndomorphism glvEndomorphism = c.GetEndomorphism() as GlvEndomorphism;
  52. if (glvEndomorphism != null)
  53. {
  54. return ImplCheckResult(ImplSumOfMultipliesGlv(imported, ks, glvEndomorphism));
  55. }
  56. return ImplCheckResult(ImplSumOfMultiplies(imported, ks));
  57. }
  58. public static ECPoint SumOfTwoMultiplies(ECPoint P, BigInteger a, ECPoint Q, BigInteger b)
  59. {
  60. ECCurve cp = P.Curve;
  61. Q = ImportPoint(cp, Q);
  62. // Point multiplication for Koblitz curves (using WTNAF) beats Shamir's trick
  63. {
  64. AbstractF2mCurve f2mCurve = cp as AbstractF2mCurve;
  65. if (f2mCurve != null && f2mCurve.IsKoblitz)
  66. {
  67. return ImplCheckResult(P.Multiply(a).Add(Q.Multiply(b)));
  68. }
  69. }
  70. GlvEndomorphism glvEndomorphism = cp.GetEndomorphism() as GlvEndomorphism;
  71. if (glvEndomorphism != null)
  72. {
  73. return ImplCheckResult(
  74. ImplSumOfMultipliesGlv(new ECPoint[] { P, Q }, new BigInteger[] { a, b }, glvEndomorphism));
  75. }
  76. return ImplCheckResult(ImplShamirsTrickWNaf(P, a, Q, b));
  77. }
  78. /*
  79. * "Shamir's Trick", originally due to E. G. Straus
  80. * (Addition chains of vectors. American Mathematical Monthly,
  81. * 71(7):806-808, Aug./Sept. 1964)
  82. *
  83. * Input: The points P, Q, scalar k = (km?, ... , k1, k0)
  84. * and scalar l = (lm?, ... , l1, l0).
  85. * Output: R = k * P + l * Q.
  86. * 1: Z <- P + Q
  87. * 2: R <- O
  88. * 3: for i from m-1 down to 0 do
  89. * 4: R <- R + R {point doubling}
  90. * 5: if (ki = 1) and (li = 0) then R <- R + P end if
  91. * 6: if (ki = 0) and (li = 1) then R <- R + Q end if
  92. * 7: if (ki = 1) and (li = 1) then R <- R + Z end if
  93. * 8: end for
  94. * 9: return R
  95. */
  96. public static ECPoint ShamirsTrick(ECPoint P, BigInteger k, ECPoint Q, BigInteger l)
  97. {
  98. ECCurve cp = P.Curve;
  99. Q = ImportPoint(cp, Q);
  100. return ImplCheckResult(ImplShamirsTrickJsf(P, k, Q, l));
  101. }
  102. public static ECPoint ImportPoint(ECCurve c, ECPoint p)
  103. {
  104. ECCurve cp = p.Curve;
  105. if (!c.Equals(cp))
  106. throw new ArgumentException("Point must be on the same curve");
  107. return c.ImportPoint(p);
  108. }
  109. public static void MontgomeryTrick(ECFieldElement[] zs, int off, int len)
  110. {
  111. MontgomeryTrick(zs, off, len, null);
  112. }
  113. public static void MontgomeryTrick(ECFieldElement[] zs, int off, int len, ECFieldElement scale)
  114. {
  115. /*
  116. * Uses the "Montgomery Trick" to invert many field elements, with only a single actual
  117. * field inversion. See e.g. the paper:
  118. * "Fast Multi-scalar Multiplication Methods on Elliptic Curves with Precomputation Strategy Using Montgomery Trick"
  119. * by Katsuyuki Okeya, Kouichi Sakurai.
  120. */
  121. ECFieldElement[] c = new ECFieldElement[len];
  122. c[0] = zs[off];
  123. int i = 0;
  124. while (++i < len)
  125. {
  126. c[i] = c[i - 1].Multiply(zs[off + i]);
  127. }
  128. --i;
  129. if (scale != null)
  130. {
  131. c[i] = c[i].Multiply(scale);
  132. }
  133. ECFieldElement u = c[i].Invert();
  134. while (i > 0)
  135. {
  136. int j = off + i--;
  137. ECFieldElement tmp = zs[j];
  138. zs[j] = c[i].Multiply(u);
  139. u = u.Multiply(tmp);
  140. }
  141. zs[off] = u;
  142. }
  143. /**
  144. * Simple shift-and-add multiplication. Serves as reference implementation to verify (possibly
  145. * faster) implementations, and for very small scalars. CAUTION: This implementation is NOT
  146. * constant-time in any way. It is only intended to be used for diagnostics.
  147. *
  148. * @param p
  149. * The point to multiply.
  150. * @param k
  151. * The multiplier.
  152. * @return The result of the point multiplication <code>kP</code>.
  153. */
  154. public static ECPoint ReferenceMultiply(ECPoint p, BigInteger k)
  155. {
  156. BigInteger x = k.Abs();
  157. ECPoint q = p.Curve.Infinity;
  158. int t = x.BitLength;
  159. if (t > 0)
  160. {
  161. if (x.TestBit(0))
  162. {
  163. q = p;
  164. }
  165. for (int i = 1; i < t; i++)
  166. {
  167. p = p.Twice();
  168. if (x.TestBit(i))
  169. {
  170. q = q.Add(p);
  171. }
  172. }
  173. }
  174. return k.SignValue < 0 ? q.Negate() : q;
  175. }
  176. public static ECPoint ValidatePoint(ECPoint p)
  177. {
  178. if (!p.IsValid())
  179. throw new InvalidOperationException("Invalid point");
  180. return p;
  181. }
  182. public static ECPoint CleanPoint(ECCurve c, ECPoint p)
  183. {
  184. ECCurve cp = p.Curve;
  185. if (!c.Equals(cp))
  186. throw new ArgumentException("Point must be on the same curve", "p");
  187. return c.DecodePoint(p.GetEncoded(false));
  188. }
  189. internal static ECPoint ImplCheckResult(ECPoint p)
  190. {
  191. if (!p.IsValidPartial())
  192. throw new InvalidOperationException("Invalid result");
  193. return p;
  194. }
  195. internal static ECPoint ImplShamirsTrickJsf(ECPoint P, BigInteger k, ECPoint Q, BigInteger l)
  196. {
  197. ECCurve curve = P.Curve;
  198. ECPoint infinity = curve.Infinity;
  199. // TODO conjugate co-Z addition (ZADDC) can return both of these
  200. ECPoint PaddQ = P.Add(Q);
  201. ECPoint PsubQ = P.Subtract(Q);
  202. ECPoint[] points = new ECPoint[] { Q, PsubQ, P, PaddQ };
  203. curve.NormalizeAll(points);
  204. ECPoint[] table = new ECPoint[] {
  205. points[3].Negate(), points[2].Negate(), points[1].Negate(),
  206. points[0].Negate(), infinity, points[0],
  207. points[1], points[2], points[3] };
  208. byte[] jsf = WNafUtilities.GenerateJsf(k, l);
  209. ECPoint R = infinity;
  210. int i = jsf.Length;
  211. while (--i >= 0)
  212. {
  213. int jsfi = jsf[i];
  214. // NOTE: The shifting ensures the sign is extended correctly
  215. int kDigit = ((jsfi << 24) >> 28), lDigit = ((jsfi << 28) >> 28);
  216. int index = 4 + (kDigit * 3) + lDigit;
  217. R = R.TwicePlus(table[index]);
  218. }
  219. return R;
  220. }
  221. internal static ECPoint ImplShamirsTrickWNaf(ECPoint P, BigInteger k,
  222. ECPoint Q, BigInteger l)
  223. {
  224. bool negK = k.SignValue < 0, negL = l.SignValue < 0;
  225. BigInteger kAbs = k.Abs(), lAbs = l.Abs();
  226. int minWidthP = WNafUtilities.GetWindowSize(kAbs.BitLength, 8);
  227. int minWidthQ = WNafUtilities.GetWindowSize(lAbs.BitLength, 8);
  228. WNafPreCompInfo infoP = WNafUtilities.Precompute(P, minWidthP, true);
  229. WNafPreCompInfo infoQ = WNafUtilities.Precompute(Q, minWidthQ, true);
  230. // When P, Q are 'promoted' (i.e. reused several times), switch to fixed-point algorithm
  231. {
  232. ECCurve c = P.Curve;
  233. int combSize = FixedPointUtilities.GetCombSize(c);
  234. if (!negK && !negL
  235. && k.BitLength <= combSize && l.BitLength <= combSize
  236. && infoP.IsPromoted && infoQ.IsPromoted)
  237. {
  238. return ImplShamirsTrickFixedPoint(P, k, Q, l);
  239. }
  240. }
  241. int widthP = System.Math.Min(8, infoP.Width);
  242. int widthQ = System.Math.Min(8, infoQ.Width);
  243. ECPoint[] preCompP = negK ? infoP.PreCompNeg : infoP.PreComp;
  244. ECPoint[] preCompQ = negL ? infoQ.PreCompNeg : infoQ.PreComp;
  245. ECPoint[] preCompNegP = negK ? infoP.PreComp : infoP.PreCompNeg;
  246. ECPoint[] preCompNegQ = negL ? infoQ.PreComp : infoQ.PreCompNeg;
  247. byte[] wnafP = WNafUtilities.GenerateWindowNaf(widthP, kAbs);
  248. byte[] wnafQ = WNafUtilities.GenerateWindowNaf(widthQ, lAbs);
  249. return ImplShamirsTrickWNaf(preCompP, preCompNegP, wnafP, preCompQ, preCompNegQ, wnafQ);
  250. }
  251. internal static ECPoint ImplShamirsTrickWNaf(ECEndomorphism endomorphism, ECPoint P, BigInteger k, BigInteger l)
  252. {
  253. bool negK = k.SignValue < 0, negL = l.SignValue < 0;
  254. k = k.Abs();
  255. l = l.Abs();
  256. int minWidth = WNafUtilities.GetWindowSize(System.Math.Max(k.BitLength, l.BitLength), 8);
  257. WNafPreCompInfo infoP = WNafUtilities.Precompute(P, minWidth, true);
  258. ECPoint Q = EndoUtilities.MapPoint(endomorphism, P);
  259. WNafPreCompInfo infoQ = WNafUtilities.PrecomputeWithPointMap(Q, endomorphism.PointMap, infoP, true);
  260. int widthP = System.Math.Min(8, infoP.Width);
  261. int widthQ = System.Math.Min(8, infoQ.Width);
  262. ECPoint[] preCompP = negK ? infoP.PreCompNeg : infoP.PreComp;
  263. ECPoint[] preCompQ = negL ? infoQ.PreCompNeg : infoQ.PreComp;
  264. ECPoint[] preCompNegP = negK ? infoP.PreComp : infoP.PreCompNeg;
  265. ECPoint[] preCompNegQ = negL ? infoQ.PreComp : infoQ.PreCompNeg;
  266. byte[] wnafP = WNafUtilities.GenerateWindowNaf(widthP, k);
  267. byte[] wnafQ = WNafUtilities.GenerateWindowNaf(widthQ, l);
  268. return ImplShamirsTrickWNaf(preCompP, preCompNegP, wnafP, preCompQ, preCompNegQ, wnafQ);
  269. }
  270. private static ECPoint ImplShamirsTrickWNaf(ECPoint[] preCompP, ECPoint[] preCompNegP, byte[] wnafP,
  271. ECPoint[] preCompQ, ECPoint[] preCompNegQ, byte[] wnafQ)
  272. {
  273. int len = System.Math.Max(wnafP.Length, wnafQ.Length);
  274. ECCurve curve = preCompP[0].Curve;
  275. ECPoint infinity = curve.Infinity;
  276. ECPoint R = infinity;
  277. int zeroes = 0;
  278. for (int i = len - 1; i >= 0; --i)
  279. {
  280. int wiP = i < wnafP.Length ? (int)(sbyte)wnafP[i] : 0;
  281. int wiQ = i < wnafQ.Length ? (int)(sbyte)wnafQ[i] : 0;
  282. if ((wiP | wiQ) == 0)
  283. {
  284. ++zeroes;
  285. continue;
  286. }
  287. ECPoint r = infinity;
  288. if (wiP != 0)
  289. {
  290. int nP = System.Math.Abs(wiP);
  291. ECPoint[] tableP = wiP < 0 ? preCompNegP : preCompP;
  292. r = r.Add(tableP[nP >> 1]);
  293. }
  294. if (wiQ != 0)
  295. {
  296. int nQ = System.Math.Abs(wiQ);
  297. ECPoint[] tableQ = wiQ < 0 ? preCompNegQ : preCompQ;
  298. r = r.Add(tableQ[nQ >> 1]);
  299. }
  300. if (zeroes > 0)
  301. {
  302. R = R.TimesPow2(zeroes);
  303. zeroes = 0;
  304. }
  305. R = R.TwicePlus(r);
  306. }
  307. if (zeroes > 0)
  308. {
  309. R = R.TimesPow2(zeroes);
  310. }
  311. return R;
  312. }
  313. internal static ECPoint ImplSumOfMultiplies(ECPoint[] ps, BigInteger[] ks)
  314. {
  315. int count = ps.Length;
  316. bool[] negs = new bool[count];
  317. WNafPreCompInfo[] infos = new WNafPreCompInfo[count];
  318. byte[][] wnafs = new byte[count][];
  319. for (int i = 0; i < count; ++i)
  320. {
  321. BigInteger ki = ks[i]; negs[i] = ki.SignValue < 0; ki = ki.Abs();
  322. int minWidth = WNafUtilities.GetWindowSize(ki.BitLength, 8);
  323. WNafPreCompInfo info = WNafUtilities.Precompute(ps[i], minWidth, true);
  324. int width = System.Math.Min(8, info.Width);
  325. infos[i] = info;
  326. wnafs[i] = WNafUtilities.GenerateWindowNaf(width, ki);
  327. }
  328. return ImplSumOfMultiplies(negs, infos, wnafs);
  329. }
  330. internal static ECPoint ImplSumOfMultipliesGlv(ECPoint[] ps, BigInteger[] ks, GlvEndomorphism glvEndomorphism)
  331. {
  332. BigInteger n = ps[0].Curve.Order;
  333. int len = ps.Length;
  334. BigInteger[] abs = new BigInteger[len << 1];
  335. for (int i = 0, j = 0; i < len; ++i)
  336. {
  337. BigInteger[] ab = glvEndomorphism.DecomposeScalar(ks[i].Mod(n));
  338. abs[j++] = ab[0];
  339. abs[j++] = ab[1];
  340. }
  341. if (glvEndomorphism.HasEfficientPointMap)
  342. {
  343. return ImplSumOfMultiplies(glvEndomorphism, ps, abs);
  344. }
  345. ECPoint[] pqs = new ECPoint[len << 1];
  346. for (int i = 0, j = 0; i < len; ++i)
  347. {
  348. ECPoint p = ps[i];
  349. ECPoint q = EndoUtilities.MapPoint(glvEndomorphism, p);
  350. pqs[j++] = p;
  351. pqs[j++] = q;
  352. }
  353. return ImplSumOfMultiplies(pqs, abs);
  354. }
  355. internal static ECPoint ImplSumOfMultiplies(ECEndomorphism endomorphism, ECPoint[] ps, BigInteger[] ks)
  356. {
  357. int halfCount = ps.Length, fullCount = halfCount << 1;
  358. bool[] negs = new bool[fullCount];
  359. WNafPreCompInfo[] infos = new WNafPreCompInfo[fullCount];
  360. byte[][] wnafs = new byte[fullCount][];
  361. ECPointMap pointMap = endomorphism.PointMap;
  362. for (int i = 0; i < halfCount; ++i)
  363. {
  364. int j0 = i << 1, j1 = j0 + 1;
  365. BigInteger kj0 = ks[j0]; negs[j0] = kj0.SignValue < 0; kj0 = kj0.Abs();
  366. BigInteger kj1 = ks[j1]; negs[j1] = kj1.SignValue < 0; kj1 = kj1.Abs();
  367. int minWidth = WNafUtilities.GetWindowSize(System.Math.Max(kj0.BitLength, kj1.BitLength), 8);
  368. ECPoint P = ps[i];
  369. WNafPreCompInfo infoP = WNafUtilities.Precompute(P, minWidth, true);
  370. ECPoint Q = EndoUtilities.MapPoint(endomorphism, P);
  371. WNafPreCompInfo infoQ = WNafUtilities.PrecomputeWithPointMap(Q, pointMap, infoP, true);
  372. int widthP = System.Math.Min(8, infoP.Width);
  373. int widthQ = System.Math.Min(8, infoQ.Width);
  374. infos[j0] = infoP;
  375. infos[j1] = infoQ;
  376. wnafs[j0] = WNafUtilities.GenerateWindowNaf(widthP, kj0);
  377. wnafs[j1] = WNafUtilities.GenerateWindowNaf(widthQ, kj1);
  378. }
  379. return ImplSumOfMultiplies(negs, infos, wnafs);
  380. }
  381. private static ECPoint ImplSumOfMultiplies(bool[] negs, WNafPreCompInfo[] infos, byte[][] wnafs)
  382. {
  383. int len = 0, count = wnafs.Length;
  384. for (int i = 0; i < count; ++i)
  385. {
  386. len = System.Math.Max(len, wnafs[i].Length);
  387. }
  388. ECCurve curve = infos[0].PreComp[0].Curve;
  389. ECPoint infinity = curve.Infinity;
  390. ECPoint R = infinity;
  391. int zeroes = 0;
  392. for (int i = len - 1; i >= 0; --i)
  393. {
  394. ECPoint r = infinity;
  395. for (int j = 0; j < count; ++j)
  396. {
  397. byte[] wnaf = wnafs[j];
  398. int wi = i < wnaf.Length ? (int)(sbyte)wnaf[i] : 0;
  399. if (wi != 0)
  400. {
  401. int n = System.Math.Abs(wi);
  402. WNafPreCompInfo info = infos[j];
  403. ECPoint[] table = (wi < 0 == negs[j]) ? info.PreComp : info.PreCompNeg;
  404. r = r.Add(table[n >> 1]);
  405. }
  406. }
  407. if (r == infinity)
  408. {
  409. ++zeroes;
  410. continue;
  411. }
  412. if (zeroes > 0)
  413. {
  414. R = R.TimesPow2(zeroes);
  415. zeroes = 0;
  416. }
  417. R = R.TwicePlus(r);
  418. }
  419. if (zeroes > 0)
  420. {
  421. R = R.TimesPow2(zeroes);
  422. }
  423. return R;
  424. }
  425. private static ECPoint ImplShamirsTrickFixedPoint(ECPoint p, BigInteger k, ECPoint q, BigInteger l)
  426. {
  427. ECCurve c = p.Curve;
  428. int combSize = FixedPointUtilities.GetCombSize(c);
  429. if (k.BitLength > combSize || l.BitLength > combSize)
  430. {
  431. /*
  432. * TODO The comb works best when the scalars are less than the (possibly unknown) order.
  433. * Still, if we want to handle larger scalars, we could allow customization of the comb
  434. * size, or alternatively we could deal with the 'extra' bits either by running the comb
  435. * multiple times as necessary, or by using an alternative multiplier as prelude.
  436. */
  437. throw new InvalidOperationException("fixed-point comb doesn't support scalars larger than the curve order");
  438. }
  439. FixedPointPreCompInfo infoP = FixedPointUtilities.Precompute(p);
  440. FixedPointPreCompInfo infoQ = FixedPointUtilities.Precompute(q);
  441. ECLookupTable lookupTableP = infoP.LookupTable;
  442. ECLookupTable lookupTableQ = infoQ.LookupTable;
  443. int widthP = infoP.Width;
  444. int widthQ = infoQ.Width;
  445. // TODO This shouldn't normally happen, but a better "solution" is desirable anyway
  446. if (widthP != widthQ)
  447. {
  448. FixedPointCombMultiplier m = new FixedPointCombMultiplier();
  449. ECPoint r1 = m.Multiply(p, k);
  450. ECPoint r2 = m.Multiply(q, l);
  451. return r1.Add(r2);
  452. }
  453. int width = widthP;
  454. int d = (combSize + width - 1) / width;
  455. ECPoint R = c.Infinity;
  456. int fullComb = d * width;
  457. uint[] K = Nat.FromBigInteger(fullComb, k);
  458. uint[] L = Nat.FromBigInteger(fullComb, l);
  459. int top = fullComb - 1;
  460. for (int i = 0; i < d; ++i)
  461. {
  462. uint secretIndexK = 0, secretIndexL = 0;
  463. for (int j = top - i; j >= 0; j -= d)
  464. {
  465. uint secretBitK = K[j >> 5] >> (j & 0x1F);
  466. secretIndexK ^= secretBitK >> 1;
  467. secretIndexK <<= 1;
  468. secretIndexK ^= secretBitK;
  469. uint secretBitL = L[j >> 5] >> (j & 0x1F);
  470. secretIndexL ^= secretBitL >> 1;
  471. secretIndexL <<= 1;
  472. secretIndexL ^= secretBitL;
  473. }
  474. ECPoint addP = lookupTableP.LookupVar((int)secretIndexK);
  475. ECPoint addQ = lookupTableQ.LookupVar((int)secretIndexL);
  476. ECPoint T = addP.Add(addQ);
  477. R = R.TwicePlus(T);
  478. }
  479. return R.Add(infoP.Offset).Add(infoQ.Offset);
  480. }
  481. }
  482. }
  483. #pragma warning restore
  484. #endif