-
+ DC79CACA9A6A286AEC3B4484F21E55F8A61AE1B991CE17909CB3DAFE0EF2F761ECA6043CF6A86F10EE7E8582DD95F233E271978210DD8778F4140D51DDC8E040
ffa/libffa/fz_prime.ads
(0 . 0)(1 . 41)
615 ------------------------------------------------------------------------------
616 ------------------------------------------------------------------------------
617 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
618 -- --
619 -- (C) 2019 Stanislav Datskovskiy ( www.loper-os.org ) --
620 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
621 -- --
622 -- You do not have, nor can you ever acquire the right to use, copy or --
623 -- distribute this software ; Should you use this software for any purpose, --
624 -- or copy and distribute it to anyone or in any manner, you are breaking --
625 -- the laws of whatever soi-disant jurisdiction, and you promise to --
626 -- continue doing so for the indefinite future. In any case, please --
627 -- always : read and understand any software ; verify any PGP signatures --
628 -- that you use - for any purpose. --
629 -- --
630 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
631 ------------------------------------------------------------------------------
632 ------------------------------------------------------------------------------
633
634 with Words; use Words;
635 with FZ_Type; use FZ_Type;
636
637
638 package FZ_Prime is
639
640 pragma Pure;
641
642 -- Constant-Time Miller-Rabin Test on N using the given Witness.
643 -- Witness will be used as-is if it conforms to the valid bounds,
644 -- i.e. 2 <= Witness <= N - 2; otherwise will be transformed into a
645 -- valid Witness via modular arithmetic.
646 -- Outputs ONE if N WAS FOUND composite; ZERO if NOT FOUND.
647 -- Handles degenerate cases of N that M-R per se cannot eat:
648 -- N=0, N=1: ALWAYS 'FOUND COMPOSITE'; 2, 3 - ALWAYS 'NOT FOUND'.
649 -- If N is Even and not equal to 2, N is ALWAYS 'FOUND COMPOSITE.'
650 -- For ALL other N, the output is equal to that of the M-R test.
651 function FZ_MR_Composite_On_Witness(N : in FZ;
652 Witness : in FZ) return WBool
653 with Pre => N'Length = Witness'Length;
654
655 end FZ_Prime;