Пример #1
0
        public static unsafe void HashWithDomain(out Span <byte> signatureBytes, out Span <byte> blsSignatureBytes, Span <byte> hashBytes, Span <byte> domainBytes)
        {
            blsSignatureBytes = new byte[BlsSignatureLength];
            signatureBytes    = new byte[SignatureLength];

            Span <byte> hashWithDomain = stackalloc byte[HashLength + DomainLength];

            hashBytes.CopyTo(hashWithDomain.Slice(0, 32));
            domainBytes.CopyTo(hashWithDomain.Slice(32, 8));

            fixed(byte *signatureBytesRef = signatureBytes)
            fixed(byte *blsSignatureBytesRef = blsSignatureBytes)
            fixed(byte *hashWithDomainRef    = hashWithDomain)
            {
                switch (Platform)
                {
                case OsPlatform.Windows:
                    Win64Lib.blsHashWithDomainToFp2(signatureBytesRef, hashWithDomainRef);
                    break;

                case OsPlatform.Mac:
                    MacLib.blsHashWithDomainToFp2(signatureBytesRef, hashWithDomainRef);
                    break;

                case OsPlatform.Linux:
                    PosixLib.blsHashWithDomainToFp2(signatureBytesRef, hashWithDomainRef);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(Platform.ToString());
                }

                DeserializeSignature(blsSignatureBytesRef, signatureBytesRef);
            }
        }