-
+ A61E949EB6A9D5EA3A15661A3E85F563512425BB3B9B88E611D7D4D1B185998B8DA2F51C730EF2453A71174ECB0B787FEDE98F5C98ACDD8434EF6AF1C03853E3
ffa/libffa/fz_barr.ads
(0 . 0)(1 . 53)
520 ------------------------------------------------------------------------------
521 ------------------------------------------------------------------------------
522 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
523 -- --
524 -- (C) 2018 Stanislav Datskovskiy ( www.loper-os.org ) --
525 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
526 -- --
527 -- You do not have, nor can you ever acquire the right to use, copy or --
528 -- distribute this software ; Should you use this software for any purpose, --
529 -- or copy and distribute it to anyone or in any manner, you are breaking --
530 -- the laws of whatever soi-disant jurisdiction, and you promise to --
531 -- continue doing so for the indefinite future. In any case, please --
532 -- always : read and understand any software ; verify any PGP signatures --
533 -- that you use - for any purpose. --
534 -- --
535 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
536 ------------------------------------------------------------------------------
537 ------------------------------------------------------------------------------
538
539 with Words; use Words;
540 with FZ_Type; use FZ_Type;
541
542
543 package FZ_Barr is
544
545 pragma Pure;
546
547 -- Precomputed data for Barrett's Modular Reduction
548 type Barretoid(ZXMLength : Indices;
549 BarretoidLength : Indices) is
550 record
551 ZXM : FZ(1 .. ZXMLength); -- Zero-Extended Modulus
552 J : FZBit_Index; -- Jm
553 B : FZ(1 .. BarretoidLength); -- The Barrettoid itself
554 ZSlide : FZBit_Index; -- Amount to slide Z
555 Degenerate : WBool; -- Is it degenerate case?
556 end record;
557
558
559 -- Prepare the precomputed Barrettoid corresponding to a given Modulus
560 procedure FZ_Make_Barrettoid(Modulus : in FZ;
561 Result : out Barretoid)
562 with Pre => Result.B'Length = 2 * Modulus'Length and
563 Result.ZXM'Length = Modulus'Length + 1;
564
565
566 -- Reduce N using the given precomputed Barrettoid.
567 procedure FZ_Barrett_Reduce(X : in FZ;
568 Bar : in Barretoid;
569 XReduced : in out FZ);
570 pragma Inline_Always(FZ_Barrett_Reduce);
571
572 end FZ_Barr;