Ejemplo n.º 1
0
        public static bool Verify(PublicKey publicKey, ReadOnlySpan <byte> signature, Hash256 channelId, XrpAmount amount)
        {
            Span <byte> buffer = stackalloc byte[44];

            System.Buffers.Binary.BinaryPrimitives.WriteUInt32BigEndian(buffer, hpCLM);
            channelId.CopyTo(buffer.Slice(4));
            System.Buffers.Binary.BinaryPrimitives.WriteUInt64BigEndian(buffer.Slice(36), amount.Drops);
            return(publicKey.Verify(buffer, signature));
        }
Ejemplo n.º 2
0
        public static Hash256 CalculatePage(Hash256 root, uint page)
        {
            Span <byte> buffer = stackalloc byte[38];

            System.Buffers.Binary.BinaryPrimitives.WriteUInt16BigEndian(buffer, 0x0064);
            root.CopyTo(buffer.Slice(2));
            System.Buffers.Binary.BinaryPrimitives.WriteUInt32BigEndian(buffer.Slice(34), page);
            return(CalculateId(buffer));
        }
Ejemplo n.º 3
0
        private const uint hpCLM = 0x434C4D00u; // CLM

        public static byte[] Authorize(KeyPair keyPair, Hash256 channelId, XrpAmount amount)
        {
            Span <byte> buffer = stackalloc byte[44];

            System.Buffers.Binary.BinaryPrimitives.WriteUInt32BigEndian(buffer, hpCLM);
            channelId.CopyTo(buffer.Slice(4));
            System.Buffers.Binary.BinaryPrimitives.WriteUInt64BigEndian(buffer.Slice(36), amount.Drops);
            return(keyPair.Sign(buffer));
        }