diff --git a/soroban-env-host/observations/22/test__bls12_381__g1_msm.json b/soroban-env-host/observations/22/test__bls12_381__g1_msm.json index e80e531ad..6cf77e292 100644 --- a/soroban-env-host/observations/22/test__bls12_381__g1_msm.json +++ b/soroban-env-host/observations/22/test__bls12_381__g1_msm.json @@ -6,88 +6,88 @@ " 4 ret vec_new -> Ok(Vec(obj#3))": "cpu:1002, mem:128, objs:-/2@14339b3d", " 5 call bls12_381_g1_msm(Vec(obj#1), Vec(obj#3))": "", " 6 ret bls12_381_g1_msm -> Err(Error(Crypto, InvalidInput))": "cpu:1246", - " 7 call bytes_new_from_slice(96)": "cpu:1907", - " 8 ret bytes_new_from_slice -> Ok(Bytes(obj#5))": "cpu:2892, mem:304, objs:-/3@f987415", - " 9 call bytes_new_from_slice(96)": "cpu:3553", - " 10 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:4538, mem:480, objs:-/4@f550cb25", + " 7 call bytes_new_from_slice(96)": "cpu:2568", + " 8 ret bytes_new_from_slice -> Ok(Bytes(obj#5))": "cpu:3553, mem:304, objs:-/3@f987415", + " 9 call bytes_new_from_slice(96)": "cpu:4875", + " 10 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:5860, mem:480, objs:-/4@f550cb25", " 11 call vec_new_from_slice(2)": "", - " 12 ret vec_new_from_slice -> Ok(Vec(obj#9))": "cpu:5625, mem:576, objs:-/5@27393823", + " 12 ret vec_new_from_slice -> Ok(Vec(obj#9))": "cpu:6947, mem:576, objs:-/5@27393823", " 13 call obj_from_u256_pieces(2515383451482204963, 3798294199605637777, 9874121741094930036, 5634530503602181405)": "", - " 14 ret obj_from_u256_pieces -> Ok(U256(obj#11))": "cpu:6126, mem:640, objs:-/6@3f49b7c2", + " 14 ret obj_from_u256_pieces -> Ok(U256(obj#11))": "cpu:7448, mem:640, objs:-/6@3f49b7c2", " 15 call obj_from_u256_pieces(16161944172311556037, 9348631246554537043, 7119928359786205760, 2656543668720567255)": "", - " 16 ret obj_from_u256_pieces -> Ok(U256(obj#13))": "cpu:6627, mem:704, objs:-/7@2ed0a706", + " 16 ret obj_from_u256_pieces -> Ok(U256(obj#13))": "cpu:7949, mem:704, objs:-/7@2ed0a706", " 17 call obj_from_u256_pieces(9580499452994475139, 12513764331848801915, 17507952593492800906, 8551509165293236575)": "", - " 18 ret obj_from_u256_pieces -> Ok(U256(obj#15))": "cpu:7128, mem:768, objs:-/8@43230a4b", + " 18 ret obj_from_u256_pieces -> Ok(U256(obj#15))": "cpu:8450, mem:768, objs:-/8@43230a4b", " 19 call vec_new_from_slice(3)": "", - " 20 ret vec_new_from_slice -> Ok(Vec(obj#17))": "cpu:8278, mem:872, objs:-/9@ac0e3b8c", + " 20 ret vec_new_from_slice -> Ok(Vec(obj#17))": "cpu:9600, mem:872, objs:-/9@ac0e3b8c", " 21 call bls12_381_g1_msm(Vec(obj#9), Vec(obj#17))": "", - " 22 ret bls12_381_g1_msm -> Err(Error(Crypto, InvalidInput))": "cpu:8522", - " 23 call vec_new_from_slice(3)": "cpu:17750, mem:1576, objs:-/13@561be3e7", - " 24 ret vec_new_from_slice -> Ok(Vec(obj#27))": "cpu:18900, mem:1680, objs:-/14@c49c6ff2", + " 22 ret bls12_381_g1_msm -> Err(Error(Crypto, InvalidInput))": "cpu:9844", + " 23 call vec_new_from_slice(3)": "cpu:19072, mem:1576, objs:-/13@561be3e7", + " 24 ret vec_new_from_slice -> Ok(Vec(obj#27))": "cpu:20222, mem:1680, objs:-/14@c49c6ff2", " 25 call obj_from_u256_pieces(11943197420912477102, 14634913559439210090, 15499375484791752188, 12925620935896195067)": "", - " 26 ret obj_from_u256_pieces -> Ok(U256(obj#29))": "cpu:19401, mem:1744, objs:-/15@3da47540", + " 26 ret obj_from_u256_pieces -> Ok(U256(obj#29))": "cpu:20723, mem:1744, objs:-/15@3da47540", " 27 call obj_from_u256_pieces(5622195026378228418, 9560417407481221846, 8127851712333271140, 4557073498745857109)": "", - " 28 ret obj_from_u256_pieces -> Ok(U256(obj#31))": "cpu:19902, mem:1808, objs:-/16@d07ec2c0", + " 28 ret obj_from_u256_pieces -> Ok(U256(obj#31))": "cpu:21224, mem:1808, objs:-/16@d07ec2c0", " 29 call obj_from_u256_pieces(12072680829433668232, 2892971212195715449, 599041459787463398, 17399677212821182399)": "", - " 30 ret obj_from_u256_pieces -> Ok(U256(obj#33))": "cpu:20403, mem:1872, objs:-/17@2d23aeeb", + " 30 ret obj_from_u256_pieces -> Ok(U256(obj#33))": "cpu:21725, mem:1872, objs:-/17@2d23aeeb", " 31 call vec_new_from_slice(3)": "", - " 32 ret vec_new_from_slice -> Ok(Vec(obj#35))": "cpu:21553, mem:1976, objs:-/18@9ffeec8c", + " 32 ret vec_new_from_slice -> Ok(Vec(obj#35))": "cpu:22875, mem:1976, objs:-/18@9ffeec8c", " 33 call bls12_381_g1_msm(Vec(obj#27), Vec(obj#35))": "", - " 34 call vec_len(Vec(obj#27))": "cpu:21797", - " 35 ret vec_len -> Ok(U32(3))": "cpu:21919", - " 36 call vec_len(Vec(obj#35))": "cpu:1491400, mem:2280", - " 37 ret vec_len -> Ok(U32(3))": "cpu:1491522", - " 38 ret bls12_381_g1_msm -> Err(Error(Crypto, InvalidInput))": "cpu:1498194, mem:2392", - " 39 call vec_new_from_slice(3)": "cpu:1500501, mem:2568, objs:-/19@42952458", - " 40 ret vec_new_from_slice -> Ok(Vec(obj#39))": "cpu:1501651, mem:2672, objs:-/20@a0bd3ff", + " 34 call vec_len(Vec(obj#27))": "cpu:23119", + " 35 ret vec_len -> Ok(U32(3))": "cpu:23241", + " 36 call vec_len(Vec(obj#35))": "cpu:1492722, mem:2280", + " 37 ret vec_len -> Ok(U32(3))": "cpu:1492844", + " 38 ret bls12_381_g1_msm -> Err(Error(Crypto, InvalidInput))": "cpu:1499516, mem:2392", + " 39 call vec_new_from_slice(3)": "cpu:1501823, mem:2568, objs:-/19@42952458", + " 40 ret vec_new_from_slice -> Ok(Vec(obj#39))": "cpu:1502973, mem:2672, objs:-/20@a0bd3ff", " 41 call obj_from_u256_pieces(9030446305465662626, 6854247188031249140, 3026823929057343686, 5018424221301027056)": "", - " 42 ret obj_from_u256_pieces -> Ok(U256(obj#41))": "cpu:1502152, mem:2736, objs:-/21@5d27dd7c", + " 42 ret obj_from_u256_pieces -> Ok(U256(obj#41))": "cpu:1503474, mem:2736, objs:-/21@5d27dd7c", " 43 call obj_from_u256_pieces(17540322581155608940, 9042723259083353182, 9336846948556567215, 15266620357577816939)": "", - " 44 ret obj_from_u256_pieces -> Ok(U256(obj#43))": "cpu:1502653, mem:2800, objs:-/22@32305aea", + " 44 ret obj_from_u256_pieces -> Ok(U256(obj#43))": "cpu:1503975, mem:2800, objs:-/22@32305aea", " 45 call obj_from_u256_pieces(2273584195287690476, 203274327658109228, 545101579437905274, 9593152778203258958)": "", - " 46 ret obj_from_u256_pieces -> Ok(U256(obj#45))": "cpu:1503154, mem:2864, objs:-/23@d5672c27", + " 46 ret obj_from_u256_pieces -> Ok(U256(obj#45))": "cpu:1504476, mem:2864, objs:-/23@d5672c27", " 47 call vec_new_from_slice(3)": "", - " 48 ret vec_new_from_slice -> Ok(Vec(obj#47))": "cpu:1504304, mem:2968, objs:-/24@f299ae2e", + " 48 ret vec_new_from_slice -> Ok(Vec(obj#47))": "cpu:1505626, mem:2968, objs:-/24@f299ae2e", " 49 call bls12_381_g1_msm(Vec(obj#39), Vec(obj#47))": "", - " 50 call vec_len(Vec(obj#39))": "cpu:1504548", - " 51 ret vec_len -> Ok(U32(3))": "cpu:1504670", - " 52 call vec_len(Vec(obj#47))": "cpu:3708626, mem:3272", - " 53 ret vec_len -> Ok(U32(3))": "cpu:3708748", - " 54 ret bls12_381_g1_msm -> Ok(Bytes(obj#49))": "cpu:8496472, mem:121366, objs:-/25@e3c1a53", - " 55 call obj_cmp(Bytes(obj#49), Bytes(obj#51))": "cpu:8498779, mem:121542, objs:-/26@f6f4e327", - " 56 ret obj_cmp -> Ok(0)": "cpu:8499079", - " 57 call bytes_new_from_slice(96)": "cpu:8499740", - " 58 ret bytes_new_from_slice -> Ok(Bytes(obj#53))": "cpu:8500725, mem:121718, objs:-/27@de36fc43", - " 59 call bytes_new_from_slice(96)": "cpu:8501386", - " 60 ret bytes_new_from_slice -> Ok(Bytes(obj#55))": "cpu:8502371, mem:121894, objs:-/28@d5575135", - " 61 call bytes_new_from_slice(96)": "cpu:8503032", - " 62 ret bytes_new_from_slice -> Ok(Bytes(obj#57))": "cpu:8504017, mem:122070, objs:-/29@75b6bfd6", + " 50 call vec_len(Vec(obj#39))": "cpu:1505870", + " 51 ret vec_len -> Ok(U32(3))": "cpu:1505992", + " 52 call vec_len(Vec(obj#47))": "cpu:3709948, mem:3272", + " 53 ret vec_len -> Ok(U32(3))": "cpu:3710070", + " 54 ret bls12_381_g1_msm -> Ok(Bytes(obj#49))": "cpu:8497794, mem:121366, objs:-/25@e3c1a53", + " 55 call obj_cmp(Bytes(obj#49), Bytes(obj#51))": "cpu:8500101, mem:121542, objs:-/26@f6f4e327", + " 56 ret obj_cmp -> Ok(0)": "cpu:8500401", + " 57 call bytes_new_from_slice(96)": "cpu:8501723", + " 58 ret bytes_new_from_slice -> Ok(Bytes(obj#53))": "cpu:8502708, mem:121718, objs:-/27@de36fc43", + " 59 call bytes_new_from_slice(96)": "cpu:8504030", + " 60 ret bytes_new_from_slice -> Ok(Bytes(obj#55))": "cpu:8505015, mem:121894, objs:-/28@d5575135", + " 61 call bytes_new_from_slice(96)": "cpu:8506337", + " 62 ret bytes_new_from_slice -> Ok(Bytes(obj#57))": "cpu:8507322, mem:122070, objs:-/29@75b6bfd6", " 63 call vec_new_from_slice(3)": "", - " 64 ret vec_new_from_slice -> Ok(Vec(obj#59))": "cpu:8505167, mem:122174, objs:-/30@a0da8ba2", + " 64 ret vec_new_from_slice -> Ok(Vec(obj#59))": "cpu:8508472, mem:122174, objs:-/30@a0da8ba2", " 65 call vec_new_from_slice(3)": "", - " 66 ret vec_new_from_slice -> Ok(Vec(obj#61))": "cpu:8506134, mem:122278, objs:-/31@3969541b", + " 66 ret vec_new_from_slice -> Ok(Vec(obj#61))": "cpu:8509439, mem:122278, objs:-/31@3969541b", " 67 call bls12_381_g1_msm(Vec(obj#59), Vec(obj#61))": "", - " 68 call vec_len(Vec(obj#59))": "cpu:8506378", - " 69 ret vec_len -> Ok(U32(3))": "cpu:8506500", - " 70 call vec_len(Vec(obj#61))": "cpu:10710456, mem:122582", - " 71 ret vec_len -> Ok(U32(3))": "cpu:10710578", - " 72 ret bls12_381_g1_msm -> Ok(Bytes(obj#63))": "cpu:15498119, mem:240676, objs:-/32@4cf72b63", - " 73 call obj_cmp(Bytes(obj#63), Bytes(obj#65))": "cpu:15500426, mem:240852, objs:-/33@2b1e328c", - " 74 ret obj_cmp -> Ok(0)": "cpu:15500726", - " 75 call obj_cmp(Bytes(obj#67), Bytes(obj#69))": "cpu:15505340, mem:241204, objs:-/35@c5e3864a", - " 76 ret obj_cmp -> Ok(-1)": "cpu:15505640", - " 77 call vec_new_from_slice(2)": "cpu:16242422, mem:241380, objs:-/36@48960b91", - " 78 ret vec_new_from_slice -> Ok(Vec(obj#73))": "cpu:16243509, mem:241476, objs:-/37@9fba2a30", + " 68 call vec_len(Vec(obj#59))": "cpu:8509683", + " 69 ret vec_len -> Ok(U32(3))": "cpu:8509805", + " 70 call vec_len(Vec(obj#61))": "cpu:10713761, mem:122582", + " 71 ret vec_len -> Ok(U32(3))": "cpu:10713883", + " 72 ret bls12_381_g1_msm -> Ok(Bytes(obj#63))": "cpu:15501424, mem:240676, objs:-/32@4cf72b63", + " 73 call obj_cmp(Bytes(obj#63), Bytes(obj#65))": "cpu:15503731, mem:240852, objs:-/33@2b1e328c", + " 74 ret obj_cmp -> Ok(0)": "cpu:15504031", + " 75 call obj_cmp(Bytes(obj#67), Bytes(obj#69))": "cpu:15508645, mem:241204, objs:-/35@c5e3864a", + " 76 ret obj_cmp -> Ok(-1)": "cpu:15508945", + " 77 call vec_new_from_slice(2)": "cpu:16245727, mem:241380, objs:-/36@48960b91", + " 78 ret vec_new_from_slice -> Ok(Vec(obj#73))": "cpu:16246814, mem:241476, objs:-/37@9fba2a30", " 79 call vec_new_from_slice(2)": "", - " 80 ret vec_new_from_slice -> Ok(Vec(obj#75))": "cpu:16244474, mem:241572, objs:-/38@417ebf06", + " 80 ret vec_new_from_slice -> Ok(Vec(obj#75))": "cpu:16247779, mem:241572, objs:-/38@417ebf06", " 81 call bls12_381_g1_msm(Vec(obj#73), Vec(obj#75))": "", - " 82 call vec_len(Vec(obj#73))": "cpu:16244718", - " 83 ret vec_len -> Ok(U32(2))": "cpu:16244840", - " 84 call vec_len(Vec(obj#75))": "cpu:17714309, mem:241780", - " 85 ret vec_len -> Ok(U32(2))": "cpu:17714431", - " 86 ret bls12_381_g1_msm -> Ok(Bytes(obj#77))": "cpu:21746867, mem:357071, objs:-/39@d2932e3e", - " 87 call obj_cmp(Bytes(obj#77), Bytes(obj#79))": "cpu:21749174, mem:357247, objs:-/40@3b58e936", - " 88 ret obj_cmp -> Ok(0)": "cpu:21749474", + " 82 call vec_len(Vec(obj#73))": "cpu:16248023", + " 83 ret vec_len -> Ok(U32(2))": "cpu:16248145", + " 84 call vec_len(Vec(obj#75))": "cpu:17717614, mem:241780", + " 85 ret vec_len -> Ok(U32(2))": "cpu:17717736", + " 86 ret bls12_381_g1_msm -> Ok(Bytes(obj#77))": "cpu:21750172, mem:357071, objs:-/39@d2932e3e", + " 87 call obj_cmp(Bytes(obj#77), Bytes(obj#79))": "cpu:21752479, mem:357247, objs:-/40@3b58e936", + " 88 ret obj_cmp -> Ok(0)": "cpu:21752779", " 89 call obj_from_u256_pieces(2137869300824195577, 2408943964792666977, 4119820914549582912, 10689500621133072587)": "cpu:9228, mem:704, objs:-/44@bdf24bea", " 90 ret obj_from_u256_pieces -> Ok(U256(obj#89))": "cpu:9729, mem:768, objs:-/45@ff9db193", " 91 call obj_from_u256_pieces(1962485755387024656, 9106496787558144827, 9789057793268231909, 16221084701331329973)": "", @@ -226,137 +226,137 @@ " 224 ret bls12_381_g1_msm -> Ok(Bytes(obj#161))": "cpu:93340649, mem:1337691, objs:-/81@9f62a7d5", " 225 call obj_cmp(Bytes(obj#161), Bytes(obj#101))": "", " 226 ret obj_cmp -> Ok(0)": "cpu:93340949", - " 227 call bytes_new_from_slice(96)": "cpu:661, mem:0", - " 228 ret bytes_new_from_slice -> Ok(Bytes(obj#163))": "cpu:1646, mem:176, objs:-/82@dd48ce00", - " 229 call bytes_new_from_slice(96)": "cpu:2307", - " 230 ret bytes_new_from_slice -> Ok(Bytes(obj#165))": "cpu:3292, mem:352, objs:-/83@2ba0a36c", - " 231 call bytes_new_from_slice(96)": "cpu:3953", - " 232 ret bytes_new_from_slice -> Ok(Bytes(obj#167))": "cpu:4938, mem:528, objs:-/84@a00db887", - " 233 call bytes_new_from_slice(96)": "cpu:5599", - " 234 ret bytes_new_from_slice -> Ok(Bytes(obj#169))": "cpu:6584, mem:704, objs:-/85@2ff3a0e7", - " 235 call bytes_new_from_slice(96)": "cpu:7245", - " 236 ret bytes_new_from_slice -> Ok(Bytes(obj#171))": "cpu:8230, mem:880, objs:-/86@67a727f9", - " 237 call bytes_new_from_slice(96)": "cpu:8891", - " 238 ret bytes_new_from_slice -> Ok(Bytes(obj#173))": "cpu:9876, mem:1056, objs:-/87@928f7064", - " 239 call bytes_new_from_slice(96)": "cpu:10537", - " 240 ret bytes_new_from_slice -> Ok(Bytes(obj#175))": "cpu:11522, mem:1232, objs:-/88@8e6f6128", - " 241 call bytes_new_from_slice(96)": "cpu:12183", - " 242 ret bytes_new_from_slice -> Ok(Bytes(obj#177))": "cpu:13168, mem:1408, objs:-/89@8b355a07", - " 243 call bytes_new_from_slice(96)": "cpu:13829", - " 244 ret bytes_new_from_slice -> Ok(Bytes(obj#179))": "cpu:14814, mem:1584, objs:-/90@2bebefc3", - " 245 call bytes_new_from_slice(96)": "cpu:15475", - " 246 ret bytes_new_from_slice -> Ok(Bytes(obj#181))": "cpu:16460, mem:1760, objs:-/91@87d223bb", + " 227 call bytes_new_from_slice(96)": "cpu:1322, mem:0", + " 228 ret bytes_new_from_slice -> Ok(Bytes(obj#163))": "cpu:2307, mem:176, objs:-/82@dd48ce00", + " 229 call bytes_new_from_slice(96)": "cpu:3629", + " 230 ret bytes_new_from_slice -> Ok(Bytes(obj#165))": "cpu:4614, mem:352, objs:-/83@2ba0a36c", + " 231 call bytes_new_from_slice(96)": "cpu:5936", + " 232 ret bytes_new_from_slice -> Ok(Bytes(obj#167))": "cpu:6921, mem:528, objs:-/84@a00db887", + " 233 call bytes_new_from_slice(96)": "cpu:8243", + " 234 ret bytes_new_from_slice -> Ok(Bytes(obj#169))": "cpu:9228, mem:704, objs:-/85@2ff3a0e7", + " 235 call bytes_new_from_slice(96)": "cpu:10550", + " 236 ret bytes_new_from_slice -> Ok(Bytes(obj#171))": "cpu:11535, mem:880, objs:-/86@67a727f9", + " 237 call bytes_new_from_slice(96)": "cpu:12857", + " 238 ret bytes_new_from_slice -> Ok(Bytes(obj#173))": "cpu:13842, mem:1056, objs:-/87@928f7064", + " 239 call bytes_new_from_slice(96)": "cpu:15164", + " 240 ret bytes_new_from_slice -> Ok(Bytes(obj#175))": "cpu:16149, mem:1232, objs:-/88@8e6f6128", + " 241 call bytes_new_from_slice(96)": "cpu:17471", + " 242 ret bytes_new_from_slice -> Ok(Bytes(obj#177))": "cpu:18456, mem:1408, objs:-/89@8b355a07", + " 243 call bytes_new_from_slice(96)": "cpu:19778", + " 244 ret bytes_new_from_slice -> Ok(Bytes(obj#179))": "cpu:20763, mem:1584, objs:-/90@2bebefc3", + " 245 call bytes_new_from_slice(96)": "cpu:22085", + " 246 ret bytes_new_from_slice -> Ok(Bytes(obj#181))": "cpu:23070, mem:1760, objs:-/91@87d223bb", " 247 call vec_new_from_slice(10)": "", - " 248 ret vec_new_from_slice -> Ok(Vec(obj#183))": "cpu:18051, mem:1920, objs:-/92@e05d7d45", + " 248 ret vec_new_from_slice -> Ok(Vec(obj#183))": "cpu:24661, mem:1920, objs:-/92@e05d7d45", " 249 call obj_from_u256_pieces(17618770950827998744, 14662068724577735075, 2249062990298394979, 9977923089826089615)": "", - " 250 ret obj_from_u256_pieces -> Ok(U256(obj#185))": "cpu:18552, mem:1984, objs:-/93@e4abda0a", + " 250 ret obj_from_u256_pieces -> Ok(U256(obj#185))": "cpu:25162, mem:1984, objs:-/93@e4abda0a", " 251 call obj_from_u256_pieces(2821194631792961874, 16547277464900892467, 14819559542962736549, 17981056101655367365)": "", - " 252 ret obj_from_u256_pieces -> Ok(U256(obj#187))": "cpu:19053, mem:2048, objs:-/94@59894c0f", + " 252 ret obj_from_u256_pieces -> Ok(U256(obj#187))": "cpu:25663, mem:2048, objs:-/94@59894c0f", " 253 call obj_from_u256_pieces(14823680325444367514, 16057910356200631686, 11653412393475167983, 17971148540471083046)": "", - " 254 ret obj_from_u256_pieces -> Ok(U256(obj#189))": "cpu:19554, mem:2112, objs:-/95@f611f183", + " 254 ret obj_from_u256_pieces -> Ok(U256(obj#189))": "cpu:26164, mem:2112, objs:-/95@f611f183", " 255 call obj_from_u256_pieces(16502273625602787483, 2713688267813643125, 15061415354752276271, 16690818686241479208)": "", - " 256 ret obj_from_u256_pieces -> Ok(U256(obj#191))": "cpu:20055, mem:2176, objs:-/96@b6efa1b5", + " 256 ret obj_from_u256_pieces -> Ok(U256(obj#191))": "cpu:26665, mem:2176, objs:-/96@b6efa1b5", " 257 call obj_from_u256_pieces(7027192125185647877, 17045944964573428771, 10144290202347477085, 10705035438189734679)": "", - " 258 ret obj_from_u256_pieces -> Ok(U256(obj#193))": "cpu:20556, mem:2240, objs:-/97@f626d632", + " 258 ret obj_from_u256_pieces -> Ok(U256(obj#193))": "cpu:27166, mem:2240, objs:-/97@f626d632", " 259 call obj_from_u256_pieces(14552017996338670628, 17384320552016825872, 12623460464266321339, 2351693706725345962)": "", - " 260 ret obj_from_u256_pieces -> Ok(U256(obj#195))": "cpu:21057, mem:2304, objs:-/98@dc0fd6a8", + " 260 ret obj_from_u256_pieces -> Ok(U256(obj#195))": "cpu:27667, mem:2304, objs:-/98@dc0fd6a8", " 261 call obj_from_u256_pieces(4037855643097226315, 3588748593401323528, 18145554024939280631, 6805129555195258487)": "", - " 262 ret obj_from_u256_pieces -> Ok(U256(obj#197))": "cpu:21558, mem:2368, objs:-/99@3a43cf0d", + " 262 ret obj_from_u256_pieces -> Ok(U256(obj#197))": "cpu:28168, mem:2368, objs:-/99@3a43cf0d", " 263 call obj_from_u256_pieces(10690484396013942008, 3220507769215303921, 6575779185716732641, 1735816512470570891)": "", - " 264 ret obj_from_u256_pieces -> Ok(U256(obj#199))": "cpu:22059, mem:2432, objs:-/100@72aa4d1", + " 264 ret obj_from_u256_pieces -> Ok(U256(obj#199))": "cpu:28669, mem:2432, objs:-/100@72aa4d1", " 265 call obj_from_u256_pieces(854729243539327218, 14181304886955281704, 12059208175304010597, 16702944845996181439)": "", - " 266 ret obj_from_u256_pieces -> Ok(U256(obj#201))": "cpu:22560, mem:2496, objs:-/101@898aec71", + " 266 ret obj_from_u256_pieces -> Ok(U256(obj#201))": "cpu:29170, mem:2496, objs:-/101@898aec71", " 267 call obj_from_u256_pieces(11497158191995684079, 43326291776979156, 14533160951240524555, 12852174102015084654)": "", - " 268 ret obj_from_u256_pieces -> Ok(U256(obj#203))": "cpu:23061, mem:2560, objs:-/102@a0762125", + " 268 ret obj_from_u256_pieces -> Ok(U256(obj#203))": "cpu:29671, mem:2560, objs:-/102@a0762125", " 269 call vec_new_from_slice(10)": "", - " 270 ret vec_new_from_slice -> Ok(Vec(obj#205))": "cpu:24652, mem:2720, objs:-/103@d1b8c868", + " 270 ret vec_new_from_slice -> Ok(Vec(obj#205))": "cpu:31262, mem:2720, objs:-/103@d1b8c868", " 271 call bls12_381_g1_msm(Vec(obj#183), Vec(obj#205))": "", - " 272 call vec_len(Vec(obj#183))": "cpu:24896", - " 273 ret vec_len -> Ok(U32(10))": "cpu:25018", - " 274 call vec_len(Vec(obj#205))": "cpu:7370383, mem:3696", - " 275 ret vec_len -> Ok(U32(10))": "cpu:7370505", - " 276 ret bls12_381_g1_msm -> Ok(Bytes(obj#207))": "cpu:17444390, mem:141410, objs:-/104@5e3fb337", - " 277 call vec_get(Vec(obj#183), U32(0))": "cpu:17446697, mem:141586, objs:-/105@cc1ad99a", - " 278 ret vec_get -> Ok(Bytes(obj#163))": "cpu:17446923", + " 272 call vec_len(Vec(obj#183))": "cpu:31506", + " 273 ret vec_len -> Ok(U32(10))": "cpu:31628", + " 274 call vec_len(Vec(obj#205))": "cpu:7376993, mem:3696", + " 275 ret vec_len -> Ok(U32(10))": "cpu:7377115", + " 276 ret bls12_381_g1_msm -> Ok(Bytes(obj#207))": "cpu:17451000, mem:141410, objs:-/104@5e3fb337", + " 277 call vec_get(Vec(obj#183), U32(0))": "cpu:17453307, mem:141586, objs:-/105@cc1ad99a", + " 278 ret vec_get -> Ok(Bytes(obj#163))": "cpu:17453533", " 279 call vec_get(Vec(obj#205), U32(0))": "", - " 280 ret vec_get -> Ok(U256(obj#185))": "cpu:17447149", + " 280 ret vec_get -> Ok(U256(obj#185))": "cpu:17453759", " 281 call bls12_381_g1_mul(Bytes(obj#163), U256(obj#185))": "", - " 282 ret bls12_381_g1_mul -> Ok(Bytes(obj#211))": "cpu:20737796, mem:141762, objs:-/106@4d87b466", + " 282 ret bls12_381_g1_mul -> Ok(Bytes(obj#211))": "cpu:20744406, mem:141762, objs:-/106@4d87b466", " 283 call bls12_381_g1_add(Bytes(obj#209), Bytes(obj#211))": "", - " 284 ret bls12_381_g1_add -> Ok(Bytes(obj#213))": "cpu:20848547, mem:141938, objs:-/107@a668862", + " 284 ret bls12_381_g1_add -> Ok(Bytes(obj#213))": "cpu:20855157, mem:141938, objs:-/107@a668862", " 285 call vec_get(Vec(obj#183), U32(1))": "", - " 286 ret vec_get -> Ok(Bytes(obj#165))": "cpu:20848773", + " 286 ret vec_get -> Ok(Bytes(obj#165))": "cpu:20855383", " 287 call vec_get(Vec(obj#205), U32(1))": "", - " 288 ret vec_get -> Ok(U256(obj#187))": "cpu:20848999", + " 288 ret vec_get -> Ok(U256(obj#187))": "cpu:20855609", " 289 call bls12_381_g1_mul(Bytes(obj#165), U256(obj#187))": "", - " 290 ret bls12_381_g1_mul -> Ok(Bytes(obj#215))": "cpu:24139646, mem:142114, objs:-/108@26939bdb", + " 290 ret bls12_381_g1_mul -> Ok(Bytes(obj#215))": "cpu:24146256, mem:142114, objs:-/108@26939bdb", " 291 call bls12_381_g1_add(Bytes(obj#213), Bytes(obj#215))": "", - " 292 ret bls12_381_g1_add -> Ok(Bytes(obj#217))": "cpu:24250397, mem:142290, objs:-/109@afa942f2", + " 292 ret bls12_381_g1_add -> Ok(Bytes(obj#217))": "cpu:24257007, mem:142290, objs:-/109@afa942f2", " 293 call vec_get(Vec(obj#183), U32(2))": "", - " 294 ret vec_get -> Ok(Bytes(obj#167))": "cpu:24250623", + " 294 ret vec_get -> Ok(Bytes(obj#167))": "cpu:24257233", " 295 call vec_get(Vec(obj#205), U32(2))": "", - " 296 ret vec_get -> Ok(U256(obj#189))": "cpu:24250849", + " 296 ret vec_get -> Ok(U256(obj#189))": "cpu:24257459", " 297 call bls12_381_g1_mul(Bytes(obj#167), U256(obj#189))": "", - " 298 ret bls12_381_g1_mul -> Ok(Bytes(obj#219))": "cpu:27541496, mem:142466, objs:-/110@80ebabcb", + " 298 ret bls12_381_g1_mul -> Ok(Bytes(obj#219))": "cpu:27548106, mem:142466, objs:-/110@80ebabcb", " 299 call bls12_381_g1_add(Bytes(obj#217), Bytes(obj#219))": "", - " 300 ret bls12_381_g1_add -> Ok(Bytes(obj#221))": "cpu:27652247, mem:142642, objs:-/111@c5129985", + " 300 ret bls12_381_g1_add -> Ok(Bytes(obj#221))": "cpu:27658857, mem:142642, objs:-/111@c5129985", " 301 call vec_get(Vec(obj#183), U32(3))": "", - " 302 ret vec_get -> Ok(Bytes(obj#169))": "cpu:27652473", + " 302 ret vec_get -> Ok(Bytes(obj#169))": "cpu:27659083", " 303 call vec_get(Vec(obj#205), U32(3))": "", - " 304 ret vec_get -> Ok(U256(obj#191))": "cpu:27652699", + " 304 ret vec_get -> Ok(U256(obj#191))": "cpu:27659309", " 305 call bls12_381_g1_mul(Bytes(obj#169), U256(obj#191))": "", - " 306 ret bls12_381_g1_mul -> Ok(Bytes(obj#223))": "cpu:30943346, mem:142818, objs:-/112@185b22ec", + " 306 ret bls12_381_g1_mul -> Ok(Bytes(obj#223))": "cpu:30949956, mem:142818, objs:-/112@185b22ec", " 307 call bls12_381_g1_add(Bytes(obj#221), Bytes(obj#223))": "", - " 308 ret bls12_381_g1_add -> Ok(Bytes(obj#225))": "cpu:31054097, mem:142994, objs:-/113@c4f97300", + " 308 ret bls12_381_g1_add -> Ok(Bytes(obj#225))": "cpu:31060707, mem:142994, objs:-/113@c4f97300", " 309 call vec_get(Vec(obj#183), U32(4))": "", - " 310 ret vec_get -> Ok(Bytes(obj#171))": "cpu:31054323", + " 310 ret vec_get -> Ok(Bytes(obj#171))": "cpu:31060933", " 311 call vec_get(Vec(obj#205), U32(4))": "", - " 312 ret vec_get -> Ok(U256(obj#193))": "cpu:31054549", + " 312 ret vec_get -> Ok(U256(obj#193))": "cpu:31061159", " 313 call bls12_381_g1_mul(Bytes(obj#171), U256(obj#193))": "", - " 314 ret bls12_381_g1_mul -> Ok(Bytes(obj#227))": "cpu:34345196, mem:143170, objs:-/114@5dcb2245", + " 314 ret bls12_381_g1_mul -> Ok(Bytes(obj#227))": "cpu:34351806, mem:143170, objs:-/114@5dcb2245", " 315 call bls12_381_g1_add(Bytes(obj#225), Bytes(obj#227))": "", - " 316 ret bls12_381_g1_add -> Ok(Bytes(obj#229))": "cpu:34455947, mem:143346, objs:-/115@9b8b7719", + " 316 ret bls12_381_g1_add -> Ok(Bytes(obj#229))": "cpu:34462557, mem:143346, objs:-/115@9b8b7719", " 317 call vec_get(Vec(obj#183), U32(5))": "", - " 318 ret vec_get -> Ok(Bytes(obj#173))": "cpu:34456173", + " 318 ret vec_get -> Ok(Bytes(obj#173))": "cpu:34462783", " 319 call vec_get(Vec(obj#205), U32(5))": "", - " 320 ret vec_get -> Ok(U256(obj#195))": "cpu:34456399", + " 320 ret vec_get -> Ok(U256(obj#195))": "cpu:34463009", " 321 call bls12_381_g1_mul(Bytes(obj#173), U256(obj#195))": "", - " 322 ret bls12_381_g1_mul -> Ok(Bytes(obj#231))": "cpu:37747046, mem:143522, objs:-/116@7e32132b", + " 322 ret bls12_381_g1_mul -> Ok(Bytes(obj#231))": "cpu:37753656, mem:143522, objs:-/116@7e32132b", " 323 call bls12_381_g1_add(Bytes(obj#229), Bytes(obj#231))": "", - " 324 ret bls12_381_g1_add -> Ok(Bytes(obj#233))": "cpu:37857797, mem:143698, objs:-/117@820927b5", + " 324 ret bls12_381_g1_add -> Ok(Bytes(obj#233))": "cpu:37864407, mem:143698, objs:-/117@820927b5", " 325 call vec_get(Vec(obj#183), U32(6))": "", - " 326 ret vec_get -> Ok(Bytes(obj#175))": "cpu:37858023", + " 326 ret vec_get -> Ok(Bytes(obj#175))": "cpu:37864633", " 327 call vec_get(Vec(obj#205), U32(6))": "", - " 328 ret vec_get -> Ok(U256(obj#197))": "cpu:37858249", + " 328 ret vec_get -> Ok(U256(obj#197))": "cpu:37864859", " 329 call bls12_381_g1_mul(Bytes(obj#175), U256(obj#197))": "", - " 330 ret bls12_381_g1_mul -> Ok(Bytes(obj#235))": "cpu:41148896, mem:143874, objs:-/118@734cedc3", + " 330 ret bls12_381_g1_mul -> Ok(Bytes(obj#235))": "cpu:41155506, mem:143874, objs:-/118@734cedc3", " 331 call bls12_381_g1_add(Bytes(obj#233), Bytes(obj#235))": "", - " 332 ret bls12_381_g1_add -> Ok(Bytes(obj#237))": "cpu:41259647, mem:144050, objs:-/119@9f782901", + " 332 ret bls12_381_g1_add -> Ok(Bytes(obj#237))": "cpu:41266257, mem:144050, objs:-/119@9f782901", " 333 call vec_get(Vec(obj#183), U32(7))": "", - " 334 ret vec_get -> Ok(Bytes(obj#177))": "cpu:41259873", + " 334 ret vec_get -> Ok(Bytes(obj#177))": "cpu:41266483", " 335 call vec_get(Vec(obj#205), U32(7))": "", - " 336 ret vec_get -> Ok(U256(obj#199))": "cpu:41260099", + " 336 ret vec_get -> Ok(U256(obj#199))": "cpu:41266709", " 337 call bls12_381_g1_mul(Bytes(obj#177), U256(obj#199))": "", - " 338 ret bls12_381_g1_mul -> Ok(Bytes(obj#239))": "cpu:44550746, mem:144226, objs:-/120@6222b65f", + " 338 ret bls12_381_g1_mul -> Ok(Bytes(obj#239))": "cpu:44557356, mem:144226, objs:-/120@6222b65f", " 339 call bls12_381_g1_add(Bytes(obj#237), Bytes(obj#239))": "", - " 340 ret bls12_381_g1_add -> Ok(Bytes(obj#241))": "cpu:44661497, mem:144402, objs:-/121@ec08d7b8", + " 340 ret bls12_381_g1_add -> Ok(Bytes(obj#241))": "cpu:44668107, mem:144402, objs:-/121@ec08d7b8", " 341 call vec_get(Vec(obj#183), U32(8))": "", - " 342 ret vec_get -> Ok(Bytes(obj#179))": "cpu:44661723", + " 342 ret vec_get -> Ok(Bytes(obj#179))": "cpu:44668333", " 343 call vec_get(Vec(obj#205), U32(8))": "", - " 344 ret vec_get -> Ok(U256(obj#201))": "cpu:44661949", + " 344 ret vec_get -> Ok(U256(obj#201))": "cpu:44668559", " 345 call bls12_381_g1_mul(Bytes(obj#179), U256(obj#201))": "", - " 346 ret bls12_381_g1_mul -> Ok(Bytes(obj#243))": "cpu:47952596, mem:144578, objs:-/122@ed50266c", + " 346 ret bls12_381_g1_mul -> Ok(Bytes(obj#243))": "cpu:47959206, mem:144578, objs:-/122@ed50266c", " 347 call bls12_381_g1_add(Bytes(obj#241), Bytes(obj#243))": "", - " 348 ret bls12_381_g1_add -> Ok(Bytes(obj#245))": "cpu:48063347, mem:144754, objs:-/123@c4adee2a", + " 348 ret bls12_381_g1_add -> Ok(Bytes(obj#245))": "cpu:48069957, mem:144754, objs:-/123@c4adee2a", " 349 call vec_get(Vec(obj#183), U32(9))": "", - " 350 ret vec_get -> Ok(Bytes(obj#181))": "cpu:48063573", + " 350 ret vec_get -> Ok(Bytes(obj#181))": "cpu:48070183", " 351 call vec_get(Vec(obj#205), U32(9))": "", - " 352 ret vec_get -> Ok(U256(obj#203))": "cpu:48063799", + " 352 ret vec_get -> Ok(U256(obj#203))": "cpu:48070409", " 353 call bls12_381_g1_mul(Bytes(obj#181), U256(obj#203))": "", - " 354 ret bls12_381_g1_mul -> Ok(Bytes(obj#247))": "cpu:51354446, mem:144930, objs:-/124@e5cf2285", + " 354 ret bls12_381_g1_mul -> Ok(Bytes(obj#247))": "cpu:51361056, mem:144930, objs:-/124@e5cf2285", " 355 call bls12_381_g1_add(Bytes(obj#245), Bytes(obj#247))": "", - " 356 ret bls12_381_g1_add -> Ok(Bytes(obj#249))": "cpu:51465197, mem:145106, objs:-/125@e28e8633", + " 356 ret bls12_381_g1_add -> Ok(Bytes(obj#249))": "cpu:51471807, mem:145106, objs:-/125@e28e8633", " 357 call obj_cmp(Bytes(obj#249), Bytes(obj#207))": "", - " 358 ret obj_cmp -> Ok(0)": "cpu:51465497", - " 359 end": "cpu:51465497, mem:145106, prngs:-/-, objs:-/125@e28e8633, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-" + " 358 ret obj_cmp -> Ok(0)": "cpu:51472107", + " 359 end": "cpu:51472107, mem:145106, prngs:-/-, objs:-/125@e28e8633, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-" } \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__bls12_381__g2_msm.json b/soroban-env-host/observations/22/test__bls12_381__g2_msm.json index 65bb88699..7a8c4af56 100644 --- a/soroban-env-host/observations/22/test__bls12_381__g2_msm.json +++ b/soroban-env-host/observations/22/test__bls12_381__g2_msm.json @@ -6,106 +6,106 @@ " 4 ret vec_new -> Ok(Vec(obj#3))": "cpu:1002, mem:128, objs:-/2@14339b3d", " 5 call bls12_381_g2_msm(Vec(obj#1), Vec(obj#3))": "", " 6 ret bls12_381_g2_msm -> Err(Error(Crypto, InvalidInput))": "cpu:1246", - " 7 call bytes_new_from_slice(192)": "cpu:1907", - " 8 ret bytes_new_from_slice -> Ok(Bytes(obj#5))": "cpu:2916, mem:400, objs:-/3@bd2bad33", - " 9 call bytes_new_from_slice(192)": "cpu:3577", - " 10 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:4586, mem:672, objs:-/4@84c0214b", + " 7 call bytes_new_from_slice(192)": "cpu:3890", + " 8 ret bytes_new_from_slice -> Ok(Bytes(obj#5))": "cpu:4899, mem:400, objs:-/3@bd2bad33", + " 9 call bytes_new_from_slice(192)": "cpu:7543", + " 10 ret bytes_new_from_slice -> Ok(Bytes(obj#7))": "cpu:8552, mem:672, objs:-/4@84c0214b", " 11 call vec_new_from_slice(2)": "", - " 12 ret vec_new_from_slice -> Ok(Vec(obj#9))": "cpu:5673, mem:768, objs:-/5@e2867bea", + " 12 ret vec_new_from_slice -> Ok(Vec(obj#9))": "cpu:9639, mem:768, objs:-/5@e2867bea", " 13 call obj_from_u256_pieces(11753201120659576617, 12800183645227990272, 6449591311112480650, 11530214657355711865)": "", - " 14 ret obj_from_u256_pieces -> Ok(U256(obj#11))": "cpu:6174, mem:832, objs:-/6@d2c1550a", + " 14 ret obj_from_u256_pieces -> Ok(U256(obj#11))": "cpu:10140, mem:832, objs:-/6@d2c1550a", " 15 call obj_from_u256_pieces(17867260108045272079, 6594056455511558201, 8394146189024495608, 16477234698079725300)": "", - " 16 ret obj_from_u256_pieces -> Ok(U256(obj#13))": "cpu:6675, mem:896, objs:-/7@b83c4f1d", + " 16 ret obj_from_u256_pieces -> Ok(U256(obj#13))": "cpu:10641, mem:896, objs:-/7@b83c4f1d", " 17 call obj_from_u256_pieces(5093470543443933884, 12596616304565341690, 2875592832172597214, 8474459150244119113)": "", - " 18 ret obj_from_u256_pieces -> Ok(U256(obj#15))": "cpu:7176, mem:960, objs:-/8@5b2279ba", + " 18 ret obj_from_u256_pieces -> Ok(U256(obj#15))": "cpu:11142, mem:960, objs:-/8@5b2279ba", " 19 call vec_new_from_slice(3)": "", - " 20 ret vec_new_from_slice -> Ok(Vec(obj#17))": "cpu:8326, mem:1064, objs:-/9@2c5030af", + " 20 ret vec_new_from_slice -> Ok(Vec(obj#17))": "cpu:12292, mem:1064, objs:-/9@2c5030af", " 21 call bls12_381_g2_msm(Vec(obj#9), Vec(obj#17))": "", - " 22 ret bls12_381_g2_msm -> Err(Error(Crypto, InvalidInput))": "cpu:8570", - " 23 call vec_new_from_slice(3)": "cpu:23182, mem:2152, objs:-/13@c72ec5e5", - " 24 ret vec_new_from_slice -> Ok(Vec(obj#27))": "cpu:24332, mem:2256, objs:-/14@138c972e", + " 22 ret bls12_381_g2_msm -> Err(Error(Crypto, InvalidInput))": "cpu:12536", + " 23 call vec_new_from_slice(3)": "cpu:27148, mem:2152, objs:-/13@c72ec5e5", + " 24 ret vec_new_from_slice -> Ok(Vec(obj#27))": "cpu:28298, mem:2256, objs:-/14@138c972e", " 25 call obj_from_u256_pieces(2670602178858449459, 7519702381861979968, 12131847362652268029, 15324157160071379208)": "", - " 26 ret obj_from_u256_pieces -> Ok(U256(obj#29))": "cpu:24833, mem:2320, objs:-/15@cca0974f", + " 26 ret obj_from_u256_pieces -> Ok(U256(obj#29))": "cpu:28799, mem:2320, objs:-/15@cca0974f", " 27 call obj_from_u256_pieces(14448951281277473340, 10183372082303375121, 11609568207825743232, 10582668507445555283)": "", - " 28 ret obj_from_u256_pieces -> Ok(U256(obj#31))": "cpu:25334, mem:2384, objs:-/16@338703b5", + " 28 ret obj_from_u256_pieces -> Ok(U256(obj#31))": "cpu:29300, mem:2384, objs:-/16@338703b5", " 29 call obj_from_u256_pieces(8613971480719722045, 14687201964851969652, 13467859308725023972, 5056481814551667924)": "", - " 30 ret obj_from_u256_pieces -> Ok(U256(obj#33))": "cpu:25835, mem:2448, objs:-/17@e29c96a4", + " 30 ret obj_from_u256_pieces -> Ok(U256(obj#33))": "cpu:29801, mem:2448, objs:-/17@e29c96a4", " 31 call vec_new_from_slice(3)": "", - " 32 ret vec_new_from_slice -> Ok(Vec(obj#35))": "cpu:26985, mem:2552, objs:-/18@bd3fe61d", + " 32 ret vec_new_from_slice -> Ok(Vec(obj#35))": "cpu:30951, mem:2552, objs:-/18@bd3fe61d", " 33 call bls12_381_g2_msm(Vec(obj#27), Vec(obj#35))": "", - " 34 call vec_len(Vec(obj#27))": "cpu:27229", - " 35 ret vec_len -> Ok(U32(3))": "cpu:27351", - " 36 call vec_len(Vec(obj#35))": "cpu:2163406, mem:3144", - " 37 ret vec_len -> Ok(U32(3))": "cpu:2163528", - " 38 ret bls12_381_g2_msm -> Err(Error(Crypto, InvalidInput))": "cpu:2170200, mem:3256", - " 39 call vec_new_from_slice(3)": "cpu:2173853, mem:3528, objs:-/19@fc4eae83", - " 40 ret vec_new_from_slice -> Ok(Vec(obj#39))": "cpu:2175003, mem:3632, objs:-/20@fc5a7848", + " 34 call vec_len(Vec(obj#27))": "cpu:31195", + " 35 ret vec_len -> Ok(U32(3))": "cpu:31317", + " 36 call vec_len(Vec(obj#35))": "cpu:2167372, mem:3144", + " 37 ret vec_len -> Ok(U32(3))": "cpu:2167494", + " 38 ret bls12_381_g2_msm -> Err(Error(Crypto, InvalidInput))": "cpu:2174166, mem:3256", + " 39 call vec_new_from_slice(3)": "cpu:2177819, mem:3528, objs:-/19@fc4eae83", + " 40 ret vec_new_from_slice -> Ok(Vec(obj#39))": "cpu:2178969, mem:3632, objs:-/20@fc5a7848", " 41 call obj_from_u256_pieces(10885390432521285204, 10089357480003724487, 11017657889674374380, 349979284301977343)": "", - " 42 ret obj_from_u256_pieces -> Ok(U256(obj#41))": "cpu:2175504, mem:3696, objs:-/21@c11c1e9", + " 42 ret obj_from_u256_pieces -> Ok(U256(obj#41))": "cpu:2179470, mem:3696, objs:-/21@c11c1e9", " 43 call obj_from_u256_pieces(15502034860521929120, 5197508503879521041, 10172360046471299633, 18026852881196000031)": "", - " 44 ret obj_from_u256_pieces -> Ok(U256(obj#43))": "cpu:2176005, mem:3760, objs:-/22@fbed0030", + " 44 ret obj_from_u256_pieces -> Ok(U256(obj#43))": "cpu:2179971, mem:3760, objs:-/22@fbed0030", " 45 call obj_from_u256_pieces(7434520258580032483, 1508470301556677986, 6272863840242768080, 12830499169355232182)": "", - " 46 ret obj_from_u256_pieces -> Ok(U256(obj#45))": "cpu:2176506, mem:3824, objs:-/23@7c759a0d", + " 46 ret obj_from_u256_pieces -> Ok(U256(obj#45))": "cpu:2180472, mem:3824, objs:-/23@7c759a0d", " 47 call vec_new_from_slice(3)": "", - " 48 ret vec_new_from_slice -> Ok(Vec(obj#47))": "cpu:2177656, mem:3928, objs:-/24@892a5924", + " 48 ret vec_new_from_slice -> Ok(Vec(obj#47))": "cpu:2181622, mem:3928, objs:-/24@892a5924", " 49 call bls12_381_g2_msm(Vec(obj#39), Vec(obj#47))": "", - " 50 call vec_len(Vec(obj#39))": "cpu:2177900", - " 51 ret vec_len -> Ok(U32(3))": "cpu:2178022", - " 52 call vec_len(Vec(obj#47))": "cpu:5381821, mem:4520", - " 53 ret vec_len -> Ok(U32(3))": "cpu:5381943", - " 54 ret bls12_381_g2_msm -> Ok(Bytes(obj#49))": "cpu:20786867, mem:232870, objs:-/25@b3e2fb94", - " 55 call obj_cmp(Bytes(obj#49), Bytes(obj#51))": "cpu:20790520, mem:233142, objs:-/26@36256f36", - " 56 ret obj_cmp -> Ok(0)": "cpu:20790832", - " 57 call bytes_new_from_slice(192)": "cpu:20791493", - " 58 ret bytes_new_from_slice -> Ok(Bytes(obj#53))": "cpu:20792502, mem:233414, objs:-/27@8ed979ac", - " 59 call bytes_new_from_slice(192)": "cpu:20793163", - " 60 ret bytes_new_from_slice -> Ok(Bytes(obj#55))": "cpu:20794172, mem:233686, objs:-/28@a3eb6aea", - " 61 call bytes_new_from_slice(192)": "cpu:20794833", - " 62 ret bytes_new_from_slice -> Ok(Bytes(obj#57))": "cpu:20795842, mem:233958, objs:-/29@9bc29a7f", + " 50 call vec_len(Vec(obj#39))": "cpu:2181866", + " 51 ret vec_len -> Ok(U32(3))": "cpu:2181988", + " 52 call vec_len(Vec(obj#47))": "cpu:5385787, mem:4520", + " 53 ret vec_len -> Ok(U32(3))": "cpu:5385909", + " 54 ret bls12_381_g2_msm -> Ok(Bytes(obj#49))": "cpu:20790833, mem:232870, objs:-/25@b3e2fb94", + " 55 call obj_cmp(Bytes(obj#49), Bytes(obj#51))": "cpu:20794486, mem:233142, objs:-/26@36256f36", + " 56 ret obj_cmp -> Ok(0)": "cpu:20794798", + " 57 call bytes_new_from_slice(192)": "cpu:20797442", + " 58 ret bytes_new_from_slice -> Ok(Bytes(obj#53))": "cpu:20798451, mem:233414, objs:-/27@8ed979ac", + " 59 call bytes_new_from_slice(192)": "cpu:20801095", + " 60 ret bytes_new_from_slice -> Ok(Bytes(obj#55))": "cpu:20802104, mem:233686, objs:-/28@a3eb6aea", + " 61 call bytes_new_from_slice(192)": "cpu:20804748", + " 62 ret bytes_new_from_slice -> Ok(Bytes(obj#57))": "cpu:20805757, mem:233958, objs:-/29@9bc29a7f", " 63 call vec_new_from_slice(3)": "", - " 64 ret vec_new_from_slice -> Ok(Vec(obj#59))": "cpu:20796992, mem:234062, objs:-/30@379dffd4", + " 64 ret vec_new_from_slice -> Ok(Vec(obj#59))": "cpu:20806907, mem:234062, objs:-/30@379dffd4", " 65 call vec_new_from_slice(3)": "", - " 66 ret vec_new_from_slice -> Ok(Vec(obj#61))": "cpu:20797959, mem:234166, objs:-/31@f3d911e6", + " 66 ret vec_new_from_slice -> Ok(Vec(obj#61))": "cpu:20807874, mem:234166, objs:-/31@f3d911e6", " 67 call bls12_381_g2_msm(Vec(obj#59), Vec(obj#61))": "", - " 68 call vec_len(Vec(obj#59))": "cpu:20798203", - " 69 ret vec_len -> Ok(U32(3))": "cpu:20798325", - " 70 call vec_len(Vec(obj#61))": "cpu:24002124, mem:234758", - " 71 ret vec_len -> Ok(U32(3))": "cpu:24002246", - " 72 ret bls12_381_g2_msm -> Ok(Bytes(obj#63))": "cpu:39406987, mem:463108, objs:-/32@99e86db8", - " 73 call obj_cmp(Bytes(obj#63), Bytes(obj#65))": "cpu:39410640, mem:463380, objs:-/33@d5a55acc", - " 74 ret obj_cmp -> Ok(0)": "cpu:39410952", - " 75 call obj_cmp(Bytes(obj#67), Bytes(obj#69))": "cpu:39418258, mem:463924, objs:-/35@52d12591", - " 76 ret obj_cmp -> Ok(-1)": "cpu:39418570", - " 77 call vec_new_from_slice(2)": "cpu:40489967, mem:464196, objs:-/36@f4b12971", - " 78 ret vec_new_from_slice -> Ok(Vec(obj#73))": "cpu:40491054, mem:464292, objs:-/37@43b753fc", + " 68 call vec_len(Vec(obj#59))": "cpu:20808118", + " 69 ret vec_len -> Ok(U32(3))": "cpu:20808240", + " 70 call vec_len(Vec(obj#61))": "cpu:24012039, mem:234758", + " 71 ret vec_len -> Ok(U32(3))": "cpu:24012161", + " 72 ret bls12_381_g2_msm -> Ok(Bytes(obj#63))": "cpu:39416902, mem:463108, objs:-/32@99e86db8", + " 73 call obj_cmp(Bytes(obj#63), Bytes(obj#65))": "cpu:39420555, mem:463380, objs:-/33@d5a55acc", + " 74 ret obj_cmp -> Ok(0)": "cpu:39420867", + " 75 call obj_cmp(Bytes(obj#67), Bytes(obj#69))": "cpu:39428173, mem:463924, objs:-/35@52d12591", + " 76 ret obj_cmp -> Ok(-1)": "cpu:39428485", + " 77 call vec_new_from_slice(2)": "cpu:40499882, mem:464196, objs:-/36@f4b12971", + " 78 ret vec_new_from_slice -> Ok(Vec(obj#73))": "cpu:40500969, mem:464292, objs:-/37@43b753fc", " 79 call vec_new_from_slice(2)": "", - " 80 ret vec_new_from_slice -> Ok(Vec(obj#75))": "cpu:40492019, mem:464388, objs:-/38@d88a608d", + " 80 ret vec_new_from_slice -> Ok(Vec(obj#75))": "cpu:40501934, mem:464388, objs:-/38@d88a608d", " 81 call bls12_381_g2_msm(Vec(obj#73), Vec(obj#75))": "", - " 82 call vec_len(Vec(obj#73))": "cpu:40492263", - " 83 ret vec_len -> Ok(U32(2))": "cpu:40492385", - " 84 call vec_len(Vec(obj#75))": "cpu:42628416, mem:464788", - " 85 ret vec_len -> Ok(U32(2))": "cpu:42628538", - " 86 ret bls12_381_g2_msm -> Ok(Bytes(obj#77))": "cpu:55612005, mem:690335, objs:-/39@308f505c", - " 87 call obj_cmp(Bytes(obj#77), Bytes(obj#79))": "cpu:55615658, mem:690607, objs:-/40@9dfbcd24", - " 88 ret obj_cmp -> Ok(0)": "cpu:55615970", - " 89 call obj_from_u256_pieces(576349249354864704, 6205532040440579369, 13730557568579417905, 2677733454007168321)": "cpu:55630582, mem:691695, objs:-/44@cd73d980", - " 90 ret obj_from_u256_pieces -> Ok(U256(obj#89))": "cpu:55631083, mem:691759, objs:-/45@d173b8e8", + " 82 call vec_len(Vec(obj#73))": "cpu:40502178", + " 83 ret vec_len -> Ok(U32(2))": "cpu:40502300", + " 84 call vec_len(Vec(obj#75))": "cpu:42638331, mem:464788", + " 85 ret vec_len -> Ok(U32(2))": "cpu:42638453", + " 86 ret bls12_381_g2_msm -> Ok(Bytes(obj#77))": "cpu:55621920, mem:690335, objs:-/39@308f505c", + " 87 call obj_cmp(Bytes(obj#77), Bytes(obj#79))": "cpu:55625573, mem:690607, objs:-/40@9dfbcd24", + " 88 ret obj_cmp -> Ok(0)": "cpu:55625885", + " 89 call obj_from_u256_pieces(576349249354864704, 6205532040440579369, 13730557568579417905, 2677733454007168321)": "cpu:55640497, mem:691695, objs:-/44@cd73d980", + " 90 ret obj_from_u256_pieces -> Ok(U256(obj#89))": "cpu:55640998, mem:691759, objs:-/45@d173b8e8", " 91 call obj_from_u256_pieces(15107729625736847273, 3736362233123338213, 1310693883286457402, 15587527586950209119)": "", - " 92 ret obj_from_u256_pieces -> Ok(U256(obj#91))": "cpu:55631584, mem:691823, objs:-/46@8a8ce1f3", + " 92 ret obj_from_u256_pieces -> Ok(U256(obj#91))": "cpu:55641499, mem:691823, objs:-/46@8a8ce1f3", " 93 call obj_from_u256_pieces(7130333837602304766, 15809650852848135414, 16809337653702689547, 14300891233011973695)": "", - " 94 ret obj_from_u256_pieces -> Ok(U256(obj#93))": "cpu:55632085, mem:691887, objs:-/47@eacff4b8", + " 94 ret obj_from_u256_pieces -> Ok(U256(obj#93))": "cpu:55642000, mem:691887, objs:-/47@eacff4b8", " 95 call obj_from_u256_pieces(5531006726045309341, 889630097820975985, 16583573122393188327, 9061467097759417586)": "", - " 96 ret obj_from_u256_pieces -> Ok(U256(obj#95))": "cpu:55632586, mem:691951, objs:-/48@42874a94", + " 96 ret obj_from_u256_pieces -> Ok(U256(obj#95))": "cpu:55642501, mem:691951, objs:-/48@42874a94", " 97 call vec_new_from_slice(4)": "", - " 98 ret vec_new_from_slice -> Ok(Vec(obj#97))": "cpu:55633799, mem:692063, objs:-/49@239aaa14", + " 98 ret vec_new_from_slice -> Ok(Vec(obj#97))": "cpu:55643714, mem:692063, objs:-/49@239aaa14", " 99 call vec_new_from_slice(4)": "", - " 100 ret vec_new_from_slice -> Ok(Vec(obj#99))": "cpu:55635012, mem:692175, objs:-/50@60ff6572", + " 100 ret vec_new_from_slice -> Ok(Vec(obj#99))": "cpu:55644927, mem:692175, objs:-/50@60ff6572", " 101 call bls12_381_g2_msm(Vec(obj#97), Vec(obj#99))": "", - " 102 call vec_len(Vec(obj#97))": "cpu:55635256", - " 103 ret vec_len -> Ok(U32(4))": "cpu:55635378", - " 104 call vec_len(Vec(obj#99))": "cpu:59906945, mem:692959", - " 105 ret vec_len -> Ok(U32(4))": "cpu:59907067", - " 106 ret bls12_381_g2_msm -> Ok(Bytes(obj#101))": "cpu:77733326, mem:924112, objs:-/51@6bf9c3f3", + " 102 call vec_len(Vec(obj#97))": "cpu:55645171", + " 103 ret vec_len -> Ok(U32(4))": "cpu:55645293", + " 104 call vec_len(Vec(obj#99))": "cpu:59916860, mem:692959", + " 105 ret vec_len -> Ok(U32(4))": "cpu:59916982", + " 106 ret bls12_381_g2_msm -> Ok(Bytes(obj#101))": "cpu:77743241, mem:924112, objs:-/51@6bf9c3f3", " 107 call vec_new_from_slice(4)": "cpu:0, mem:0", " 108 ret vec_new_from_slice -> Ok(Vec(obj#103))": "cpu:1213, mem:112, objs:-/52@c42f87dd", " 109 call vec_new_from_slice(4)": "", @@ -226,77 +226,77 @@ " 224 ret bls12_381_g2_msm -> Ok(Bytes(obj#161))": "cpu:22100740, mem:232161, objs:-/81@151aaaa4", " 225 call obj_cmp(Bytes(obj#161), Bytes(obj#101))": "", " 226 ret obj_cmp -> Ok(0)": "cpu:22101052", - " 227 call bytes_new_from_slice(192)": "cpu:661, mem:0", - " 228 ret bytes_new_from_slice -> Ok(Bytes(obj#163))": "cpu:1670, mem:272, objs:-/82@526b5995", - " 229 call bytes_new_from_slice(192)": "cpu:2331", - " 230 ret bytes_new_from_slice -> Ok(Bytes(obj#165))": "cpu:3340, mem:544, objs:-/83@6efe8bf2", - " 231 call bytes_new_from_slice(192)": "cpu:4001", - " 232 ret bytes_new_from_slice -> Ok(Bytes(obj#167))": "cpu:5010, mem:816, objs:-/84@d65370d1", - " 233 call bytes_new_from_slice(192)": "cpu:5671", - " 234 ret bytes_new_from_slice -> Ok(Bytes(obj#169))": "cpu:6680, mem:1088, objs:-/85@768353f3", - " 235 call bytes_new_from_slice(192)": "cpu:7341", - " 236 ret bytes_new_from_slice -> Ok(Bytes(obj#171))": "cpu:8350, mem:1360, objs:-/86@d38309a4", + " 227 call bytes_new_from_slice(192)": "cpu:2644, mem:0", + " 228 ret bytes_new_from_slice -> Ok(Bytes(obj#163))": "cpu:3653, mem:272, objs:-/82@526b5995", + " 229 call bytes_new_from_slice(192)": "cpu:6297", + " 230 ret bytes_new_from_slice -> Ok(Bytes(obj#165))": "cpu:7306, mem:544, objs:-/83@6efe8bf2", + " 231 call bytes_new_from_slice(192)": "cpu:9950", + " 232 ret bytes_new_from_slice -> Ok(Bytes(obj#167))": "cpu:10959, mem:816, objs:-/84@d65370d1", + " 233 call bytes_new_from_slice(192)": "cpu:13603", + " 234 ret bytes_new_from_slice -> Ok(Bytes(obj#169))": "cpu:14612, mem:1088, objs:-/85@768353f3", + " 235 call bytes_new_from_slice(192)": "cpu:17256", + " 236 ret bytes_new_from_slice -> Ok(Bytes(obj#171))": "cpu:18265, mem:1360, objs:-/86@d38309a4", " 237 call vec_new_from_slice(5)": "", - " 238 ret vec_new_from_slice -> Ok(Vec(obj#173))": "cpu:9626, mem:1480, objs:-/87@3939bbac", + " 238 ret vec_new_from_slice -> Ok(Vec(obj#173))": "cpu:19541, mem:1480, objs:-/87@3939bbac", " 239 call obj_from_u256_pieces(17073613341124213686, 9800153404225276109, 6607116724722439497, 842746758976683084)": "", - " 240 ret obj_from_u256_pieces -> Ok(U256(obj#175))": "cpu:10127, mem:1544, objs:-/88@a1c554a1", + " 240 ret obj_from_u256_pieces -> Ok(U256(obj#175))": "cpu:20042, mem:1544, objs:-/88@a1c554a1", " 241 call obj_from_u256_pieces(16040841695964229797, 5061605267848115623, 14000740750614834722, 13904863006945675968)": "", - " 242 ret obj_from_u256_pieces -> Ok(U256(obj#177))": "cpu:10628, mem:1608, objs:-/89@5dbca5f2", + " 242 ret obj_from_u256_pieces -> Ok(U256(obj#177))": "cpu:20543, mem:1608, objs:-/89@5dbca5f2", " 243 call obj_from_u256_pieces(5830218664442262694, 4114147737062195718, 16434537214804972826, 1396935906550304884)": "", - " 244 ret obj_from_u256_pieces -> Ok(U256(obj#179))": "cpu:11129, mem:1672, objs:-/90@329f03eb", + " 244 ret obj_from_u256_pieces -> Ok(U256(obj#179))": "cpu:21044, mem:1672, objs:-/90@329f03eb", " 245 call obj_from_u256_pieces(8756542147870587062, 2334579494105318157, 3880849428716171604, 577514052903835922)": "", - " 246 ret obj_from_u256_pieces -> Ok(U256(obj#181))": "cpu:11630, mem:1736, objs:-/91@8451f38d", + " 246 ret obj_from_u256_pieces -> Ok(U256(obj#181))": "cpu:21545, mem:1736, objs:-/91@8451f38d", " 247 call obj_from_u256_pieces(5259919734814292314, 1486637374753912723, 9060486243487422013, 18066450239200677051)": "", - " 248 ret obj_from_u256_pieces -> Ok(U256(obj#183))": "cpu:12131, mem:1800, objs:-/92@c5a670c", + " 248 ret obj_from_u256_pieces -> Ok(U256(obj#183))": "cpu:22046, mem:1800, objs:-/92@c5a670c", " 249 call vec_new_from_slice(5)": "", - " 250 ret vec_new_from_slice -> Ok(Vec(obj#185))": "cpu:13407, mem:1920, objs:-/93@80ddd82c", + " 250 ret vec_new_from_slice -> Ok(Vec(obj#185))": "cpu:23322, mem:1920, objs:-/93@80ddd82c", " 251 call bls12_381_g2_msm(Vec(obj#173), Vec(obj#185))": "", - " 252 call vec_len(Vec(obj#173))": "cpu:13651", - " 253 ret vec_len -> Ok(U32(5))": "cpu:13773", - " 254 call vec_len(Vec(obj#185))": "cpu:5353108, mem:2896", - " 255 ret vec_len -> Ok(U32(5))": "cpu:5353230", - " 256 ret bls12_381_g2_msm -> Ok(Bytes(obj#187))": "cpu:25600824, mem:236852, objs:-/94@37bd5b7d", - " 257 call vec_get(Vec(obj#173), U32(0))": "cpu:25604477, mem:237124, objs:-/95@47f3520c", - " 258 ret vec_get -> Ok(Bytes(obj#163))": "cpu:25604703", + " 252 call vec_len(Vec(obj#173))": "cpu:23566", + " 253 ret vec_len -> Ok(U32(5))": "cpu:23688", + " 254 call vec_len(Vec(obj#185))": "cpu:5363023, mem:2896", + " 255 ret vec_len -> Ok(U32(5))": "cpu:5363145", + " 256 ret bls12_381_g2_msm -> Ok(Bytes(obj#187))": "cpu:25610739, mem:236852, objs:-/94@37bd5b7d", + " 257 call vec_get(Vec(obj#173), U32(0))": "cpu:25614392, mem:237124, objs:-/95@47f3520c", + " 258 ret vec_get -> Ok(Bytes(obj#163))": "cpu:25614618", " 259 call vec_get(Vec(obj#185), U32(0))": "", - " 260 ret vec_get -> Ok(U256(obj#175))": "cpu:25604929", + " 260 ret vec_get -> Ok(U256(obj#175))": "cpu:25614844", " 261 call bls12_381_g2_mul(Bytes(obj#163), U256(obj#175))": "", - " 262 ret bls12_381_g2_mul -> Ok(Bytes(obj#191))": "cpu:34652525, mem:237396, objs:-/96@8cc676a4", + " 262 ret bls12_381_g2_mul -> Ok(Bytes(obj#191))": "cpu:34662440, mem:237396, objs:-/96@8cc676a4", " 263 call bls12_381_g2_add(Bytes(obj#189), Bytes(obj#191))": "", - " 264 ret bls12_381_g2_add -> Ok(Bytes(obj#193))": "cpu:34802154, mem:237668, objs:-/97@fd5accef", + " 264 ret bls12_381_g2_add -> Ok(Bytes(obj#193))": "cpu:34812069, mem:237668, objs:-/97@fd5accef", " 265 call vec_get(Vec(obj#173), U32(1))": "", - " 266 ret vec_get -> Ok(Bytes(obj#165))": "cpu:34802380", + " 266 ret vec_get -> Ok(Bytes(obj#165))": "cpu:34812295", " 267 call vec_get(Vec(obj#185), U32(1))": "", - " 268 ret vec_get -> Ok(U256(obj#177))": "cpu:34802606", + " 268 ret vec_get -> Ok(U256(obj#177))": "cpu:34812521", " 269 call bls12_381_g2_mul(Bytes(obj#165), U256(obj#177))": "", - " 270 ret bls12_381_g2_mul -> Ok(Bytes(obj#195))": "cpu:43850202, mem:237940, objs:-/98@287ee088", + " 270 ret bls12_381_g2_mul -> Ok(Bytes(obj#195))": "cpu:43860117, mem:237940, objs:-/98@287ee088", " 271 call bls12_381_g2_add(Bytes(obj#193), Bytes(obj#195))": "", - " 272 ret bls12_381_g2_add -> Ok(Bytes(obj#197))": "cpu:43999831, mem:238212, objs:-/99@85bfd7f9", + " 272 ret bls12_381_g2_add -> Ok(Bytes(obj#197))": "cpu:44009746, mem:238212, objs:-/99@85bfd7f9", " 273 call vec_get(Vec(obj#173), U32(2))": "", - " 274 ret vec_get -> Ok(Bytes(obj#167))": "cpu:44000057", + " 274 ret vec_get -> Ok(Bytes(obj#167))": "cpu:44009972", " 275 call vec_get(Vec(obj#185), U32(2))": "", - " 276 ret vec_get -> Ok(U256(obj#179))": "cpu:44000283", + " 276 ret vec_get -> Ok(U256(obj#179))": "cpu:44010198", " 277 call bls12_381_g2_mul(Bytes(obj#167), U256(obj#179))": "", - " 278 ret bls12_381_g2_mul -> Ok(Bytes(obj#199))": "cpu:53047879, mem:238484, objs:-/100@83eb557e", + " 278 ret bls12_381_g2_mul -> Ok(Bytes(obj#199))": "cpu:53057794, mem:238484, objs:-/100@83eb557e", " 279 call bls12_381_g2_add(Bytes(obj#197), Bytes(obj#199))": "", - " 280 ret bls12_381_g2_add -> Ok(Bytes(obj#201))": "cpu:53197508, mem:238756, objs:-/101@356eda48", + " 280 ret bls12_381_g2_add -> Ok(Bytes(obj#201))": "cpu:53207423, mem:238756, objs:-/101@356eda48", " 281 call vec_get(Vec(obj#173), U32(3))": "", - " 282 ret vec_get -> Ok(Bytes(obj#169))": "cpu:53197734", + " 282 ret vec_get -> Ok(Bytes(obj#169))": "cpu:53207649", " 283 call vec_get(Vec(obj#185), U32(3))": "", - " 284 ret vec_get -> Ok(U256(obj#181))": "cpu:53197960", + " 284 ret vec_get -> Ok(U256(obj#181))": "cpu:53207875", " 285 call bls12_381_g2_mul(Bytes(obj#169), U256(obj#181))": "", - " 286 ret bls12_381_g2_mul -> Ok(Bytes(obj#203))": "cpu:62245556, mem:239028, objs:-/102@633754c7", + " 286 ret bls12_381_g2_mul -> Ok(Bytes(obj#203))": "cpu:62255471, mem:239028, objs:-/102@633754c7", " 287 call bls12_381_g2_add(Bytes(obj#201), Bytes(obj#203))": "", - " 288 ret bls12_381_g2_add -> Ok(Bytes(obj#205))": "cpu:62395185, mem:239300, objs:-/103@d51e3c43", + " 288 ret bls12_381_g2_add -> Ok(Bytes(obj#205))": "cpu:62405100, mem:239300, objs:-/103@d51e3c43", " 289 call vec_get(Vec(obj#173), U32(4))": "", - " 290 ret vec_get -> Ok(Bytes(obj#171))": "cpu:62395411", + " 290 ret vec_get -> Ok(Bytes(obj#171))": "cpu:62405326", " 291 call vec_get(Vec(obj#185), U32(4))": "", - " 292 ret vec_get -> Ok(U256(obj#183))": "cpu:62395637", + " 292 ret vec_get -> Ok(U256(obj#183))": "cpu:62405552", " 293 call bls12_381_g2_mul(Bytes(obj#171), U256(obj#183))": "", - " 294 ret bls12_381_g2_mul -> Ok(Bytes(obj#207))": "cpu:71443233, mem:239572, objs:-/104@e5da1eed", + " 294 ret bls12_381_g2_mul -> Ok(Bytes(obj#207))": "cpu:71453148, mem:239572, objs:-/104@e5da1eed", " 295 call bls12_381_g2_add(Bytes(obj#205), Bytes(obj#207))": "", - " 296 ret bls12_381_g2_add -> Ok(Bytes(obj#209))": "cpu:71592862, mem:239844, objs:-/105@395f149e", + " 296 ret bls12_381_g2_add -> Ok(Bytes(obj#209))": "cpu:71602777, mem:239844, objs:-/105@395f149e", " 297 call obj_cmp(Bytes(obj#209), Bytes(obj#187))": "", - " 298 ret obj_cmp -> Ok(0)": "cpu:71593174", - " 299 end": "cpu:71593174, mem:239844, prngs:-/-, objs:-/105@395f149e, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-" + " 298 ret obj_cmp -> Ok(0)": "cpu:71603089", + " 299 end": "cpu:71603089, mem:239844, prngs:-/-, objs:-/105@395f149e, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-" } \ No newline at end of file diff --git a/soroban-env-host/observations/22/test__bls12_381__map_fp2_to_g2.json b/soroban-env-host/observations/22/test__bls12_381__map_fp2_to_g2.json index e8225f15a..858be58a0 100644 --- a/soroban-env-host/observations/22/test__bls12_381__map_fp2_to_g2.json +++ b/soroban-env-host/observations/22/test__bls12_381__map_fp2_to_g2.json @@ -1,13 +1,13 @@ { " 0 begin": "cpu:0, mem:0, prngs:-/-, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", - " 1 call bytes_new_from_slice(95)": "cpu:661", - " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1644, mem:175, objs:-/1@14742518", + " 1 call bytes_new_from_slice(95)": "cpu:1322", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:2305, mem:175, objs:-/1@14742518", " 3 call bls12_381_map_fp2_to_g2(Bytes(obj#1))": "", - " 4 ret bls12_381_map_fp2_to_g2 -> Err(Error(Crypto, InvalidInput))": "cpu:1766", - " 5 call bytes_new_from_slice(97)": "cpu:2427", - " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#3))": "cpu:3412, mem:352, objs:-/2@b8cae411", + " 4 ret bls12_381_map_fp2_to_g2 -> Err(Error(Crypto, InvalidInput))": "cpu:2427", + " 5 call bytes_new_from_slice(97)": "cpu:4410", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#3))": "cpu:5395, mem:352, objs:-/2@b8cae411", " 7 call bls12_381_map_fp2_to_g2(Bytes(obj#3))": "", - " 8 ret bls12_381_map_fp2_to_g2 -> Err(Error(Crypto, InvalidInput))": "cpu:3534", + " 8 ret bls12_381_map_fp2_to_g2 -> Err(Error(Crypto, InvalidInput))": "cpu:5517", " 9 call bytes_new_from_slice(192)": "cpu:0, mem:0", " 10 ret bytes_new_from_slice -> Ok(Bytes(obj#5))": "cpu:1009, mem:272, objs:-/3@84cbabcf", " 11 call bytes_new_from_slice(96)": "", diff --git a/soroban-env-host/observations/22/test__bls12_381__map_fp_to_g1.json b/soroban-env-host/observations/22/test__bls12_381__map_fp_to_g1.json index 6c4e39cd5..69440959a 100644 --- a/soroban-env-host/observations/22/test__bls12_381__map_fp_to_g1.json +++ b/soroban-env-host/observations/22/test__bls12_381__map_fp_to_g1.json @@ -4,10 +4,10 @@ " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1632, mem:127, objs:-/1@705fbc72", " 3 call bls12_381_map_fp_to_g1(Bytes(obj#1))": "", " 4 ret bls12_381_map_fp_to_g1 -> Err(Error(Crypto, InvalidInput))": "cpu:1754", - " 5 call bytes_new_from_slice(49)": "cpu:2415", - " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#3))": "cpu:3388, mem:256, objs:-/2@7385e39e", + " 5 call bytes_new_from_slice(49)": "cpu:3076", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#3))": "cpu:4049, mem:256, objs:-/2@7385e39e", " 7 call bls12_381_map_fp_to_g1(Bytes(obj#3))": "", - " 8 ret bls12_381_map_fp_to_g1 -> Err(Error(Crypto, InvalidInput))": "cpu:3510", + " 8 ret bls12_381_map_fp_to_g1 -> Err(Error(Crypto, InvalidInput))": "cpu:4171", " 9 call bytes_new_from_slice(96)": "cpu:0, mem:0", " 10 ret bytes_new_from_slice -> Ok(Bytes(obj#5))": "cpu:985, mem:176, objs:-/3@cdeaaaab", " 11 call bytes_new_from_slice(48)": "", diff --git a/soroban-env-host/observations/22/test__bls12_381__pairing.json b/soroban-env-host/observations/22/test__bls12_381__pairing.json index 67bad5244..3ea23e46d 100644 --- a/soroban-env-host/observations/22/test__bls12_381__pairing.json +++ b/soroban-env-host/observations/22/test__bls12_381__pairing.json @@ -1,69 +1,69 @@ { " 0 begin": "cpu:0, mem:0, prngs:-/-, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", - " 1 call bytes_new_from_slice(96)": "cpu:661", - " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:1646, mem:176, objs:-/1@2142c5f5", - " 3 call bytes_new_from_slice(96)": "cpu:2307", - " 4 ret bytes_new_from_slice -> Ok(Bytes(obj#3))": "cpu:3292, mem:352, objs:-/2@a5d3f802", - " 5 call bytes_new_from_slice(96)": "cpu:3953", - " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#5))": "cpu:4938, mem:528, objs:-/3@d1e19abc", + " 1 call bytes_new_from_slice(96)": "cpu:1322", + " 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:2307, mem:176, objs:-/1@2142c5f5", + " 3 call bytes_new_from_slice(96)": "cpu:3629", + " 4 ret bytes_new_from_slice -> Ok(Bytes(obj#3))": "cpu:4614, mem:352, objs:-/2@a5d3f802", + " 5 call bytes_new_from_slice(96)": "cpu:5936", + " 6 ret bytes_new_from_slice -> Ok(Bytes(obj#5))": "cpu:6921, mem:528, objs:-/3@d1e19abc", " 7 call vec_new_from_slice(3)": "", - " 8 ret vec_new_from_slice -> Ok(Vec(obj#7))": "cpu:6088, mem:632, objs:-/4@8244fa30", - " 9 call bytes_new_from_slice(192)": "cpu:6749", - " 10 ret bytes_new_from_slice -> Ok(Bytes(obj#9))": "cpu:7758, mem:904, objs:-/5@7db97cd4", - " 11 call bytes_new_from_slice(192)": "cpu:8419", - " 12 ret bytes_new_from_slice -> Ok(Bytes(obj#11))": "cpu:9428, mem:1176, objs:-/6@2f986967", + " 8 ret vec_new_from_slice -> Ok(Vec(obj#7))": "cpu:8071, mem:632, objs:-/4@8244fa30", + " 9 call bytes_new_from_slice(192)": "cpu:10715", + " 10 ret bytes_new_from_slice -> Ok(Bytes(obj#9))": "cpu:11724, mem:904, objs:-/5@7db97cd4", + " 11 call bytes_new_from_slice(192)": "cpu:14368", + " 12 ret bytes_new_from_slice -> Ok(Bytes(obj#11))": "cpu:15377, mem:1176, objs:-/6@2f986967", " 13 call vec_new_from_slice(2)": "", - " 14 ret vec_new_from_slice -> Ok(Vec(obj#13))": "cpu:10515, mem:1272, objs:-/7@e86d844b", + " 14 ret vec_new_from_slice -> Ok(Vec(obj#13))": "cpu:16464, mem:1272, objs:-/7@e86d844b", " 15 call bls12_381_multi_pairing_check(Vec(obj#7), Vec(obj#13))": "", - " 16 ret bls12_381_multi_pairing_check -> Err(Error(Crypto, InvalidInput))": "cpu:10759", + " 16 ret bls12_381_multi_pairing_check -> Err(Error(Crypto, InvalidInput))": "cpu:16708", " 17 call vec_new_from_slice(0)": "", - " 18 ret vec_new_from_slice -> Ok(Vec(obj#15))": "cpu:11720, mem:1352, objs:-/8@aefe5995", + " 18 ret vec_new_from_slice -> Ok(Vec(obj#15))": "cpu:17669, mem:1352, objs:-/8@aefe5995", " 19 call vec_new_from_slice(0)": "", - " 20 ret vec_new_from_slice -> Ok(Vec(obj#17))": "cpu:12681, mem:1432, objs:-/9@e19454cb", + " 20 ret vec_new_from_slice -> Ok(Vec(obj#17))": "cpu:18630, mem:1432, objs:-/9@e19454cb", " 21 call bls12_381_multi_pairing_check(Vec(obj#15), Vec(obj#17))": "", - " 22 ret bls12_381_multi_pairing_check -> Err(Error(Crypto, InvalidInput))": "cpu:12925", - " 23 call bytes_new_from_slice(96)": "cpu:13586", - " 24 ret bytes_new_from_slice -> Ok(Bytes(obj#19))": "cpu:14571, mem:1608, objs:-/10@d5c411e9", - " 25 call bytes_new_from_slice(96)": "cpu:15232", - " 26 ret bytes_new_from_slice -> Ok(Bytes(obj#21))": "cpu:16217, mem:1784, objs:-/11@9371ef1d", - " 27 call bytes_new_from_slice(96)": "cpu:16878", - " 28 ret bytes_new_from_slice -> Ok(Bytes(obj#23))": "cpu:17863, mem:1960, objs:-/12@3462be9a", + " 22 ret bls12_381_multi_pairing_check -> Err(Error(Crypto, InvalidInput))": "cpu:18874", + " 23 call bytes_new_from_slice(96)": "cpu:20196", + " 24 ret bytes_new_from_slice -> Ok(Bytes(obj#19))": "cpu:21181, mem:1608, objs:-/10@d5c411e9", + " 25 call bytes_new_from_slice(96)": "cpu:22503", + " 26 ret bytes_new_from_slice -> Ok(Bytes(obj#21))": "cpu:23488, mem:1784, objs:-/11@9371ef1d", + " 27 call bytes_new_from_slice(96)": "cpu:24810", + " 28 ret bytes_new_from_slice -> Ok(Bytes(obj#23))": "cpu:25795, mem:1960, objs:-/12@3462be9a", " 29 call vec_new_from_slice(3)": "", - " 30 ret vec_new_from_slice -> Ok(Vec(obj#25))": "cpu:19013, mem:2064, objs:-/13@21b206a8", - " 31 call vec_put(Vec(obj#25), U32(1), Bytes(obj#27))": "cpu:21320, mem:2240, objs:-/14@211e7ae", - " 32 ret vec_put -> Ok(Vec(obj#29))": "cpu:22574, mem:2344, objs:-/15@d6218c40", - " 33 call bytes_new_from_slice(192)": "cpu:23235", - " 34 ret bytes_new_from_slice -> Ok(Bytes(obj#31))": "cpu:24244, mem:2616, objs:-/16@1fbd75b9", - " 35 call bytes_new_from_slice(192)": "cpu:24905", - " 36 ret bytes_new_from_slice -> Ok(Bytes(obj#33))": "cpu:25914, mem:2888, objs:-/17@eb01b50b", + " 30 ret vec_new_from_slice -> Ok(Vec(obj#25))": "cpu:26945, mem:2064, objs:-/13@21b206a8", + " 31 call vec_put(Vec(obj#25), U32(1), Bytes(obj#27))": "cpu:29252, mem:2240, objs:-/14@211e7ae", + " 32 ret vec_put -> Ok(Vec(obj#29))": "cpu:30506, mem:2344, objs:-/15@d6218c40", + " 33 call bytes_new_from_slice(192)": "cpu:33150", + " 34 ret bytes_new_from_slice -> Ok(Bytes(obj#31))": "cpu:34159, mem:2616, objs:-/16@1fbd75b9", + " 35 call bytes_new_from_slice(192)": "cpu:36803", + " 36 ret bytes_new_from_slice -> Ok(Bytes(obj#33))": "cpu:37812, mem:2888, objs:-/17@eb01b50b", " 37 call vec_new_from_slice(2)": "", - " 38 ret vec_new_from_slice -> Ok(Vec(obj#35))": "cpu:27001, mem:2984, objs:-/18@88878336", + " 38 ret vec_new_from_slice -> Ok(Vec(obj#35))": "cpu:38899, mem:2984, objs:-/18@88878336", " 39 call bls12_381_multi_pairing_check(Vec(obj#29), Vec(obj#35))": "", - " 40 ret bls12_381_multi_pairing_check -> Err(Error(Crypto, InvalidInput))": "cpu:27245", - " 41 call bytes_new_from_slice(96)": "cpu:27906", - " 42 ret bytes_new_from_slice -> Ok(Bytes(obj#37))": "cpu:28891, mem:3160, objs:-/19@bef467b3", - " 43 call bytes_new_from_slice(96)": "cpu:29552", - " 44 ret bytes_new_from_slice -> Ok(Bytes(obj#39))": "cpu:30537, mem:3336, objs:-/20@7711af03", - " 45 call bytes_new_from_slice(96)": "cpu:31198", - " 46 ret bytes_new_from_slice -> Ok(Bytes(obj#41))": "cpu:32183, mem:3512, objs:-/21@bd0eaa67", + " 40 ret bls12_381_multi_pairing_check -> Err(Error(Crypto, InvalidInput))": "cpu:39143", + " 41 call bytes_new_from_slice(96)": "cpu:40465", + " 42 ret bytes_new_from_slice -> Ok(Bytes(obj#37))": "cpu:41450, mem:3160, objs:-/19@bef467b3", + " 43 call bytes_new_from_slice(96)": "cpu:42772", + " 44 ret bytes_new_from_slice -> Ok(Bytes(obj#39))": "cpu:43757, mem:3336, objs:-/20@7711af03", + " 45 call bytes_new_from_slice(96)": "cpu:45079", + " 46 ret bytes_new_from_slice -> Ok(Bytes(obj#41))": "cpu:46064, mem:3512, objs:-/21@bd0eaa67", " 47 call vec_new_from_slice(3)": "", - " 48 ret vec_new_from_slice -> Ok(Vec(obj#43))": "cpu:33333, mem:3616, objs:-/22@4745d9cc", - " 49 call bytes_new_from_slice(192)": "cpu:33994", - " 50 ret bytes_new_from_slice -> Ok(Bytes(obj#45))": "cpu:35003, mem:3888, objs:-/23@2ac90b2", - " 51 call bytes_new_from_slice(192)": "cpu:35664", - " 52 ret bytes_new_from_slice -> Ok(Bytes(obj#47))": "cpu:36673, mem:4160, objs:-/24@d104dc23", - " 53 call bytes_new_from_slice(192)": "cpu:37334", - " 54 ret bytes_new_from_slice -> Ok(Bytes(obj#49))": "cpu:38343, mem:4432, objs:-/25@11f7750c", + " 48 ret vec_new_from_slice -> Ok(Vec(obj#43))": "cpu:47214, mem:3616, objs:-/22@4745d9cc", + " 49 call bytes_new_from_slice(192)": "cpu:49858", + " 50 ret bytes_new_from_slice -> Ok(Bytes(obj#45))": "cpu:50867, mem:3888, objs:-/23@2ac90b2", + " 51 call bytes_new_from_slice(192)": "cpu:53511", + " 52 ret bytes_new_from_slice -> Ok(Bytes(obj#47))": "cpu:54520, mem:4160, objs:-/24@d104dc23", + " 53 call bytes_new_from_slice(192)": "cpu:57164", + " 54 ret bytes_new_from_slice -> Ok(Bytes(obj#49))": "cpu:58173, mem:4432, objs:-/25@11f7750c", " 55 call vec_new_from_slice(3)": "", - " 56 ret vec_new_from_slice -> Ok(Vec(obj#51))": "cpu:39493, mem:4536, objs:-/26@ada08c01", - " 57 call vec_put(Vec(obj#51), U32(1), Bytes(obj#53))": "cpu:43146, mem:4808, objs:-/27@f2ac27ac", - " 58 ret vec_put -> Ok(Vec(obj#55))": "cpu:44400, mem:4912, objs:-/28@6d6b0a1", + " 56 ret vec_new_from_slice -> Ok(Vec(obj#51))": "cpu:59323, mem:4536, objs:-/26@ada08c01", + " 57 call vec_put(Vec(obj#51), U32(1), Bytes(obj#53))": "cpu:62976, mem:4808, objs:-/27@f2ac27ac", + " 58 ret vec_put -> Ok(Vec(obj#55))": "cpu:64230, mem:4912, objs:-/28@6d6b0a1", " 59 call bls12_381_multi_pairing_check(Vec(obj#43), Vec(obj#55))": "", - " 60 call vec_len(Vec(obj#43))": "cpu:44644", - " 61 ret vec_len -> Ok(U32(3))": "cpu:44766", - " 62 call vec_len(Vec(obj#55))": "cpu:2248722, mem:5216", - " 63 ret vec_len -> Ok(U32(3))": "cpu:2248844", - " 64 ret bls12_381_multi_pairing_check -> Err(Error(Crypto, InvalidInput))": "cpu:3327077, mem:5808", + " 60 call vec_len(Vec(obj#43))": "cpu:64474", + " 61 ret vec_len -> Ok(U32(3))": "cpu:64596", + " 62 call vec_len(Vec(obj#55))": "cpu:2268552, mem:5216", + " 63 ret vec_len -> Ok(U32(3))": "cpu:2268674", + " 64 ret bls12_381_multi_pairing_check -> Err(Error(Crypto, InvalidInput))": "cpu:3346907, mem:5808", " 65 call bls12_381_g2_add(Bytes(obj#61), Bytes(obj#63))": "cpu:746395, mem:896, objs:-/32@be1f7a8e", " 66 ret bls12_381_g2_add -> Ok(Bytes(obj#65))": "cpu:896024, mem:1168, objs:-/33@9d890a7b", " 67 call vec_new_from_slice(3)": "", @@ -118,54 +118,54 @@ " 116 call vec_len(Vec(obj#113))": "cpu:41777386, mem:3304", " 117 ret vec_len -> Ok(U32(4))": "cpu:41777508", " 118 ret bls12_381_multi_pairing_check -> Ok(True)": "cpu:76385043, mem:298181", - " 119 call bytes_new_from_slice(96)": "cpu:661, mem:0", - " 120 ret bytes_new_from_slice -> Ok(Bytes(obj#115))": "cpu:1646, mem:176, objs:-/58@ac299a82", - " 121 call bytes_new_from_slice(96)": "cpu:2307", - " 122 ret bytes_new_from_slice -> Ok(Bytes(obj#117))": "cpu:3292, mem:352, objs:-/59@113198f9", - " 123 call bytes_new_from_slice(96)": "cpu:3953", - " 124 ret bytes_new_from_slice -> Ok(Bytes(obj#119))": "cpu:4938, mem:528, objs:-/60@37eadd60", + " 119 call bytes_new_from_slice(96)": "cpu:1322, mem:0", + " 120 ret bytes_new_from_slice -> Ok(Bytes(obj#115))": "cpu:2307, mem:176, objs:-/58@ac299a82", + " 121 call bytes_new_from_slice(96)": "cpu:3629", + " 122 ret bytes_new_from_slice -> Ok(Bytes(obj#117))": "cpu:4614, mem:352, objs:-/59@113198f9", + " 123 call bytes_new_from_slice(96)": "cpu:5936", + " 124 ret bytes_new_from_slice -> Ok(Bytes(obj#119))": "cpu:6921, mem:528, objs:-/60@37eadd60", " 125 call vec_new_from_slice(3)": "", - " 126 ret vec_new_from_slice -> Ok(Vec(obj#121))": "cpu:6088, mem:632, objs:-/61@b3526a16", - " 127 call vec_put(Vec(obj#121), U32(1), Bytes(obj#123))": "cpu:8395, mem:808, objs:-/62@e4a76af5", - " 128 ret vec_put -> Ok(Vec(obj#125))": "cpu:9649, mem:912, objs:-/63@5b689763", - " 129 call bytes_new_from_slice(192)": "cpu:10310", - " 130 ret bytes_new_from_slice -> Ok(Bytes(obj#127))": "cpu:11319, mem:1184, objs:-/64@8aa5fc15", - " 131 call bytes_new_from_slice(192)": "cpu:11980", - " 132 ret bytes_new_from_slice -> Ok(Bytes(obj#129))": "cpu:12989, mem:1456, objs:-/65@b4fc63e0", - " 133 call bytes_new_from_slice(192)": "cpu:13650", - " 134 ret bytes_new_from_slice -> Ok(Bytes(obj#131))": "cpu:14659, mem:1728, objs:-/66@5c98ecb1", + " 126 ret vec_new_from_slice -> Ok(Vec(obj#121))": "cpu:8071, mem:632, objs:-/61@b3526a16", + " 127 call vec_put(Vec(obj#121), U32(1), Bytes(obj#123))": "cpu:10378, mem:808, objs:-/62@e4a76af5", + " 128 ret vec_put -> Ok(Vec(obj#125))": "cpu:11632, mem:912, objs:-/63@5b689763", + " 129 call bytes_new_from_slice(192)": "cpu:14276", + " 130 ret bytes_new_from_slice -> Ok(Bytes(obj#127))": "cpu:15285, mem:1184, objs:-/64@8aa5fc15", + " 131 call bytes_new_from_slice(192)": "cpu:17929", + " 132 ret bytes_new_from_slice -> Ok(Bytes(obj#129))": "cpu:18938, mem:1456, objs:-/65@b4fc63e0", + " 133 call bytes_new_from_slice(192)": "cpu:21582", + " 134 ret bytes_new_from_slice -> Ok(Bytes(obj#131))": "cpu:22591, mem:1728, objs:-/66@5c98ecb1", " 135 call vec_new_from_slice(3)": "", - " 136 ret vec_new_from_slice -> Ok(Vec(obj#133))": "cpu:15809, mem:1832, objs:-/67@3f3912a7", + " 136 ret vec_new_from_slice -> Ok(Vec(obj#133))": "cpu:23741, mem:1832, objs:-/67@3f3912a7", " 137 call bls12_381_multi_pairing_check(Vec(obj#125), Vec(obj#133))": "", - " 138 call vec_len(Vec(obj#125))": "cpu:16053", - " 139 ret vec_len -> Ok(U32(3))": "cpu:16175", - " 140 call vec_len(Vec(obj#133))": "cpu:2220131, mem:2136", - " 141 ret vec_len -> Ok(U32(3))": "cpu:2220253", - " 142 ret bls12_381_multi_pairing_check -> Ok(False)": "cpu:30815794, mem:223849", - " 143 call bytes_new_from_slice(96)": "cpu:661, mem:0", - " 144 ret bytes_new_from_slice -> Ok(Bytes(obj#135))": "cpu:1646, mem:176, objs:-/68@47cc533a", - " 145 call bytes_new_from_slice(96)": "cpu:2307", - " 146 ret bytes_new_from_slice -> Ok(Bytes(obj#137))": "cpu:3292, mem:352, objs:-/69@9420de5f", - " 147 call bytes_new_from_slice(96)": "cpu:3953", - " 148 ret bytes_new_from_slice -> Ok(Bytes(obj#139))": "cpu:4938, mem:528, objs:-/70@f09a5b7a", + " 138 call vec_len(Vec(obj#125))": "cpu:23985", + " 139 ret vec_len -> Ok(U32(3))": "cpu:24107", + " 140 call vec_len(Vec(obj#133))": "cpu:2228063, mem:2136", + " 141 ret vec_len -> Ok(U32(3))": "cpu:2228185", + " 142 ret bls12_381_multi_pairing_check -> Ok(False)": "cpu:30823726, mem:223849", + " 143 call bytes_new_from_slice(96)": "cpu:1322, mem:0", + " 144 ret bytes_new_from_slice -> Ok(Bytes(obj#135))": "cpu:2307, mem:176, objs:-/68@47cc533a", + " 145 call bytes_new_from_slice(96)": "cpu:3629", + " 146 ret bytes_new_from_slice -> Ok(Bytes(obj#137))": "cpu:4614, mem:352, objs:-/69@9420de5f", + " 147 call bytes_new_from_slice(96)": "cpu:5936", + " 148 ret bytes_new_from_slice -> Ok(Bytes(obj#139))": "cpu:6921, mem:528, objs:-/70@f09a5b7a", " 149 call vec_new_from_slice(3)": "", - " 150 ret vec_new_from_slice -> Ok(Vec(obj#141))": "cpu:6088, mem:632, objs:-/71@71e61918", - " 151 call bytes_new_from_slice(192)": "cpu:6749", - " 152 ret bytes_new_from_slice -> Ok(Bytes(obj#143))": "cpu:7758, mem:904, objs:-/72@b2c885b9", - " 153 call bytes_new_from_slice(192)": "cpu:8419", - " 154 ret bytes_new_from_slice -> Ok(Bytes(obj#145))": "cpu:9428, mem:1176, objs:-/73@890ee9f4", - " 155 call bytes_new_from_slice(192)": "cpu:10089", - " 156 ret bytes_new_from_slice -> Ok(Bytes(obj#147))": "cpu:11098, mem:1448, objs:-/74@c894f888", + " 150 ret vec_new_from_slice -> Ok(Vec(obj#141))": "cpu:8071, mem:632, objs:-/71@71e61918", + " 151 call bytes_new_from_slice(192)": "cpu:10715", + " 152 ret bytes_new_from_slice -> Ok(Bytes(obj#143))": "cpu:11724, mem:904, objs:-/72@b2c885b9", + " 153 call bytes_new_from_slice(192)": "cpu:14368", + " 154 ret bytes_new_from_slice -> Ok(Bytes(obj#145))": "cpu:15377, mem:1176, objs:-/73@890ee9f4", + " 155 call bytes_new_from_slice(192)": "cpu:18021", + " 156 ret bytes_new_from_slice -> Ok(Bytes(obj#147))": "cpu:19030, mem:1448, objs:-/74@c894f888", " 157 call vec_new_from_slice(3)": "", - " 158 ret vec_new_from_slice -> Ok(Vec(obj#149))": "cpu:12248, mem:1552, objs:-/75@6f0bc56a", - " 159 call vec_put(Vec(obj#149), U32(2), Bytes(obj#151))": "cpu:15901, mem:1824, objs:-/76@85e20168", - " 160 ret vec_put -> Ok(Vec(obj#153))": "cpu:17155, mem:1928, objs:-/77@35e77666", + " 158 ret vec_new_from_slice -> Ok(Vec(obj#149))": "cpu:20180, mem:1552, objs:-/75@6f0bc56a", + " 159 call vec_put(Vec(obj#149), U32(2), Bytes(obj#151))": "cpu:23833, mem:1824, objs:-/76@85e20168", + " 160 ret vec_put -> Ok(Vec(obj#153))": "cpu:25087, mem:1928, objs:-/77@35e77666", " 161 call bls12_381_multi_pairing_check(Vec(obj#141), Vec(obj#153))": "", - " 162 call vec_len(Vec(obj#141))": "cpu:17399", - " 163 ret vec_len -> Ok(U32(3))": "cpu:17521", - " 164 call vec_len(Vec(obj#153))": "cpu:2221477, mem:2232", - " 165 ret vec_len -> Ok(U32(3))": "cpu:2221599", - " 166 ret bls12_381_multi_pairing_check -> Ok(False)": "cpu:30817140, mem:223945", + " 162 call vec_len(Vec(obj#141))": "cpu:25331", + " 163 ret vec_len -> Ok(U32(3))": "cpu:25453", + " 164 call vec_len(Vec(obj#153))": "cpu:2229409, mem:2232", + " 165 ret vec_len -> Ok(U32(3))": "cpu:2229531", + " 166 ret bls12_381_multi_pairing_check -> Ok(False)": "cpu:30825072, mem:223945", " 167 call vec_new_from_slice(5)": "cpu:11535, mem:880, objs:-/82@40297403", " 168 ret vec_new_from_slice -> Ok(Vec(obj#165))": "cpu:12811, mem:1000, objs:-/83@2d838f8e", " 169 call vec_new_from_slice(5)": "cpu:31076, mem:2360, objs:-/88@c33dc4c0", diff --git a/soroban-env-host/observations/22/test__bls12_381__test_serialization_roundtrip.json b/soroban-env-host/observations/22/test__bls12_381__test_serialization_roundtrip.json new file mode 100644 index 000000000..c726bf0d3 --- /dev/null +++ b/soroban-env-host/observations/22/test__bls12_381__test_serialization_roundtrip.json @@ -0,0 +1,44 @@ +{ + " 0 begin": "cpu:0, mem:0, prngs:-/-, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-", + " 1 call obj_from_u256_pieces(2395589458197215953, 3306305587277880961, 1302117398068482837, 1091207826991875146)": "cpu:50772796, mem:28008, objs:-/137@d07a46d8", + " 2 ret obj_from_u256_pieces -> Ok(U256(obj#275))": "cpu:50773297, mem:28072, objs:-/138@99d5e5d2", + " 3 call obj_from_u256_pieces(4030740013859617607, 13817590489558995017, 443594582117458576, 245589856645029399)": "cpu:50776507, mem:28320", + " 4 ret obj_from_u256_pieces -> Ok(U256(obj#277))": "cpu:50777008, mem:28384, objs:-/139@ce81e5d9", + " 5 call obj_from_u256_pieces(2309403286221278731, 240231957602763745, 18358523006851037387, 13739599435256500115)": "cpu:50780218, mem:28632", + " 6 ret obj_from_u256_pieces -> Ok(U256(obj#279))": "cpu:50780719, mem:28696, objs:-/140@279a975", + " 7 call obj_from_u256_pieces(5744460099082395691, 11679559040025848215, 5800079206407269482, 14330949528024819573)": "cpu:50783929, mem:28944", + " 8 ret obj_from_u256_pieces -> Ok(U256(obj#281))": "cpu:50784430, mem:29008, objs:-/141@3f854b89", + " 9 call obj_from_u256_pieces(912784256554815413, 7739630991749586382, 11693624627592045674, 9648884353269389255)": "cpu:50787640, mem:29256", + " 10 ret obj_from_u256_pieces -> Ok(U256(obj#283))": "cpu:50788141, mem:29320, objs:-/142@24879da6", + " 11 call obj_from_u256_pieces(1298169624505566978, 11840534902383509259, 10489044078202748843, 10046771591107357601)": "cpu:50791351, mem:29568", + " 12 ret obj_from_u256_pieces -> Ok(U256(obj#285))": "cpu:50791852, mem:29632, objs:-/143@765f0703", + " 13 call obj_from_u256_pieces(4462537922610993750, 5476907946140276402, 15301198056592352265, 8829090581031049060)": "cpu:50795062, mem:29880", + " 14 ret obj_from_u256_pieces -> Ok(U256(obj#287))": "cpu:50795563, mem:29944, objs:-/144@fc5d4293", + " 15 call obj_from_u256_pieces(1483814255270150809, 2240693107019974066, 11035480608488985609, 5591664456856301659)": "cpu:50798773, mem:30192", + " 16 ret obj_from_u256_pieces -> Ok(U256(obj#289))": "cpu:50799274, mem:30256, objs:-/145@3c777c38", + " 17 call obj_from_u256_pieces(2823066946149997955, 4017845098771023863, 2091132495329236295, 4382883068235871617)": "cpu:50802484, mem:30504", + " 18 ret obj_from_u256_pieces -> Ok(U256(obj#291))": "cpu:50802985, mem:30568, objs:-/146@5fdd6fd7", + " 19 call obj_from_u256_pieces(8147738635046659263, 10838147310065800303, 9456691195047663294, 4156381095270017721)": "cpu:50806195, mem:30816", + " 20 ret obj_from_u256_pieces -> Ok(U256(obj#293))": "cpu:50806696, mem:30880, objs:-/147@d2116a6", + " 21 call obj_from_u256_pieces(4759692657470168240, 3248115619405505989, 1935398248938956755, 17870100943070610895)": "cpu:50809906, mem:31128", + " 22 ret obj_from_u256_pieces -> Ok(U256(obj#295))": "cpu:50810407, mem:31192, objs:-/148@d3aca663", + " 23 call obj_from_u256_pieces(6299505550503794325, 934313480772554357, 9575559878597866574, 13968606194827052782)": "cpu:50813617, mem:31440", + " 24 ret obj_from_u256_pieces -> Ok(U256(obj#297))": "cpu:50814118, mem:31504, objs:-/149@49b852dc", + " 25 call obj_from_u256_pieces(5154620316501156786, 16487987160575941779, 7214314208877781085, 7991574812575765638)": "cpu:50817328, mem:31752", + " 26 ret obj_from_u256_pieces -> Ok(U256(obj#299))": "cpu:50817829, mem:31816, objs:-/150@9ae0887", + " 27 call obj_from_u256_pieces(532576566866806321, 10721499738797675969, 16215558025196189643, 12632335931862967898)": "cpu:50821039, mem:32064", + " 28 ret obj_from_u256_pieces -> Ok(U256(obj#301))": "cpu:50821540, mem:32128, objs:-/151@22cb95b8", + " 29 call obj_from_u256_pieces(8159131102163283424, 8923210778304361529, 1540766709305171743, 2989208879561351542)": "cpu:50824750, mem:32376", + " 30 ret obj_from_u256_pieces -> Ok(U256(obj#303))": "cpu:50825251, mem:32440, objs:-/152@ed27ba1d", + " 31 call obj_from_u256_pieces(5698022951443837324, 16779749181027918978, 6902233456353033725, 10646855747138121935)": "cpu:50828461, mem:32688", + " 32 ret obj_from_u256_pieces -> Ok(U256(obj#305))": "cpu:50828962, mem:32752, objs:-/153@7d1f6066", + " 33 call obj_from_u256_pieces(3849184316064635501, 8312667462643589578, 14602721145082682090, 4963389936466161700)": "cpu:50832172, mem:33000", + " 34 ret obj_from_u256_pieces -> Ok(U256(obj#307))": "cpu:50832673, mem:33064, objs:-/154@610bedde", + " 35 call obj_from_u256_pieces(6428876429662729984, 1159517746365042179, 5484564165453778753, 15411623082197541403)": "cpu:50835883, mem:33312", + " 36 ret obj_from_u256_pieces -> Ok(U256(obj#309))": "cpu:50836384, mem:33376, objs:-/155@40c4136a", + " 37 call obj_from_u256_pieces(801460342213299702, 9908357551484169280, 1024931740778734376, 6858226285216280857)": "cpu:50839594, mem:33624", + " 38 ret obj_from_u256_pieces -> Ok(U256(obj#311))": "cpu:50840095, mem:33688, objs:-/156@794e1c81", + " 39 call obj_from_u256_pieces(3249626194219012092, 12917896548134785039, 10675741979518937446, 3611643771666195033)": "cpu:50843305, mem:33936", + " 40 ret obj_from_u256_pieces -> Ok(U256(obj#313))": "cpu:50843806, mem:34000, objs:-/157@1912f2a7", + " 41 end": "cpu:50845861, mem:34000, prngs:-/-, objs:-/157@1912f2a7, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-" +} \ No newline at end of file diff --git a/soroban-env-host/src/cost_runner/cost_types/bls12_381.rs b/soroban-env-host/src/cost_runner/cost_types/bls12_381.rs index 301791037..a50dc891f 100644 --- a/soroban-env-host/src/cost_runner/cost_types/bls12_381.rs +++ b/soroban-env-host/src/cost_runner/cost_types/bls12_381.rs @@ -3,6 +3,7 @@ use ark_ec::pairing::PairingOutput; use crate::{ cost_runner::{CostRunner, CostType}, + crypto::bls12_381::FP_SERIALIZED_SIZE, impl_const_cost_runner_for_bls_consume_sample, impl_const_cost_runner_for_bls_deref_sample, impl_lin_cost_runner_for_bls_deref_sample, xdr::ContractCostType::{ @@ -251,7 +252,7 @@ impl CostRunner for Bls12381EncodeFpRun { ) -> Self::RecycledType { let Bls12381EncodeFpSample(buf, fp) = &mut sample; let _ = host - .serialize_uncompressed_into_slice(fp, buf, 1, "test") + .serialize_uncompressed_into_slice::(fp, buf, "test") .unwrap(); black_box(Some(sample)) } @@ -282,7 +283,7 @@ impl CostRunner for Bls12381DecodeFpRun { ) -> Self::RecycledType { let Bls12381DecodeFpSample(buf) = &sample; let res = host - .deserialize_uncompessed_no_validate(buf, 1, "test") + .deserialize_uncompessed_no_validate::(buf, "test") .unwrap(); black_box((Some(sample), Some(res))) } diff --git a/soroban-env-host/src/crypto/bls12_381.rs b/soroban-env-host/src/crypto/bls12_381.rs index c6554c698..8b8a26708 100644 --- a/soroban-env-host/src/crypto/bls12_381.rs +++ b/soroban-env-host/src/crypto/bls12_381.rs @@ -6,14 +6,19 @@ use crate::{ U256Small, U256Val, Val, VecObject, U256, }; use ark_bls12_381::{ - Bls12_381, Fq, Fq12, Fq2, Fr, G1Affine, G1Projective, G2Affine, G2Projective, + g1::Config as G1Config, g2::Config as G2Config, Bls12_381, Fq, Fq12, Fq2, Fr, G1Affine, + G1Projective, G2Affine, G2Projective, }; use ark_ec::{ hashing::{ curve_maps::wb::{WBConfig, WBMap}, map_to_curve_hasher::{MapToCurve, MapToCurveBasedHasher}, HashToCurve, - }, pairing::{Pairing, PairingOutput}, scalar_mul::variable_base::VariableBaseMSM, short_weierstrass::{Affine, Projective, SWCurveConfig}, AffineRepr, CurveGroup + }, + pairing::{Pairing, PairingOutput}, + scalar_mul::variable_base::VariableBaseMSM, + short_weierstrass::{Affine, Projective, SWCurveConfig}, + AffineRepr, CurveGroup, }; use ark_ff::{field_hashers::DefaultFieldHasher, BigInteger, Field, PrimeField}; use ark_serialize::{CanonicalDeserialize, CanonicalSerialize, Compress, Validate}; @@ -29,20 +34,41 @@ pub(crate) const G1_SERIALIZED_SIZE: usize = FP_SERIALIZED_SIZE * 2; pub(crate) const G2_SERIALIZED_SIZE: usize = FP2_SERIALIZED_SIZE * 2; pub(crate) const FR_SERIALIZED_SIZE: usize = 32; +#[inline(always)] +fn units_of_fp() -> u64 { + ((EXPECTED_SIZE + FP_SERIALIZED_SIZE - 1) / FP_SERIALIZED_SIZE) as u64 +} + impl Host { // This is the internal routine performing deserialization on various // element types, which can be conceptually decomposed into units of Fp // (the base field element), and will be charged accordingly. // Validation of the deserialized entity must be performed outside of this // function, to keep budget charging isolated. - pub(crate) fn deserialize_uncompessed_no_validate( + pub(crate) fn deserialize_uncompessed_no_validate< + const EXPECTED_SIZE: usize, + T: CanonicalDeserialize, + >( &self, slice: &[u8], - units_of_fp: u64, msg: &str, ) -> Result { - self.as_budget() - .bulk_charge(ContractCostType::Bls12381DecodeFp, units_of_fp, None)?; + if EXPECTED_SIZE == 0 || slice.len() != EXPECTED_SIZE { + return Err(self.err( + ScErrorType::Crypto, + ScErrorCode::InvalidInput, + format!("bls12-381 {msg}: invalid input length to deserialize").as_str(), + &[ + Val::from_u32(slice.len() as u32).into(), + Val::from_u32(EXPECTED_SIZE as u32).into(), + ], + )); + } + self.as_budget().bulk_charge( + ContractCostType::Bls12381DecodeFp, + units_of_fp::(), + None, + )?; // validation turned off here to isolate the cost of serialization. // proper validation has to be performed outside of this function T::deserialize_with_mode(slice, Compress::No, Validate::No).map_err(|_e| { @@ -58,15 +84,31 @@ impl Host { // This is the internal routine performing serialization on various // element types, which can be conceptually decomposed into units of Fp // (the base field element), and will be charged accordingly. - pub(crate) fn serialize_uncompressed_into_slice( + pub(crate) fn serialize_uncompressed_into_slice< + const EXPECTED_SIZE: usize, + T: CanonicalSerialize, + >( &self, element: &T, buf: &mut [u8], - units_of_fp: u64, msg: &str, ) -> Result<(), HostError> { - self.as_budget() - .bulk_charge(ContractCostType::Bls12381EncodeFp, units_of_fp, None)?; + if EXPECTED_SIZE == 0 || buf.len() != EXPECTED_SIZE { + return Err(self.err( + ScErrorType::Crypto, + ScErrorCode::InvalidInput, + format!("bls12-381 {msg}: invalid buffer length to serialize into").as_str(), + &[ + Val::from_u32(buf.len() as u32).into(), + Val::from_u32(EXPECTED_SIZE as u32).into(), + ], + )); + } + self.as_budget().bulk_charge( + ContractCostType::Bls12381EncodeFp, + units_of_fp::(), + None, + )?; element.serialize_uncompressed(buf).map_err(|_e| { self.err( ScErrorType::Crypto, @@ -136,34 +178,19 @@ impl Host { Ok(pt.is_in_correct_subgroup_assuming_on_curve()) } - pub(crate) fn g1_affine_deserialize_from_bytesobj( + pub(crate) fn affine_deserialize( &self, bo: BytesObject, + ct_curve: ContractCostType, subgroup_check: bool, - ) -> Result { - let msg: &str = "G1"; - let pt: G1Affine = self.visit_obj(bo, |bytes: &ScBytes| { - self.validate_point_encoding::(&bytes, msg)?; - // `CanonicalDeserialize` of `Affine

` calls into - // `P::deserialize_with_mode`, where `P` is `arc_bls12_381::g1::Config`, the - // core logic is in `arc_bls12_381::curves::util::read_g1_uncompressed`. - // - // The `arc_bls12_381` lib already expects the input to be serialized in - // big-endian order (aligning with the common standard and contrary - // to ark::serialize's convention), - // - // i.e. `input = be_bytes(X) || be_bytes(Y)` and the - // most-significant three bits of X are flags: - // - // `bits(X) = [compression_flag, infinity_flag, sort_flag, bit_3, .. bit_383]` - // - // internally when deserializing `Fp`, the flag bits are masked off - // to get `X: Fp`. The Y however, does not have the top bits masked off - // so it is possible for Y to exceed 381 bits. I've checked all over and - // didn't find that being an invalid condition, so we will leave them as is. - self.deserialize_uncompessed_no_validate(&bytes, 2, msg) + ct_subgroup: ContractCostType, + msg: &str, + ) -> Result, HostError> { + let pt: Affine

= self.visit_obj(bo, |bytes: &ScBytes| { + self.validate_point_encoding::(&bytes, msg)?; + self.deserialize_uncompessed_no_validate::(bytes.as_slice(), msg) })?; - if !self.check_point_is_on_curve(&pt, &ContractCostType::Bls12381G1CheckPointOnCurve)? { + if !self.check_point_is_on_curve(&pt, &ct_curve)? { return Err(self.err( ScErrorType::Crypto, ScErrorCode::InvalidInput, @@ -171,12 +198,7 @@ impl Host { &[], )); } - if subgroup_check - && !self.check_point_is_in_subgroup( - &pt, - &ContractCostType::Bls12381G1CheckPointInSubgroup, - )? - { + if subgroup_check && !self.check_point_is_in_subgroup(&pt, &ct_subgroup)? { return Err(self.err( ScErrorType::Crypto, ScErrorCode::InvalidInput, @@ -187,55 +209,66 @@ impl Host { Ok(pt) } + pub(crate) fn g1_affine_deserialize_from_bytesobj( + &self, + bo: BytesObject, + subgroup_check: bool, + ) -> Result { + // `CanonicalDeserialize` of `Affine

` calls into + // `P::deserialize_with_mode`, where `P` is `arc_bls12_381::g1::Config`, the + // core logic is in `arc_bls12_381::curves::util::read_g1_uncompressed`. + // + // The `arc_bls12_381` lib already expects the input to be serialized in + // big-endian order (aligning with the common standard and contrary + // to ark::serialize's convention), + // + // i.e. `input = be_bytes(X) || be_bytes(Y)` and the + // most-significant three bits of X are flags: + // + // `bits(X) = [compression_flag, infinity_flag, sort_flag, bit_3, .. bit_383]` + // + // internally when deserializing `Fp`, the flag bits are masked off + // to get `X: Fp`. The Y however, does not have the top bits masked off + // so it is possible for Y to exceed 381 bits. I've checked all over and + // didn't find that being an invalid condition, so we will leave them as is. + self.affine_deserialize::( + bo, + ContractCostType::Bls12381G1CheckPointOnCurve, + subgroup_check, + ContractCostType::Bls12381G1CheckPointInSubgroup, + "G1", + ) + } + pub(crate) fn g2_affine_deserialize_from_bytesobj( &self, bo: BytesObject, subgroup_check: bool, ) -> Result { - let msg: &str = "G2"; - let pt: G2Affine = self.visit_obj(bo, |bytes: &ScBytes| { - self.validate_point_encoding::(&bytes, msg)?; - // `CanonicalDeserialize` of `Affine

` calls into - // `P::deserialize_with_mode`, where `P` is `arc_bls12_381::g2::Config`, the - // core logic is in `arc_bls12_381::curves::util::read_g2_uncompressed`. - // - // The `arc_bls12_381` lib already expects the input to be serialized in - // big-endian order (aligning with the common standard and contrary - // to ark::serialize's convention), - // - // i.e. `input = be_bytes(X) || be_bytes(Y)` and the - // most-significant three bits of X are flags: - // - // `bits(X) = [compression_flag, infinity_flag, sort_flag, bit_3, .. bit_383]` - // - // internally when deserializing `Fp`, the flag bits are masked off - // to get `X: Fp`. The Y however, does not have the top bits masked off - // so it is possible for Y to exceed 381 bits. I've checked all over and - // didn't find that being an invalid condition, so we will leave them as is. - self.deserialize_uncompessed_no_validate(&bytes, 4, msg) - })?; - if !self.check_point_is_on_curve(&pt, &ContractCostType::Bls12381G2CheckPointOnCurve)? { - return Err(self.err( - ScErrorType::Crypto, - ScErrorCode::InvalidInput, - format!("bls12-381 {}: point not on curve", msg).as_str(), - &[], - )); - } - if subgroup_check - && !self.check_point_is_in_subgroup( - &pt, - &ContractCostType::Bls12381G2CheckPointInSubgroup, - )? - { - return Err(self.err( - ScErrorType::Crypto, - ScErrorCode::InvalidInput, - format!("bls12-381 {}: point not in the correct subgroup", msg).as_str(), - &[], - )); - } - Ok(pt) + // `CanonicalDeserialize` of `Affine

` calls into + // `P::deserialize_with_mode`, where `P` is `arc_bls12_381::g2::Config`, the + // core logic is in `arc_bls12_381::curves::util::read_g2_uncompressed`. + // + // The `arc_bls12_381` lib already expects the input to be serialized in + // big-endian order (aligning with the common standard and contrary + // to ark::serialize's convention), + // + // i.e. `input = be_bytes(X) || be_bytes(Y)` and the + // most-significant three bits of X are flags: + // + // `bits(X) = [compression_flag, infinity_flag, sort_flag, bit_3, .. bit_383]` + // + // internally when deserializing `Fp`, the flag bits are masked off + // to get `X: Fp`. The Y however, does not have the top bits masked off + // so it is possible for Y to exceed 381 bits. I've checked all over and + // didn't find that being an invalid condition, so we will leave them as is. + self.affine_deserialize::( + bo, + ContractCostType::Bls12381G2CheckPointOnCurve, + subgroup_check, + ContractCostType::Bls12381G2CheckPointInSubgroup, + "G2", + ) } pub(crate) fn g1_projective_into_affine( @@ -248,7 +281,7 @@ impl Host { pub(crate) fn g1_affine_serialize_uncompressed( &self, - g1: G1Affine, + g1: &G1Affine, ) -> Result { let mut buf = [0; G1_SERIALIZED_SIZE]; // `CanonicalSerialize of Affine

` calls into @@ -260,7 +293,7 @@ impl Host { // // This aligns with our chosen standard // (https://github.com/zcash/librustzcash/blob/6e0364cd42a2b3d2b958a54771ef51a8db79dd29/pairing/src/bls12_381/README.md#serialization) - self.serialize_uncompressed_into_slice(&g1, &mut buf, 2, "G1")?; + self.serialize_uncompressed_into_slice::(g1, &mut buf, "G1")?; self.add_host_object(self.scbytes_from_slice(&buf)?) } @@ -269,7 +302,7 @@ impl Host { g1: G1Projective, ) -> Result { let g1_affine = self.g1_projective_into_affine(g1)?; - self.g1_affine_serialize_uncompressed(g1_affine) + self.g1_affine_serialize_uncompressed(&g1_affine) } pub(crate) fn g2_projective_into_affine( @@ -282,7 +315,7 @@ impl Host { pub(crate) fn g2_affine_serialize_uncompressed( &self, - g2: G2Affine, + g2: &G2Affine, ) -> Result { let mut buf = [0; G2_SERIALIZED_SIZE]; // `CanonicalSerialization of Affine

` where `P` is `ark_bls12_381::curves::g2::Config`, @@ -295,7 +328,7 @@ impl Host { // `bits(X_c1) = [compression_flag, infinity_flag, sort_flag, bit_3, .. bit_383]` // // This aligns with the standard we've picked https://github.com/zcash/librustzcash/blob/6e0364cd42a2b3d2b958a54771ef51a8db79dd29/pairing/src/bls12_381/README.md#serialization - self.serialize_uncompressed_into_slice(&g2, &mut buf, 4, "G2")?; + self.serialize_uncompressed_into_slice::(g2, &mut buf, "G2")?; self.add_host_object(self.scbytes_from_slice(&buf)?) } @@ -304,7 +337,7 @@ impl Host { g2: G2Projective, ) -> Result { let g2_affine = self.g2_projective_into_affine(g2)?; - self.g2_affine_serialize_uncompressed(g2_affine) + self.g2_affine_serialize_uncompressed(&g2_affine) } pub(crate) fn fr_from_u256val(&self, sv: U256Val) -> Result { @@ -336,64 +369,57 @@ impl Host { self.map_err(U256Val::try_from_val(self, &u)) } - pub(crate) fn fp_deserialize_from_bytesobj(&self, bo: BytesObject) -> Result { - let expected_size = FP_SERIALIZED_SIZE; + pub(crate) fn field_element_deserialize( + &self, + bo: BytesObject, + msg: &str, + ) -> Result { self.visit_obj(bo, |bytes: &ScBytes| { - if bytes.len() != expected_size { + if bytes.len() != EXPECTED_SIZE { return Err(self.err( ScErrorType::Crypto, ScErrorCode::InvalidInput, - "bls12-381 field element (Fp): invalid input length to deserialize", + format!( + "bls12-381 field element {}: invalid input length to deserialize", + msg + ) + .as_str(), &[ Val::from_u32(bytes.len() as u32).into(), - Val::from_u32(expected_size as u32).into(), + Val::from_u32(EXPECTED_SIZE as u32).into(), ], )); } - // `CanonicalDeserialize for Fp` assumes input bytes in - // little-endian order, with the highest bits being empty flags. - // thus we must first reverse the bytes before passing them in. - // there is no other check for Fp besides the length check. - self.charge_budget(ContractCostType::MemCpy, Some(FP_SERIALIZED_SIZE as u64))?; - let mut buf = [0u8; FP_SERIALIZED_SIZE]; + self.charge_budget(ContractCostType::MemCpy, Some(EXPECTED_SIZE as u64))?; + let mut buf = [0u8; EXPECTED_SIZE]; buf.copy_from_slice(bytes); buf.reverse(); - self.deserialize_uncompessed_no_validate(&buf, 1, "Fp") + self.deserialize_uncompessed_no_validate::(&buf, msg) }) } + pub(crate) fn fp_deserialize_from_bytesobj(&self, bo: BytesObject) -> Result { + // `CanonicalDeserialize for Fp` assumes input bytes in + // little-endian order, with the highest bits being empty flags. + // thus we must first reverse the bytes before passing them in. + // there is no other check for Fp besides the length check. + self.field_element_deserialize::(bo, "Fp") + } + pub(crate) fn fp2_deserialize_from_bytesobj(&self, bo: BytesObject) -> Result { - let expected_size = FP2_SERIALIZED_SIZE; - self.visit_obj(bo, |bytes: &ScBytes| { - if bytes.len() != expected_size { - return Err(self.err( - ScErrorType::Crypto, - ScErrorCode::InvalidInput, - "bls12-381 quadradic extension field element (Fp2): invalid input length to deserialize", - &[ - Val::from_u32(bytes.len() as u32).into(), - Val::from_u32(expected_size as u32).into(), - ], - )); - } - // `CanonicalDeserialize for QuadExtField

` reads the first chunk, - // deserialize it into `Fp` as c0. Then repeat for c1. The - // deserialization for `Fp` follows same rules as above, where the - // bytes are expected in little-endian, with the highest bits being - // empty flags. There is no check involved. - // - // This is entirely reversed from the [standard](https://github.com/zcash/librustzcash/blob/6e0364cd42a2b3d2b958a54771ef51a8db79dd29/pairing/src/bls12_381/README.md#serialization) - // we have adopted. This is the input format we provide: - // - // `input = be_bytes(c1) || be_bytes(c0)` - // - // So we just need to reverse our input. - self.charge_budget(ContractCostType::MemCpy, Some(FP2_SERIALIZED_SIZE as u64))?; - let mut buf = [0u8; FP2_SERIALIZED_SIZE]; - buf.copy_from_slice(&bytes); - buf.reverse(); - self.deserialize_uncompessed_no_validate(&buf, 2, "Fp2") - }) + // `CanonicalDeserialize for QuadExtField

` reads the first chunk, + // deserialize it into `Fp` as c0. Then repeat for c1. The + // deserialization for `Fp` follows same rules as above, where the + // bytes are expected in little-endian, with the highest bits being + // empty flags. There is no check involved. + // + // This is entirely reversed from the [standard](https://github.com/zcash/librustzcash/blob/6e0364cd42a2b3d2b958a54771ef51a8db79dd29/pairing/src/bls12_381/README.md#serialization) + // we have adopted. This is the input format we provide: + // + // `input = be_bytes(c1) || be_bytes(c0)` + // + // So we just need to reverse our input. + self.field_element_deserialize::(bo, "Fp2") } pub(crate) fn g1_vec_from_vecobj(&self, vp: VecObject) -> Result, HostError> { @@ -527,7 +553,11 @@ impl Host { Ok(G2Projective::msm_unchecked(points, scalars)) } - pub(crate) fn map_to_curve(&self, fp: as AffineRepr>::BaseField, ty: ContractCostType) -> Result, HostError> { + pub(crate) fn map_to_curve( + &self, + fp: as AffineRepr>::BaseField, + ty: ContractCostType, + ) -> Result, HostError> { self.charge_budget(ty, None)?; // The `WBMap::new()` first calls @@ -583,7 +613,7 @@ impl Host { &self, domain: &[u8], msg: &[u8], - ty: &ContractCostType + ty: &ContractCostType, ) -> Result, HostError> { self.charge_budget(*ty, Some(msg.len() as u64))?; @@ -593,19 +623,18 @@ impl Host { // - Construction of WBMap follows the exact same analysis as map_to_curve // function earlier. // This function cannot realistically produce an error or panic. - let mapper = MapToCurveBasedHasher::< - Projective

, - DefaultFieldHasher, - WBMap

, - >::new(domain) - .map_err(|e| { - self.err( - ScErrorType::Crypto, - ScErrorCode::InternalError, - format!("hash-to-curve error {e}").as_str(), - &[], + let mapper = + MapToCurveBasedHasher::, DefaultFieldHasher, WBMap

>::new( + domain, ) - })?; + .map_err(|e| { + self.err( + ScErrorType::Crypto, + ScErrorCode::InternalError, + format!("hash-to-curve error {e}").as_str(), + &[], + ) + })?; // `ark_ec::hashing::map_to_curve_hasher::MapToCurveBasedHasher::hash` // contains the following calls diff --git a/soroban-env-host/src/host.rs b/soroban-env-host/src/host.rs index a7be6f999..8cf050b97 100644 --- a/soroban-env-host/src/host.rs +++ b/soroban-env-host/src/host.rs @@ -2979,7 +2979,7 @@ impl VmCallerEnv for Host { ) -> Result { let fp = self.fp_deserialize_from_bytesobj(fp)?; let g1 = self.map_to_curve(fp, ContractCostType::Bls12381MapFpToG1)?; - self.g1_affine_serialize_uncompressed(g1) + self.g1_affine_serialize_uncompressed(&g1) } fn bls12_381_hash_to_g1( @@ -3002,10 +3002,14 @@ impl VmCallerEnv for Host { &[], )); } - self.hash_to_curve(dst.as_slice(), msg.as_slice(), &ContractCostType::Bls12381HashToG1) + self.hash_to_curve( + dst.as_slice(), + msg.as_slice(), + &ContractCostType::Bls12381HashToG1, + ) }) })?; - self.g1_affine_serialize_uncompressed(g1) + self.g1_affine_serialize_uncompressed(&g1) } fn bls12_381_check_g2_is_in_subgroup( @@ -3094,10 +3098,14 @@ impl VmCallerEnv for Host { &[], )); } - self.hash_to_curve(dst.as_slice(), msg.as_slice(), &ContractCostType::Bls12381HashToG2) + self.hash_to_curve( + dst.as_slice(), + msg.as_slice(), + &ContractCostType::Bls12381HashToG2, + ) }) })?; - self.g2_affine_serialize_uncompressed(g2) + self.g2_affine_serialize_uncompressed(&g2) } fn bls12_381_multi_pairing_check( diff --git a/soroban-env-host/src/test/bls12_381.rs b/soroban-env-host/src/test/bls12_381.rs index 51d7a8007..2666e3eaf 100644 --- a/soroban-env-host/src/test/bls12_381.rs +++ b/soroban-env-host/src/test/bls12_381.rs @@ -5,7 +5,7 @@ use crate::{ xdr::{ScErrorCode, ScErrorType}, BytesObject, Env, EnvBase, Host, HostError, U256Val, U32Val, Val, VecObject, }; -use ark_bls12_381::{Fq, Fq2, G1Affine, G2Affine}; +use ark_bls12_381::{Fq, Fq2, Fr, G1Affine, G2Affine, FQ_ONE, FQ_ZERO}; use ark_ec::AffineRepr; use ark_ff::UniformRand; use ark_serialize::CanonicalSerialize; @@ -14,6 +14,22 @@ use rand::{rngs::StdRng, SeedableRng}; use serde::Deserialize; use std::cmp::Ordering; +impl Host { + pub(crate) fn fp_serialize_into_bytesobj(&self, fp: &Fq) -> Result { + let mut buf = [0u8; FP_SERIALIZED_SIZE]; + self.serialize_uncompressed_into_slice::(&fp, &mut buf, "Fp")?; + buf.reverse(); + self.add_host_object(self.scbytes_from_slice(&buf)?) + } + + pub(crate) fn fp2_serialize_into_bytesobj(&self, fp2: &Fq2) -> Result { + let mut buf = [0u8; FP2_SERIALIZED_SIZE]; + self.serialize_uncompressed_into_slice::(&fp2, &mut buf, "Fp")?; + buf.reverse(); + self.add_host_object(self.scbytes_from_slice(&buf)?) + } +} + enum InvalidPointTypes { TooManyBytes, TooFewBytes, @@ -75,7 +91,7 @@ fn parse_hex(s: &str) -> Vec { } fn sample_g1(host: &Host, rng: &mut StdRng) -> Result { - host.g1_affine_serialize_uncompressed(G1Affine::rand(rng)) + host.g1_affine_serialize_uncompressed(&G1Affine::rand(rng)) } fn sample_g1_not_on_curve(host: &Host, rng: &mut StdRng) -> Result { @@ -84,7 +100,7 @@ fn sample_g1_not_on_curve(host: &Host, rng: &mut StdRng) -> Result Result Result { - host.g1_affine_serialize_uncompressed(G1Affine::zero()) + host.g1_affine_serialize_uncompressed(&G1Affine::zero()) } fn neg_g1(bo: BytesObject, host: &Host) -> Result { let g1 = host.g1_affine_deserialize_from_bytesobj(bo, true)?; - host.g1_affine_serialize_uncompressed(-g1) + host.g1_affine_serialize_uncompressed(&-g1) } fn invalid_g1( @@ -117,7 +133,7 @@ fn invalid_g1( ) -> Result { let affine = G1Affine::rand(rng); assert!(!affine.is_zero()); - let bo = host.g1_affine_serialize_uncompressed(affine)?; + let bo = host.g1_affine_serialize_uncompressed(&affine)?; match ty { InvalidPointTypes::TooManyBytes => { // insert an empty byte to the end @@ -148,7 +164,7 @@ fn invalid_g1( } fn sample_g2(host: &Host, rng: &mut StdRng) -> Result { - host.g2_affine_serialize_uncompressed(G2Affine::rand(rng)) + host.g2_affine_serialize_uncompressed(&G2Affine::rand(rng)) } fn sample_g2_not_on_curve(host: &Host, rng: &mut StdRng) -> Result { @@ -157,7 +173,7 @@ fn sample_g2_not_on_curve(host: &Host, rng: &mut StdRng) -> Result Result Result { - host.g2_affine_serialize_uncompressed(G2Affine::zero()) + host.g2_affine_serialize_uncompressed(&G2Affine::zero()) } fn neg_g2(bo: BytesObject, host: &Host) -> Result { let g2 = host.g2_affine_deserialize_from_bytesobj(bo, true)?; - host.g2_affine_serialize_uncompressed(-g2) + host.g2_affine_serialize_uncompressed(&-g2) } fn invalid_g2( @@ -190,7 +206,7 @@ fn invalid_g2( ) -> Result { let affine = G2Affine::rand(rng); assert!(!affine.is_zero()); - let bo = host.g2_affine_serialize_uncompressed(affine)?; + let bo = host.g2_affine_serialize_uncompressed(&affine)?; match ty { InvalidPointTypes::TooManyBytes => { // insert an empty byte to the end @@ -238,9 +254,7 @@ fn parse_g2_point_test_case(host: &Host, p: Point) -> Result Result { let fp = Fq::rand(rng); - let mut buf = [0u8; FP_SERIALIZED_SIZE]; - host.serialize_uncompressed_into_slice(&fp, &mut buf, 1, "test")?; - host.bytes_new_from_slice(&buf) + host.fp_serialize_into_bytesobj(&fp) } fn invalid_fp( @@ -252,12 +266,12 @@ fn invalid_fp( match ty { InvalidPointTypes::TooManyBytes => { let mut buf = [0u8; FP_SERIALIZED_SIZE + 1]; // one extra zero byte - host.serialize_uncompressed_into_slice(&fp, &mut buf, 1, "test")?; + host.serialize_uncompressed_into_slice::<49, _>(&fp, &mut buf, "test")?; host.bytes_new_from_slice(&buf) } InvalidPointTypes::TooFewBytes => { let mut buf = [0u8; FP_SERIALIZED_SIZE]; - host.serialize_uncompressed_into_slice(&fp, &mut buf, 1, "test")?; + host.serialize_uncompressed_into_slice::(&fp, &mut buf, "test")?; host.bytes_new_from_slice(&buf[0..FP_SERIALIZED_SIZE - 1]) // take one less byte } _ => panic!("not available"), @@ -266,10 +280,8 @@ fn invalid_fp( #[allow(unused)] fn sample_fp2(host: &Host, rng: &mut StdRng) -> Result { - let fp = Fq2::rand(rng); - let mut buf = [0u8; FP2_SERIALIZED_SIZE]; - host.serialize_uncompressed_into_slice(&fp, &mut buf, 1, "test")?; - host.bytes_new_from_slice(&buf) + let fp2 = Fq2::rand(rng); + host.fp2_serialize_into_bytesobj(&fp2) } fn invalid_fp2( @@ -281,12 +293,14 @@ fn invalid_fp2( match ty { InvalidPointTypes::TooManyBytes => { let mut buf = [0u8; FP2_SERIALIZED_SIZE + 1]; // one extra zero byte - host.serialize_uncompressed_into_slice(&fp, &mut buf, 1, "test")?; + host.serialize_uncompressed_into_slice::<97, _>(&fp, &mut buf, "test")?; host.bytes_new_from_slice(&buf) } InvalidPointTypes::TooFewBytes => { let mut buf = [0u8; FP2_SERIALIZED_SIZE]; - host.serialize_uncompressed_into_slice(&fp, &mut buf, 1, "test")?; + host.serialize_uncompressed_into_slice::( + &fp, &mut buf, "test", + )?; host.bytes_new_from_slice(&buf[0..FP2_SERIALIZED_SIZE - 1]) // take one less byte } _ => panic!("not available"), @@ -303,9 +317,8 @@ fn sample_fr(host: &Host, rng: &mut StdRng) -> Result { Ok(obj.into()) } -fn sample_host_vec( +fn sample_host_vec( host: &Host, - buf_size: usize, vec_len: usize, rng: &mut StdRng, ) -> Result { @@ -313,8 +326,8 @@ fn sample_host_vec( .into_iter() .map(|_| { let t = T::rand(rng); - let mut buf = vec![0; buf_size]; - host.serialize_uncompressed_into_slice(&t, &mut buf, 1, "test") + let mut buf = vec![0; EXPECTED_SIZE]; + host.serialize_uncompressed_into_slice::(&t, &mut buf, "test") .unwrap(); host.bytes_new_from_slice(&buf).unwrap().to_val() }) @@ -672,7 +685,7 @@ fn g1_msm() -> Result<(), HostError> { } // vector lengths not equal { - let vp = sample_host_vec::(&host, G1_SERIALIZED_SIZE, 2, &mut rng)?; + let vp = sample_host_vec::(&host, 2, &mut rng)?; let vs = sample_fr_vec(&host, 3, &mut rng)?; assert!(HostError::result_matches_err( host.bls12_381_g1_msm(vp, vs), @@ -704,7 +717,7 @@ fn g1_msm() -> Result<(), HostError> { } // vector of zero scalars result in zero point { - let vp = sample_host_vec::(&host, G1_SERIALIZED_SIZE, 3, &mut rng)?; + let vp = sample_host_vec::(&host, 3, &mut rng)?; let vs = host.vec_new_from_slice(&[U256Val::from_u32(0).to_val(); 3])?; let res = host.bls12_381_g1_msm(vp, vs)?; assert_eq!( @@ -772,7 +785,7 @@ fn g1_msm() -> Result<(), HostError> { // 8. msm result is same as invidial mul and add { host.budget_ref().reset_default()?; - let vp = sample_host_vec::(&host, G1_SERIALIZED_SIZE, 10, &mut rng)?; + let vp = sample_host_vec::(&host, 10, &mut rng)?; let vs = sample_fr_vec(&host, 10, &mut rng)?; let ref_res = host.bls12_381_g1_msm(vp, vs)?; let mut res = g1_zero(&host)?; @@ -1211,7 +1224,7 @@ fn g2_msm() -> Result<(), HostError> { } // vector lengths not equal { - let vp = sample_host_vec::(&host, G2_SERIALIZED_SIZE, 2, &mut rng)?; + let vp = sample_host_vec::(&host, 2, &mut rng)?; let vs = sample_fr_vec(&host, 3, &mut rng)?; assert!(HostError::result_matches_err( host.bls12_381_g2_msm(vp, vs), @@ -1243,7 +1256,7 @@ fn g2_msm() -> Result<(), HostError> { } // vector of zero scalars result in zero point { - let vp = sample_host_vec::(&host, G2_SERIALIZED_SIZE, 3, &mut rng)?; + let vp = sample_host_vec::(&host, 3, &mut rng)?; let vs = host.vec_new_from_slice(&[U256Val::from_u32(0).to_val(); 3])?; let res = host.bls12_381_g2_msm(vp, vs)?; assert_eq!( @@ -1311,7 +1324,7 @@ fn g2_msm() -> Result<(), HostError> { // 8. msm result is same as invidial mul and add { host.budget_ref().reset_default()?; - let vp = sample_host_vec::(&host, G2_SERIALIZED_SIZE, 5, &mut rng)?; + let vp = sample_host_vec::(&host, 5, &mut rng)?; let vs = sample_fr_vec(&host, 5, &mut rng)?; let ref_res = host.bls12_381_g2_msm(vp, vs)?; let mut res = g2_zero(&host)?; @@ -1432,8 +1445,8 @@ fn pairing() -> Result<(), HostError> { host.enable_debug()?; // 1. vector lengths don't match { - let vp1 = sample_host_vec::(&host, G1_SERIALIZED_SIZE, 3, &mut rng)?; - let vp2 = sample_host_vec::(&host, G2_SERIALIZED_SIZE, 2, &mut rng)?; + let vp1 = sample_host_vec::(&host, 3, &mut rng)?; + let vp2 = sample_host_vec::(&host, 2, &mut rng)?; assert!(HostError::result_matches_err( host.bls12_381_multi_pairing_check(vp1, vp2), (ScErrorType::Crypto, ScErrorCode::InvalidInput) @@ -1441,8 +1454,8 @@ fn pairing() -> Result<(), HostError> { } // 2. vector length is 0 { - let vp1 = sample_host_vec::(&host, G1_SERIALIZED_SIZE, 0, &mut rng)?; - let vp2 = sample_host_vec::(&host, G2_SERIALIZED_SIZE, 0, &mut rng)?; + let vp1 = sample_host_vec::(&host, 0, &mut rng)?; + let vp2 = sample_host_vec::(&host, 0, &mut rng)?; assert!(HostError::result_matches_err( host.bls12_381_multi_pairing_check(vp1, vp2), (ScErrorType::Crypto, ScErrorCode::InvalidInput) @@ -1450,13 +1463,13 @@ fn pairing() -> Result<(), HostError> { } // 3. any g1 is invalid { - let mut vp1 = sample_host_vec::(&host, G1_SERIALIZED_SIZE, 3, &mut rng)?; + let mut vp1 = sample_host_vec::(&host, 3, &mut rng)?; vp1 = host.vec_put( vp1, U32Val::from(1), sample_g1_not_in_subgroup(&host, &mut rng)?.to_val(), )?; - let vp2 = sample_host_vec::(&host, G2_SERIALIZED_SIZE, 2, &mut rng)?; + let vp2 = sample_host_vec::(&host, 2, &mut rng)?; assert!(HostError::result_matches_err( host.bls12_381_multi_pairing_check(vp1, vp2), (ScErrorType::Crypto, ScErrorCode::InvalidInput) @@ -1464,8 +1477,8 @@ fn pairing() -> Result<(), HostError> { } // 4. any g2 is invalid { - let vp1 = sample_host_vec::(&host, G1_SERIALIZED_SIZE, 3, &mut rng)?; - let mut vp2 = sample_host_vec::(&host, G2_SERIALIZED_SIZE, 3, &mut rng)?; + let vp1 = sample_host_vec::(&host, 3, &mut rng)?; + let mut vp2 = sample_host_vec::(&host, 3, &mut rng)?; vp2 = host.vec_put( vp2, U32Val::from(1), @@ -1533,16 +1546,16 @@ fn pairing() -> Result<(), HostError> { // 8. any of g1 point is infinity { host.budget_ref().reset_default()?; - let mut vp1 = sample_host_vec::(&host, G1_SERIALIZED_SIZE, 3, &mut rng)?; + let mut vp1 = sample_host_vec::(&host, 3, &mut rng)?; vp1 = host.vec_put(vp1, U32Val::from(1), g1_zero(&host)?.to_val())?; - let vp2 = sample_host_vec::(&host, G2_SERIALIZED_SIZE, 3, &mut rng)?; + let vp2 = sample_host_vec::(&host, 3, &mut rng)?; assert!(host.bls12_381_multi_pairing_check(vp1, vp2).is_ok()); } // 9. any of g2 point is infinity { host.budget_ref().reset_default()?; - let vp1 = sample_host_vec::(&host, G1_SERIALIZED_SIZE, 3, &mut rng)?; - let mut vp2 = sample_host_vec::(&host, G2_SERIALIZED_SIZE, 3, &mut rng)?; + let vp1 = sample_host_vec::(&host, 3, &mut rng)?; + let mut vp2 = sample_host_vec::(&host, 3, &mut rng)?; vp2 = host.vec_put(vp2, U32Val::from(2), g2_zero(&host)?.to_val())?; assert!(host.bls12_381_multi_pairing_check(vp1, vp2).is_ok()); } @@ -1556,10 +1569,130 @@ fn pairing() -> Result<(), HostError> { Ok(()) } -// ethereum test - // fr arithmetics // serialization roundtrip - -// fuzzing tests +#[test] +fn test_serialization_roundtrip() -> Result<(), HostError> { + let mut rng = StdRng::from_seed([0xff; 32]); + let host = observe_host!(Host::test_host()); + host.enable_debug()?; + // g1 + { + let g1_roundtrip_check = |g1: &G1Affine, subgroup_check: bool| -> Result { + let bo = host.g1_affine_serialize_uncompressed(&g1)?; + let g1_back = host.g1_affine_deserialize_from_bytesobj(bo, subgroup_check)?; + Ok(g1.eq(&g1_back)) + }; + assert!(g1_roundtrip_check(&G1Affine::zero(), true)?); + assert!(g1_roundtrip_check(&G1Affine::generator(), true)?); + for _ in 0..20 { + // on curve and in subgroup + let g1 = G1Affine::rand(&mut rng); + assert!(g1_roundtrip_check(&g1, true)?) + } + for i in 0..10 { + // on curve and not in subgroup + let g1 = G1Affine::get_point_from_x_unchecked(Fq::rand(&mut rng), (i % 2) != 0) + .unwrap_or(G1Affine::zero()); + assert!(g1_roundtrip_check(&g1, false)?); + if !g1.is_in_correct_subgroup_assuming_on_curve() { + assert!(HostError::result_matches_err( + g1_roundtrip_check(&g1, true), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + } + for _ in 0..10 { + // not on curve + let g1 = G1Affine::new_unchecked(Fq::rand(&mut rng), Fq::rand(&mut rng)); + if g1.is_on_curve() { + continue; + } + assert!(HostError::result_matches_err( + g1_roundtrip_check(&g1, false), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + } + // g2 + { + let g2_roundtrip_check = |g2: &G2Affine, subgroup_check: bool| -> Result { + let bo = host.g2_affine_serialize_uncompressed(&g2)?; + let g2_back = host.g2_affine_deserialize_from_bytesobj(bo, subgroup_check)?; + Ok(g2.eq(&g2_back)) + }; + assert!(g2_roundtrip_check(&G2Affine::zero(), true)?); + assert!(g2_roundtrip_check(&G2Affine::generator(), true)?); + for _ in 0..20 { + // on curve and in subgroup + let g2 = G2Affine::rand(&mut rng); + assert!(g2_roundtrip_check(&g2, true)?) + } + for i in 0..10 { + // on curve and not in subgroup + let g2 = G2Affine::get_point_from_x_unchecked(Fq2::rand(&mut rng), (i % 2) != 0) + .unwrap_or(G2Affine::zero()); + assert!(g2_roundtrip_check(&g2, false)?); + if !g2.is_in_correct_subgroup_assuming_on_curve() { + assert!(HostError::result_matches_err( + g2_roundtrip_check(&g2, true), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + } + for _ in 0..10 { + // not on curve + let g2 = G2Affine::new_unchecked(Fq2::rand(&mut rng), Fq2::rand(&mut rng)); + if g2.is_on_curve() { + continue; + } + assert!(HostError::result_matches_err( + g2_roundtrip_check(&g2, false), + (ScErrorType::Crypto, ScErrorCode::InvalidInput) + )); + } + } + // fp + { + let fp_roundtrip_check = |fp: &Fq| -> Result { + let mut buf = [0; FP_SERIALIZED_SIZE]; + host.serialize_uncompressed_into_slice::(fp, &mut buf, "Fp")?; + buf.reverse(); + let bo = host.add_host_object(host.scbytes_from_slice(&buf)?)?; + let fp_back = host.fp_deserialize_from_bytesobj(bo)?; + Ok(fp.eq(&fp_back)) + }; + assert!(fp_roundtrip_check(&FQ_ZERO)?); + assert!(fp_roundtrip_check(&FQ_ONE)?); + for _ in 0..20 { + assert!(fp_roundtrip_check(&Fq::rand(&mut rng))?) + } + } + // fp2 + { + let fp2_roundtrip_check = |fp2: &Fq2| -> Result { + let mut buf = [0; FP2_SERIALIZED_SIZE]; + host.serialize_uncompressed_into_slice::(fp2, &mut buf, "Fp2")?; + buf.reverse(); + let bo = host.add_host_object(host.scbytes_from_slice(&buf)?)?; + let fp2_back = host.fp2_deserialize_from_bytesobj(bo)?; + Ok(fp2.eq(&fp2_back)) + }; + for _ in 0..20 { + assert!(fp2_roundtrip_check(&Fq2::rand(&mut rng))?) + } + } + // fr + { + let fr_roundtrip_check = |fr: Fr| -> Result { + let uv = host.fr_to_u256val(fr.clone())?; + let fr_back = host.fr_from_u256val(uv)?; + Ok(fr == fr_back) + }; + for _ in 0..20 { + assert!(fr_roundtrip_check(Fr::rand(&mut rng))?) + } + } + Ok(()) +}