mattrglobal / pairing_crypto

A library for pairing based cryptography
Apache License 2.0
14 stars 7 forks source link

Obj-c wrapper generateKeyPair supports nullable "ikm" #104

Closed zhenwenc closed 1 year ago

zhenwenc commented 1 year ago

At the moment, when generating a BbsBls12381Sha256KeyPair or BbsBls12381Shake256KeyPair keypair, the ikm argument must be specified:

https://github.com/mattrglobal/pairing_crypto/blob/1b92ff562f85b31507d5fca45fb273c6ffcf6eef/wrappers/obj-c/pairing_crypto/bbs_bls12381_shake256_key_pair.m#L20-L22

However, the React Native wrapper is expected to support nullable ikm and/or keyInfo. As a workaround, it generates random bytes to be the value when ikm is absent:

https://github.com/mattrglobal/pairing_crypto/blob/09386deae1ba8d62b22cd1cd6049cc74abe6cbf9/wrappers/react-native/ios/PairingCryptoRn.m#L37-L44

This needs to be implemented in the C or Obj-c wrapper instead, and use secure random properly.