Search in sources :

Example 1 with OptimizedEquiValidator

use of org.aion.equihash.OptimizedEquiValidator in project aion by aionnetwork.

the class EquihashValidatorTest method invalidSolutionLengthTest.

// Delete last 8 solutions
@Test
public void invalidSolutionLengthTest() {
    byte[] header = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    byte[] nonce = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    int n = 210;
    int k = 9;
    int[] solution = { 20355, 2545802, 907342, 1930412, 905311, 3877411, 1903231, 2689731, 506861, 2315704, 1951052, 2227153, 2777366, 3236666, 3589074, 3643676, 504683, 1356644, 1438735, 3811518, 2217209, 3942573, 3417766, 3756123, 678546, 1762659, 2764197, 4043088, 837400, 3860117, 845468, 2155675, 158339, 1624003, 296319, 2896689, 1890905, 2739467, 2400006, 2772678, 465854, 833805, 512180, 1188591, 994659, 2860954, 1118590, 1430454, 468682, 2389668, 1777223, 2936757, 482455, 2375862, 1500518, 1974003, 658874, 3347208, 1725007, 2957767, 1148912, 3836887, 2679675, 3926943, 34780, 2564574, 2390936, 2555613, 946022, 3803691, 2314033, 4106977, 1433928, 2898030, 1534277, 1818947, 2262862, 4100511, 2705431, 4040332, 270150, 3015764, 1312138, 3075144, 1080444, 2162225, 2959308, 3157745, 385118, 2198870, 2851713, 3714102, 515881, 3397675, 2382411, 2444766, 48996, 3898535, 3129497, 3693976, 95695, 2435387, 2911079, 3718581, 578995, 1981490, 1002209, 2070152, 859812, 929850, 1206926, 4153868, 203330, 2339854, 2964095, 3552937, 842873, 3698309, 2497048, 3769276, 584594, 1264798, 1933308, 3523328, 1283227, 2242647, 2190815, 3020750, 41390, 3771880, 263000, 758924, 559478, 3168011, 1303488, 3381537, 717900, 4072531, 1661229, 3319094, 1127203, 2119989, 1850536, 2099166, 121852, 2843305, 566396, 1051840, 791008, 2612111, 1570629, 2709103, 812775, 3641315, 1053858, 1492834, 2578414, 3127037, 2987191, 3276177, 183924, 1831245, 878825, 2604335, 1595819, 4145284, 1610183, 3268750, 448042, 1999222, 1006093, 2711058, 2788669, 3201236, 2905205, 4191295, 263045, 288816, 708465, 3818877, 477879, 3014614, 2424026, 3730921, 268146, 1481166, 1687705, 1851825, 1115358, 4087438, 2834812, 3655853, 142275, 2932955, 2978299, 3315362, 866230, 1167961, 1666141, 3445169, 1076566, 1877713, 2740346, 3081165, 1684805, 2848657, 1961158, 3927792, 424919, 2869909, 1390027, 2948742, 672678, 1305311, 2335716, 2408750, 1656898, 2315900, 2228009, 3897974, 2080083, 3358645, 2183017, 2474962, 227904, 3257048, 1015946, 2246708, 744733, 4046023, 1305041, 4000191, 597568, 3788490, 1629963, 3055481, 1203517, 1878102, 2311148, 3069747, 475712, 2736079, 2093117, 2709022, 1766719, 2760187, 2308251, 3000603, 1122895, 4052370, 2081446, 2580232, 1497222, 1861105, 2240286, 2531758, 30071, 2842909, 590630, 3979760, 696925, 3258522, 1514676, 3716048, 1030285, 1986957, 2226931, 2864777, 2455350, 3168779, 3066230, 3403299, 256066, 2499634, 3560516, 4094756, 1256581, 2305277, 1782337, 4079485, 426456, 2259473, 464202, 3688991, 1861389, 3444866, 2960951, 3186120, 96490, 3786348, 912465, 2189746, 3408757, 3465881, 3510320, 4162223, 371697, 1169844, 2378665, 3735875, 1591695, 1866557, 1893808, 2941633, 754250, 3548696, 1247845, 3450148, 1067081, 1578401, 1486825, 3237627, 767078, 3201793, 1632439, 2521903, 1137703, 2456425, 1407972, 2485769, 160330, 3614857, 1481210, 1578079, 1996927, 4075979, 2984588, 3931673, 743440, 1237620, 1744748, 3133823, 1673449, 2727191, 1793757, 4002209, 200923, 1287230, 1452788, 1850912, 1456000, 4019882, 1605453, 3160917, 386477, 3366002, 3231682, 3735723, 491335, 4153328, 1244051, 2764520, 177653, 2136121, 1266815, 1362612, 1486929, 4194196, 3374899, 3540741, 220240, 2833638, 1866174, 3835077, 669705, 1597154, 1154067, 2212093, 317749, 3488031, 3363506, 3598838, 2808761, 3451142, 3535535, 3937125, 907483, 4099106, 1958727, 3318901, 2551208, 3087618, 2600877, 3702862, 44753, 3160552, 456566, 2367674, 1691363, 3123342, 3187852, 3760152, 1103888, 2963337, 3512868, 3825332, 1146648, 1433039, 3309183, 3492584, 207921, 3987717, 251562, 3497242, 3207164, 4065140, 3998081, 4109968, 584588, 3212329, 774474, 3481768, 2096006, 3238743, 3115602, 3803926, 66244, 309456, 640355, 2060813, 877456, 1728849, 1902807, 2306919, 289666, 4152610, 2712657, 3324726, 599498, 1425451, 1839380, 2385592, 705670, 3056467, 2670990, 2847010, 1188781, 2812793, 1769251, 3789434, 1898743, 2446962, 2867004, 3715274, 2354821, 3601552, 3140000, 3578421, 140339, 598398, 606801, 1294404, 1806336, 1986146, 2500515, 3164517, 1599048, 2800323, 3361171, 3678605, 1606340, 1901611, 2081741, 2494676, 821973, 3172246, 1760974, 3682564, 1307586, 1596950, 1339018, 1768126, 1033573, 2310148, 1821481, 2445292, 1948298, 2221343, 2225320, 3313311, 160437, 1281935, 386292, 3121792, 944232, 1247064, 2646561, 2904304, 546854, 4051902, 664040, 2880916, 1721878, 2042202, 3076451, 4054925, 232459, 3321779, 389694, 2063343, 920162, 3452042, 3197977, 4166342 };
    OptimizedEquiValidator ov = new OptimizedEquiValidator(n, k);
    byte[] minimal = EquiUtils.getMinimalFromIndices(solution, n / (k + 1));
    boolean isValid = ov.isValidSolution(minimal, header, nonce);
    boolean isValidNative = ov.isValidSolutionNative(minimal, header, nonce);
    assertEquals(false, isValid);
    assertEquals(false, isValidNative);
}
Also used : OptimizedEquiValidator(org.aion.equihash.OptimizedEquiValidator) Test(org.junit.Test)

Example 2 with OptimizedEquiValidator

use of org.aion.equihash.OptimizedEquiValidator in project aion by aionnetwork.

the class EquihashValidatorTest method changeIndexTest.

// Change solution index 0
@Test
public void changeIndexTest() {
    byte[] header = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    byte[] nonce = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    int n = 210;
    int k = 9;
    int[] solution = { 20356, 2545802, 907342, 1930412, 905311, 3877411, 1903231, 2689731, 506861, 2315704, 1951052, 2227153, 2777366, 3236666, 3589074, 3643676, 504683, 1356644, 1438735, 3811518, 2217209, 3942573, 3417766, 3756123, 678546, 1762659, 2764197, 4043088, 837400, 3860117, 845468, 2155675, 158339, 1624003, 296319, 2896689, 1890905, 2739467, 2400006, 2772678, 465854, 833805, 512180, 1188591, 994659, 2860954, 1118590, 1430454, 468682, 2389668, 1777223, 2936757, 482455, 2375862, 1500518, 1974003, 658874, 3347208, 1725007, 2957767, 1148912, 3836887, 2679675, 3926943, 34780, 2564574, 2390936, 2555613, 946022, 3803691, 2314033, 4106977, 1433928, 2898030, 1534277, 1818947, 2262862, 4100511, 2705431, 4040332, 270150, 3015764, 1312138, 3075144, 1080444, 2162225, 2959308, 3157745, 385118, 2198870, 2851713, 3714102, 515881, 3397675, 2382411, 2444766, 48996, 3898535, 3129497, 3693976, 95695, 2435387, 2911079, 3718581, 578995, 1981490, 1002209, 2070152, 859812, 929850, 1206926, 4153868, 203330, 2339854, 2964095, 3552937, 842873, 3698309, 2497048, 3769276, 584594, 1264798, 1933308, 3523328, 1283227, 2242647, 2190815, 3020750, 41390, 3771880, 263000, 758924, 559478, 3168011, 1303488, 3381537, 717900, 4072531, 1661229, 3319094, 1127203, 2119989, 1850536, 2099166, 121852, 2843305, 566396, 1051840, 791008, 2612111, 1570629, 2709103, 812775, 3641315, 1053858, 1492834, 2578414, 3127037, 2987191, 3276177, 183924, 1831245, 878825, 2604335, 1595819, 4145284, 1610183, 3268750, 448042, 1999222, 1006093, 2711058, 2788669, 3201236, 2905205, 4191295, 263045, 288816, 708465, 3818877, 477879, 3014614, 2424026, 3730921, 268146, 1481166, 1687705, 1851825, 1115358, 4087438, 2834812, 3655853, 142275, 2932955, 2978299, 3315362, 866230, 1167961, 1666141, 3445169, 1076566, 1877713, 2740346, 3081165, 1684805, 2848657, 1961158, 3927792, 424919, 2869909, 1390027, 2948742, 672678, 1305311, 2335716, 2408750, 1656898, 2315900, 2228009, 3897974, 2080083, 3358645, 2183017, 2474962, 227904, 3257048, 1015946, 2246708, 744733, 4046023, 1305041, 4000191, 597568, 3788490, 1629963, 3055481, 1203517, 1878102, 2311148, 3069747, 475712, 2736079, 2093117, 2709022, 1766719, 2760187, 2308251, 3000603, 1122895, 4052370, 2081446, 2580232, 1497222, 1861105, 2240286, 2531758, 30071, 2842909, 590630, 3979760, 696925, 3258522, 1514676, 3716048, 1030285, 1986957, 2226931, 2864777, 2455350, 3168779, 3066230, 3403299, 256066, 2499634, 3560516, 4094756, 1256581, 2305277, 1782337, 4079485, 426456, 2259473, 464202, 3688991, 1861389, 3444866, 2960951, 3186120, 96490, 3786348, 912465, 2189746, 3408757, 3465881, 3510320, 4162223, 371697, 1169844, 2378665, 3735875, 1591695, 1866557, 1893808, 2941633, 754250, 3548696, 1247845, 3450148, 1067081, 1578401, 1486825, 3237627, 767078, 3201793, 1632439, 2521903, 1137703, 2456425, 1407972, 2485769, 160330, 3614857, 1481210, 1578079, 1996927, 4075979, 2984588, 3931673, 743440, 1237620, 1744748, 3133823, 1673449, 2727191, 1793757, 4002209, 200923, 1287230, 1452788, 1850912, 1456000, 4019882, 1605453, 3160917, 386477, 3366002, 3231682, 3735723, 491335, 4153328, 1244051, 2764520, 177653, 2136121, 1266815, 1362612, 1486929, 4194196, 3374899, 3540741, 220240, 2833638, 1866174, 3835077, 669705, 1597154, 1154067, 2212093, 317749, 3488031, 3363506, 3598838, 2808761, 3451142, 3535535, 3937125, 907483, 4099106, 1958727, 3318901, 2551208, 3087618, 2600877, 3702862, 44753, 3160552, 456566, 2367674, 1691363, 3123342, 3187852, 3760152, 1103888, 2963337, 3512868, 3825332, 1146648, 1433039, 3309183, 3492584, 207921, 3987717, 251562, 3497242, 3207164, 4065140, 3998081, 4109968, 584588, 3212329, 774474, 3481768, 2096006, 3238743, 3115602, 3803926, 66244, 309456, 640355, 2060813, 877456, 1728849, 1902807, 2306919, 289666, 4152610, 2712657, 3324726, 599498, 1425451, 1839380, 2385592, 705670, 3056467, 2670990, 2847010, 1188781, 2812793, 1769251, 3789434, 1898743, 2446962, 2867004, 3715274, 2354821, 3601552, 3140000, 3578421, 140339, 598398, 606801, 1294404, 1806336, 1986146, 2500515, 3164517, 1599048, 2800323, 3361171, 3678605, 1606340, 1901611, 2081741, 2494676, 821973, 3172246, 1760974, 3682564, 1307586, 1596950, 1339018, 1768126, 1033573, 2310148, 1821481, 2445292, 1948298, 2221343, 2225320, 3313311, 160437, 1281935, 386292, 3121792, 944232, 1247064, 2646561, 2904304, 546854, 4051902, 664040, 2880916, 1721878, 2042202, 3076451, 4054925, 232459, 3321779, 389694, 2063343, 920162, 3452042, 3197977, 4166342, 452733, 4016722, 2713436, 3119993, 913404, 2140622, 1655092, 2472993 };
    OptimizedEquiValidator ov = new OptimizedEquiValidator(n, k);
    byte[] minimal = EquiUtils.getMinimalFromIndices(solution, n / (k + 1));
    boolean isValid = ov.isValidSolution(minimal, header, nonce);
    boolean isValidNative = ov.isValidSolutionNative(minimal, header, nonce);
    assertEquals(false, isValid);
    assertEquals(false, isValidNative);
}
Also used : OptimizedEquiValidator(org.aion.equihash.OptimizedEquiValidator) Test(org.junit.Test)

Example 3 with OptimizedEquiValidator

use of org.aion.equihash.OptimizedEquiValidator in project aion by aionnetwork.

the class EquihashValidatorTest method validSolutionTest.

@Test
public void validSolutionTest() {
    byte[] header = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    byte[] nonce = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    int n = 210;
    int k = 9;
    int[] solution = { 20355, 2545802, 907342, 1930412, 905311, 3877411, 1903231, 2689731, 506861, 2315704, 1951052, 2227153, 2777366, 3236666, 3589074, 3643676, 504683, 1356644, 1438735, 3811518, 2217209, 3942573, 3417766, 3756123, 678546, 1762659, 2764197, 4043088, 837400, 3860117, 845468, 2155675, 158339, 1624003, 296319, 2896689, 1890905, 2739467, 2400006, 2772678, 465854, 833805, 512180, 1188591, 994659, 2860954, 1118590, 1430454, 468682, 2389668, 1777223, 2936757, 482455, 2375862, 1500518, 1974003, 658874, 3347208, 1725007, 2957767, 1148912, 3836887, 2679675, 3926943, 34780, 2564574, 2390936, 2555613, 946022, 3803691, 2314033, 4106977, 1433928, 2898030, 1534277, 1818947, 2262862, 4100511, 2705431, 4040332, 270150, 3015764, 1312138, 3075144, 1080444, 2162225, 2959308, 3157745, 385118, 2198870, 2851713, 3714102, 515881, 3397675, 2382411, 2444766, 48996, 3898535, 3129497, 3693976, 95695, 2435387, 2911079, 3718581, 578995, 1981490, 1002209, 2070152, 859812, 929850, 1206926, 4153868, 203330, 2339854, 2964095, 3552937, 842873, 3698309, 2497048, 3769276, 584594, 1264798, 1933308, 3523328, 1283227, 2242647, 2190815, 3020750, 41390, 3771880, 263000, 758924, 559478, 3168011, 1303488, 3381537, 717900, 4072531, 1661229, 3319094, 1127203, 2119989, 1850536, 2099166, 121852, 2843305, 566396, 1051840, 791008, 2612111, 1570629, 2709103, 812775, 3641315, 1053858, 1492834, 2578414, 3127037, 2987191, 3276177, 183924, 1831245, 878825, 2604335, 1595819, 4145284, 1610183, 3268750, 448042, 1999222, 1006093, 2711058, 2788669, 3201236, 2905205, 4191295, 263045, 288816, 708465, 3818877, 477879, 3014614, 2424026, 3730921, 268146, 1481166, 1687705, 1851825, 1115358, 4087438, 2834812, 3655853, 142275, 2932955, 2978299, 3315362, 866230, 1167961, 1666141, 3445169, 1076566, 1877713, 2740346, 3081165, 1684805, 2848657, 1961158, 3927792, 424919, 2869909, 1390027, 2948742, 672678, 1305311, 2335716, 2408750, 1656898, 2315900, 2228009, 3897974, 2080083, 3358645, 2183017, 2474962, 227904, 3257048, 1015946, 2246708, 744733, 4046023, 1305041, 4000191, 597568, 3788490, 1629963, 3055481, 1203517, 1878102, 2311148, 3069747, 475712, 2736079, 2093117, 2709022, 1766719, 2760187, 2308251, 3000603, 1122895, 4052370, 2081446, 2580232, 1497222, 1861105, 2240286, 2531758, 30071, 2842909, 590630, 3979760, 696925, 3258522, 1514676, 3716048, 1030285, 1986957, 2226931, 2864777, 2455350, 3168779, 3066230, 3403299, 256066, 2499634, 3560516, 4094756, 1256581, 2305277, 1782337, 4079485, 426456, 2259473, 464202, 3688991, 1861389, 3444866, 2960951, 3186120, 96490, 3786348, 912465, 2189746, 3408757, 3465881, 3510320, 4162223, 371697, 1169844, 2378665, 3735875, 1591695, 1866557, 1893808, 2941633, 754250, 3548696, 1247845, 3450148, 1067081, 1578401, 1486825, 3237627, 767078, 3201793, 1632439, 2521903, 1137703, 2456425, 1407972, 2485769, 160330, 3614857, 1481210, 1578079, 1996927, 4075979, 2984588, 3931673, 743440, 1237620, 1744748, 3133823, 1673449, 2727191, 1793757, 4002209, 200923, 1287230, 1452788, 1850912, 1456000, 4019882, 1605453, 3160917, 386477, 3366002, 3231682, 3735723, 491335, 4153328, 1244051, 2764520, 177653, 2136121, 1266815, 1362612, 1486929, 4194196, 3374899, 3540741, 220240, 2833638, 1866174, 3835077, 669705, 1597154, 1154067, 2212093, 317749, 3488031, 3363506, 3598838, 2808761, 3451142, 3535535, 3937125, 907483, 4099106, 1958727, 3318901, 2551208, 3087618, 2600877, 3702862, 44753, 3160552, 456566, 2367674, 1691363, 3123342, 3187852, 3760152, 1103888, 2963337, 3512868, 3825332, 1146648, 1433039, 3309183, 3492584, 207921, 3987717, 251562, 3497242, 3207164, 4065140, 3998081, 4109968, 584588, 3212329, 774474, 3481768, 2096006, 3238743, 3115602, 3803926, 66244, 309456, 640355, 2060813, 877456, 1728849, 1902807, 2306919, 289666, 4152610, 2712657, 3324726, 599498, 1425451, 1839380, 2385592, 705670, 3056467, 2670990, 2847010, 1188781, 2812793, 1769251, 3789434, 1898743, 2446962, 2867004, 3715274, 2354821, 3601552, 3140000, 3578421, 140339, 598398, 606801, 1294404, 1806336, 1986146, 2500515, 3164517, 1599048, 2800323, 3361171, 3678605, 1606340, 1901611, 2081741, 2494676, 821973, 3172246, 1760974, 3682564, 1307586, 1596950, 1339018, 1768126, 1033573, 2310148, 1821481, 2445292, 1948298, 2221343, 2225320, 3313311, 160437, 1281935, 386292, 3121792, 944232, 1247064, 2646561, 2904304, 546854, 4051902, 664040, 2880916, 1721878, 2042202, 3076451, 4054925, 232459, 3321779, 389694, 2063343, 920162, 3452042, 3197977, 4166342, 452733, 4016722, 2713436, 3119993, 913404, 2140622, 1655092, 2472993 };
    OptimizedEquiValidator ov = new OptimizedEquiValidator(n, k);
    byte[] minimal = EquiUtils.getMinimalFromIndices(solution, n / (k + 1));
    long start = 0;
    long end = 0;
    start = System.nanoTime();
    boolean isValid = ov.isValidSolution(minimal, header, nonce);
    end = System.nanoTime();
    System.out.println("Java validation runtime: " + (end - start));
    start = System.nanoTime();
    boolean isValidNative = ov.isValidSolutionNative(minimal, header, nonce);
    end = System.nanoTime();
    System.out.println("Native validation runtime: " + (end - start));
    assertEquals(true, isValid);
    assertEquals(true, isValidNative);
}
Also used : OptimizedEquiValidator(org.aion.equihash.OptimizedEquiValidator) Test(org.junit.Test)

Example 4 with OptimizedEquiValidator

use of org.aion.equihash.OptimizedEquiValidator in project aion by aionnetwork.

the class EquihashValidatorTest method swapPairTest.

// Swap the first pair of indices with next pair
@Test
public void swapPairTest() {
    byte[] header = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    byte[] nonce = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    int n = 210;
    int k = 9;
    int[] solution = { 907342, 1930412, 20355, 2545802, 905311, 3877411, 1903231, 2689731, 506861, 2315704, 1951052, 2227153, 2777366, 3236666, 3589074, 3643676, 504683, 1356644, 1438735, 3811518, 2217209, 3942573, 3417766, 3756123, 678546, 1762659, 2764197, 4043088, 837400, 3860117, 845468, 2155675, 158339, 1624003, 296319, 2896689, 1890905, 2739467, 2400006, 2772678, 465854, 833805, 512180, 1188591, 994659, 2860954, 1118590, 1430454, 468682, 2389668, 1777223, 2936757, 482455, 2375862, 1500518, 1974003, 658874, 3347208, 1725007, 2957767, 1148912, 3836887, 2679675, 3926943, 34780, 2564574, 2390936, 2555613, 946022, 3803691, 2314033, 4106977, 1433928, 2898030, 1534277, 1818947, 2262862, 4100511, 2705431, 4040332, 270150, 3015764, 1312138, 3075144, 1080444, 2162225, 2959308, 3157745, 385118, 2198870, 2851713, 3714102, 515881, 3397675, 2382411, 2444766, 48996, 3898535, 3129497, 3693976, 95695, 2435387, 2911079, 3718581, 578995, 1981490, 1002209, 2070152, 859812, 929850, 1206926, 4153868, 203330, 2339854, 2964095, 3552937, 842873, 3698309, 2497048, 3769276, 584594, 1264798, 1933308, 3523328, 1283227, 2242647, 2190815, 3020750, 41390, 3771880, 263000, 758924, 559478, 3168011, 1303488, 3381537, 717900, 4072531, 1661229, 3319094, 1127203, 2119989, 1850536, 2099166, 121852, 2843305, 566396, 1051840, 791008, 2612111, 1570629, 2709103, 812775, 3641315, 1053858, 1492834, 2578414, 3127037, 2987191, 3276177, 183924, 1831245, 878825, 2604335, 1595819, 4145284, 1610183, 3268750, 448042, 1999222, 1006093, 2711058, 2788669, 3201236, 2905205, 4191295, 263045, 288816, 708465, 3818877, 477879, 3014614, 2424026, 3730921, 268146, 1481166, 1687705, 1851825, 1115358, 4087438, 2834812, 3655853, 142275, 2932955, 2978299, 3315362, 866230, 1167961, 1666141, 3445169, 1076566, 1877713, 2740346, 3081165, 1684805, 2848657, 1961158, 3927792, 424919, 2869909, 1390027, 2948742, 672678, 1305311, 2335716, 2408750, 1656898, 2315900, 2228009, 3897974, 2080083, 3358645, 2183017, 2474962, 227904, 3257048, 1015946, 2246708, 744733, 4046023, 1305041, 4000191, 597568, 3788490, 1629963, 3055481, 1203517, 1878102, 2311148, 3069747, 475712, 2736079, 2093117, 2709022, 1766719, 2760187, 2308251, 3000603, 1122895, 4052370, 2081446, 2580232, 1497222, 1861105, 2240286, 2531758, 30071, 2842909, 590630, 3979760, 696925, 3258522, 1514676, 3716048, 1030285, 1986957, 2226931, 2864777, 2455350, 3168779, 3066230, 3403299, 256066, 2499634, 3560516, 4094756, 1256581, 2305277, 1782337, 4079485, 426456, 2259473, 464202, 3688991, 1861389, 3444866, 2960951, 3186120, 96490, 3786348, 912465, 2189746, 3408757, 3465881, 3510320, 4162223, 371697, 1169844, 2378665, 3735875, 1591695, 1866557, 1893808, 2941633, 754250, 3548696, 1247845, 3450148, 1067081, 1578401, 1486825, 3237627, 767078, 3201793, 1632439, 2521903, 1137703, 2456425, 1407972, 2485769, 160330, 3614857, 1481210, 1578079, 1996927, 4075979, 2984588, 3931673, 743440, 1237620, 1744748, 3133823, 1673449, 2727191, 1793757, 4002209, 200923, 1287230, 1452788, 1850912, 1456000, 4019882, 1605453, 3160917, 386477, 3366002, 3231682, 3735723, 491335, 4153328, 1244051, 2764520, 177653, 2136121, 1266815, 1362612, 1486929, 4194196, 3374899, 3540741, 220240, 2833638, 1866174, 3835077, 669705, 1597154, 1154067, 2212093, 317749, 3488031, 3363506, 3598838, 2808761, 3451142, 3535535, 3937125, 907483, 4099106, 1958727, 3318901, 2551208, 3087618, 2600877, 3702862, 44753, 3160552, 456566, 2367674, 1691363, 3123342, 3187852, 3760152, 1103888, 2963337, 3512868, 3825332, 1146648, 1433039, 3309183, 3492584, 207921, 3987717, 251562, 3497242, 3207164, 4065140, 3998081, 4109968, 584588, 3212329, 774474, 3481768, 2096006, 3238743, 3115602, 3803926, 66244, 309456, 640355, 2060813, 877456, 1728849, 1902807, 2306919, 289666, 4152610, 2712657, 3324726, 599498, 1425451, 1839380, 2385592, 705670, 3056467, 2670990, 2847010, 1188781, 2812793, 1769251, 3789434, 1898743, 2446962, 2867004, 3715274, 2354821, 3601552, 3140000, 3578421, 140339, 598398, 606801, 1294404, 1806336, 1986146, 2500515, 3164517, 1599048, 2800323, 3361171, 3678605, 1606340, 1901611, 2081741, 2494676, 821973, 3172246, 1760974, 3682564, 1307586, 1596950, 1339018, 1768126, 1033573, 2310148, 1821481, 2445292, 1948298, 2221343, 2225320, 3313311, 160437, 1281935, 386292, 3121792, 944232, 1247064, 2646561, 2904304, 546854, 4051902, 664040, 2880916, 1721878, 2042202, 3076451, 4054925, 232459, 3321779, 389694, 2063343, 920162, 3452042, 3197977, 4166342, 452733, 4016722, 2713436, 3119993, 913404, 2140622, 1655092, 2472993 };
    OptimizedEquiValidator ov = new OptimizedEquiValidator(n, k);
    byte[] minimal = EquiUtils.getMinimalFromIndices(solution, n / (k + 1));
    boolean isValid = ov.isValidSolution(minimal, header, nonce);
    boolean isValidNative = ov.isValidSolutionNative(minimal, header, nonce);
    assertEquals(false, isValid);
    assertEquals(false, isValidNative);
}
Also used : OptimizedEquiValidator(org.aion.equihash.OptimizedEquiValidator) Test(org.junit.Test)

Example 5 with OptimizedEquiValidator

use of org.aion.equihash.OptimizedEquiValidator in project aion by aionnetwork.

the class EquihashValidatorTest method sortedIndiesTest.

// Sort solution and submit sorted array
@Test
public void sortedIndiesTest() {
    byte[] header = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    byte[] nonce = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    int n = 210;
    int k = 9;
    int[] solution = { 20355, 2545802, 907342, 1930412, 905311, 3877411, 1903231, 2689731, 506861, 2315704, 1951052, 2227153, 2777366, 3236666, 3589074, 3643676, 504683, 1356644, 1438735, 3811518, 2217209, 3942573, 3417766, 3756123, 678546, 1762659, 2764197, 4043088, 837400, 3860117, 845468, 2155675, 158339, 1624003, 296319, 2896689, 1890905, 2739467, 2400006, 2772678, 465854, 833805, 512180, 1188591, 994659, 2860954, 1118590, 1430454, 468682, 2389668, 1777223, 2936757, 482455, 2375862, 1500518, 1974003, 658874, 3347208, 1725007, 2957767, 1148912, 3836887, 2679675, 3926943, 34780, 2564574, 2390936, 2555613, 946022, 3803691, 2314033, 4106977, 1433928, 2898030, 1534277, 1818947, 2262862, 4100511, 2705431, 4040332, 270150, 3015764, 1312138, 3075144, 1080444, 2162225, 2959308, 3157745, 385118, 2198870, 2851713, 3714102, 515881, 3397675, 2382411, 2444766, 48996, 3898535, 3129497, 3693976, 95695, 2435387, 2911079, 3718581, 578995, 1981490, 1002209, 2070152, 859812, 929850, 1206926, 4153868, 203330, 2339854, 2964095, 3552937, 842873, 3698309, 2497048, 3769276, 584594, 1264798, 1933308, 3523328, 1283227, 2242647, 2190815, 3020750, 41390, 3771880, 263000, 758924, 559478, 3168011, 1303488, 3381537, 717900, 4072531, 1661229, 3319094, 1127203, 2119989, 1850536, 2099166, 121852, 2843305, 566396, 1051840, 791008, 2612111, 1570629, 2709103, 812775, 3641315, 1053858, 1492834, 2578414, 3127037, 2987191, 3276177, 183924, 1831245, 878825, 2604335, 1595819, 4145284, 1610183, 3268750, 448042, 1999222, 1006093, 2711058, 2788669, 3201236, 2905205, 4191295, 263045, 288816, 708465, 3818877, 477879, 3014614, 2424026, 3730921, 268146, 1481166, 1687705, 1851825, 1115358, 4087438, 2834812, 3655853, 142275, 2932955, 2978299, 3315362, 866230, 1167961, 1666141, 3445169, 1076566, 1877713, 2740346, 3081165, 1684805, 2848657, 1961158, 3927792, 424919, 2869909, 1390027, 2948742, 672678, 1305311, 2335716, 2408750, 1656898, 2315900, 2228009, 3897974, 2080083, 3358645, 2183017, 2474962, 227904, 3257048, 1015946, 2246708, 744733, 4046023, 1305041, 4000191, 597568, 3788490, 1629963, 3055481, 1203517, 1878102, 2311148, 3069747, 475712, 2736079, 2093117, 2709022, 1766719, 2760187, 2308251, 3000603, 1122895, 4052370, 2081446, 2580232, 1497222, 1861105, 2240286, 2531758, 30071, 2842909, 590630, 3979760, 696925, 3258522, 1514676, 3716048, 1030285, 1986957, 2226931, 2864777, 2455350, 3168779, 3066230, 3403299, 256066, 2499634, 3560516, 4094756, 1256581, 2305277, 1782337, 4079485, 426456, 2259473, 464202, 3688991, 1861389, 3444866, 2960951, 3186120, 96490, 3786348, 912465, 2189746, 3408757, 3465881, 3510320, 4162223, 371697, 1169844, 2378665, 3735875, 1591695, 1866557, 1893808, 2941633, 754250, 3548696, 1247845, 3450148, 1067081, 1578401, 1486825, 3237627, 767078, 3201793, 1632439, 2521903, 1137703, 2456425, 1407972, 2485769, 160330, 3614857, 1481210, 1578079, 1996927, 4075979, 2984588, 3931673, 743440, 1237620, 1744748, 3133823, 1673449, 2727191, 1793757, 4002209, 200923, 1287230, 1452788, 1850912, 1456000, 4019882, 1605453, 3160917, 386477, 3366002, 3231682, 3735723, 491335, 4153328, 1244051, 2764520, 177653, 2136121, 1266815, 1362612, 1486929, 4194196, 3374899, 3540741, 220240, 2833638, 1866174, 3835077, 669705, 1597154, 1154067, 2212093, 317749, 3488031, 3363506, 3598838, 2808761, 3451142, 3535535, 3937125, 907483, 4099106, 1958727, 3318901, 2551208, 3087618, 2600877, 3702862, 44753, 3160552, 456566, 2367674, 1691363, 3123342, 3187852, 3760152, 1103888, 2963337, 3512868, 3825332, 1146648, 1433039, 3309183, 3492584, 207921, 3987717, 251562, 3497242, 3207164, 4065140, 3998081, 4109968, 584588, 3212329, 774474, 3481768, 2096006, 3238743, 3115602, 3803926, 66244, 309456, 640355, 2060813, 877456, 1728849, 1902807, 2306919, 289666, 4152610, 2712657, 3324726, 599498, 1425451, 1839380, 2385592, 705670, 3056467, 2670990, 2847010, 1188781, 2812793, 1769251, 3789434, 1898743, 2446962, 2867004, 3715274, 2354821, 3601552, 3140000, 3578421, 140339, 598398, 606801, 1294404, 1806336, 1986146, 2500515, 3164517, 1599048, 2800323, 3361171, 3678605, 1606340, 1901611, 2081741, 2494676, 821973, 3172246, 1760974, 3682564, 1307586, 1596950, 1339018, 1768126, 1033573, 2310148, 1821481, 2445292, 1948298, 2221343, 2225320, 3313311, 160437, 1281935, 386292, 3121792, 944232, 1247064, 2646561, 2904304, 546854, 4051902, 664040, 2880916, 1721878, 2042202, 3076451, 4054925, 232459, 3321779, 389694, 2063343, 920162, 3452042, 3197977, 4166342, 452733, 4016722, 2713436, 3119993, 913404, 2140622, 1655092, 2472993 };
    Arrays.sort(solution);
    OptimizedEquiValidator ov = new OptimizedEquiValidator(n, k);
    byte[] minimal = EquiUtils.getMinimalFromIndices(solution, n / (k + 1));
    boolean isValid = ov.isValidSolution(minimal, header, nonce);
    boolean isValidNative = ov.isValidSolutionNative(minimal, header, nonce);
    assertEquals(false, isValid);
    assertEquals(false, isValidNative);
}
Also used : OptimizedEquiValidator(org.aion.equihash.OptimizedEquiValidator) Test(org.junit.Test)

Aggregations

OptimizedEquiValidator (org.aion.equihash.OptimizedEquiValidator)12 Test (org.junit.Test)12 EquiValidator (org.aion.equihash.EquiValidator)1 Equihash (org.aion.equihash.Equihash)1