Пример #1
0
        public BlsKeyPair(byte[] keyData)
        {
            if (keyData.Length == SecretKeySize)
            {
                SecretKey = new ReadOnlyCollection <byte>(keyData);

                using var context = new UnmanagedMemoryContext();

                Native.bls_get_public_key(context.ToBuffer(keyData), out var publicKey, out var error);
                context.ThrowIfNeeded(error);

                PublicKey = context.ToReadOnlyCollection(publicKey);
            }
            else if (keyData.Length == PublicKeySize)
            {
                PublicKey = new ReadOnlyCollection <byte>(keyData);
            }
            else
            {
                throw new BbsException("Invalid key size");
            }
        }