Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › crypto › ff › Modulus › shiftIn Private Function shiftIn Doc Source Private Function std.crypto.ff.Modulus.shiftIn
fn shiftIn (self : Self , x : *Fe , y : Limb ) void Params File crypto/ff.zig: 509
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535 fn shiftIn (self : Self , x : *Fe , y : Limb ) void {
var d = self .zero ;
const x_limbs = x .v .limbs ();
const d_limbs = d .v .limbs ();
const m_limbs = self .v .limbsConst ();
var need_sub = false ;
var i : usize = t_bits - 1 ;
while (true ) : (i -= 1 ) {
var carry : u1 = @truncate (math .shr (Limb , y , i ));
var borrow : u1 = 0 ;
for (0 ..self .limbs_count ()) |j | {
const l = ct .select (need_sub , d_limbs [j ], x_limbs [j ]);
var res = (l << 1 ) + carry ;
x_limbs [j ] = @as (TLimb , @truncate (res ));
carry = @truncate (res >> t_bits );
res = x_limbs [j ] -% m_limbs [j ] -% borrow ;
d_limbs [j ] = @as (TLimb , @truncate (res ));
borrow = @truncate (res >> t_bits );
}
need_sub = ct .eql (carry , borrow );
if (i == 0 ) break ;
}
x .v .cmov (need_sub , d .v );
}
Computes x << t_bits + y (mod m)