Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shargon committed Jan 9, 2024
1 parent 9dc76fe commit 2abbfa0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Neo.Cryptography.BLS12_381/MathUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,20 @@ public static (ulong low, ulong high) Mac(ulong z, ulong x, ulong y, ulong carry
return (low, high);
}

/// <summary>Produces the full product of two unsigned 64-bit numbers.</summary>
/// <param name="a">The first number to multiply.</param>
/// <param name="b">The second number to multiply.</param>
/// <param name="low">The low 64-bit of the product of the specified numbers.</param>
/// <returns>The high 64-bit of the product of the specified numbers.</returns>
public static ulong BigMul(ulong a, ulong b, out ulong low)
{
// Adaptation of algorithm for multiplication
// of 32-bit unsigned integers described
// in Hacker's Delight by Henry S. Warren, Jr. (ISBN 0-201-91465-4), Chapter 8
// Basically, it's an optimized version of FOIL method applied to
// low and high dwords of each operand

// Use 32-bit uints to optimize the fallback for 32-bit platforms.
uint al = (uint)a;
uint ah = (uint)(a >> 32);
uint bl = (uint)b;
Expand Down

0 comments on commit 2abbfa0

Please sign in to comment.