Table of Contents

Class SecureBigUnsignedInteger

Namespace
LibSodium
Assembly
LibSodium.Net.dll

Provides methods for working with arbitrary large little endian big unsigned integers in a secure way (constant time for a given length)

public static class SecureBigUnsignedInteger
Inheritance
SecureBigUnsignedInteger
Inherited Members

Methods

Add(Span<byte>, ReadOnlySpan<byte>)

Adds two byte buffers representing big unsigned integers in constant time, storing the result in the second buffer

public static void Add(Span<byte> a, ReadOnlySpan<byte> b)

Parameters

a Span<byte>

The first byte buffer representing a big unsigned integer.

b ReadOnlySpan<byte>

The second byte buffer representing a big unsigned integer. It receives the result.

Compare(ReadOnlySpan<byte>, ReadOnlySpan<byte>)

Compares two byte buffers representing big unsigned integers.

public static int Compare(ReadOnlySpan<byte> b1, ReadOnlySpan<byte> b2)

Parameters

b1 ReadOnlySpan<byte>

The first byte buffer.

b2 ReadOnlySpan<byte>

The second byte buffer.

Returns

int

A negative number if b1 is less than b2, zero if they are equal, and a positive number if b1 is greater than b2.

Equals(ReadOnlySpan<byte>, ReadOnlySpan<byte>)

Compares two byte buffers for equality in constant time.

public static bool Equals(ReadOnlySpan<byte> b1, ReadOnlySpan<byte> b2)

Parameters

b1 ReadOnlySpan<byte>

First buffer to compare.

b2 ReadOnlySpan<byte>

Second buffer to compare.

Returns

bool

True if the buffers are equal, false otherwise.

Increment(Span<byte>)

Increments the given byte buffer representing a big unsigned integer by 1.

public static void Increment(Span<byte> number)

Parameters

number Span<byte>

The byte buffer to increment.

Increment(Span<byte>, ulong)

Increments the given byte buffer representing a big unsigned integer by a specified value.

public static void Increment(Span<byte> number, ulong increment)

Parameters

number Span<byte>

The byte buffer representing a big unsigned integer to increment.

increment ulong

The value to increment by.

IsZero(ReadOnlySpan<byte>)

Checks if the given byte buffer is zero.

public static bool IsZero(ReadOnlySpan<byte> b)

Parameters

b ReadOnlySpan<byte>

The byte buffer to check.

Returns

bool

True if the byte buffer is zero, false otherwise.

Subtract(Span<byte>, ReadOnlySpan<byte>)

Subtracts one byte buffer from another representing big unsigned integers.

public static void Subtract(Span<byte> subtrahend, ReadOnlySpan<byte> minuend)

Parameters

subtrahend Span<byte>

The byte buffer to subtract from.

minuend ReadOnlySpan<byte>

The byte buffer to subtract.