public BlsKeyPair(byte[] keyData) { if (keyData.Length == SecretKeySize) { SecretKey = new ReadOnlyCollection <byte>(keyData); using var context = new UnmanagedMemoryContext(); NativeMethods.bls_get_public_key(context.ToBuffer(keyData), out var publicKey, out var error); context.ThrowOnError(error); PublicKey = context.ToReadOnlyCollection(publicKey); } else if (keyData.Length == PublicKeySize) { PublicKey = new ReadOnlyCollection <byte>(keyData); } else { throw new BbsException("Invalid key size"); } }