Private/Checksum/New-SecretSharingChecksum.ps1

function New-SecretSharingChecksum {
    <#
    .SYNOPSIS
        Computes the 3-word RS1024 checksum for a SLIP-0039 share's data words.
    .DESCRIPTION
        Appends 3 zero placeholder words to the customization string + Data, computes
        the RS1024 polymod, XORs it with 1, and returns the 3 checksum words (each a
        10-bit value 0-1023) most-significant word first - the value to append after
        Data to form a complete, checksummed share.
    #>

    [CmdletBinding()]
    [OutputType([int[]], [System.Object[]])]
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute(
        'PSUseShouldProcessForStateChangingFunctions', '',
        Justification = 'Pure in-memory computation; no external state is changed.')]
    param(
        [Parameter(Mandatory)]
        [int[]]$Data,

        [switch]$Extendable
    )

    $constant = Get-SecretSharingChecksumConstant
    $customizationString = Get-SecretSharingChecksumCustomizationString -Extendable:$Extendable
    $padding = [int[]]::new($constant.ChecksumLengthWords)

    $values = [int[]]($customizationString + $Data + $padding)
    $polymod = (Invoke-SecretSharingRs1024Polymod -Value $values) -bxor 1

    $checksum = [int[]]::new($constant.ChecksumLengthWords)
    for ($i = 0; $i -lt $constant.ChecksumLengthWords; $i++) {
        $wordIndex = $constant.ChecksumLengthWords - 1 - $i
        $checksum[$i] = ($polymod -shr (10 * $wordIndex)) -band 1023
    }

    return , $checksum
}