Esempio n. 1
0
        private static void MixIn(Span <byte> span, int value)
        {
            Span <byte> valueBytes = stackalloc byte[32];

            BinaryPrimitives.WriteInt32LittleEndian(valueBytes.Slice(0, 4), value);
            Chunk result = HashConcatenation(MemoryMarshal.Cast <byte, Chunk>(span)[0], MemoryMarshal.Cast <byte, Chunk>(valueBytes)[0], 0);

            result.ToLittleEndian(span);
        }
Esempio n. 2
0
        internal static Chunk HashConcatenation(Chunk left, Chunk right, int level)
        {
            if (IsZeroHash(left, level) && IsZeroHash(right, level))
            {
                return(ZeroHashes[level + 1]);
            }

            Span <Chunk> concatenation = stackalloc Chunk[2];

            concatenation[0] = left;
            concatenation[1] = right;
            return(Compute(concatenation));
        }
Esempio n. 3
0
 private static bool IsZeroHash(Chunk span, int level)
 {
     return(span.Equals(ZeroHashes[level]));
 }