public bool BlsVerify(BlsPublicKey publicKey, Hash32 messageHash, BlsSignature signature, Domain domain)
        {
            var blsParameters = new BLSParameters()
            {
                PublicKey = publicKey.AsSpan().ToArray()
            };

            using var signatureAlgorithm = SignatureAlgorithmFactory(blsParameters);
            return(signatureAlgorithm.VerifyHash(messageHash.AsSpan(), signature.AsSpan(), domain.AsSpan()));
        }
        public bool BlsVerify(BlsPublicKey publicKey, Root signingRoot, BlsSignature signature)
        {
            BLSParameters blsParameters = new BLSParameters()
            {
                PublicKey = publicKey.AsSpan().ToArray()
            };

            using BLS signatureAlgorithm = SignatureAlgorithmFactory(blsParameters);
            return(signatureAlgorithm.VerifyHash(signingRoot.AsSpan(), signature.AsSpan()));
        }
        public bool BlsAggregateVerify(IList <BlsPublicKey> publicKeys, IList <Root> signingRoots, BlsSignature signature)
        {
            int count = publicKeys.Count();

            Span <byte> publicKeysSpan      = new Span <byte>(new byte[count * BlsPublicKey.Length]);
            int         publicKeysSpanIndex = 0;

            foreach (BlsPublicKey publicKey in publicKeys)
            {
                publicKey.AsSpan().CopyTo(publicKeysSpan.Slice(publicKeysSpanIndex));
                publicKeysSpanIndex += BlsPublicKey.Length;
            }

            Span <byte> signingRootsSpan      = new Span <byte>(new byte[count * Root.Length]);
            int         signingRootsSpanIndex = 0;

            foreach (Root signingRoot in signingRoots)
            {
                signingRoot.AsSpan().CopyTo(signingRootsSpan.Slice(signingRootsSpanIndex));
                signingRootsSpanIndex += Root.Length;
            }

            return(_bls.AggregateVerifyData(publicKeysSpan, signingRootsSpan, signature.AsSpan()));
        }
Exemplo n.º 4
0
        public bool BlsVerifyMultiple(IEnumerable<BlsPublicKey> publicKeys, IEnumerable<Hash32> messageHashes, BlsSignature signature, Domain domain)
        {
            int count = publicKeys.Count();

            Span<byte> publicKeysSpan = new Span<byte>(new byte[count * BlsPublicKey.Length]);
            int publicKeysSpanIndex = 0;
            foreach (BlsPublicKey publicKey in publicKeys)
            {
                publicKey.AsSpan().CopyTo(publicKeysSpan.Slice(publicKeysSpanIndex));
                publicKeysSpanIndex += BlsPublicKey.Length;
            }

            Span<byte> messageHashesSpan = new Span<byte>(new byte[count * Hash32.Length]);
            int messageHashesSpanIndex = 0;
            foreach (Hash32 messageHash in messageHashes)
            {
                messageHash.AsSpan().CopyTo(messageHashesSpan.Slice(messageHashesSpanIndex));
                messageHashesSpanIndex += Hash32.Length;
            }

            using BLS signatureAlgorithm = SignatureAlgorithmFactory(new BLSParameters());
            return signatureAlgorithm.VerifyAggregate(publicKeysSpan, messageHashesSpan, signature.AsSpan(), domain.AsSpan());
        }
 public bool BlsVerify(BlsPublicKey publicKey, Root signingRoot, BlsSignature signature)
 {
     return(_bls.VerifyData(publicKey.AsSpan(), signingRoot.AsSpan(), signature.AsSpan()));
 }
        public bool BlsFastAggregateVerify(IList <BlsPublicKey> publicKeys, Root signingRoot, BlsSignature signature)
        {
            List <byte[]> publicKeysList = new List <byte[]>();

            foreach (BlsPublicKey publicKey in publicKeys)
            {
                publicKeysList.Add(publicKey.Bytes);
            }

            return(_bls.FastAggregateVerifyData(publicKeysList, signingRoot.AsSpan(), signature.AsSpan()));
        }
 public static SszElement ToSszBasicVector(this BlsSignature item)
 {
     return(new SszBasicVector(item.AsSpan()));
 }
        public bool BlsAggregateVerify(IList <BlsPublicKey> publicKeys, IList <Root> signingRoots, BlsSignature signature)
        {
            int count = publicKeys.Count();

            Span <byte> publicKeysSpan      = new Span <byte>(new byte[count * BlsPublicKey.Length]);
            int         publicKeysSpanIndex = 0;

            foreach (BlsPublicKey publicKey in publicKeys)
            {
                publicKey.AsSpan().CopyTo(publicKeysSpan.Slice(publicKeysSpanIndex));
                publicKeysSpanIndex += BlsPublicKey.Length;
            }

            Span <byte> signingRootsSpan      = new Span <byte>(new byte[count * Root.Length]);
            int         signingRootsSpanIndex = 0;

            foreach (Root signingRoot in signingRoots)
            {
                signingRoot.AsSpan().CopyTo(signingRootsSpan.Slice(signingRootsSpanIndex));
                signingRootsSpanIndex += Root.Length;
            }

            using BLS signatureAlgorithm = SignatureAlgorithmFactory(new BLSParameters());
            return(signatureAlgorithm.AggregateVerifyHashes(publicKeysSpan, signingRootsSpan, signature.AsSpan()));
        }