Chia-Network / bls-signatures

BLS signatures in C++, using the blst library for BLS12-381
Apache License 2.0
295 stars 211 forks source link

Child derivation difference #461

Closed ItsANameToo closed 1 week ago

ItsANameToo commented 1 month ago

We're looking at using this library to generate BLS12-381 keypairs in accordance with EIP2333. For context, we're using https://iancoleman.io/eip2333/ as a reference (you can use airport worry fire noodle exhaust humble cruel raccoon actor stairs energy fury guitar mass mail stay grit cause muscle tide lawsuit gentle father useful as BIP39 menmonic to generate the values to check against).

Using this library, we noticed that the child derivation results in a different public/private key compared to the above website. A reproduction snippet below

master_key = PrivateKey.from_bytes(bytes.fromhex("1d36878261a6217ed16084479fbfdb9957996b819efc27472fe5748b80e34371"))
print('master_key', master_key, master_key.get_g1())

child: PrivateKey = AugSchemeMPL. derive_child_sk_unhardened(master_key, 0)
print('child', child, child.get_g1())

This results in

master_key <PrivateKey 1d36878261a6217ed16084479fbfdb9957996b819efc27472fe5748b80e34371> b3accbd4b6f6ce449d032e499748fc490f663a4e8993269e541bff852d7661da359c92c0ff77829e39addf8776928f6e
child <PrivateKey 345791229bc84b3ba358b1034c8c4a8bc42155751aa930d79d57fb00fdcc2055> ad0b723bf8ff25d399957940010288a04f38b69ceca9f07d14d7ab2db265570403a9ca1c9f0c16b889adeedba230419

This correctly outputs the same master key and master public key, but the child derivation is different. Is there something we're overlooking when using this library to have the correct derivation to match the linked site?

ItsANameToo commented 1 month ago

For anyone interested, the difference is due to this library implementing v2 while the website relies on the v4 BLS specs. This library can be adjusted to support that, please refer to the PR on our fork to see how

github-actions[bot] commented 2 weeks ago

'This issue has been flagged as stale as there has been no activity on it in 14 days. If this issue is still affecting you and in need of review, please update it to keep it open.'

github-actions[bot] commented 1 week ago

'This issue was automatically closed because it has been flagged as stale and subsequently passed 7 days with no further activity.'