-
Notifications
You must be signed in to change notification settings - Fork 20
Description
I have been testing a number of crypto libraries with the BLS12-381 curve and have noticed a discrepancy in the result of FP12.pow(BIG) in the JS library for AMCL version 3.
Here is a test case:
FP12 pt:
[[[18cd7a565a749009cc4c5f6601ea0856a47a3323f9ebb5953e4c2b1c4010d0dc7ca86ef548c4332b4cc2602e92e19f0f,09e148c258387a5e91c961df72cd340c19cdcdf799c249458969e00bf4d1275dbfcb139b49857e189f19ce71ae7fa8ee],
[0a2ac22c8737727e985aea988b18549379dc9821dd42d0974e7fd89b3d3c13114371ebfb3304cbda9d26c7a0a0b83025,0728ccef15044f5df498bb80ce5313d6dfc9a3ae9d4e4bb0f3ea398d8a2af607479cd6f66a6daeeb495d22aa8de2e256]],
[[0938dfc7cb18005c641319bb00149ce4a25edfa4aa50557aa8c780cce9cc6351261920f7212a41a3b0b097d3e827d3c3,07e500c72020555a613e32a7726c5d66350163663e4bdbc1b8b65b22c49dd19c91e7c859790a5290c526a391d2e896ef],
[171201bdd27cbe71d915e6e7d3cef10ce7251fa9b863c71652e0e63c16702c83993559129ee682b9c8c597b9849b843d,12c5a8f92088dba00d78e4c33bb18010e5bcd5ae193aedc291186dd9091ada24fc0d61f0efe90857e4528fc013583d12]],
[[1301d3f107fdcbbaffc05707e0e2611dc8d4ed9ad90c0fd221df7e706b4b4d46c943daf03a6f3a1eddd2d2c9bc4ddbc5,018fde8c2958612913a7ac368d9c778adaaf7dd88bedab9ada2e709ef173091735dd153382584c2bc0c7993937318ecd],
[19b0de4003f7f0c81918595a674a1d9d67bfcdafc2194aa7c2d799c3f21015e52018cd6999add6bc685dfc8b33ef41e2,03bce826c38b87e80c66b61ef71d705e67faeb0acf6f89fc5a6d4d9957bb766dc76b5c82d7f0d553260f4e2a7ef1c6b8]]]
BIG num:
0000000000000000000000000000000082fda182fda9e0755870887b25421b85b1f50051a22b4041135f9c153e354e02
(By the way, it would be VERY nice if there was a set(string) function on each class that accepts the output of the toString() for that class.)
For the other libraries I get this result for pt.pow(num):
FP12 result:
00c40389f91081c4a147c38944ec0c8696c45d4404a15990733226fbda393d4f69a70875240304cba6ea58d69a6739f3
15ab5b2d3e69220a755ca5e3eab9c6d2ef3d99fed681fd330a9f9a6ec8365a679e69402b71f6706c3e54ac0af7ff355e
0faeb132568224efce5169db3a9f0754bd3b028a8a9626a31f7673b6658e96f6b70984bd11bb572aa5d5f41cdb0c6c3e
0c2223234ff6fa4525002c36d574d9c70cf9ce4a81162ef54909af38a6768b40ed47348aa6f27f4e63aac352eff23524
0d334017e82fe7b51dace4ea243ba2897226c8eb6a6f16d2eb22e443f42b35a956c47ff83b6b012945253e579b4b903f
0f1063b5f569a9c4946dff4b73dc892f2234f2da0bab7926f3e4190cc3eeb07598f7e39f19456b74ac392a215baceb6e
04145ba9d429a25887aeb091bd03df38b908956665efaa8bff1c1d459ae787f9c7776dde504c7b6371cc0ce5352a5260
05ef1024a7b1cfb5f5f39efce60140d0df9e89ddf7aab232af493ff57cad9409119a19da7018123aac6531eae1068a57
002fd10ca8a397210c31a3fda02f68e1179868fffd6636afab08e14e6f026bce6f203d8b8f2ad5cc88e061ecda56f84a
15ad17363cf7246c68baa971644b3fbbe34f1b8ed8034619373debf0797c0d0096faec29bf29d6b559fb530ebe10e11f
175293de14123c3f530bf11903323f1a525d61f7f0fe9d0ef0fd3056f094bd61060bf1730a0037f71b782ff97f2e752b
10731a03c2a59150f572a8c2bf10241a650f3100faeec7204257222b5938bcb86b7fe00628d93d22e8076aeb59515d61
But in AMCL I get:
[[[17cdc384c7ce3e1ed2d11f04f692012710137e98f9b228e6c8fc9081b41ef35a02372d8f2d75421c210187c5e6f9db58,08b6852d7f5772b1e049f8ca8091c3b0121bb76c412493fc5bdb156e7161dc03a4a792c77d55bec457cf13894316d036],[15fb6af1f71a9e4688067a0bc56e7b547e9ef27feedc40dc91e02f62c252ce65586fff97ec67adad73368ed3474a765a,1224c3ac9873814d8e496e03f4400f8cb43826a86f8ee928cc11d1ae69d83416bc702160ae164371f7ec49fd91bc044d]],[[0f257efbbc8543fb9ce6959eefb9e8e8f1d7d4b9d7f24d04a867df8b1db735dfba3b1c0053e805a805f752a59d9dcc9f,01808b073d9d4fcdc023076e9b659b60da1a415ad213c24d891b0ea81a138cbeb7b369dc4bf8b1a8b1e16f351653dfed],[1799ea9ed9db2cdc6bae34fc4fec3f535500e0bcdf5ee3ed01ed5df4265c609ce8beaba683d0bdc88c40a88b2fb3474d,1969b47f62c7df1f62c8ae4c41527196afeed0dedd2b4587cfa0f79a978359e4fc23a30cb8a5642e4202c0a5a54d7d1f]],[[04950dee0be2ec1e54eb6c338198aaa5a7e0fbe35302ec21e7563b2f8e22707b4c7e80c0b3f39cb53b792e1279217979,02b9288d0c8dc4e821ba23b8c1a79c4afeddc363acc01f36fa7dee1808f873fe16286915065c7c3d4f4e550fb57efe65],[141b039ca264c22502f0f6ad8386c205a5f8e7bc95c70c4b75742eec892812bb11fa162d2156861f7aded25246f13ada,16a4f9a37208a154a7f85abbbd893d8583d077db7fd50a7e7d09d0512016e4f15efda050177a94249324bedc4cfbfbb0]]]
In case it's not clear, if you remove the brackets from the AMCL result you get 12 hex strings. The result from the other libraries is presented as 12 hex strings, in the same order as the AMCL result. The 12 hex strings from the two results should be exactly the same, in the same order.
I can provide a number of other examples if you need them.
Thank you