Closed onchain-eren closed 1 year ago
How about removing 0x
prefix of strings like https://github.com/herumi/bls-eth-go-binary/blob/master/examples/sample.go#L54 ?
hey even after remove 0x it doesn't work.. I basically implement this function: given msg, pks and sig, aggregate verify whether sig is valid
// this function return true if sigToVerify is aggregated signature generated by hexstring pk each independently sign the same underlying msg, otherwise return false
func aggregateVerify(msg string, rawPks []string, sigToVerify string) bool {
sig := bls.Sign{}
sigByte, _ := hex.DecodeString(sigToVerify)
sig.Deserialize(sigByte)
msgByte, _ := hex.DecodeString(msg)
var pks []bls.PublicKey
for _, rawPk := range rawPks {
pk := &bls.PublicKey{}
pkByte, _ := hex.DecodeString(rawPk)
pk.Deserialize(pkByte)
pks = append(pks, *pk)
}
return sig.FastAggregateVerify(pks, msgByte)
}
This is the parameter I feed to this func:
b52ca7a2dfa7f1e3a3b941a49853ad16c20d01b8571979e7b0f8a42104437d22
[800cd4cfd2435129611858d0c40e6947f8d86bd5789b5e082c19c3b7ea50f2210657d5c73b8cd2c078a0c5a45b0bc205 a5efd8815431a4a524e969e5083e27e1765dee3a47e126504a3fdc400a6bab067eddb56962abcaf31450a77f86129585 affae95beb57c70611916a88e95b578a77214c3a496de5d055ae68c16680b56ef3b55a6990f27c5c6407442dad156aa4 a42dfd1b1779532784d542e3027627d6ddd4d85b127365070e5d5165578252b598bb18610907df02a653a4a770cbd3fb a253e453396998a1afb2e82cc5a1342caf9791a748fc2ec157222eae56417da7992f0765d61b938d6fb80b85127a1290 a46b65e296a4074c2337e0bd03fcab7fc98fb547dc57d6788aa2225522edeaa6b6392469bb69b581f02b61fc196edbab 8687ea262db11c69dafaff6a37958a96a2a787b9c7829b184d9ca8cdac38488f002b47c8e41ca245be69593b8475823e 87fddbb216b4600b1caa6144e82f2f805c88f3089aa4f71049b481c9cf6a99c4cc8ff0b7ead923da815a66e7845c6ae4 b1474ef061ec9eacc0cd61d1c86e9ede1e0707981aea973db21f9859e669e9a4fa075f748b3b226301ef051912f7defe 812eb33770b893f48357f8be1061ed2300b7959718bcfad90c3f8130c983f044e27102afc2c493d452ffcd57d833f92c b564016a894ba6663d3b78bf18c31eeec4ec866a86c7f3c15c404e364b19f641818b84c6fa2b269633b8f0324a292dbe 897c50b34cad2bd969d2292fdf6b284bf95c76d92438ffc8a9461117710f88472402c6b4676fe57073978cef46cea8aa 861e88b65930de619b29b3d9f0c1c16e829aa443571b5a2465d17fa50044a3499776b7c14ab10d221dceb43fa8568687 8317d31b8ac285c0147d227d828dd0f67aa17ff752f8a41a983d29c80ed7c5b8991e17599e4631933daa850a2d7ce063 b4d77b23c4f451f7385cd39f27cc8d80efe2e5ee02bcc194a646c8f2c3509b6af1e4ff0ee2df3546f8eb325ab59b251b 92d5a8b54e08b5688a0283aa3cb7f4bcf8f7246ffffce436bf1eebc01f764d11580677281c22b08c601afdaa7c67ef0e 948a71dd47bae0623e7002affdfb6936dd2d42b795a0a87ef2d71de193d65154ab091aab1bced1c94f38be5270d4d682 a08c353f8dd6c5c5cdbdf5e5e3a2180fc560c3c7f8735db5545ec8bf80b40e89268b50e3536baa0ded00380da767f0ed 933f52c0ff0618f427ba56dbe063585552cc6b3f07126237e0667a0757f78de7f94def368a8950792808d7e366848c46 b7f889030d9be530ae29c9b16eea1853d47879d0f946120627c200e08e5b599fdb9676d12b39cc2dba281b48090f5fea b1e2677eb67f2b765a219a86edab8d59daf6f0aa000844fdaa841b0a96d876354cfd1fdba8d9d1d735d84d489db3f552 a11bf796ff2b3f0cb8a93af98a80805bc2efd2713a6cca85ffef5cee07ffb9d00a9a4273f058bd09feabc11be35a688e a7e5063508df31d8d9e62089fdc9f57254cb565bed1ae692fd4a4bb89bd32abb2032704500114df15561b251536bf3ee 8ec36e89533961a6f2f9eff239b9fcd15790785108b229fab5380bacbc21dd501159a303d96775c6a18ce31f01c139cc 919651193f8ddb2f930b31da056afdc7340f3feb3435c56718dd405c5ba8a3c7430162038ea0b313c572e35ee43aedfc b5e74cf955ed11485a1708a6bb5ff51b7ef6e7d905d496e8f5a2eb8081b8b62d54eafe12a3d5b28e086925e7495e130d 8bdc1739025affedaeb19f0e71de561a9062f82c7edf63dd34e4d95e47afe82de1ed3d2476701d856891df4ccea93c99 afb440a45ad31a2ee45bbc4d15c05720e185739470c0c98dfeb38195975c18f5c85683db8418a5a791f49ddef2a5bc48 ac7069b538439a4fe98ddaee74762c773ada68759f8c7bb42eff84bcfd90cde86b89fbde99da8dd5044ba932ee3a0f29 aac9ae7c8319609f81d8fee7964775cbab97a60aa70e4c1b84a8cb8cba8e0f402b59c6ccd62ff23101dcb5490b35ae76 ab1e995a1fe0568195ad5bbf835fccdd42414a7132f767cea67611a579b44c6fec36d3bc6f9eb756ffb137d95ecf0325 adc91c830046a2d302c60a1c1de4eda90e3bda3002c5e996b7d0b07c32ea00eb628f40423ec0973f94ca3f45ceb3b29d b8f59038bb863c859e77cd5aec2acbb0bab92feafcc033a5a54b1645df0d380c7ecfd766259555e6b8fb24ab822949e9 98d928175cefa8e3fd124fad143646952d49ae53329234b5b296ed8956d3d9939cd389a7422eb027ae0632e9691e7160 8a1ecb0c2be18e2df787fedd7342fbd5ac8e4e7f2d85631b7fa023e9e90f5bef2f69cdbc48e3980f25e5a93b9fd1b856 951721b4bb3a7bf67b5b2edc82f93b71537f3b5d757e79ec8239bf710fba3e90198f0a16c3635db63d90216960a7a9f4 8a44ef032508f116329e43f41ce6e1afa350db572e618528b1c50a1b5f699787b5dd9762681910c192d6ca1868dd7265 a14c68f297ecfcf3d777cc39719b1ba6d83c3863f3da45d8e476dddaa2a067277e1ae293abad3d789e03908ba64e41a6 a215190dd77661a7e6eb4eea91cd1d1c303908be6ab87852680f198d4d0e293eedb2baa6fef223c4f725f96a7c70b3f7 9363ec5ccb8b726ecc361515f19695453051fea934a9af99df4ec09d8c0c1626300ba6cf03e6ba0d69a0b4e286842440 893b70972a4b4f1c9e0334d6fcefd56c4f4bcd19b9c7663492f4b7da4ff83b42d81f87eae4d94fbeba5939b6ce204967 a3ed099c265a4cd130e414b86648cab75e3366eafd0322a19856bbddfc2ec50d7e13e4e66607c57273584b4052a09ef8 b6cd5d7f23d9cfa7067eb15ebbe90a6892f6914dc840cfa8367fa0d644342f070f5ec349731304bece9ec81c661a6f93 ae2679c0a6f499f6b73775deb640c3120fbf04586cf0dce4b271c7645021a9f81523c3de9bada4631dcb57be29060640 8130267288cdadeec03f24efb8844976d83b9246a6eca11ee005c6d70c5d265557d74dba5699ab6ee3986d276b79bcaf 8473d51a199db15dc0718e1bbd8270671361a3ca22be3ac3545bcda123240a1df78000654ff23189ced538a40c86f966 b2582952a2a53a312ba03671d5168335121da55215d70753cc86c3095ed5f6e92cfc1f0e62ec10461469fe95dd25a454 85f6841b5073259644168f93d3cbb7d91acf4a623a05d28a52bc11a275f94b871f775813783f1240d688ec366bb74810 a3e5eeb07c168334ec2f059aef396b741021cec9b1ff4bff2cb120188d155abde2bca4857547162be85e4be39a90a580 94ae9cddc014f85e805fc54e575f23ab38a4530c3a326a0fc8e22a9957e0e87c1c33a1a9b3e8ff0fd40be148ef008f50 ad48b106c5f4fc767ca862688f08bcc82360d8c121fa2e8d49fde783a31a31ea86cdf94a95f8985d68c17d31c1b41ef1 8cc4cb32bd5f1a659ea8f52743d836f29ad2541f181270473352dc98a5217b0c72329bd24244a4e3c9e5c80aff1d1861 ab845a017ffc5e5237cedc08bd55a36f6a8e98fb77940f84e07c055f90fd109096fc8299fce6104654e1367fc5989804 a087d9746b891e6e312d94755da09672f9719aeba3282fdb6821c9c8b3179624d703ce8e91c2f4cae5264bf762bc9cd8 a57fa8f7d35b5821f477146251b3e3db8154fe3bb95a7a48f989710387014c08a77d7f708784be380979d6478e0dc4b1 ac9e6ce41b04b23408b94ed3e00f92ce46ae711a65e04231cb92dd8bf205597c38041e8cd04a8c4c773b06d2b9805244 99339c2cd96ab9da7369dd9659b927b7a223e89dad76533b31512ead7feacc3516c20c6a5934502f75dd58d806042e7e a646b8451b78b4d1d52cd3c97e901a2d0ded09738ea060a72946c4756cd821d0bc246338e71aec25c3e9d81ceda95ed2 892098735433f418ebad464cdcc48023ebd0004cd4b5b66bce9e951a40e04ad7622c788466765f5d79e71841e2beaba5 b3a2e715d85a6bbb21d65a500300bbd9e8d2befff9deda1c7cdccca77e051891e5a04f11dce0242e4e8b134591e72df6 95e6d88bd14905771c78cde4a997ca260ab293c060d0a0f92315c65cb3bb383726d4cd0bb8b82302099db4c32da031e1 9900f4866d13a62c33167510ac7bfb38f0ce44e1fa1937995badb28a6858f52c8cd206ac94fde4c21da78174fc480538 962b38f837905ca5532e82398087ac2e66117ff49eff7ace01f89a5384077674d3b453fdb1e4e358be7c95277a10c2e8 8ecd67b1efd5b6a87de4ca48f659f4120720dfb06721dbd83c4dd916683a2affe72ae8daa8b069ab5f6e197800ca1e2c 92d049706d48b2971a9ab183064caa7eb4e1b416e88e20403eee3880ee73412186f0567a9fc3d0b510e4f5295ca62283 885e21055123f2437e26c37b3dc92a7d1984c56dff528913906da3e8914cd39487b2d4d3f315f5b14d3e3ee13f5e989b b283ab3d13cada85c19395b8a42f942576fac7f71e82f68982400ed9ddb43b8eef3292dd19cd07d289028da8b0549c6e 8559f6f78387ded052d4c4d0bdb5f3f0181ea41d5c424f978047ac683bed1b4071a55f9fe8d0eeadefc63ae5357c954f 87fce6fee1c4ed1f5567868154e619c052fd1c4d235a0e6da87017b7ea664a8a6d09c01cab85a7d7d41fd8b0a643030d a1d4ed6fe6f4ea90d517bf0ab1509e5df619a3d6b75c377d3951c0f094c23a16f84fe2634938501f2f4ab5a6cfa899f6 abdfe4741b8cafdd61fbf4bc898c920690e049806403f4f31ca68e859b27c0c0316e1132b57c1a026ce1995ed6269c47 94484222afc5fc68977f9c5c709e23d1d4187ccf03cff82ca221fa04e3814d017cbdf3ca1984dc33db262eecf198f6e9 adbaf8f15cd0940bd60f1c5bc93d9efc24cb3ddeb066bc3bfc3265deede4b0bdbeff1b91b60a7ff7f0f3e860cfd8d78a 8658a54fdf73c593d4561af5f06400b5939dc8ee1cfdc6c76a9c6e9178b34afce57d001faa1bf181afcdc3cfcae0c9fe b05934860522fc7fe1e2eae00b371e7b7274c4ec85159c1bc41e8040973b7a6889bb97855d335a326b9d9eb5b1f182d2 b538763148782c913b192476fa91df291f2fd984d79ef68aef0aad6fbfac45434b91006fbfdf7c6944400413fd6c467f 90d98b58243adab59d024f92dc7b8398e621cc731a1d364a591a8e109fcf7a4761b41ff687c3b9c3a3d884de4af61b0c 82403f8651bac9c492772948654acb23410adf0a2bf11846e295a2ee6beadb5e5ed1ab87a667fd8e3cc0fc1c5c33e624 a333e341abdb4657e531d463a16604b85526805569bf8ff09a8fbb8518453bf4533f10c2cc959a6348e16136eda82ed3 a8009eac25133a055a35867d2133d031c82c930d205f53c1417626108faa1f57d881ca9ab4744cd15409f9b5ba79d252 b33b3c25b527241922f1e87802b08a786ce260e648cf7aecf0201d48dc0d69836e25bdc2cbda22edd7a83456e37bbbda aa2ea1635d6a2b9aadbbfdb91bc73d571b0e0b138e05e90ddf3a6ff0b532196a564bcdbf1981c85028858e3cbf9bd0ef 975ee5df931748b50c7aee31758d08a8276a18d4ee2ddb33da2c15af5898f6c274dbc56d7b28a056445b8f47d7f128c9 90a0fe62326711bafdff78e94e0c567b0c43192d01787a441a8d0b0a392d7cc4cb3ee337e3680039d889e8a4f9ef4867 a73cbc800b6a002b725965fa0bdf7b6ab594fcf9f3e78da927a5ee962db98fbae649132b2256708a28954b3ff7a9cd4e 8713b38dfc2dacb2d41cf6b5186e4bc2e19d3c02b3f6e76c144c5f4663481349f46fda1526ab1666a31148219abadfc5 b7a81f78b0c20181192b1c0bdf03cc3b2c03151df1063b79e9270eb1445d7740e6c6e4be2187ba1ceb248675e96b314a 91d09d302e3dbab08a4afeba5ba79278bfdc3196f0d5e54de7df5b2e65a68a72af328f9ca52f0150e89cd52ecc8e132d b529ca1e9e6a0c15f574e08b2275defe1901a2e39119de6d9e053a4b4b8e33c65cc51cc9e4040bd91f1e7246605c1a8a b20d466ba3755e0599e43bd158f976b1b2d029f9c2058c35ec50079dc8e451321599e9af6d63a44149a47f0637354e64 993f3eb51314c67b85b59e1ca28575bf8687c343640d8b4aec2224eb5c1ab50674e2947d0be67f8effcc727ff205bacb a7fc0accdfcbe377a89df768cd6ee86dbe7083efc593a30b797fbb7ccb4236d5ccfa0113a3e82ff21e65da19d0d6609f a8e65a265ff8a71d1e42f5e8cbb63e79148a9d232fa962e0540225f4ae8f4f7cf510e0c60f6b270ea5ccf7fbee814342 b38908f1680da87f85b64ee26c121632aba4bf9faf3be9d924a0737776ec47a10d68295dc4954fb2eac9dc5fc248c864 b17e172e9a0cc54feaa793f4d654a4eb6639bb09710c3374bb2d580e71d2fb39d94e359648ae55cff42a7959dc8e86d8 b6568bfeae23df67f6b62e2ed0680f19e69d8eb1662702eebd86b9f09b0139ce06f2bd010a5813166be534422405b34d 86ada7858bc832a2e94639f4fbaf259f386e258c10eb345027332cb32910ea77c85206a3f6c77a21afeca4ed1716542d 9849c0df037d1f8c3d05b5b1d4c8f464f5e8bfc0841e0ae5766919b624ae8849697560289186c151aa32c2cf202f4bc5 8f470c12d1640a76f299b7161b9c75e70b259404317a0334358794c2cdb8df6a74f2060b678c74eb5ee394f3bcd3cb78 b2e27c491bab61d1eddf7305a40c662d5e7bb023259e646bf400eac83e2b8adf5af5c7c6d2780b97756478f2a0d4e954 aed804445e3f9a396e386a408f0830f8361a797de43b8d7215859fe4ec37cb82817e3be1844161c8a067a0a757af2a74 aa14a73c4ac0ab8be1646df06954a44d93d3422025e70ba1d88aa8398aec842dfb7a2cc52bde2c8e90b39850a63b0bac b90869d001a7b42f2bd5479d11c3a693e4e035194db3e5bf9bd1627216198e7a674b43e69c322d3019eff8dcdfa89229 8b7489acf4b6dc658c9f32fece2d3698944ef160e925074601bdfd9138f0d0c26b52b9ee1b9acfd00e182882c86d3f31 a8d4f8f8eb71c3ef8b0e9dba2e3c1f97188bf1177aab0c63e7c7dc3d73c2c207b41438ddcf3f1d80780fe8abaae2a548 abb058c32ced59d237b3a831da0f311e3efb149067bfc8d6e000d3976ae80b93fcbac1a3197443ad3c03912eb95811ea 8a9ce1265b81d3f5e9b242db001ff3c6c7ac9835914769b573147c3e59e605dc3c66f04ba32d4fd86c1517f2285a7671 85bc9255ce0322d30a3a2a2ceab7c2db83a771650b70a09a86323cdbb0d367dd966ad6e23940b3440ced7406853742e9 996dc7580cd22bb4f9024ec0661bc0fd71992c92cee9268dcad81eb71be238c1c62ca2107ebbdd20152f8b41248db8c9 842c33fe207dc99c84c91a94bc52c568d92cc250e7803f29f544e8a2613f1fa96ccbfaffc36dff10f5366011975d2c0c 8ed5f887dd1a855b66b3716cf04489e0527ab602c87cf3978ffefca4d557df6c02867eb0e10cd91ea023d723749dc592 8db25f47ed86404b8d167caf40a3432714e0ad8954315136db1b85de63c746c1a7f304b440805fb9aa4529ac4c8e72fb a2f231118737cc7021e50962cd5b667f9f8f9c6973d4bf2e515796fb27fb8621b7967576e2a7de969d885b57923874e1 a27d24ecf1424633c31015ca0ea87950e461776367e7fef8e65920e57eb2f3f5840c18ec7b011aefc02e13affeff4e54 8fe305b7ef273e59b3f32de74f5673668345e36483e2cc635a7b07a6706365798c14d31a7ae93a52072b708f968a9395 a3336775df5bab0efab52985d0a03eb1959b26280068b7c2068e243406fda56a04056a15b491c08113609f368b88abc6 85c5bb042edd8d7257df699146d3aebefe5670511db85183d7a73433ab73049e7f90540ffc8dfa56bf7e489585745a40 96103029bf130319c800e897a755efe319c94a34fb073f41bdc8e7a751a8a3f9476ded1aa076c4a2117185f50b13682b b255909e148a0c716d34051565cb211c0cc41daaedd707864113e92aa8cf2ecf5a9ee7d660b265a4528798fae433ea62 8b48b8d098947cab106bb4b967e4f6f63640f4908753fec1c20ecab1132e30fd7071e73b51f2e85707b03a85086dd9d2 97ea609ce92b5f349193a71cb1e2e9c0821400507206845c7b7a4bea1711b5b3df5bd46fbeb8d0a757012f39123f85d0 a966c6478398de6fe91710898730b4c3a86383037a2a4f659c4c172d6232a1bde5dad7a08392a06726975b933f8371be a70e3806e6d90364d37769f315799dc8ea3401f4b5ec2b1de840c85dacce73a3c952763985a9f8255b89ea0b83cf6935 88714770cfeef4a0630fc34e1c658863eedbf9c55daf3279726d442d66b707146034c748eb532a45228ae4def61b5f59 8f6dd348d8522121a33f94988f9b6ef9b06935991226da4f85ae4819e3d38e5d024d6546c710c50b383e0f485a7c9664 9750aaf660ca8070f745383a69f4ed97d377f3023228ae71489e90d5480564796a971ef90f22eed3ac8817b64603f378 af754ca7fc20a7990d1b48604923e32297c287d6c871b33d940e975052bb9fa01173dc4d7ec7627ee7776a55730ed001 af23e84cbf581a19763f1b0c3dd017becc76286bb6a7ad4fe1ceead5c35293a8dd68b8b3da74efcefcbcb8097d269d3a ac5847d053ab3f9a18e410f4b72412f73a7394b0dd2764718b79913644d268e69baf4e68a4b005d9550cc950dbd91435]
0x866239e8df85b037fa11322e5f22662e8c412e82ae0df6a3dee4895853f8e9ae79c4bd5c394dff261caad03b381195c701f27f7b02581cf2a9fbb7543fe29724dbfea844e1919386191c850d93aaf7392168004ba198a87ef4aaca5f33947236
The data comes from attestation 0 of block 1041104: https://beaconcha.in/slot/1041104#attestations But I get "false", could you please help take a look on what could go wrong with it? Same thing happen for all other attestations. If I don't remove "0x", then I just get true and false quite randomly from the function.
@herumi
I'll verify it, please wait a moment. By the way, bls-eth-go-binary passes the test in https://github.com/herumi/bls-eth-go-binary/tree/master/bls/tests, which Ethereum provides. Does beaconcha use the same configuration?
https://github.com/herumi/bls-eth-go-binary/issues/51#issue-1456678029
pk1.SetHexString
Please use DeserializeHexStr
instead of SetHexString
.
err := pk1.DeserializeHexStr("a72e1527927d43beb052ddbdbfe4417d26d1b3d739bf28e7f5ebcc2382354933d6361a586cd578884c009d04c89d80ba")
if err != nil {
fmt.Printf("pk1 err=%s\n", err)
return
}
fmt.Printf("pk1=%x\n", pk1.Serialize())
How to create pk from hex string? I am trying to verify an aggregated bls signature but always get false for a valid signature.
Also where can we get the root hash of the data aalidator is signing on eth2.0? Is it the block root / state root / some other things that can't been seen here?