#!/bin/sh

if [ $# -ne 1 ] ; then
    echo "usage:  $0 bits" >&2
    exit 1
fi

bits="$1"

m=`select -M prime -from primes.M -where "bits=$bits" | randomize | head -1`
if [ "$m" = '' ] ; then
    echo "$0: no prime available with that number of bits" >&2
    exit 1
fi
n=`echo "random($m)" | ./bic`

echo "n: $n"
echo "m: $m"
echo 'modinv:'
echo "modinv($n,$m)" | time ./bic
echo 'binmodinv:'
echo "binmodinv($n,$m)" | time ./bic
