public static byte[] GetPublicKey(byte[] privateKey, bool compressed) { byte[] publicKey = new byte[64]; if (Platform == OsPlatform.Windows ? !Win64Lib.secp256k1_ec_pubkey_create(Context, publicKey, privateKey) : !(Platform == OsPlatform.Linux ? PosixLib.secp256k1_ec_pubkey_create(Context, publicKey, privateKey) : MacLib.secp256k1_ec_pubkey_create(Context, publicKey, privateKey))) { return(null); } byte[] serializedPublicKey = new byte[compressed ? 33 : 65]; uint outputSize = (uint)serializedPublicKey.Length; uint flags = compressed ? Secp256K1EcCompressed : Secp256K1EcUncompressed; if (Platform == OsPlatform.Windows ? !Win64Lib.secp256k1_ec_pubkey_serialize(Context, serializedPublicKey, ref outputSize, publicKey, flags) : !(Platform == OsPlatform.Linux ? PosixLib.secp256k1_ec_pubkey_serialize(Context, serializedPublicKey, ref outputSize, publicKey, flags) : MacLib.secp256k1_ec_pubkey_serialize(Context, serializedPublicKey, ref outputSize, publicKey, flags))) { return(null); } return(serializedPublicKey); }