c-kzg-4844/bindings/csharp/Ckzg.Test/E2eTests.cs

40 lines
513 KiB
C#
Raw Normal View History

namespace Ckzg.Test;
2022-11-03 13:08:17 +00:00
[TestFixture]
public class E2eTests
2022-11-03 13:08:17 +00:00
{
[Test]
public void VerifyE2e()
2022-11-03 13:08:17 +00:00
{
IntPtr ts = Ckzg.load_trusted_setup("trusted_setup.txt");
Assert.That((ulong)ts, Is.Not.EqualTo((ulong)0));
var blobs = Convert.FromHexString("89504e470d0a1a0a0000000d49484452000000f0000000f00803000000098b0019a00000000467414d410000b18f0bfc6105000000017352474200aece1ce900000000097048597300000dd700000dd70142289b78000002ac504c54454770004c627eea627eea617eea627eea637de9627eea5d5dff627eea627eea627eea00667ceb5e72ff627eea8080ff627eea0000ff627eea6080df627eea627fea6d006ddb627eea627eea617dea627eeb617fe9627eea5571e3637feb627eea627d00e9617eeb627eea627eea617fe9617eea627eea637eea5d74e8627fea647deb00627eea627eea627eea627fe9627eeb6680e6627eea617fea617dea627eea64007de7627eea627dea627eea627eea627eea627eeb627eea627fe9627dea617d00ed6480e8627eea627eeb617fea627deb627eea637eeb627deb627de7627ee900627eeb627deb637deb627eea637dee627eea637fe9637dea627eea627eea620080e9607cea617fea607eea617eea627deb627ee9617dea627eeb627ee9627f00ea627dea627eea637feb627fea627eea627dea617dec6280ea5e79e4627eea00637eeb627eea637fea627eea627fea617ee95e80ef637eeb627dea617eeac100ccf7627eeaffffff8198eedce2faadbbf4637feac0cbf76480ea6581ea6c8700eb6883ebbfcaf66682eb718aec6984ebfefeffb1bff57b93ed98abf28197ee00bdc8f6738ceca1b2f3bec9f6bbc7f691a5f0f8f9fe9eb0f2748dec889def700089ecaabaf494a7f1a6b6f37890ed7e95ee6e88ecacbbf4b0bef48ea2f0758e00edb8c5f6879cef7f96eefbfbfeb9c5f6aebcf48399ee859bef6a85ebecf0fc008ba0f08da1f0d0d9f9778fedbfcaf7e7ebfcb6c3f5b5c2f58299ee6b86ebfc00fcff7d94eea3b4f39badf29caef2849aef7a92edd7defadee4fbfdfdff8a9f00efc3cef7f5f6feb4c1f57991edf3f5fda5b6f390a4f0e2e7fbcbd4f8f2f4fd00d6ddf9e1e6fba8b7f3eef1fdc1cdf6f7f8fecdd6f8e8ecfcf0f3fdb8c4f5ba00c6f6c9d2f8b3c1f5d9e0faebeefc9aacf2f9fafecfd8f9c6d0f793a6f17c9400eea0b1f2c5cff7dae1fa95a8f1bdc9f6e4e9fbb3c0f596a8f1d3dbf9afbdf4004f05b1c20000007274524e5300fbdd36db3bf102fef5ef0c05fd04f901eb0800c9a807ced9175a39c40933e95e71e37fa5e1ab6f0b951968f77799880af35300c0d214425684d7d0a2ca2db31b3892652f669d4cbd20ed74af58cd1dec523100e6fa4425a023c77c826d96d591b6df408fdeb9273c13cb2a609b634f460fb000b87bd1e342ae00000f764944415478dadd9df94354e51ac75f161d1d19148100041441c41d05441157dc3545cd2c73d72cdb6f75cf39b38502828a823b2e8900e256b72c35dcd2cab55b69376f2ed7ca7bedda6df947eecc20c8cc59e79cef0073e6d0f7679d733e9ced7dbecff33e0f6326a9cb807619992316f7195a10bd00d26eefc8f31dedf695d10543fb2c1e9199da6e4017f6e751a7b4818b5fe8d600995754e7a2b7fb0f4cebd4e6598767bd15dd81d7ac0ed133b286b755ea949900e34b1cbc0e45958c9f99d2c6606de939dd75c1b668c99079716d85b65f611f003b0f903da930d7fab45da78ccae3611a3436a39fa5715721699b94f7ec2aab00d2be39a980275151ce300be2162775e6c9d43929c6626fe5295379629564d8002c83db63602c6f82620776b5046edca4b9bc49ea991379e4b88c68de44f5ea009b1c51dc2ea9a6e2066eec99110cacd2bbf311d0e8b408e10e18ece023a20e007d664500373ea7231f31e53d196f36efc4d17c443532dddc2f6fd6d37c841500b5d4c4b062552c6f01c59af5f28acf72f096906388291ec1b4eebc6594f80c003defab79bc859497418c9bfc1a6f318dea41c93b2b91b79c9e9846c7bba227006f41cdfe0b15ef930ede927264d2b81afd79cbea35829566a7b1bc85f5c29b00f0d0a8047f969b1a71bf55000ea05eec85e775fef701f0d7b2a16b9057086c002b8fcbc59d461a5e6380ce4602c16377467071774b813f688779d7abda13f000565cf201735f42d799c341bc24d6c67dc10f5c5681fccd8eed20de869d8277007b650098bb01fdd5f6001f64cc6c0aded2e3421330e784fe6e82e137d73334006985234233f08135d8e4c48bc678c7f522e1ddbfa505985b8ffde9ec0186d600934fd0ac048f098f81bddbb0bf5d62a00ac846b47eae135a0173473cd85f5f00a63f92208a8fd6dc0b02e6b6837f7fb0eef89728b4392c0403d7be0f3e80ce00f8783851bc7ffa540830b715ed08e8f2406625d0f07a5c4228b0f73cf818d30075f85c5d5f26baa11f082260eed777d0ce5ef85ee66422debd572580b97af400619e0d97f7752a33e6a220055cb3177d9c301dfaf954f985864a49606e173c002711960312ff1c11ef3b7f17a481b983e8438d0e27d33682ea86de29c8019f0028471f2b2b8c909fca71dfb64516987b883e5894e6fc710fb27cf74d411ed800bb117db458addfa62154bcf5820230b7d3833ede088d9e0e55fd4673d0200300ccbd07bfa99fd2f4862ea1bac0270565e0db6be16f6a2d15b83954bc570ea900007367e1c7d410378da35a72782e086ac0deddf0e587bae1338aea029f13540081b97de820829fac9a55a1fa04affe5a0330f701fab00e95fc4b17b29a24af00a005b87a35fab8dd95ab8d53a9788f566a02e636c18f5ca858df4eb5c67ae700baa00d98db035f6f29999893a82ef02e412bf0c952f4b15f55b8c0cb89787d00b951adc0dcbfd107cf968f1317515de03b8276606c06d5af81b2be5d2f22de000f853080f141c4dc1e26
2022-11-03 13:08:17 +00:00
byte[] proof = new byte[48];
byte[] commitment = new byte[48];
Ckzg.compute_aggregate_kzg_proof(proof, blobs, 1, ts);
Ckzg.blob_to_kzg_commitment(commitment, blobs, ts);
int result = Ckzg.verify_aggregate_kzg_proof(blobs, commitment, 1, proof, ts);
Assert.That(result, Is.EqualTo(0));
Ckzg.free_trusted_setup(ts);
}
2022-11-03 13:08:17 +00:00
[Test]
public void VerifyGethPayload()
{
IntPtr ts = Ckzg.load_trusted_setup("devnetv2-geth.txt");
Assert.That((ulong)ts, Is.Not.EqualTo((ulong)0));
var blobs = Convert.FromHexString("89504e470d0a1a0a0000000d49484452000000f0000000f00803000000098b0019a00000000467414d410000b18f0bfc6105000000017352474200aece1ce900000000097048597300000dd700000dd70142289b78000002ac504c54454770004c627eea627eea617eea627eea637de9627eea5d5dff627eea627eea627eea00667ceb5e72ff627eea8080ff627eea0000ff627eea6080df627eea627fea6d006ddb627eea627eea617dea627eeb617fe9627eea5571e3637feb627eea627d00e9617eeb627eea627eea617fe9617eea627eea637eea5d74e8627fea647deb00627eea627eea627eea627fe9627eeb6680e6627eea617fea617dea627eea64007de7627eea627dea627eea627eea627eea627eeb627eea627fe9627dea617d00ed6480e8627eea627eeb617fea627deb627eea637eeb627deb627de7627ee900627eeb627deb637deb627eea637dee627eea637fe9637dea627eea627eea620080e9607cea617fea607eea617eea627deb627ee9617dea627eeb627ee9627f00ea627dea627eea637feb627fea627eea627dea617dec6280ea5e79e4627eea00637eeb627eea637fea627eea627fea617ee95e80ef637eeb627dea617eeac100ccf7627eeaffffff8198eedce2faadbbf4637feac0cbf76480ea6581ea6c8700eb6883ebbfcaf66682eb718aec6984ebfefeffb1bff57b93ed98abf28197ee00bdc8f6738ceca1b2f3bec9f6bbc7f691a5f0f8f9fe9eb0f2748dec889def700089ecaabaf494a7f1a6b6f37890ed7e95ee6e88ecacbbf4b0bef48ea2f0758e00edb8c5f6879cef7f96eefbfbfeb9c5f6aebcf48399ee859bef6a85ebecf0fc008ba0f08da1f0d0d9f9778fedbfcaf7e7ebfcb6c3f5b5c2f58299ee6b86ebfc00fcff7d94eea3b4f39badf29caef2849aef7a92edd7defadee4fbfdfdff8a9f00efc3cef7f5f6feb4c1f57991edf3f5fda5b6f390a4f0e2e7fbcbd4f8f2f4fd00d6ddf9e1e6fba8b7f3eef1fdc1cdf6f7f8fecdd6f8e8ecfcf0f3fdb8c4f5ba00c6f6c9d2f8b3c1f5d9e0faebeefc9aacf2f9fafecfd8f9c6d0f793a6f17c9400eea0b1f2c5cff7dae1fa95a8f1bdc9f6e4e9fbb3c0f596a8f1d3dbf9afbdf4004f05b1c20000007274524e5300fbdd36db3bf102fef5ef0c05fd04f901eb0800c9a807ced9175a39c40933e95e71e37fa5e1ab6f0b951968f77799880af35300c0d214425684d7d0a2ca2db31b3892652f669d4cbd20ed74af58cd1dec523100e6fa4425a023c77c826d96d591b6df408fdeb9273c13cb2a609b634f460fb000b87bd1e342ae00000f764944415478dadd9df94354e51ac75f161d1d19148100041441c41d05441157dc3545cd2c73d72cdb6f75cf39b38502828a823b2e8900e256b72c35dcd2cab55b69376f2ed7ca7bedda6df947eecc20c8cc59e79cef0073e6d0f7679d733e9ced7dbecff33e0f6326a9cb807619992316f7195a10bd00d26eefc8f31dedf695d10543fb2c1e9199da6e4017f6e751a7b4818b5fe8d600995754e7a2b7fb0f4cebd4e6598767bd15dd81d7ac0ed133b286b755ea949900e34b1cbc0e45958c9f99d2c6606de939dd75c1b668c99079716d85b65f611f003b0f903da930d7fab45da78ccae3611a3436a39fa5715721699b94f7ec2aab00d2be39a980275151ce300be2162775e6c9d43929c6626fe5295379629564d8002c83db63602c6f82620776b5046edca4b9bc49ea991379e4b88c68de44f5ea009b1c51dc2ea9a6e2066eec99110cacd2bbf311d0e8b408e10e18ece023a20e007d664500373ea7231f31e53d196f36efc4d17c443532dddc2f6fd6d37c841500b5d4c4b062552c6f01c59af5f28acf72f096906388291ec1b4eebc6594f80c003defab79bc859497418c9bfc1a6f318dea41c93b2b91b79c9e9846c7bba227006f41cdfe0b15ef930ede927264d2b81afd79cbea35829566a7b1bc85f5c29b00f0d0a8047f969b1a71bf55000ea05eec85e775fef701f0d7b2a16b9057086c002b8fcbc59d461a5e6380ce4602c16377467071774b813f688779d7abda13f000565cf201735f42d799c341bc24d6c67dc10f5c5681fccd8eed20de869d8277007b650098bb01fdd5f6001f64cc6c0aded2e3421330e784fe6e82e137d73334006985234233f08135d8e4c48bc678c7f522e1ddbfa505985b8ffde9ec0186d600934fd0ac048f098f81bddbb0bf5d62a00ac846b47eae135a0173473cd85f5f00a63f92208a8fd6dc0b02e6b6837f7fb0eef89728b4392c0403d7be0f3e80ce00f8783851bc7ffa540830b715ed08e8f2406625d0f07a5c4228b0f73cf818d30075f85c5d5f26baa11f082260eed777d0ce5ef85ee66422debd572580b97af400619e0d97f7752a33e6a220055cb3177d9c301dfaf954f985864a49606e173c002711960312ff1c11ef3b7f17a481b983e8438d0e27d33682ea86de29c8019f0028471f2b2b8c909fca71dfb64516987b883e5894e6fc710fb27cf74d411ed800bb117db458addfa62154bcf5820230b7d3833ede088d9e0e55fd4673d0200300ccbd07bfa99fd2f4862ea1bac0270565e0db6be16f6a2d15b83954bc570ea900007367e1c7d410378da35a72782e086ac0deddf0e587bae1338aea029f13540081b97de820829fac9a55a1fa04affe5a0330f701fab00e95fc4b17b29a24af00a005b87a35fab8dd95ab8d53a9788f566a02e636c18f5ca858df4eb5c67ae700baa00d98db035f6f29999893a82ef02e412bf0c952f4b15f55b8c0cb89787d00b951adc0dcbfd107cf968f1317515de03b8276606c06d5af81b2be5d2f22de000f853080f141c4dc1e26
var commitments = Convert.FromHexString("acfdec40e99b3078b1be2b19bb4849854475f1c1d41377eae575897398a28d1e921d9f19bc7827b621125b3f28e2a057");
var proof = Convert.FromHexString("b477d9331410c7400ee59221f04945baf637ae2ea38500e29026f2960af37db7c4a42346a9f790990f12022bee3c1d2e");
var result = Ckzg.verify_aggregate_kzg_proof(blobs, commitments, 1, proof, ts);
Ckzg.free_trusted_setup(ts);
Assert.That(result, Is.EqualTo(0));
}
2022-11-03 13:08:17 +00:00
[Test]
public void Test_PointEvaluationPrecompile()
{
Assert.Fail();
2022-11-03 13:08:17 +00:00
}
}