Private/Field/Invoke-SecretSharingFieldDivision.ps1

function Invoke-SecretSharingFieldDivision {
    <#
    .SYNOPSIS
        Divides one GF(256) field element by another.
    .DESCRIPTION
        Uses the exponent/logarithm tables from Get-SecretSharingFieldTable: a / b =
        Exp[(Log[a] - Log[b]) mod 255] for a nonzero dividend, 0 if the dividend is 0.
        Dividing by 0 is undefined and throws.
    #>

    [CmdletBinding()]
    [OutputType([byte])]
    param(
        [Parameter(Mandatory)]
        [byte]$A,

        [Parameter(Mandatory)]
        [byte]$B
    )

    if ($B -eq 0) {
        throw [System.DivideByZeroException]::new('Cannot divide by zero in GF(256).')
    }

    if ($A -eq 0) {
        return [byte]0
    }

    $table = Get-SecretSharingFieldTable
    $exponent = (($table.Log[$A] - $table.Log[$B]) % 255 + 255) % 255
    return [byte]$table.Exp[$exponent]
}