From 0ac8aa495ca122a98c52c083e67cc544565ba061 Mon Sep 17 00:00:00 2001 From: arvidn Date: Thu, 15 Jun 2023 10:41:42 +0200 Subject: [PATCH] adjust the cost of secp256k1_verify upwards by 450k --- op-tests/test-secp-verify.txt | 2 +- op-tests/test-secp256k1.txt | 78 +++++++++++++-------------- src/chia_dialect.rs | 4 +- src/run_program.rs | 4 +- src/secp_ops.rs | 2 +- src/test_ops.rs | 2 +- tools/generate-secp256k1-tests.py | 2 +- tools/src/bin/benchmark-clvm-cost.rs | 2 +- tools/src/bin/generate-fuzz-corpus.rs | 2 +- 9 files changed, 49 insertions(+), 49 deletions(-) diff --git a/op-tests/test-secp-verify.txt b/op-tests/test-secp-verify.txt index 4a267486..63eea650 100644 --- a/op-tests/test-secp-verify.txt +++ b/op-tests/test-secp-verify.txt @@ -1,5 +1,5 @@ ; verify k1 -secp256k1_verify 0x02888b0c110ef0b4962e3fc6929cbba7a8bb25b4b2c885f55c76365018c909b439 0x74c2941eb2ebe5aa4f2287a4c5e506a6290c045004058de97a7edf0122548668 0x1acb7a6e062e78ccd4237b12c22f02b5a8d9b33cb3ba13c35e88e036baa1cbca75253bb9a96ffc48b43196c69c2972d8f965b1baa4e52348d8081cde65e6c018 => 0 | 850000 +secp256k1_verify 0x02888b0c110ef0b4962e3fc6929cbba7a8bb25b4b2c885f55c76365018c909b439 0x74c2941eb2ebe5aa4f2287a4c5e506a6290c045004058de97a7edf0122548668 0x1acb7a6e062e78ccd4237b12c22f02b5a8d9b33cb3ba13c35e88e036baa1cbca75253bb9a96ffc48b43196c69c2972d8f965b1baa4e52348d8081cde65e6c018 => 0 | 1300000 secp256k1_verify 0x02888b0c110ef0b4962e3fc6929cbba7a8bb25b4b2c885f55c76365018c909b439 0x74c2941eb2ebe5aa4f2287a4c5e506a6290c045004058de97a7edf0122548668 0x1acb7a6e062e78ccd4237b12c22f02b5a8d9b33cb3ba13c35e88e036baa1cbca75253bb9a96ffc48b43196c69c2972d8f965b1baa4e52348d8081cde65e6c019 => FAIL ; arguments too long diff --git a/op-tests/test-secp256k1.txt b/op-tests/test-secp256k1.txt index bc5ead51..14d1e94d 100644 --- a/op-tests/test-secp256k1.txt +++ b/op-tests/test-secp256k1.txt @@ -1,41 +1,41 @@ ; This file was generated by tools/generate-secp256k1-tests.py -secp256k1_verify 0x028bb490a35003c5e7ad4b22c70bfe209e7318a993b64744125a8d03f5894b310e 0x85932e4d075615be881398cc765f9f78204033f0ef5f832ac37e732f5f0cbda2 0x9213730efc55264645506993b3c17a3d6f228a9116de7866c2eca53eef5ef0ba591400683c5741402416b887c1716441d038c3614a6a76206076eea1e2b29cbd => 0 | 850000 -secp256k1_verify 0x030763619f00c856f3b2a8c3841d84da30e45cbb2f84a59016c4107dd7a5915a73 0x23a02777185712876787e32ba4b9800fa8dff0ad846e5769d9f5d57ecde10ab3 0xaa598f576a7a740560d82dca58c7846e3c3634d4cd67769620e0ab3f5313d0c72d884d64cc42e1650e2d3f5e4eb79ee9fe56559d45584cc1fe4d831cf1ac7b06 => 0 | 850000 -secp256k1_verify 0x025b76e818db00f938392d0a4031b80ca0af0105d3c2b72b03114115d1584059be 0x222b25aef8c0c85aa429f3efc19027743bad43615a8dd4e84e435c55af352e7a 0x43e59f19ae6c613811769b81d4b2768960c0240b1faa9ff792564c012fddc56957331f9c3dd5eecd2d7d818f03bddff78873c9a259ec8a0671b5833e625e9ca5 => 0 | 850000 -secp256k1_verify 0x0315c699d5a3515609a67a5f6755fd8153efbe0fd9cb1b4a454fd6c9fadb97a7cf 0x87c4d4aec1bc8cd850199319dde457ecc47af37bff4fed285c0d8acc501ef1cc 0x3afd8b6392b72c276f9b19e8d42e5ae6b7f473b4196d3427f57c0b4cb4e05d0c1185df3caf14d445966be4d2b5ec6a40d8478af42f9c930b0959a3f24e6f51df => 0 | 850000 -secp256k1_verify 0x02bd204c3d266eeb3288af023e455f19e889ae8c0ca4935b196dec72d02940d68c 0xd36eaf1c8f6f9b25a0008b44d49027818f421687187cd4a121e66f1cb8a67e0a 0x3a2344da7aa72eb596ee43f5df314ef1514be757b564a6d17fc9c1dc18b086457bed1d51bad1f8587554ef973f80f42dd47c2244736070dc42725dd0cb9b1150 => 0 | 850000 -secp256k1_verify 0x031afa2fac2fb07f98a8f2f158cc886a2003dcebead5ffeff5a6b38366b2cb11aa 0x147ec91f141bc05c902084c80649d64eef0bd2b5c32fdfc568a35436bea540e4 0x8c95233f99c72648e4dbe7c256914b39f953a1be51ffe2862cee1cfbd96fc6a641c7b02d9384b6b4fd30f7de54ef7b3022b71bb3074141e02ebce04312819311 => 0 | 850000 -secp256k1_verify 0x038aed4fbf23bc59c030cff8b0291b20fadacf6bcf4c0d8b97b2ba0e5683751343 0x369215c4a473669292fed192a5ae1a9aa641afe10d3ec4d0b455cfad5791d462 0xc0dfe41a5d0c0e34a4138133c3aa7659157eac6a5a7e77f8b041db5f1dd8578f54f0469f6178c9605a09aa231d9cae2267c33f5304a44979e97017f7d0dd6299 => 0 | 850000 -secp256k1_verify 0x02ac0ac696843fdcce44ef1237635cc8edcb78e3efdff55ec7829aca83817f471d 0x08d5b309f5897d54cd3d1eb4ea9165af063d3aff27bd2756fbc64e844f38afbe 0xeb5b619b0250a1ccd5d931e9a2c4a6ad951186bfeb674af3d674b5270ed655bb4f048a390efba8168ea52d933c1afda53fba692acd8b13ccadfcbaa9015688a1 => 0 | 850000 -secp256k1_verify 0x02364a773be0321384d540009ba2441e768481e6c08bbe0408756f746c852af8ee 0xaffd750fb25272c2e8670b1231f0acd61e0539eadb47cf23efa4fc4984fde036 0xc8f498aae0c3083946bbe392d5fcbfc86c54dfaf153580e30fd10152b4c495e617f027b5bc1cf5b4f156b7a6679b5194e3fffef67e87813e14884632cb265738 => 0 | 850000 -secp256k1_verify 0x039a785d7f1fc9833467a89c5f6d1a4eff7c5df647a637c6257a1f0bd222b99fa3 0x2c090ec4147adb7af6d2fcfeadb95bb7f0256e26a6cab4ef83aaf005491e7da3 0x805bb93a1883b471dd8fbd04b1808e029d22d6c65895f80a8d3f5c1db8a0d2ef0120ddbc8c0bd31c07933532de58306ac94c3578736819c3efa86bd132adac87 => 0 | 850000 -secp256k1_verify 0x02afe7eee5e0f6b4d8f3555bc4e49af414db818f35f4d3fbe857408b441d6d99cb 0xdb104e9c6fe422bfad4efb4d60f6b69703f59fe139c1bccbb4ad8e26c59bbdfc 0xa46d08ef84e3737ba7e6a8988930166944f04d476ea7831fbaaa5ff105260c1913518e20c9ef9d2ff3e1742c42cb43564d4e343758461ddbc039290a1b8d81bd => 0 | 850000 -secp256k1_verify 0x03f8b1ffaab6100ad049ed9a2b881a14bc921355616ca932acf6995e59336a2362 0x41bd0a80ef7761bf998254cf56f1daf89460a66edc6b40689ed4a660b4d5ec0a 0xe67d34e19221be4200c83186c73b93361982edf6cd50bd645ce5edf3572371392dc2f4bb3a323acd5d05cd6bc486bfb19041d172746621f276c9c0fa4d652e2d => 0 | 850000 -secp256k1_verify 0x02e75a5fbdb58cb0db7e11969f190326dc1bb2d5b40d32b47f104a295e53f9bebe 0xdc3c455519f7d3206b8ee435c944b7de1f99fa7f5b645f6d79cec4658cd3f313 0xa5cc79c6acde175921a57c6132ae06ef22c38440afa12dfb6da42e57437d7a803c86878b07e7e7e040aba0d8f98bd7c2e7706a58d50473f64b70ab0ac8d4aeb1 => 0 | 850000 -secp256k1_verify 0x023d6276af9da5e6a9910a5f52feb30843afcbaff8833f7f000bc63b6453a23690 0xc8f9a4a27bbc1af837fd415e6241285e4b95c0ce74600c81ded086ebcc74547f 0x9ec2ad2d679a50d90fa4e6d9097d98ed4e9ddea8800b38b55d01fd4caed8b8a86849f3d7feb9cc965e19b088cc34e167a1be04b57a68dcc61a880c4ba831cfe9 => 0 | 850000 -secp256k1_verify 0x022497b8aa90db61882c610f41877a3c94e30a51c9cc6e1bfa20abba71b04fdab8 0xea89d66edf25352d44ca5b1670a0c46255d51ef20ca5d0649b1b6450c1df4984 0x6a5ad7658c523a44ab238aff8b17368994dcbddbe9848036eca08bd286d825d20b6ca7209c081a75025c0d351aadb9ec85475a825ce8b008e46ec6c75b71f0c3 => 0 | 850000 -secp256k1_verify 0x03a9647301153f3a673231b4eb4bf8ce3ac3eb47a46d4ecc7d8b2b513128473930 0xc32749548ab386ad3930f6f1dd2a85c5063563eeb99ef633ed1fd648aabb22a2 0xf63d3f55662d414b439b66aad45dac0652c235e4b7d9f9ba056ed855ab32cab07c1852de59878bd33a96483cde4acb0e4b9bd5583836ad5ca08c22d2bb32488d => 0 | 850000 -secp256k1_verify 0x0288e7e29d9ea7abe2d8c7f2f8ae5670553861d248a0462f8a7b8c65148ba4c107 0x728395357573930ab93762774ccd98edf66db24039c08e59f76d1bbaeefe6379 0x1773bf5088f801b00e0ea5ebce25ce2875c41bdaff0a19d895a818131241542d1e31b0ea04221bdc5e4f88926b8714138dca607f7d1ad22453b52721353ad4db => 0 | 850000 -secp256k1_verify 0x03f0ba054b09ed58f510081ef87edf62193d8d3cece12b43749890fa53fc2146ba 0x4531ac1e89c712279be237a9da1f9eda8c4ed21a3112ef5c521d1cff849b4772 0xfc899da2725161a2e7ac4cde7c2170bc31a971c25e1b269d5cdb29642f323d2754fb3a93d060603c5e5f8582e96791cff4d8323cce0d04a7866b241cac1ee116 => 0 | 850000 -secp256k1_verify 0x02cf07e9a0a85afcb65d2cc4e0958a33fca3d2d665c1cf08b9cdb62875078bc90d 0xb0124a8df2a9d2c52f1ff75b6fd0b26189f963fc0dbbff9bfa64ac3efdfa7efd 0x4dc90dff0ef84f03efa7a970b30555e4ce6d367263afd38dcbfdbb2618e5c6130d507430cdad63ef546568e031b4009923e15348a2785f4d9f4acc8d1201463d => 0 | 850000 -secp256k1_verify 0x033085019044fd85e567f06b96a572e940fd7312df96c1c8ebac97f02ae5e405d0 0xa4a82d915744b1646bec9d8de7c1261d2f8034594da88c07d5b644e12fb78fa8 0x95bc79b70e262d0828a8f81eac758755785cc0f5a242d1d06160dd25ca52b15d42a166775f2dcdc7232b1cf9152f3f24778b6915f329ae8b9b7e53b12ec43eaa => 0 | 850000 -secp256k1_verify 0x03c601576c80ac0f0c0c6bf87780f0239a64ef9081cc93d08001636127a8878264 0x0e6d6511259dd00c6894752091ae31c1e92eb594cec5bfce874ddeb1074c4a8e 0xbac28c9f8046f2b8be38824315d40c25686fd69c142b0cb0edb8022ccce80978286ec7cdd88b43707dcb8d9867a4a733a0c1637961e5608c640385993bc80452 => 0 | 850000 -secp256k1_verify 0x03ba36e64074c0ea7781c421f89241222486a4eacbd1b17b9d2ea0d340f9e0df84 0x4742e3be54ab22db1ffcb63ac90a34384b1b2da07968d816556c9488c6342ff7 0x23de22f7cd51939a39935b657c3eeb2d3ad727c2a0f5ea974b453b96839357e618d54effa3e000a05dfe1a3b2348fc175caeedcebdfee9381b9b93a489aba566 => 0 | 850000 -secp256k1_verify 0x0261bdffdf9f2128b9e30706d21d16f394dad15a8ba6b11c83e2e89954573f8fb8 0x764930461dc2636cbad399be0ab3a0484f12b2289bc62c9c65b227d3d15d9331 0x5e374aad58c8f33dfa8f1b76ae0afb2d87979a3ef295e198933191c2071185a569320cbaa5de6a7c4dc1f89ab10c14f5dbd490e109bf32c0a6cf8f4ce2a04b9c => 0 | 850000 -secp256k1_verify 0x024c486edf4db677c576ba3a93fc55560107db03a2d840aef2d42583c8bc5d79f0 0x25624809df04f74c21af8bd16b33c3922490caf0920fe7ce0890b1c12c2b1f7e 0x3f19b909b887776227df84a58f38ab1d309d1cca0ff55daec79397b71570d3fa23731ce8aac5a38a3031da95c9321551408f561ca266da297192fd84e7827296 => 0 | 850000 -secp256k1_verify 0x034199e60bfc9d57c33e6ccc7e8ba407560c4b13262c25e0ac5fecf6df07f1d298 0x0374d1fc889af2526b24fc3e09068eff4403c28d482b240e3fac512482198f38 0xd64eee71ee781211263120b071930d19357acdf6377cf6cd8b7621a5f48985b15313bc745ddabcbb8b14836f5418f9ccbe63f66ce19ac3bfef55e492494592c0 => 0 | 850000 -secp256k1_verify 0x03d97dc47b6ae6d74ee013e0511cf1a14e768fdd47af0edda270b49c3034bcdab6 0x44b54aed8cffdbf091cebf733b3b448da3ea3bdecf4c4245616031fe51cb22c4 0x5b8f0272ba43a930efb1bc4e5b2be449cd3a45ee0c07f963a6477037271654aa33e6736f9b24084944987a52a54aef99a7ede47a5a44e88942694b3bfe88a6a0 => 0 | 850000 -secp256k1_verify 0x0203e94824ac4475813e3ca5412b0352b8cc061f30501f68892047b109bb4d6a51 0xc9eaff05fa43de1dea678859575344cc9497f8efbd7903ceb5ecec00525d9eae 0xa52eaf75bfc94371ed821295870d53fc6b8ecc55999af2faae6284b4846e33ec02671e480a158227d4f499fa87a51b87d9f8de8690935208ba3509746b87747f => 0 | 850000 -secp256k1_verify 0x02ff73c028db3318345aeff3d29f72e98e4d73beecfee1d0322b26b4c4a1e2b7dd 0xd3b91c33942efacc55cb620e31dc020d3d3a585b44a7eee2c42623dad052cf5d 0x8ec6f72515b8131559970102d356aac70ef471aec26bd4b6d19ee20dcaa9250b56963419942f2503d55742310d17941e0e5d2844887e87d4d86b3b6d25f43052 => 0 | 850000 -secp256k1_verify 0x0244913945a534e0f4a7fcd5da183f65badc1168447f5e3a70082fced142dcb79e 0x9243e5958a207cc63725f619124483b9fd99ca24a155089fd9e037f25c58acce 0xba9178b04cecffbd87da8397b7ccac84254631ab3bae763e2bc9f1b5783217bc7b892ec7cb98f0bba1cc6b5da6162b9a32583fb0490f97501bee5a9175668156 => 0 | 850000 -secp256k1_verify 0x021e023532f625fa4b80e35831f07976d046629f5ffc5f9bdc32a6328521847295 0x9940a483e428c608f1f9aa2f7816f6caa23f6044f1d37dff304f89a650ee734e 0x378bd9bbb548f2bb01d8d8824193ee9d5a4b4f0c7d6372af3a3fb5d2446ab3ef256a4f900989c35cb419fe6d55a856cc0fe99b234418ff4e1ceba60b3c58e648 => 0 | 850000 -secp256k1_verify 0x039a78dd7f1fc9833467a89c5f6d1a4eff7c5df647a637c6257a1f0bd222b99fa3 0x935d863e2d28d8e5d399ea8af7393ef11fdffc7d862dcc6b5217a8ef15fb5442 0x9048ea133c5089410edad375ca3b0f1af6b762ac7f6c5f471b038fc1b0ecee8c588ad1bd8728122f7524098e7e1b9ab709c0104e24843e044179666df8f82922 => FAIL -secp256k1_verify 0x021e023532f625fa4b80e35831f07976d044629f5ffc5f9bdc32a6328521847295 0x0847bede50a2174a361c292ae89c6a7f2b511ea957d379e25cae1d4dbc3a9039 0xb3ac654913e3701de7f05daa516965fa548b26f0883011d6374bc465289b01ac0da571a16fdcd25aa164a79cc3caa140738d9a9a4a65268181ef8fab6f01a68a => FAIL -secp256k1_verify 0x03a9e47301153f3a673231b4eb4bf8ce3ac3eb47a46d4ecc7d8b2b513128473930 0x4f2f997d37ef9978e517f61da2ead60b422ef1ff3b537e84ba9aa7a7afd9a3ee 0xc3b98932d14f32004a62474af1046efe00df4b611c3a7ebbfc3dd955fd29fa155c8295dbf8a3b2d9f1d862615e7ac9fbba26a5635aa9a3f999e42254d7fbc85e => FAIL -secp256k1_verify 0x03f8b1ffaab6100ad049ed9a2b881a14bc921355616ca932acf6995e59336a2362 0xc89e4fe7c56483c6d9a4fe8b5fdf983697db0b027a8daab81e908282e39f3401 0x96901ed43e39825f7a21c379187a6c793a1f1dca0ee0f167111bfc774f81e3c6354fa5d29e3a6be879cc12dbf86807f47b397812f667fb487b0e5a3a88592033 => FAIL -secp256k1_verify 0x0203e94824ac4475813e3ca5412b0352b8cc061f30501f68892047b109bb4d6a51 0x7e06c2a825c043f6fd8400ddaed28cdb9a297aa8aa71d8ba004cf685e34cbbbe 0xb90ef95be55d0c0f9c6ad3bdf3c465196ab8e041076348e480950b278764802302b3d2ab67c5638c845aa7428c3c3bf6d29635a9e066107a282f18485e88d54d => FAIL -secp256k1_verify 0x021e023532f625fa4b80e35831f07976d046629f5ffc5f9bdc32a6328521847295 0x63da4d356c8712477fa28d5d0bf2a5ae8da1b0fdbec3541c2b9e2e6ce9bf5548 0x7dfae5d2ec1a4d146d3c363d0f911fc7a009d23c696537d170151f538056e7995c65207a664f84d9367601612791fe0a943961c0f7e60e2a0b21357cae5e8cd3 => FAIL -secp256k1_verify 0x025b76e818db00f938392d0a4031b80ca0af0105d3c2b72b03114115d1584059be 0x5090b6b9f28182a3ccc1c967b22bf23493f6f31c35d05602b51335d9da70ac59 0xcb1feb36656b7fdf71c078ad8091e864bcc75fe3c0997cfe3645049b2ddde6aa450fe8135a3db1dda72de309927b3671d7ef4c09ea514cbfa9332b9e372e2840 => FAIL -secp256k1_verify 0x031afa2fac2fb07f98a8f2f158cc886a2003dcebead5ffeff5a6b38366b2cb11aa 0xbe9bed82fa8fce0fd4aaaff5aab93617b95a0778c08916ec01d77beb0e39bd10 0x08bc83e323583d4a5c51402a660a26227c41cbae1190e904662e176eb244bbbe5e3856f6fef63eb16ca8cdd4a254baa8ec903e54f172f609a26b64555a3d3537 => FAIL -secp256k1_verify 0x039a785d7f1fc9833467a89c5f6d1a4eff7c5df647a637c6257a1f0bd222b99fa3 0xdac269ea2ee6aff43216dee49c8a7049c3124162c7ae9d5fc4b7dd7e5c776440 0xcfd9583d84cb52d792836de5523c689b3f9ca540fffa9c5091fe659f1e1257b568fa0670c570c790cbe673854e3639f5a3d96cf766eb19707d0a4cab0ab891b5 => FAIL +secp256k1_verify 0x02390b19842e100324163334b16947f66125b76d4fa4a11b9ccdde9b7398e64076 0x85932e4d075615be881398cc765f9f78204033f0ef5f832ac37e732f5f0cbda2 0x481477e62a1d02268127ae89cc58929e09ad5d30229721965ae35965d098a5f630205a7e69f4cb8084f16c7407ed7312994ffbf87ba5eb1aee16682dd324943e => 0 | 1300000 +secp256k1_verify 0x0267cbd04522ada13f7a7133b5cf7249da27666d08c1a126ce58ff07a5e759d957 0x23a02777185712876787e32ba4b9800fa8dff0ad846e5769d9f5d57ecde10ab3 0xf8ecc56a3dfc030234ad52f6b4ad119ff18ecd6017b359c5b1e2c184b588f1d35918a3830bbcf4b5b0214684184dc05c120669f9c83b39d49a1bb681480f551d => 0 | 1300000 +secp256k1_verify 0x0313244678d796778b93b4e6fe6f8b2e86f64c2a6b48747235dd9e6c1644dd865a 0x222b25aef8c0c85aa429f3efc19027743bad43615a8dd4e84e435c55af352e7a 0x87e1e5a73e2ac83699462caace88a38ebe20ca9b3d0f48f7c6358e1643b993b07c58956d697cd7f5a17d69d254aa9d42a639ad58020ef0f32d5d7c695dd132bd => 0 | 1300000 +secp256k1_verify 0x02f4f7aff41a8204d4ced025c59256c9fdf7798e767569587c9af3f72a40d4abe5 0x87c4d4aec1bc8cd850199319dde457ecc47af37bff4fed285c0d8acc501ef1cc 0x89210e9d46e074119af1794912dfa894224a8479c523b4b5a4ee2164cc4a332b34ffb55896fd0713dbe9728b501b49549d2294b526003918beb20a737a3a1e7c => 0 | 1300000 +secp256k1_verify 0x03e691f4056d08df8f48a9f4de50c94dcaf8072f5098d743941412bdb480f3df93 0xd36eaf1c8f6f9b25a0008b44d49027818f421687187cd4a121e66f1cb8a67e0a 0xeeb55754863606bd463a135f97c83654543f3ad2a8eaf14656e03ff9e046e1f8555c7154a2c5918a6e3d4f55a8f0bf538a6c1eb30c5e2c433afa194205278d4a => 0 | 1300000 +secp256k1_verify 0x03c5136d0a76700c107780c9500e4bf6cb6833381c976140e436342a04f1bee3fa 0x147ec91f141bc05c902084c80649d64eef0bd2b5c32fdfc568a35436bea540e4 0x202fa22fb0639d84de8d614eb520b0f00c720dd0f17342b880e332a947df88eb3ed59ba51e60382e7d6ab2c67cb33cb80ee3095ebcc0d161c9e3f567a5158c25 => 0 | 1300000 +secp256k1_verify 0x03f4fdaa312d1ef212dbd72e68d489a004973fe2c58978ffb742bb193b9e4fec8a 0x369215c4a473669292fed192a5ae1a9aa641afe10d3ec4d0b455cfad5791d462 0x53c167943d485faa5ae40ea4a0fb42783d5c3b862d4dc5f002dd4e2cf212e69135bf9dde5cfef5047dc84337704427159d1d83e56c1f5146d486ba1ce95101fc => 0 | 1300000 +secp256k1_verify 0x02016d4e699dd0ed993e379c75dd933a57e7a6e59381e241ba79fc15440c8d65f3 0x08d5b309f5897d54cd3d1eb4ea9165af063d3aff27bd2756fbc64e844f38afbe 0x9c98674a7e9f7ebf088d5856edbe58497d9d79b5a0961f17e38af29487851cd85d26ecac613c9d23c3eabe97442a0a8001c9e6a81b98dc20ade3c7040de930d6 => 0 | 1300000 +secp256k1_verify 0x024a4add7d9b701c7b9e896f7918f9bac8dc496f5943ce28088ff15232d43c8509 0xaffd750fb25272c2e8670b1231f0acd61e0539eadb47cf23efa4fc4984fde036 0x1aae72286d5d2b845bb902da99bac31f0d095e11d01bb243fb1341c67561e9195abd2ff164343c7f4224c748e119dd79c50b5424799889dcebf735581b3800b4 => 0 | 1300000 +secp256k1_verify 0x021504be969dcf616fabe8e8d6b61ddcf6e274c5b04fce957b086dbeb7e899ac63 0x2c090ec4147adb7af6d2fcfeadb95bb7f0256e26a6cab4ef83aaf005491e7da3 0xa49419544b597497b0c03e3e226e6c7860c5d8347bd6e56f8a3ec19419de6b623027ad8dba1303e021f5f98be21bcc9961c5a9deeeea6052503648637efaf3e3 => 0 | 1300000 +secp256k1_verify 0x03593911881bbcd95035c8f94d376d76b64e7d6adc120dbf82255111e963849b76 0xdb104e9c6fe422bfad4efb4d60f6b69703f59fe139c1bccbb4ad8e26c59bbdfc 0x3bdd526dd425e132e4da103809ccfc04dddec9356d37abc2697e4f0b6a424d44783a0c3d8740576c718c4bb55f56da94dde9d2b1bb7f21f803314382ebb12a3a => 0 | 1300000 +secp256k1_verify 0x03fe102549fc7189e7d5bb31934b6dd89fbc5c135902c31245b36df1cfd58f8e58 0x41bd0a80ef7761bf998254cf56f1daf89460a66edc6b40689ed4a660b4d5ec0a 0x73cdc526c3c7dd5e2eee6d38765cd8e382882edc033f191f7f51751dd16943946ff6bb5297e6198c01d14405a4302e9cb44594f49c76e73bdc157eed11435f96 => 0 | 1300000 +secp256k1_verify 0x036ae7a30f4da51b57da15ae09efc6456e34328d97210cf3b4345184933bcb0015 0xdc3c455519f7d3206b8ee435c944b7de1f99fa7f5b645f6d79cec4658cd3f313 0x648baa0294a98ece3dedf644e6b879345589081f784f7e2f04494500bb571a412ee8b730c1050975c87ea17686d4ff1259c4f7b85685e578ac4f1421a6438957 => 0 | 1300000 +secp256k1_verify 0x0348c25a42194f3c9b110b4f1895a32f2b41df079105b6b82f6c5d2cf47b265ef6 0xc8f9a4a27bbc1af837fd415e6241285e4b95c0ce74600c81ded086ebcc74547f 0x537c4399f03500ffefa9765e5803816b32ccd3c522fdd6bc26513f86da4516cb210ff9dfc99021dfdc439fa56003da75b58446806dac4474d617b6bc86a01076 => 0 | 1300000 +secp256k1_verify 0x028cec612386b47f25965e2d7e05abf46d982edb34cd815bbdba852ffab76c58a2 0xea89d66edf25352d44ca5b1670a0c46255d51ef20ca5d0649b1b6450c1df4984 0x2b158f722a76440714e5cca4953dd65c36535f5fe85e9df74c06422aa74bfa3216d1347eb97570734787c5165220df191a7572bb88453016e5263e53546fb9ba => 0 | 1300000 +secp256k1_verify 0x026a97a1efcb8685ea11c25ddf0ec2b8e4e14d3ee4603d9a1f4d40466fac6cdc9f 0xc32749548ab386ad3930f6f1dd2a85c5063563eeb99ef633ed1fd648aabb22a2 0x184cd32d241da4838f5b9c5ea039781f7f83fce50e153691ad1088e3494c29a67ed33c693510cd283573f3589e9ceffee63adf0e8c84b6daa35f5b047d8f581b => 0 | 1300000 +secp256k1_verify 0x0226e8d4deb63fe90fd6d21d07d01eebd3b1323354dbf6ebe75221d27a7f142d4f 0x728395357573930ab93762774ccd98edf66db24039c08e59f76d1bbaeefe6379 0xe36b809d7d5400c7808669fd41a743164d03413f0e2a734d9b10dfef6c46403d7ea64a32586fff1d12f854967f071f2cd8fdcbd192565d2f2f572bb2b336f4a1 => 0 | 1300000 +secp256k1_verify 0x02bc74370ae27ad34156be8b7e822bad5d9a4ef2c18ac3adc4b9f9b13edbdbed03 0x4531ac1e89c712279be237a9da1f9eda8c4ed21a3112ef5c521d1cff849b4772 0xb82af9e075234f9370ba31c4f81281d569d685fcfa58fa76d8dcede98c9bec0e0c36759dc32bba1340ccfd8e304943717124fedf837818d25ffff94fddfce9cc => 0 | 1300000 +secp256k1_verify 0x0314a724996fe7eca4bf6596b3ac1224eb7892bcb2e150d5aba7e9f3f1f54f4e07 0xb0124a8df2a9d2c52f1ff75b6fd0b26189f963fc0dbbff9bfa64ac3efdfa7efd 0x8df1d03cfeca2dcd8d8f6b995d485bdee7483d3589804ded5e5207d1e9a235173d00cde597a9c1d367238c8dead286991b265811572f4cbdf7c39f8bcc0bc3c8 => 0 | 1300000 +secp256k1_verify 0x03a28f8a7618b02e3fda2483740c4fadb5fd320ab92b7e0493c8a7e80aa538a59d 0xa4a82d915744b1646bec9d8de7c1261d2f8034594da88c07d5b644e12fb78fa8 0x4b64b2cd071746d7e3398a421dd661604a6dd313f0662bc2a19d285d71fe019061f1a969d233eb5c4bcca0cce05503d9c8a669e67ddd83539c064e3963ad30da => 0 | 1300000 +secp256k1_verify 0x026a96039e1a50339ab2cf5421aea875a0fcc45da59fae53a427a6c345f352e563 0x0e6d6511259dd00c6894752091ae31c1e92eb594cec5bfce874ddeb1074c4a8e 0x4a65dbaf56719a4e2d5cfceaa4db411e4092181d1302716f23a790ff099f6c033de32f2a981eaec6b7a82a75090e4e0e7c757c54516b65361535a28079d52a9d => 0 | 1300000 +secp256k1_verify 0x02c15636ea079a2226359b71c78866756cea233807456b7b4f88a275b22f9887e0 0x4742e3be54ab22db1ffcb63ac90a34384b1b2da07968d816556c9488c6342ff7 0x9438e5cb2fc9e28b7f5a230817f6b678096a9bef79203b122965ced411e14b1251120df5691d208fa7ea9d5bb25191e9aee3ee992f1080eca864c164bd50c33c => 0 | 1300000 +secp256k1_verify 0x0294440d2bac9bf1242ef6a1b286749fa4696a8210153a362ec2c8921f4823c4f5 0x764930461dc2636cbad399be0ab3a0484f12b2289bc62c9c65b227d3d15d9331 0x067bd53c9861502dcfea195cd1caeaad03b1e18bd367fa488b2b4a0250d9f0e171d0b7db9df17348553461222e67d1fce88828a8891846dc073f754c7c3dec35 => 0 | 1300000 +secp256k1_verify 0x03400ae4eeddd2b87e9e520a745fdf0a35242d94ef0f698c9cb16bb23679b5d7e3 0x25624809df04f74c21af8bd16b33c3922490caf0920fe7ce0890b1c12c2b1f7e 0x2fe49ea6d288bd8af19f8619064a0b71b37ecec4ee35cb8bf6c2d38027a7293a267d9fa7077ee5836dbd812d02535b84ab6dcbb4eb3b38c801039d122fab7f9e => 0 | 1300000 +secp256k1_verify 0x0234c0de5aab11010df9a312520c148576f8a44273ce16b9be727bed06882d3cc4 0x0374d1fc889af2526b24fc3e09068eff4403c28d482b240e3fac512482198f38 0xa1792fc62799d8bd705678565e750353a297d1b732d230af909bb0248ff31a7e7fba014e66ace958e44cf851ffbfe618789a8bde53625c15176d9bc48859c50a => 0 | 1300000 +secp256k1_verify 0x02df4d7ecf8d6805a378b9c5549f1bb37b1466a53a5bec59cedf8b4d165324afcb 0x44b54aed8cffdbf091cebf733b3b448da3ea3bdecf4c4245616031fe51cb22c4 0xeb24aaa3242af85bc42f139c51d3d9df655349d4318d0183cb3cbbf4d9ac429e68736f8ee05375da677c6646fb4d4e7ab6abb0b4e6270f00fbb3345d06372b42 => 0 | 1300000 +secp256k1_verify 0x020a61283af85db990f7819a761bcff7b9c72d32dfa2de5090c197fe0f07d28cc9 0xc9eaff05fa43de1dea678859575344cc9497f8efbd7903ceb5ecec00525d9eae 0x6fe31f404ba0d9303583f4f0f1fede3cc9d15326d4d76b3d0c3609727a611d9f4a63d2daaf180270347c8b4f2cedb5b83de2912e338839c4785ea78aa84e35a9 => 0 | 1300000 +secp256k1_verify 0x030daaaafc8abded8bd209b174b5cca6b7e39ba411016fb167209c1541676d85cc 0xd3b91c33942efacc55cb620e31dc020d3d3a585b44a7eee2c42623dad052cf5d 0xe040e132c132ce5ef7f652d881142051df92612c5ce3fc1131591cd48f5b2fdb53180550f80050759df1a30f28ded49bbf8ee621071fdaac2e887c7bcb316548 => 0 | 1300000 +secp256k1_verify 0x0378c57811d48283a2dea8776db6f4756002c130e83846e0b4d46eb17c1a64a49f 0x9243e5958a207cc63725f619124483b9fd99ca24a155089fd9e037f25c58acce 0xa9b9275bb1e318f07c46caf4a2a167b29b91531b9dfda3cf24f9de9d5ae73e9828a17bd9745c2020612e1ba19068f2e2599851588cc86327cb60ebbc46abc9e8 => 0 | 1300000 +secp256k1_verify 0x02b3b3957d5d8bf7d13248a119e91b09e683e0fcd516d3adff652a462f450b4ef3 0x9940a483e428c608f1f9aa2f7816f6caa23f6044f1d37dff304f89a650ee734e 0x1fe73f91d3d0c81436c3e92e2032e5a209e2f3e3fef734b043b926fcff0fa4d07b080410d473280163cd3fcd7d18f90461fad3bb1399d66a418f0323de6447c2 => 0 | 1300000 +secp256k1_verify 0x0215043e969dcf616fabe8e8d6b61ddcf6e274c5b04fce957b086dbeb7e899ac63 0x935d863e2d28d8e5d399ea8af7393ef11fdffc7d862dcc6b5217a8ef15fb5442 0xbbf0712cc0a283a842011c19682629a5381c5f7ead576defcf12a9a19378e23b087cd0be730dbe78722dcfc81543fca17a30e41070ca2e5b3ae77ccec2cca935 => FAIL +secp256k1_verify 0x02b3b3957d5d8bf7d13248a119e91b09e681e0fcd516d3adff652a462f450b4ef3 0x0847bede50a2174a361c292ae89c6a7f2b511ea957d379e25cae1d4dbc3a9039 0x259f6f8a55d11014e26d86807741349cf7d82c87be45fd8271d9174c341b099d2a0f9f1602dc96e4c4a68603c469dad1dacb4c774b3931bf2fbc02c08a56fdc2 => FAIL +secp256k1_verify 0x026a17a1efcb8685ea11c25ddf0ec2b8e4e14d3ee4603d9a1f4d40466fac6cdc9f 0x4f2f997d37ef9978e517f61da2ead60b422ef1ff3b537e84ba9aa7a7afd9a3ee 0x6f9eae1181a3d4093511c9dcf569c0bbf389c7fb9c41ee0b1f9bb2a59c4862122ac88cf2c53056d1a733c7f357cd18b5fa6408a44354f451892a85d2503f7c21 => FAIL +secp256k1_verify 0x03fe102549fc7189e7d5bb31934b6dd89fbc5c135902c31245b36df1cfd58f8e58 0xc89e4fe7c56483c6d9a4fe8b5fdf983697db0b027a8daab81e908282e39f3401 0x8f45904c4cc15b0ae336c3a0cbfdf72cdbcef6c64c60e7ba4003bbe765e4542a78db791bd80bfebf8224d2b03bcf8774037622415bc9b618c375efc8937ff47a => FAIL +secp256k1_verify 0x020a61283af85db990f7819a761bcff7b9c72d32dfa2de5090c197fe0f07d28cc9 0x7e06c2a825c043f6fd8400ddaed28cdb9a297aa8aa71d8ba004cf685e34cbbbe 0x7db37780639294cfbc793e50f365aca4e6e4eb656868b1a2666ddc808f069a307b5db842d617c9b31ff4af106c4ae9c34cd0c86f2e13f9809ba7e3d333dda84e => FAIL +secp256k1_verify 0x02b3b3957d5d8bf7d13248a119e91b09e683e0fcd516d3adff652a462f450b4ef3 0x63da4d356c8712477fa28d5d0bf2a5ae8da1b0fdbec3541c2b9e2e6ce9bf5548 0xb39666cc43b7bf977e6ffbc6d33f41af903d953ca3a4ff71e0f5bb6f014120c620c73ad597c4325d698045d74511828d4e4f1e8d0aa1419732bcfa9e5912b764 => FAIL +secp256k1_verify 0x0313244678d796778b93b4e6fe6f8b2e86f64c2a6b48747235dd9e6c1644dd865a 0x5090b6b9f28182a3ccc1c967b22bf23493f6f31c35d05602b51335d9da70ac59 0xb6412970a41acefe83eacc5f6a62be59de6ffd67dabcdf2fa0075b8bd707b7d501c4a1ec1ed5d081fc5801cb90bbcabec670927bb36237d36c024612426bc356 => FAIL +secp256k1_verify 0x03c5136d0a76700c107780c9500e4bf6cb6833381c976140e436342a04f1bee3fa 0xbe9bed82fa8fce0fd4aaaff5aab93617b95a0778c08916ec01d77beb0e39bd10 0x89e9ad009b5f1a9c1b871ccb906217370a0a404387d1afa52f6468ab7a3e4d800745c46e762c45002f42cded33bc6df41d2d5dc22ac02c0821f31302af1123f4 => FAIL +secp256k1_verify 0x021504be969dcf616fabe8e8d6b61ddcf6e274c5b04fce957b086dbeb7e899ac63 0xdac269ea2ee6aff43216dee49c8a7049c3124162c7ae9d5fc4b7dd7e5c776440 0x851d282f25f94d6aed45dc57ecec80671eff25a6bcb32136b43b09a8d64971c14df85a0a588a49534bd88f8cd0b98253bd33bc80368ac3ec587f1a3b88a6a835 => FAIL diff --git a/src/chia_dialect.rs b/src/chia_dialect.rs index 7dd95c7f..f4978127 100644 --- a/src/chia_dialect.rs +++ b/src/chia_dialect.rs @@ -92,11 +92,11 @@ impl Dialect for ChiaDialect { let opcode = u32::from_be_bytes(b.try_into().unwrap()); if (self.flags & ENABLE_SECP_OPS) != 0 { - // the secp operators have a fixed cost of 1850000 and 850000, + // the secp operators have a fixed cost of 1850000 and 1300000, // which makes the multiplier 0x1c3a8f and 0x0cf84f (there is an // implied +1) and cost function 0 let f = match opcode { - 0x0cf84f00 => op_secp256k1_verify, + 0x13d61f00 => op_secp256k1_verify, 0x1c3a8f00 => op_secp256r1_verify, _ => { return unknown_operator(allocator, o, argument_list, self.flags, max_cost); diff --git a/src/run_program.rs b/src/run_program.rs index 2b1e723f..c5e18b0d 100644 --- a/src/run_program.rs +++ b/src/run_program.rs @@ -1264,7 +1264,7 @@ const TEST_CASES: &[RunProgramTest] = &[ args: "()", flags: ENABLE_SECP_OPS, result: Some("0"), - cost: 850061, + cost: 1300061, err: "", }, // invalid signature @@ -1281,7 +1281,7 @@ const TEST_CASES: &[RunProgramTest] = &[ args: "()", flags: 0, result: Some("0"), - cost: 850061, + cost: 1300061, err: "", }, diff --git a/src/secp_ops.rs b/src/secp_ops.rs index 063f2b42..b131847d 100644 --- a/src/secp_ops.rs +++ b/src/secp_ops.rs @@ -9,7 +9,7 @@ use p256::ecdsa::signature::hazmat::PrehashVerifier; use p256::ecdsa::{Signature as P1Signature, VerifyingKey as P1VerifyingKey}; const SECP256R1_VERIFY_COST: Cost = 1850000; -const SECP256K1_VERIFY_COST: Cost = 850000; +const SECP256K1_VERIFY_COST: Cost = 1300000; // expects: pubkey msg sig pub fn op_secp256r1_verify(a: &mut Allocator, input: NodePtr, max_cost: Cost) -> Response { diff --git a/src/test_ops.rs b/src/test_ops.rs index 9625cf10..8bec02e5 100644 --- a/src/test_ops.rs +++ b/src/test_ops.rs @@ -99,7 +99,7 @@ fn parse_atom(a: &mut Allocator, v: &str) -> NodePtr { "g2_map" => a.new_atom(&[57]).unwrap(), "bls_pairing_identity" => a.new_atom(&[58]).unwrap(), "bls_verify" => a.new_atom(&[59]).unwrap(), - "secp256k1_verify" => a.new_atom(&[0x0c, 0xf8, 0x4f, 0x00]).unwrap(), + "secp256k1_verify" => a.new_atom(&[0x13, 0xd6, 0x1f, 0x00]).unwrap(), "secp256r1_verify" => a.new_atom(&[0x1c, 0x3a, 0x8f, 0x00]).unwrap(), _ => { panic!("atom not supported \"{}\"", v); diff --git a/tools/generate-secp256k1-tests.py b/tools/generate-secp256k1-tests.py index 34078cdc..d9b83ef4 100644 --- a/tools/generate-secp256k1-tests.py +++ b/tools/generate-secp256k1-tests.py @@ -11,7 +11,7 @@ def flip_bit(b: bytes) -> bytearray: def print_validation_test_case(f, num_cases, filter_pk, filter_msg, filter_sig, expect: str): sks = sample(secret_keys, num_cases) - cost = 850000 + cost = 1300000 sigs = [] args = "" diff --git a/tools/src/bin/benchmark-clvm-cost.rs b/tools/src/bin/benchmark-clvm-cost.rs index 83bd718b..89b3bbe8 100644 --- a/tools/src/bin/benchmark-clvm-cost.rs +++ b/tools/src/bin/benchmark-clvm-cost.rs @@ -376,7 +376,7 @@ pub fn main() { mode: Mode::MultiArg, }, Operator { - opcode: 0x0cf84f00, + opcode: 0x13d61f00, name: "secp256k1_verify", arg: OpArgs::ThreeArgs(k1_pk, k1_msg, k1_sig), extra: None, diff --git a/tools/src/bin/generate-fuzz-corpus.rs b/tools/src/bin/generate-fuzz-corpus.rs index e5900320..f281ddd1 100644 --- a/tools/src/bin/generate-fuzz-corpus.rs +++ b/tools/src/bin/generate-fuzz-corpus.rs @@ -271,7 +271,7 @@ const OPERATORS: [OperatorInfo; 79] = [ ), // op_secp256k1_verify op( - 0x0cf84f00, + 0x13d61f00, &[Type::Sec1, Type::Bytes32, Type::Sig], Type::Zero, ),