diff --git a/lib/std/crypto/pcurves/p256/p256_64.zig b/lib/std/crypto/pcurves/p256/p256_64.zig index c60ca6c110..11c7652968 100644 --- a/lib/std/crypto/pcurves/p256/p256_64.zig +++ b/lib/std/crypto/pcurves/p256/p256_64.zig @@ -18,7 +18,6 @@ // if x1 & (2^256-1) < 2^255 then x1 & (2^256-1) else (x1 & (2^256-1)) - 2^256 const std = @import("std"); -const cast = std.meta.cast; const mode = std.builtin.mode; // Checked arithmetic is disabled in non-debug modes to avoid side channels // The type MontgomeryDomainFieldElement is a field element in the Montgomery domain. @@ -148,7 +147,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x17: u64 = undefined; var x18: u1 = undefined; addcarryxU64(&x17, &x18, x16, x8, x5); - const x19 = (cast(u64, x18) + x6); + const x19 = (@as(u64, x18) + x6); var x20: u64 = undefined; var x21: u64 = undefined; mulxU64(&x20, &x21, x11, 0xffffffff00000001); @@ -161,7 +160,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x26: u64 = undefined; var x27: u1 = undefined; addcarryxU64(&x26, &x27, 0x0, x25, x22); - const x28 = (cast(u64, x27) + x23); + const x28 = (@as(u64, x27) + x23); var x29: u64 = undefined; var x30: u1 = undefined; addcarryxU64(&x29, &x30, 0x0, x11, x24); @@ -198,7 +197,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x51: u64 = undefined; var x52: u1 = undefined; addcarryxU64(&x51, &x52, x50, x42, x39); - const x53 = (cast(u64, x52) + x40); + const x53 = (@as(u64, x52) + x40); var x54: u64 = undefined; var x55: u1 = undefined; addcarryxU64(&x54, &x55, 0x0, x31, x45); @@ -213,7 +212,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme addcarryxU64(&x60, &x61, x59, x37, x51); var x62: u64 = undefined; var x63: u1 = undefined; - addcarryxU64(&x62, &x63, x61, cast(u64, x38), x53); + addcarryxU64(&x62, &x63, x61, @as(u64, x38), x53); var x64: u64 = undefined; var x65: u64 = undefined; mulxU64(&x64, &x65, x54, 0xffffffff00000001); @@ -226,7 +225,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x70: u64 = undefined; var x71: u1 = undefined; addcarryxU64(&x70, &x71, 0x0, x69, x66); - const x72 = (cast(u64, x71) + x67); + const x72 = (@as(u64, x71) + x67); var x73: u64 = undefined; var x74: u1 = undefined; addcarryxU64(&x73, &x74, 0x0, x54, x68); @@ -242,7 +241,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x81: u64 = undefined; var x82: u1 = undefined; addcarryxU64(&x81, &x82, x80, x62, x65); - const x83 = (cast(u64, x82) + cast(u64, x63)); + const x83 = (@as(u64, x82) + @as(u64, x63)); var x84: u64 = undefined; var x85: u64 = undefined; mulxU64(&x84, &x85, x2, (arg2[3])); @@ -264,7 +263,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x96: u64 = undefined; var x97: u1 = undefined; addcarryxU64(&x96, &x97, x95, x87, x84); - const x98 = (cast(u64, x97) + x85); + const x98 = (@as(u64, x97) + x85); var x99: u64 = undefined; var x100: u1 = undefined; addcarryxU64(&x99, &x100, 0x0, x75, x90); @@ -292,7 +291,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x115: u64 = undefined; var x116: u1 = undefined; addcarryxU64(&x115, &x116, 0x0, x114, x111); - const x117 = (cast(u64, x116) + x112); + const x117 = (@as(u64, x116) + x112); var x118: u64 = undefined; var x119: u1 = undefined; addcarryxU64(&x118, &x119, 0x0, x99, x113); @@ -308,7 +307,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x126: u64 = undefined; var x127: u1 = undefined; addcarryxU64(&x126, &x127, x125, x107, x110); - const x128 = (cast(u64, x127) + cast(u64, x108)); + const x128 = (@as(u64, x127) + @as(u64, x108)); var x129: u64 = undefined; var x130: u64 = undefined; mulxU64(&x129, &x130, x3, (arg2[3])); @@ -330,7 +329,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x141: u64 = undefined; var x142: u1 = undefined; addcarryxU64(&x141, &x142, x140, x132, x129); - const x143 = (cast(u64, x142) + x130); + const x143 = (@as(u64, x142) + x130); var x144: u64 = undefined; var x145: u1 = undefined; addcarryxU64(&x144, &x145, 0x0, x120, x135); @@ -358,7 +357,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x160: u64 = undefined; var x161: u1 = undefined; addcarryxU64(&x160, &x161, 0x0, x159, x156); - const x162 = (cast(u64, x161) + x157); + const x162 = (@as(u64, x161) + x157); var x163: u64 = undefined; var x164: u1 = undefined; addcarryxU64(&x163, &x164, 0x0, x144, x158); @@ -374,7 +373,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x171: u64 = undefined; var x172: u1 = undefined; addcarryxU64(&x171, &x172, x170, x152, x155); - const x173 = (cast(u64, x172) + cast(u64, x153)); + const x173 = (@as(u64, x172) + @as(u64, x153)); var x174: u64 = undefined; var x175: u1 = undefined; subborrowxU64(&x174, &x175, 0x0, x165, 0xffffffffffffffff); @@ -383,13 +382,13 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme subborrowxU64(&x176, &x177, x175, x167, 0xffffffff); var x178: u64 = undefined; var x179: u1 = undefined; - subborrowxU64(&x178, &x179, x177, x169, cast(u64, 0x0)); + subborrowxU64(&x178, &x179, x177, x169, @as(u64, 0x0)); var x180: u64 = undefined; var x181: u1 = undefined; subborrowxU64(&x180, &x181, x179, x171, 0xffffffff00000001); var x182: u64 = undefined; var x183: u1 = undefined; - subborrowxU64(&x182, &x183, x181, x173, cast(u64, 0x0)); + subborrowxU64(&x182, &x183, x181, x173, @as(u64, 0x0)); var x184: u64 = undefined; cmovznzU64(&x184, x183, x174, x165); var x185: u64 = undefined; @@ -440,7 +439,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl var x17: u64 = undefined; var x18: u1 = undefined; addcarryxU64(&x17, &x18, x16, x8, x5); - const x19 = (cast(u64, x18) + x6); + const x19 = (@as(u64, x18) + x6); var x20: u64 = undefined; var x21: u64 = undefined; mulxU64(&x20, &x21, x11, 0xffffffff00000001); @@ -453,7 +452,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl var x26: u64 = undefined; var x27: u1 = undefined; addcarryxU64(&x26, &x27, 0x0, x25, x22); - const x28 = (cast(u64, x27) + x23); + const x28 = (@as(u64, x27) + x23); var x29: u64 = undefined; var x30: u1 = undefined; addcarryxU64(&x29, &x30, 0x0, x11, x24); @@ -490,7 +489,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl var x51: u64 = undefined; var x52: u1 = undefined; addcarryxU64(&x51, &x52, x50, x42, x39); - const x53 = (cast(u64, x52) + x40); + const x53 = (@as(u64, x52) + x40); var x54: u64 = undefined; var x55: u1 = undefined; addcarryxU64(&x54, &x55, 0x0, x31, x45); @@ -505,7 +504,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl addcarryxU64(&x60, &x61, x59, x37, x51); var x62: u64 = undefined; var x63: u1 = undefined; - addcarryxU64(&x62, &x63, x61, cast(u64, x38), x53); + addcarryxU64(&x62, &x63, x61, @as(u64, x38), x53); var x64: u64 = undefined; var x65: u64 = undefined; mulxU64(&x64, &x65, x54, 0xffffffff00000001); @@ -518,7 +517,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl var x70: u64 = undefined; var x71: u1 = undefined; addcarryxU64(&x70, &x71, 0x0, x69, x66); - const x72 = (cast(u64, x71) + x67); + const x72 = (@as(u64, x71) + x67); var x73: u64 = undefined; var x74: u1 = undefined; addcarryxU64(&x73, &x74, 0x0, x54, x68); @@ -534,7 +533,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl var x81: u64 = undefined; var x82: u1 = undefined; addcarryxU64(&x81, &x82, x80, x62, x65); - const x83 = (cast(u64, x82) + cast(u64, x63)); + const x83 = (@as(u64, x82) + @as(u64, x63)); var x84: u64 = undefined; var x85: u64 = undefined; mulxU64(&x84, &x85, x2, (arg1[3])); @@ -556,7 +555,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl var x96: u64 = undefined; var x97: u1 = undefined; addcarryxU64(&x96, &x97, x95, x87, x84); - const x98 = (cast(u64, x97) + x85); + const x98 = (@as(u64, x97) + x85); var x99: u64 = undefined; var x100: u1 = undefined; addcarryxU64(&x99, &x100, 0x0, x75, x90); @@ -584,7 +583,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl var x115: u64 = undefined; var x116: u1 = undefined; addcarryxU64(&x115, &x116, 0x0, x114, x111); - const x117 = (cast(u64, x116) + x112); + const x117 = (@as(u64, x116) + x112); var x118: u64 = undefined; var x119: u1 = undefined; addcarryxU64(&x118, &x119, 0x0, x99, x113); @@ -600,7 +599,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl var x126: u64 = undefined; var x127: u1 = undefined; addcarryxU64(&x126, &x127, x125, x107, x110); - const x128 = (cast(u64, x127) + cast(u64, x108)); + const x128 = (@as(u64, x127) + @as(u64, x108)); var x129: u64 = undefined; var x130: u64 = undefined; mulxU64(&x129, &x130, x3, (arg1[3])); @@ -622,7 +621,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl var x141: u64 = undefined; var x142: u1 = undefined; addcarryxU64(&x141, &x142, x140, x132, x129); - const x143 = (cast(u64, x142) + x130); + const x143 = (@as(u64, x142) + x130); var x144: u64 = undefined; var x145: u1 = undefined; addcarryxU64(&x144, &x145, 0x0, x120, x135); @@ -650,7 +649,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl var x160: u64 = undefined; var x161: u1 = undefined; addcarryxU64(&x160, &x161, 0x0, x159, x156); - const x162 = (cast(u64, x161) + x157); + const x162 = (@as(u64, x161) + x157); var x163: u64 = undefined; var x164: u1 = undefined; addcarryxU64(&x163, &x164, 0x0, x144, x158); @@ -666,7 +665,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl var x171: u64 = undefined; var x172: u1 = undefined; addcarryxU64(&x171, &x172, x170, x152, x155); - const x173 = (cast(u64, x172) + cast(u64, x153)); + const x173 = (@as(u64, x172) + @as(u64, x153)); var x174: u64 = undefined; var x175: u1 = undefined; subborrowxU64(&x174, &x175, 0x0, x165, 0xffffffffffffffff); @@ -675,13 +674,13 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl subborrowxU64(&x176, &x177, x175, x167, 0xffffffff); var x178: u64 = undefined; var x179: u1 = undefined; - subborrowxU64(&x178, &x179, x177, x169, cast(u64, 0x0)); + subborrowxU64(&x178, &x179, x177, x169, @as(u64, 0x0)); var x180: u64 = undefined; var x181: u1 = undefined; subborrowxU64(&x180, &x181, x179, x171, 0xffffffff00000001); var x182: u64 = undefined; var x183: u1 = undefined; - subborrowxU64(&x182, &x183, x181, x173, cast(u64, 0x0)); + subborrowxU64(&x182, &x183, x181, x173, @as(u64, 0x0)); var x184: u64 = undefined; cmovznzU64(&x184, x183, x174, x165); var x185: u64 = undefined; @@ -728,13 +727,13 @@ pub fn add(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme subborrowxU64(&x11, &x12, x10, x3, 0xffffffff); var x13: u64 = undefined; var x14: u1 = undefined; - subborrowxU64(&x13, &x14, x12, x5, cast(u64, 0x0)); + subborrowxU64(&x13, &x14, x12, x5, @as(u64, 0x0)); var x15: u64 = undefined; var x16: u1 = undefined; subborrowxU64(&x15, &x16, x14, x7, 0xffffffff00000001); var x17: u64 = undefined; var x18: u1 = undefined; - subborrowxU64(&x17, &x18, x16, cast(u64, x8), cast(u64, 0x0)); + subborrowxU64(&x17, &x18, x16, @as(u64, x8), @as(u64, 0x0)); var x19: u64 = undefined; cmovznzU64(&x19, x18, x9, x1); var x20: u64 = undefined; @@ -774,7 +773,7 @@ pub fn sub(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x8: u1 = undefined; subborrowxU64(&x7, &x8, x6, (arg1[3]), (arg2[3])); var x9: u64 = undefined; - cmovznzU64(&x9, x8, cast(u64, 0x0), 0xffffffffffffffff); + cmovznzU64(&x9, x8, @as(u64, 0x0), 0xffffffffffffffff); var x10: u64 = undefined; var x11: u1 = undefined; addcarryxU64(&x10, &x11, 0x0, x1, x9); @@ -783,7 +782,7 @@ pub fn sub(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme addcarryxU64(&x12, &x13, x11, x3, (x9 & 0xffffffff)); var x14: u64 = undefined; var x15: u1 = undefined; - addcarryxU64(&x14, &x15, x13, x5, cast(u64, 0x0)); + addcarryxU64(&x14, &x15, x13, x5, @as(u64, 0x0)); var x16: u64 = undefined; var x17: u1 = undefined; addcarryxU64(&x16, &x17, x15, x7, (x9 & 0xffffffff00000001)); @@ -806,18 +805,18 @@ pub fn opp(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x1: u64 = undefined; var x2: u1 = undefined; - subborrowxU64(&x1, &x2, 0x0, cast(u64, 0x0), (arg1[0])); + subborrowxU64(&x1, &x2, 0x0, @as(u64, 0x0), (arg1[0])); var x3: u64 = undefined; var x4: u1 = undefined; - subborrowxU64(&x3, &x4, x2, cast(u64, 0x0), (arg1[1])); + subborrowxU64(&x3, &x4, x2, @as(u64, 0x0), (arg1[1])); var x5: u64 = undefined; var x6: u1 = undefined; - subborrowxU64(&x5, &x6, x4, cast(u64, 0x0), (arg1[2])); + subborrowxU64(&x5, &x6, x4, @as(u64, 0x0), (arg1[2])); var x7: u64 = undefined; var x8: u1 = undefined; - subborrowxU64(&x7, &x8, x6, cast(u64, 0x0), (arg1[3])); + subborrowxU64(&x7, &x8, x6, @as(u64, 0x0), (arg1[3])); var x9: u64 = undefined; - cmovznzU64(&x9, x8, cast(u64, 0x0), 0xffffffffffffffff); + cmovznzU64(&x9, x8, @as(u64, 0x0), 0xffffffffffffffff); var x10: u64 = undefined; var x11: u1 = undefined; addcarryxU64(&x10, &x11, 0x0, x1, x9); @@ -826,7 +825,7 @@ pub fn opp(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme addcarryxU64(&x12, &x13, x11, x3, (x9 & 0xffffffff)); var x14: u64 = undefined; var x15: u1 = undefined; - addcarryxU64(&x14, &x15, x13, x5, cast(u64, 0x0)); + addcarryxU64(&x14, &x15, x13, x5, @as(u64, 0x0)); var x16: u64 = undefined; var x17: u1 = undefined; addcarryxU64(&x16, &x17, x15, x7, (x9 & 0xffffffff00000001)); @@ -865,7 +864,7 @@ pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDo addcarryxU64(&x10, &x11, 0x0, x1, x6); var x12: u64 = undefined; var x13: u1 = undefined; - addcarryxU64(&x12, &x13, x11, cast(u64, 0x0), x8); + addcarryxU64(&x12, &x13, x11, @as(u64, 0x0), x8); var x14: u64 = undefined; var x15: u1 = undefined; addcarryxU64(&x14, &x15, 0x0, x12, (arg1[1])); @@ -886,10 +885,10 @@ pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDo addcarryxU64(&x24, &x25, 0x0, x14, x20); var x26: u64 = undefined; var x27: u1 = undefined; - addcarryxU64(&x26, &x27, x25, (cast(u64, x15) + (cast(u64, x13) + (cast(u64, x9) + x5))), x22); + addcarryxU64(&x26, &x27, x25, (@as(u64, x15) + (@as(u64, x13) + (@as(u64, x9) + x5))), x22); var x28: u64 = undefined; var x29: u1 = undefined; - addcarryxU64(&x28, &x29, x27, x2, (cast(u64, x23) + x19)); + addcarryxU64(&x28, &x29, x27, x2, (@as(u64, x23) + x19)); var x30: u64 = undefined; var x31: u1 = undefined; addcarryxU64(&x30, &x31, x29, x3, x16); @@ -898,10 +897,10 @@ pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDo addcarryxU64(&x32, &x33, 0x0, x26, (arg1[2])); var x34: u64 = undefined; var x35: u1 = undefined; - addcarryxU64(&x34, &x35, x33, x28, cast(u64, 0x0)); + addcarryxU64(&x34, &x35, x33, x28, @as(u64, 0x0)); var x36: u64 = undefined; var x37: u1 = undefined; - addcarryxU64(&x36, &x37, x35, x30, cast(u64, 0x0)); + addcarryxU64(&x36, &x37, x35, x30, @as(u64, 0x0)); var x38: u64 = undefined; var x39: u64 = undefined; mulxU64(&x38, &x39, x32, 0xffffffff00000001); @@ -922,19 +921,19 @@ pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDo addcarryxU64(&x48, &x49, x47, x34, x44); var x50: u64 = undefined; var x51: u1 = undefined; - addcarryxU64(&x50, &x51, x49, x36, (cast(u64, x45) + x41)); + addcarryxU64(&x50, &x51, x49, x36, (@as(u64, x45) + x41)); var x52: u64 = undefined; var x53: u1 = undefined; - addcarryxU64(&x52, &x53, x51, (cast(u64, x37) + (cast(u64, x31) + x17)), x38); + addcarryxU64(&x52, &x53, x51, (@as(u64, x37) + (@as(u64, x31) + x17)), x38); var x54: u64 = undefined; var x55: u1 = undefined; addcarryxU64(&x54, &x55, 0x0, x48, (arg1[3])); var x56: u64 = undefined; var x57: u1 = undefined; - addcarryxU64(&x56, &x57, x55, x50, cast(u64, 0x0)); + addcarryxU64(&x56, &x57, x55, x50, @as(u64, 0x0)); var x58: u64 = undefined; var x59: u1 = undefined; - addcarryxU64(&x58, &x59, x57, x52, cast(u64, 0x0)); + addcarryxU64(&x58, &x59, x57, x52, @as(u64, 0x0)); var x60: u64 = undefined; var x61: u64 = undefined; mulxU64(&x60, &x61, x54, 0xffffffff00000001); @@ -955,11 +954,11 @@ pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDo addcarryxU64(&x70, &x71, x69, x56, x66); var x72: u64 = undefined; var x73: u1 = undefined; - addcarryxU64(&x72, &x73, x71, x58, (cast(u64, x67) + x63)); + addcarryxU64(&x72, &x73, x71, x58, (@as(u64, x67) + x63)); var x74: u64 = undefined; var x75: u1 = undefined; - addcarryxU64(&x74, &x75, x73, (cast(u64, x59) + (cast(u64, x53) + x39)), x60); - const x76 = (cast(u64, x75) + x61); + addcarryxU64(&x74, &x75, x73, (@as(u64, x59) + (@as(u64, x53) + x39)), x60); + const x76 = (@as(u64, x75) + x61); var x77: u64 = undefined; var x78: u1 = undefined; subborrowxU64(&x77, &x78, 0x0, x70, 0xffffffffffffffff); @@ -968,13 +967,13 @@ pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDo subborrowxU64(&x79, &x80, x78, x72, 0xffffffff); var x81: u64 = undefined; var x82: u1 = undefined; - subborrowxU64(&x81, &x82, x80, x74, cast(u64, 0x0)); + subborrowxU64(&x81, &x82, x80, x74, @as(u64, 0x0)); var x83: u64 = undefined; var x84: u1 = undefined; subborrowxU64(&x83, &x84, x82, x76, 0xffffffff00000001); var x85: u64 = undefined; var x86: u1 = undefined; - subborrowxU64(&x85, &x86, x84, cast(u64, 0x0), cast(u64, 0x0)); + subborrowxU64(&x85, &x86, x84, @as(u64, 0x0), @as(u64, 0x0)); var x87: u64 = undefined; cmovznzU64(&x87, x86, x77, x70); var x88: u64 = undefined; @@ -1045,13 +1044,13 @@ pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDoma addcarryxU64(&x29, &x30, x28, x13, x25); var x31: u64 = undefined; var x32: u1 = undefined; - addcarryxU64(&x31, &x32, x30, x15, (cast(u64, x26) + x22)); + addcarryxU64(&x31, &x32, x30, x15, (@as(u64, x26) + x22)); var x33: u64 = undefined; var x34: u1 = undefined; addcarryxU64(&x33, &x34, x32, x17, x19); var x35: u64 = undefined; var x36: u1 = undefined; - addcarryxU64(&x35, &x36, x34, (cast(u64, x18) + x6), x20); + addcarryxU64(&x35, &x36, x34, (@as(u64, x18) + x6), x20); var x37: u64 = undefined; var x38: u64 = undefined; mulxU64(&x37, &x38, x1, 0x4fffffffd); @@ -1105,13 +1104,13 @@ pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDoma addcarryxU64(&x69, &x70, x68, x53, x65); var x71: u64 = undefined; var x72: u1 = undefined; - addcarryxU64(&x71, &x72, x70, x55, (cast(u64, x66) + x62)); + addcarryxU64(&x71, &x72, x70, x55, (@as(u64, x66) + x62)); var x73: u64 = undefined; var x74: u1 = undefined; addcarryxU64(&x73, &x74, x72, x57, x59); var x75: u64 = undefined; var x76: u1 = undefined; - addcarryxU64(&x75, &x76, x74, ((cast(u64, x58) + cast(u64, x36)) + (cast(u64, x50) + x38)), x60); + addcarryxU64(&x75, &x76, x74, ((@as(u64, x58) + @as(u64, x36)) + (@as(u64, x50) + x38)), x60); var x77: u64 = undefined; var x78: u64 = undefined; mulxU64(&x77, &x78, x2, 0x4fffffffd); @@ -1165,13 +1164,13 @@ pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDoma addcarryxU64(&x109, &x110, x108, x93, x105); var x111: u64 = undefined; var x112: u1 = undefined; - addcarryxU64(&x111, &x112, x110, x95, (cast(u64, x106) + x102)); + addcarryxU64(&x111, &x112, x110, x95, (@as(u64, x106) + x102)); var x113: u64 = undefined; var x114: u1 = undefined; addcarryxU64(&x113, &x114, x112, x97, x99); var x115: u64 = undefined; var x116: u1 = undefined; - addcarryxU64(&x115, &x116, x114, ((cast(u64, x98) + cast(u64, x76)) + (cast(u64, x90) + x78)), x100); + addcarryxU64(&x115, &x116, x114, ((@as(u64, x98) + @as(u64, x76)) + (@as(u64, x90) + x78)), x100); var x117: u64 = undefined; var x118: u64 = undefined; mulxU64(&x117, &x118, x3, 0x4fffffffd); @@ -1225,13 +1224,13 @@ pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDoma addcarryxU64(&x149, &x150, x148, x133, x145); var x151: u64 = undefined; var x152: u1 = undefined; - addcarryxU64(&x151, &x152, x150, x135, (cast(u64, x146) + x142)); + addcarryxU64(&x151, &x152, x150, x135, (@as(u64, x146) + x142)); var x153: u64 = undefined; var x154: u1 = undefined; addcarryxU64(&x153, &x154, x152, x137, x139); var x155: u64 = undefined; var x156: u1 = undefined; - addcarryxU64(&x155, &x156, x154, ((cast(u64, x138) + cast(u64, x116)) + (cast(u64, x130) + x118)), x140); + addcarryxU64(&x155, &x156, x154, ((@as(u64, x138) + @as(u64, x116)) + (@as(u64, x130) + x118)), x140); var x157: u64 = undefined; var x158: u1 = undefined; subborrowxU64(&x157, &x158, 0x0, x149, 0xffffffffffffffff); @@ -1240,13 +1239,13 @@ pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDoma subborrowxU64(&x159, &x160, x158, x151, 0xffffffff); var x161: u64 = undefined; var x162: u1 = undefined; - subborrowxU64(&x161, &x162, x160, x153, cast(u64, 0x0)); + subborrowxU64(&x161, &x162, x160, x153, @as(u64, 0x0)); var x163: u64 = undefined; var x164: u1 = undefined; subborrowxU64(&x163, &x164, x162, x155, 0xffffffff00000001); var x165: u64 = undefined; var x166: u1 = undefined; - subborrowxU64(&x165, &x166, x164, cast(u64, x156), cast(u64, 0x0)); + subborrowxU64(&x165, &x166, x164, @as(u64, x156), @as(u64, 0x0)); var x167: u64 = undefined; cmovznzU64(&x167, x166, x157, x149); var x168: u64 = undefined; @@ -1325,62 +1324,62 @@ pub fn toBytes(out1: *[32]u8, arg1: [4]u64) void { const x2 = (arg1[2]); const x3 = (arg1[1]); const x4 = (arg1[0]); - const x5 = cast(u8, (x4 & cast(u64, 0xff))); + const x5 = @truncate(u8, (x4 & @as(u64, 0xff))); const x6 = (x4 >> 8); - const x7 = cast(u8, (x6 & cast(u64, 0xff))); + const x7 = @truncate(u8, (x6 & @as(u64, 0xff))); const x8 = (x6 >> 8); - const x9 = cast(u8, (x8 & cast(u64, 0xff))); + const x9 = @truncate(u8, (x8 & @as(u64, 0xff))); const x10 = (x8 >> 8); - const x11 = cast(u8, (x10 & cast(u64, 0xff))); + const x11 = @truncate(u8, (x10 & @as(u64, 0xff))); const x12 = (x10 >> 8); - const x13 = cast(u8, (x12 & cast(u64, 0xff))); + const x13 = @truncate(u8, (x12 & @as(u64, 0xff))); const x14 = (x12 >> 8); - const x15 = cast(u8, (x14 & cast(u64, 0xff))); + const x15 = @truncate(u8, (x14 & @as(u64, 0xff))); const x16 = (x14 >> 8); - const x17 = cast(u8, (x16 & cast(u64, 0xff))); - const x18 = cast(u8, (x16 >> 8)); - const x19 = cast(u8, (x3 & cast(u64, 0xff))); + const x17 = @truncate(u8, (x16 & @as(u64, 0xff))); + const x18 = @truncate(u8, (x16 >> 8)); + const x19 = @truncate(u8, (x3 & @as(u64, 0xff))); const x20 = (x3 >> 8); - const x21 = cast(u8, (x20 & cast(u64, 0xff))); + const x21 = @truncate(u8, (x20 & @as(u64, 0xff))); const x22 = (x20 >> 8); - const x23 = cast(u8, (x22 & cast(u64, 0xff))); + const x23 = @truncate(u8, (x22 & @as(u64, 0xff))); const x24 = (x22 >> 8); - const x25 = cast(u8, (x24 & cast(u64, 0xff))); + const x25 = @truncate(u8, (x24 & @as(u64, 0xff))); const x26 = (x24 >> 8); - const x27 = cast(u8, (x26 & cast(u64, 0xff))); + const x27 = @truncate(u8, (x26 & @as(u64, 0xff))); const x28 = (x26 >> 8); - const x29 = cast(u8, (x28 & cast(u64, 0xff))); + const x29 = @truncate(u8, (x28 & @as(u64, 0xff))); const x30 = (x28 >> 8); - const x31 = cast(u8, (x30 & cast(u64, 0xff))); - const x32 = cast(u8, (x30 >> 8)); - const x33 = cast(u8, (x2 & cast(u64, 0xff))); + const x31 = @truncate(u8, (x30 & @as(u64, 0xff))); + const x32 = @truncate(u8, (x30 >> 8)); + const x33 = @truncate(u8, (x2 & @as(u64, 0xff))); const x34 = (x2 >> 8); - const x35 = cast(u8, (x34 & cast(u64, 0xff))); + const x35 = @truncate(u8, (x34 & @as(u64, 0xff))); const x36 = (x34 >> 8); - const x37 = cast(u8, (x36 & cast(u64, 0xff))); + const x37 = @truncate(u8, (x36 & @as(u64, 0xff))); const x38 = (x36 >> 8); - const x39 = cast(u8, (x38 & cast(u64, 0xff))); + const x39 = @truncate(u8, (x38 & @as(u64, 0xff))); const x40 = (x38 >> 8); - const x41 = cast(u8, (x40 & cast(u64, 0xff))); + const x41 = @truncate(u8, (x40 & @as(u64, 0xff))); const x42 = (x40 >> 8); - const x43 = cast(u8, (x42 & cast(u64, 0xff))); + const x43 = @truncate(u8, (x42 & @as(u64, 0xff))); const x44 = (x42 >> 8); - const x45 = cast(u8, (x44 & cast(u64, 0xff))); - const x46 = cast(u8, (x44 >> 8)); - const x47 = cast(u8, (x1 & cast(u64, 0xff))); + const x45 = @truncate(u8, (x44 & @as(u64, 0xff))); + const x46 = @truncate(u8, (x44 >> 8)); + const x47 = @truncate(u8, (x1 & @as(u64, 0xff))); const x48 = (x1 >> 8); - const x49 = cast(u8, (x48 & cast(u64, 0xff))); + const x49 = @truncate(u8, (x48 & @as(u64, 0xff))); const x50 = (x48 >> 8); - const x51 = cast(u8, (x50 & cast(u64, 0xff))); + const x51 = @truncate(u8, (x50 & @as(u64, 0xff))); const x52 = (x50 >> 8); - const x53 = cast(u8, (x52 & cast(u64, 0xff))); + const x53 = @truncate(u8, (x52 & @as(u64, 0xff))); const x54 = (x52 >> 8); - const x55 = cast(u8, (x54 & cast(u64, 0xff))); + const x55 = @truncate(u8, (x54 & @as(u64, 0xff))); const x56 = (x54 >> 8); - const x57 = cast(u8, (x56 & cast(u64, 0xff))); + const x57 = @truncate(u8, (x56 & @as(u64, 0xff))); const x58 = (x56 >> 8); - const x59 = cast(u8, (x58 & cast(u64, 0xff))); - const x60 = cast(u8, (x58 >> 8)); + const x59 = @truncate(u8, (x58 & @as(u64, 0xff))); + const x60 = @truncate(u8, (x58 >> 8)); out1[0] = x5; out1[1] = x7; out1[2] = x9; @@ -1430,60 +1429,60 @@ pub fn toBytes(out1: *[32]u8, arg1: [4]u64) void { pub fn fromBytes(out1: *[4]u64, arg1: [32]u8) void { @setRuntimeSafety(mode == .Debug); - const x1 = (cast(u64, (arg1[31])) << 56); - const x2 = (cast(u64, (arg1[30])) << 48); - const x3 = (cast(u64, (arg1[29])) << 40); - const x4 = (cast(u64, (arg1[28])) << 32); - const x5 = (cast(u64, (arg1[27])) << 24); - const x6 = (cast(u64, (arg1[26])) << 16); - const x7 = (cast(u64, (arg1[25])) << 8); + const x1 = (@as(u64, (arg1[31])) << 56); + const x2 = (@as(u64, (arg1[30])) << 48); + const x3 = (@as(u64, (arg1[29])) << 40); + const x4 = (@as(u64, (arg1[28])) << 32); + const x5 = (@as(u64, (arg1[27])) << 24); + const x6 = (@as(u64, (arg1[26])) << 16); + const x7 = (@as(u64, (arg1[25])) << 8); const x8 = (arg1[24]); - const x9 = (cast(u64, (arg1[23])) << 56); - const x10 = (cast(u64, (arg1[22])) << 48); - const x11 = (cast(u64, (arg1[21])) << 40); - const x12 = (cast(u64, (arg1[20])) << 32); - const x13 = (cast(u64, (arg1[19])) << 24); - const x14 = (cast(u64, (arg1[18])) << 16); - const x15 = (cast(u64, (arg1[17])) << 8); + const x9 = (@as(u64, (arg1[23])) << 56); + const x10 = (@as(u64, (arg1[22])) << 48); + const x11 = (@as(u64, (arg1[21])) << 40); + const x12 = (@as(u64, (arg1[20])) << 32); + const x13 = (@as(u64, (arg1[19])) << 24); + const x14 = (@as(u64, (arg1[18])) << 16); + const x15 = (@as(u64, (arg1[17])) << 8); const x16 = (arg1[16]); - const x17 = (cast(u64, (arg1[15])) << 56); - const x18 = (cast(u64, (arg1[14])) << 48); - const x19 = (cast(u64, (arg1[13])) << 40); - const x20 = (cast(u64, (arg1[12])) << 32); - const x21 = (cast(u64, (arg1[11])) << 24); - const x22 = (cast(u64, (arg1[10])) << 16); - const x23 = (cast(u64, (arg1[9])) << 8); + const x17 = (@as(u64, (arg1[15])) << 56); + const x18 = (@as(u64, (arg1[14])) << 48); + const x19 = (@as(u64, (arg1[13])) << 40); + const x20 = (@as(u64, (arg1[12])) << 32); + const x21 = (@as(u64, (arg1[11])) << 24); + const x22 = (@as(u64, (arg1[10])) << 16); + const x23 = (@as(u64, (arg1[9])) << 8); const x24 = (arg1[8]); - const x25 = (cast(u64, (arg1[7])) << 56); - const x26 = (cast(u64, (arg1[6])) << 48); - const x27 = (cast(u64, (arg1[5])) << 40); - const x28 = (cast(u64, (arg1[4])) << 32); - const x29 = (cast(u64, (arg1[3])) << 24); - const x30 = (cast(u64, (arg1[2])) << 16); - const x31 = (cast(u64, (arg1[1])) << 8); + const x25 = (@as(u64, (arg1[7])) << 56); + const x26 = (@as(u64, (arg1[6])) << 48); + const x27 = (@as(u64, (arg1[5])) << 40); + const x28 = (@as(u64, (arg1[4])) << 32); + const x29 = (@as(u64, (arg1[3])) << 24); + const x30 = (@as(u64, (arg1[2])) << 16); + const x31 = (@as(u64, (arg1[1])) << 8); const x32 = (arg1[0]); - const x33 = (x31 + cast(u64, x32)); + const x33 = (x31 + @as(u64, x32)); const x34 = (x30 + x33); const x35 = (x29 + x34); const x36 = (x28 + x35); const x37 = (x27 + x36); const x38 = (x26 + x37); const x39 = (x25 + x38); - const x40 = (x23 + cast(u64, x24)); + const x40 = (x23 + @as(u64, x24)); const x41 = (x22 + x40); const x42 = (x21 + x41); const x43 = (x20 + x42); const x44 = (x19 + x43); const x45 = (x18 + x44); const x46 = (x17 + x45); - const x47 = (x15 + cast(u64, x16)); + const x47 = (x15 + @as(u64, x16)); const x48 = (x14 + x47); const x49 = (x13 + x48); const x50 = (x12 + x49); const x51 = (x11 + x50); const x52 = (x10 + x51); const x53 = (x9 + x52); - const x54 = (x7 + cast(u64, x8)); + const x54 = (x7 + @as(u64, x8)); const x55 = (x6 + x54); const x56 = (x5 + x55); const x57 = (x4 + x56); @@ -1505,7 +1504,7 @@ pub fn fromBytes(out1: *[4]u64, arg1: [32]u8) void { pub fn setOne(out1: *MontgomeryDomainFieldElement) void { @setRuntimeSafety(mode == .Debug); - out1[0] = cast(u64, 0x1); + out1[0] = @as(u64, 0x1); out1[1] = 0xffffffff00000000; out1[2] = 0xffffffffffffffff; out1[3] = 0xfffffffe; @@ -1524,9 +1523,9 @@ pub fn msat(out1: *[5]u64) void { out1[0] = 0xffffffffffffffff; out1[1] = 0xffffffff; - out1[2] = cast(u64, 0x0); + out1[2] = @as(u64, 0x0); out1[3] = 0xffffffff00000001; - out1[4] = cast(u64, 0x0); + out1[4] = @as(u64, 0x0); } /// The function divstep computes a divstep. @@ -1562,11 +1561,11 @@ pub fn divstep(out1: *u64, out2: *[5]u64, out3: *[5]u64, out4: *[4]u64, out5: *[ var x1: u64 = undefined; var x2: u1 = undefined; - addcarryxU64(&x1, &x2, 0x0, (~arg1), cast(u64, 0x1)); - const x3 = (cast(u1, (x1 >> 63)) & cast(u1, ((arg3[0]) & cast(u64, 0x1)))); + addcarryxU64(&x1, &x2, 0x0, (~arg1), @as(u64, 0x1)); + const x3 = (@truncate(u1, (x1 >> 63)) & @truncate(u1, ((arg3[0]) & @as(u64, 0x1)))); var x4: u64 = undefined; var x5: u1 = undefined; - addcarryxU64(&x4, &x5, 0x0, (~arg1), cast(u64, 0x1)); + addcarryxU64(&x4, &x5, 0x0, (~arg1), @as(u64, 0x1)); var x6: u64 = undefined; cmovznzU64(&x6, x3, arg1, x4); var x7: u64 = undefined; @@ -1581,19 +1580,19 @@ pub fn divstep(out1: *u64, out2: *[5]u64, out3: *[5]u64, out4: *[4]u64, out5: *[ cmovznzU64(&x11, x3, (arg2[4]), (arg3[4])); var x12: u64 = undefined; var x13: u1 = undefined; - addcarryxU64(&x12, &x13, 0x0, cast(u64, 0x1), (~(arg2[0]))); + addcarryxU64(&x12, &x13, 0x0, @as(u64, 0x1), (~(arg2[0]))); var x14: u64 = undefined; var x15: u1 = undefined; - addcarryxU64(&x14, &x15, x13, cast(u64, 0x0), (~(arg2[1]))); + addcarryxU64(&x14, &x15, x13, @as(u64, 0x0), (~(arg2[1]))); var x16: u64 = undefined; var x17: u1 = undefined; - addcarryxU64(&x16, &x17, x15, cast(u64, 0x0), (~(arg2[2]))); + addcarryxU64(&x16, &x17, x15, @as(u64, 0x0), (~(arg2[2]))); var x18: u64 = undefined; var x19: u1 = undefined; - addcarryxU64(&x18, &x19, x17, cast(u64, 0x0), (~(arg2[3]))); + addcarryxU64(&x18, &x19, x17, @as(u64, 0x0), (~(arg2[3]))); var x20: u64 = undefined; var x21: u1 = undefined; - addcarryxU64(&x20, &x21, x19, cast(u64, 0x0), (~(arg2[4]))); + addcarryxU64(&x20, &x21, x19, @as(u64, 0x0), (~(arg2[4]))); var x22: u64 = undefined; cmovznzU64(&x22, x3, (arg3[0]), x12); var x23: u64 = undefined; @@ -1632,31 +1631,31 @@ pub fn divstep(out1: *u64, out2: *[5]u64, out3: *[5]u64, out4: *[4]u64, out5: *[ subborrowxU64(&x41, &x42, x40, x33, 0xffffffff); var x43: u64 = undefined; var x44: u1 = undefined; - subborrowxU64(&x43, &x44, x42, x35, cast(u64, 0x0)); + subborrowxU64(&x43, &x44, x42, x35, @as(u64, 0x0)); var x45: u64 = undefined; var x46: u1 = undefined; subborrowxU64(&x45, &x46, x44, x37, 0xffffffff00000001); var x47: u64 = undefined; var x48: u1 = undefined; - subborrowxU64(&x47, &x48, x46, cast(u64, x38), cast(u64, 0x0)); + subborrowxU64(&x47, &x48, x46, @as(u64, x38), @as(u64, 0x0)); const x49 = (arg4[3]); const x50 = (arg4[2]); const x51 = (arg4[1]); const x52 = (arg4[0]); var x53: u64 = undefined; var x54: u1 = undefined; - subborrowxU64(&x53, &x54, 0x0, cast(u64, 0x0), x52); + subborrowxU64(&x53, &x54, 0x0, @as(u64, 0x0), x52); var x55: u64 = undefined; var x56: u1 = undefined; - subborrowxU64(&x55, &x56, x54, cast(u64, 0x0), x51); + subborrowxU64(&x55, &x56, x54, @as(u64, 0x0), x51); var x57: u64 = undefined; var x58: u1 = undefined; - subborrowxU64(&x57, &x58, x56, cast(u64, 0x0), x50); + subborrowxU64(&x57, &x58, x56, @as(u64, 0x0), x50); var x59: u64 = undefined; var x60: u1 = undefined; - subborrowxU64(&x59, &x60, x58, cast(u64, 0x0), x49); + subborrowxU64(&x59, &x60, x58, @as(u64, 0x0), x49); var x61: u64 = undefined; - cmovznzU64(&x61, x60, cast(u64, 0x0), 0xffffffffffffffff); + cmovznzU64(&x61, x60, @as(u64, 0x0), 0xffffffffffffffff); var x62: u64 = undefined; var x63: u1 = undefined; addcarryxU64(&x62, &x63, 0x0, x53, x61); @@ -1665,7 +1664,7 @@ pub fn divstep(out1: *u64, out2: *[5]u64, out3: *[5]u64, out4: *[4]u64, out5: *[ addcarryxU64(&x64, &x65, x63, x55, (x61 & 0xffffffff)); var x66: u64 = undefined; var x67: u1 = undefined; - addcarryxU64(&x66, &x67, x65, x57, cast(u64, 0x0)); + addcarryxU64(&x66, &x67, x65, x57, @as(u64, 0x0)); var x68: u64 = undefined; var x69: u1 = undefined; addcarryxU64(&x68, &x69, x67, x59, (x61 & 0xffffffff00000001)); @@ -1677,17 +1676,17 @@ pub fn divstep(out1: *u64, out2: *[5]u64, out3: *[5]u64, out4: *[4]u64, out5: *[ cmovznzU64(&x72, x3, (arg5[2]), x66); var x73: u64 = undefined; cmovznzU64(&x73, x3, (arg5[3]), x68); - const x74 = cast(u1, (x22 & cast(u64, 0x1))); + const x74 = @truncate(u1, (x22 & @as(u64, 0x1))); var x75: u64 = undefined; - cmovznzU64(&x75, x74, cast(u64, 0x0), x7); + cmovznzU64(&x75, x74, @as(u64, 0x0), x7); var x76: u64 = undefined; - cmovznzU64(&x76, x74, cast(u64, 0x0), x8); + cmovznzU64(&x76, x74, @as(u64, 0x0), x8); var x77: u64 = undefined; - cmovznzU64(&x77, x74, cast(u64, 0x0), x9); + cmovznzU64(&x77, x74, @as(u64, 0x0), x9); var x78: u64 = undefined; - cmovznzU64(&x78, x74, cast(u64, 0x0), x10); + cmovznzU64(&x78, x74, @as(u64, 0x0), x10); var x79: u64 = undefined; - cmovznzU64(&x79, x74, cast(u64, 0x0), x11); + cmovznzU64(&x79, x74, @as(u64, 0x0), x11); var x80: u64 = undefined; var x81: u1 = undefined; addcarryxU64(&x80, &x81, 0x0, x22, x75); @@ -1704,13 +1703,13 @@ pub fn divstep(out1: *u64, out2: *[5]u64, out3: *[5]u64, out4: *[4]u64, out5: *[ var x89: u1 = undefined; addcarryxU64(&x88, &x89, x87, x26, x79); var x90: u64 = undefined; - cmovznzU64(&x90, x74, cast(u64, 0x0), x27); + cmovznzU64(&x90, x74, @as(u64, 0x0), x27); var x91: u64 = undefined; - cmovznzU64(&x91, x74, cast(u64, 0x0), x28); + cmovznzU64(&x91, x74, @as(u64, 0x0), x28); var x92: u64 = undefined; - cmovznzU64(&x92, x74, cast(u64, 0x0), x29); + cmovznzU64(&x92, x74, @as(u64, 0x0), x29); var x93: u64 = undefined; - cmovznzU64(&x93, x74, cast(u64, 0x0), x30); + cmovznzU64(&x93, x74, @as(u64, 0x0), x30); var x94: u64 = undefined; var x95: u1 = undefined; addcarryxU64(&x94, &x95, 0x0, x70, x90); @@ -1731,16 +1730,16 @@ pub fn divstep(out1: *u64, out2: *[5]u64, out3: *[5]u64, out4: *[4]u64, out5: *[ subborrowxU64(&x104, &x105, x103, x96, 0xffffffff); var x106: u64 = undefined; var x107: u1 = undefined; - subborrowxU64(&x106, &x107, x105, x98, cast(u64, 0x0)); + subborrowxU64(&x106, &x107, x105, x98, @as(u64, 0x0)); var x108: u64 = undefined; var x109: u1 = undefined; subborrowxU64(&x108, &x109, x107, x100, 0xffffffff00000001); var x110: u64 = undefined; var x111: u1 = undefined; - subborrowxU64(&x110, &x111, x109, cast(u64, x101), cast(u64, 0x0)); + subborrowxU64(&x110, &x111, x109, @as(u64, x101), @as(u64, 0x0)); var x112: u64 = undefined; var x113: u1 = undefined; - addcarryxU64(&x112, &x113, 0x0, x6, cast(u64, 0x1)); + addcarryxU64(&x112, &x113, 0x0, x6, @as(u64, 0x1)); const x114 = ((x80 >> 1) | ((x82 << 63) & 0xffffffffffffffff)); const x115 = ((x82 >> 1) | ((x84 << 63) & 0xffffffffffffffff)); const x116 = ((x84 >> 1) | ((x86 << 63) & 0xffffffffffffffff)); diff --git a/lib/std/crypto/pcurves/p256/p256_scalar_64.zig b/lib/std/crypto/pcurves/p256/p256_scalar_64.zig index 491988f8ee..d16bdb1316 100644 --- a/lib/std/crypto/pcurves/p256/p256_scalar_64.zig +++ b/lib/std/crypto/pcurves/p256/p256_scalar_64.zig @@ -18,7 +18,6 @@ // if x1 & (2^256-1) < 2^255 then x1 & (2^256-1) else (x1 & (2^256-1)) - 2^256 const std = @import("std"); -const cast = std.meta.cast; const mode = std.builtin.mode; // Checked arithmetic is disabled in non-debug modes to avoid side channels // The type MontgomeryDomainFieldElement is a field element in the Montgomery domain. @@ -148,7 +147,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x17: u64 = undefined; var x18: u1 = undefined; addcarryxU64(&x17, &x18, x16, x8, x5); - const x19 = (cast(u64, x18) + x6); + const x19 = (@as(u64, x18) + x6); var x20: u64 = undefined; var x21: u64 = undefined; mulxU64(&x20, &x21, x11, 0xccd1c8aaee00bc4f); @@ -173,7 +172,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x34: u64 = undefined; var x35: u1 = undefined; addcarryxU64(&x34, &x35, x33, x25, x22); - const x36 = (cast(u64, x35) + x23); + const x36 = (@as(u64, x35) + x23); var x37: u64 = undefined; var x38: u1 = undefined; addcarryxU64(&x37, &x38, 0x0, x11, x28); @@ -210,7 +209,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x59: u64 = undefined; var x60: u1 = undefined; addcarryxU64(&x59, &x60, x58, x50, x47); - const x61 = (cast(u64, x60) + x48); + const x61 = (@as(u64, x60) + x48); var x62: u64 = undefined; var x63: u1 = undefined; addcarryxU64(&x62, &x63, 0x0, x39, x53); @@ -225,7 +224,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme addcarryxU64(&x68, &x69, x67, x45, x59); var x70: u64 = undefined; var x71: u1 = undefined; - addcarryxU64(&x70, &x71, x69, cast(u64, x46), x61); + addcarryxU64(&x70, &x71, x69, @as(u64, x46), x61); var x72: u64 = undefined; var x73: u64 = undefined; mulxU64(&x72, &x73, x62, 0xccd1c8aaee00bc4f); @@ -250,7 +249,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x86: u64 = undefined; var x87: u1 = undefined; addcarryxU64(&x86, &x87, x85, x77, x74); - const x88 = (cast(u64, x87) + x75); + const x88 = (@as(u64, x87) + x75); var x89: u64 = undefined; var x90: u1 = undefined; addcarryxU64(&x89, &x90, 0x0, x62, x80); @@ -266,7 +265,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x97: u64 = undefined; var x98: u1 = undefined; addcarryxU64(&x97, &x98, x96, x70, x88); - const x99 = (cast(u64, x98) + cast(u64, x71)); + const x99 = (@as(u64, x98) + @as(u64, x71)); var x100: u64 = undefined; var x101: u64 = undefined; mulxU64(&x100, &x101, x2, (arg2[3])); @@ -288,7 +287,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x112: u64 = undefined; var x113: u1 = undefined; addcarryxU64(&x112, &x113, x111, x103, x100); - const x114 = (cast(u64, x113) + x101); + const x114 = (@as(u64, x113) + x101); var x115: u64 = undefined; var x116: u1 = undefined; addcarryxU64(&x115, &x116, 0x0, x91, x106); @@ -328,7 +327,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x139: u64 = undefined; var x140: u1 = undefined; addcarryxU64(&x139, &x140, x138, x130, x127); - const x141 = (cast(u64, x140) + x128); + const x141 = (@as(u64, x140) + x128); var x142: u64 = undefined; var x143: u1 = undefined; addcarryxU64(&x142, &x143, 0x0, x115, x133); @@ -344,7 +343,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x150: u64 = undefined; var x151: u1 = undefined; addcarryxU64(&x150, &x151, x149, x123, x141); - const x152 = (cast(u64, x151) + cast(u64, x124)); + const x152 = (@as(u64, x151) + @as(u64, x124)); var x153: u64 = undefined; var x154: u64 = undefined; mulxU64(&x153, &x154, x3, (arg2[3])); @@ -366,7 +365,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x165: u64 = undefined; var x166: u1 = undefined; addcarryxU64(&x165, &x166, x164, x156, x153); - const x167 = (cast(u64, x166) + x154); + const x167 = (@as(u64, x166) + x154); var x168: u64 = undefined; var x169: u1 = undefined; addcarryxU64(&x168, &x169, 0x0, x144, x159); @@ -406,7 +405,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x192: u64 = undefined; var x193: u1 = undefined; addcarryxU64(&x192, &x193, x191, x183, x180); - const x194 = (cast(u64, x193) + x181); + const x194 = (@as(u64, x193) + x181); var x195: u64 = undefined; var x196: u1 = undefined; addcarryxU64(&x195, &x196, 0x0, x168, x186); @@ -422,7 +421,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x203: u64 = undefined; var x204: u1 = undefined; addcarryxU64(&x203, &x204, x202, x176, x194); - const x205 = (cast(u64, x204) + cast(u64, x177)); + const x205 = (@as(u64, x204) + @as(u64, x177)); var x206: u64 = undefined; var x207: u1 = undefined; subborrowxU64(&x206, &x207, 0x0, x197, 0xf3b9cac2fc632551); @@ -437,7 +436,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme subborrowxU64(&x212, &x213, x211, x203, 0xffffffff00000000); var x214: u64 = undefined; var x215: u1 = undefined; - subborrowxU64(&x214, &x215, x213, x205, cast(u64, 0x0)); + subborrowxU64(&x214, &x215, x213, x205, @as(u64, 0x0)); var x216: u64 = undefined; cmovznzU64(&x216, x215, x206, x197); var x217: u64 = undefined; @@ -488,7 +487,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl var x17: u64 = undefined; var x18: u1 = undefined; addcarryxU64(&x17, &x18, x16, x8, x5); - const x19 = (cast(u64, x18) + x6); + const x19 = (@as(u64, x18) + x6); var x20: u64 = undefined; var x21: u64 = undefined; mulxU64(&x20, &x21, x11, 0xccd1c8aaee00bc4f); @@ -513,7 +512,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl var x34: u64 = undefined; var x35: u1 = undefined; addcarryxU64(&x34, &x35, x33, x25, x22); - const x36 = (cast(u64, x35) + x23); + const x36 = (@as(u64, x35) + x23); var x37: u64 = undefined; var x38: u1 = undefined; addcarryxU64(&x37, &x38, 0x0, x11, x28); @@ -550,7 +549,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl var x59: u64 = undefined; var x60: u1 = undefined; addcarryxU64(&x59, &x60, x58, x50, x47); - const x61 = (cast(u64, x60) + x48); + const x61 = (@as(u64, x60) + x48); var x62: u64 = undefined; var x63: u1 = undefined; addcarryxU64(&x62, &x63, 0x0, x39, x53); @@ -565,7 +564,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl addcarryxU64(&x68, &x69, x67, x45, x59); var x70: u64 = undefined; var x71: u1 = undefined; - addcarryxU64(&x70, &x71, x69, cast(u64, x46), x61); + addcarryxU64(&x70, &x71, x69, @as(u64, x46), x61); var x72: u64 = undefined; var x73: u64 = undefined; mulxU64(&x72, &x73, x62, 0xccd1c8aaee00bc4f); @@ -590,7 +589,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl var x86: u64 = undefined; var x87: u1 = undefined; addcarryxU64(&x86, &x87, x85, x77, x74); - const x88 = (cast(u64, x87) + x75); + const x88 = (@as(u64, x87) + x75); var x89: u64 = undefined; var x90: u1 = undefined; addcarryxU64(&x89, &x90, 0x0, x62, x80); @@ -606,7 +605,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl var x97: u64 = undefined; var x98: u1 = undefined; addcarryxU64(&x97, &x98, x96, x70, x88); - const x99 = (cast(u64, x98) + cast(u64, x71)); + const x99 = (@as(u64, x98) + @as(u64, x71)); var x100: u64 = undefined; var x101: u64 = undefined; mulxU64(&x100, &x101, x2, (arg1[3])); @@ -628,7 +627,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl var x112: u64 = undefined; var x113: u1 = undefined; addcarryxU64(&x112, &x113, x111, x103, x100); - const x114 = (cast(u64, x113) + x101); + const x114 = (@as(u64, x113) + x101); var x115: u64 = undefined; var x116: u1 = undefined; addcarryxU64(&x115, &x116, 0x0, x91, x106); @@ -668,7 +667,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl var x139: u64 = undefined; var x140: u1 = undefined; addcarryxU64(&x139, &x140, x138, x130, x127); - const x141 = (cast(u64, x140) + x128); + const x141 = (@as(u64, x140) + x128); var x142: u64 = undefined; var x143: u1 = undefined; addcarryxU64(&x142, &x143, 0x0, x115, x133); @@ -684,7 +683,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl var x150: u64 = undefined; var x151: u1 = undefined; addcarryxU64(&x150, &x151, x149, x123, x141); - const x152 = (cast(u64, x151) + cast(u64, x124)); + const x152 = (@as(u64, x151) + @as(u64, x124)); var x153: u64 = undefined; var x154: u64 = undefined; mulxU64(&x153, &x154, x3, (arg1[3])); @@ -706,7 +705,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl var x165: u64 = undefined; var x166: u1 = undefined; addcarryxU64(&x165, &x166, x164, x156, x153); - const x167 = (cast(u64, x166) + x154); + const x167 = (@as(u64, x166) + x154); var x168: u64 = undefined; var x169: u1 = undefined; addcarryxU64(&x168, &x169, 0x0, x144, x159); @@ -746,7 +745,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl var x192: u64 = undefined; var x193: u1 = undefined; addcarryxU64(&x192, &x193, x191, x183, x180); - const x194 = (cast(u64, x193) + x181); + const x194 = (@as(u64, x193) + x181); var x195: u64 = undefined; var x196: u1 = undefined; addcarryxU64(&x195, &x196, 0x0, x168, x186); @@ -762,7 +761,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl var x203: u64 = undefined; var x204: u1 = undefined; addcarryxU64(&x203, &x204, x202, x176, x194); - const x205 = (cast(u64, x204) + cast(u64, x177)); + const x205 = (@as(u64, x204) + @as(u64, x177)); var x206: u64 = undefined; var x207: u1 = undefined; subborrowxU64(&x206, &x207, 0x0, x197, 0xf3b9cac2fc632551); @@ -777,7 +776,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl subborrowxU64(&x212, &x213, x211, x203, 0xffffffff00000000); var x214: u64 = undefined; var x215: u1 = undefined; - subborrowxU64(&x214, &x215, x213, x205, cast(u64, 0x0)); + subborrowxU64(&x214, &x215, x213, x205, @as(u64, 0x0)); var x216: u64 = undefined; cmovznzU64(&x216, x215, x206, x197); var x217: u64 = undefined; @@ -830,7 +829,7 @@ pub fn add(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme subborrowxU64(&x15, &x16, x14, x7, 0xffffffff00000000); var x17: u64 = undefined; var x18: u1 = undefined; - subborrowxU64(&x17, &x18, x16, cast(u64, x8), cast(u64, 0x0)); + subborrowxU64(&x17, &x18, x16, @as(u64, x8), @as(u64, 0x0)); var x19: u64 = undefined; cmovznzU64(&x19, x18, x9, x1); var x20: u64 = undefined; @@ -870,7 +869,7 @@ pub fn sub(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x8: u1 = undefined; subborrowxU64(&x7, &x8, x6, (arg1[3]), (arg2[3])); var x9: u64 = undefined; - cmovznzU64(&x9, x8, cast(u64, 0x0), 0xffffffffffffffff); + cmovznzU64(&x9, x8, @as(u64, 0x0), 0xffffffffffffffff); var x10: u64 = undefined; var x11: u1 = undefined; addcarryxU64(&x10, &x11, 0x0, x1, (x9 & 0xf3b9cac2fc632551)); @@ -902,18 +901,18 @@ pub fn opp(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme var x1: u64 = undefined; var x2: u1 = undefined; - subborrowxU64(&x1, &x2, 0x0, cast(u64, 0x0), (arg1[0])); + subborrowxU64(&x1, &x2, 0x0, @as(u64, 0x0), (arg1[0])); var x3: u64 = undefined; var x4: u1 = undefined; - subborrowxU64(&x3, &x4, x2, cast(u64, 0x0), (arg1[1])); + subborrowxU64(&x3, &x4, x2, @as(u64, 0x0), (arg1[1])); var x5: u64 = undefined; var x6: u1 = undefined; - subborrowxU64(&x5, &x6, x4, cast(u64, 0x0), (arg1[2])); + subborrowxU64(&x5, &x6, x4, @as(u64, 0x0), (arg1[2])); var x7: u64 = undefined; var x8: u1 = undefined; - subborrowxU64(&x7, &x8, x6, cast(u64, 0x0), (arg1[3])); + subborrowxU64(&x7, &x8, x6, @as(u64, 0x0), (arg1[3])); var x9: u64 = undefined; - cmovznzU64(&x9, x8, cast(u64, 0x0), 0xffffffffffffffff); + cmovznzU64(&x9, x8, @as(u64, 0x0), 0xffffffffffffffff); var x10: u64 = undefined; var x11: u1 = undefined; addcarryxU64(&x10, &x11, 0x0, x1, (x9 & 0xf3b9cac2fc632551)); @@ -973,22 +972,22 @@ pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDo addcarryxU64(&x18, &x19, 0x0, x1, x10); var x20: u64 = undefined; var x21: u1 = undefined; - addcarryxU64(&x20, &x21, x19, cast(u64, 0x0), x12); + addcarryxU64(&x20, &x21, x19, @as(u64, 0x0), x12); var x22: u64 = undefined; var x23: u1 = undefined; - addcarryxU64(&x22, &x23, x21, cast(u64, 0x0), x14); + addcarryxU64(&x22, &x23, x21, @as(u64, 0x0), x14); var x24: u64 = undefined; var x25: u1 = undefined; - addcarryxU64(&x24, &x25, x23, cast(u64, 0x0), x16); + addcarryxU64(&x24, &x25, x23, @as(u64, 0x0), x16); var x26: u64 = undefined; var x27: u1 = undefined; addcarryxU64(&x26, &x27, 0x0, x20, (arg1[1])); var x28: u64 = undefined; var x29: u1 = undefined; - addcarryxU64(&x28, &x29, x27, x22, cast(u64, 0x0)); + addcarryxU64(&x28, &x29, x27, x22, @as(u64, 0x0)); var x30: u64 = undefined; var x31: u1 = undefined; - addcarryxU64(&x30, &x31, x29, x24, cast(u64, 0x0)); + addcarryxU64(&x30, &x31, x29, x24, @as(u64, 0x0)); var x32: u64 = undefined; var x33: u64 = undefined; mulxU64(&x32, &x33, x26, 0xccd1c8aaee00bc4f); @@ -1024,16 +1023,16 @@ pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDo addcarryxU64(&x52, &x53, x51, x30, x44); var x54: u64 = undefined; var x55: u1 = undefined; - addcarryxU64(&x54, &x55, x53, (cast(u64, x31) + (cast(u64, x25) + (cast(u64, x17) + x5))), x46); + addcarryxU64(&x54, &x55, x53, (@as(u64, x31) + (@as(u64, x25) + (@as(u64, x17) + x5))), x46); var x56: u64 = undefined; var x57: u1 = undefined; addcarryxU64(&x56, &x57, 0x0, x50, (arg1[2])); var x58: u64 = undefined; var x59: u1 = undefined; - addcarryxU64(&x58, &x59, x57, x52, cast(u64, 0x0)); + addcarryxU64(&x58, &x59, x57, x52, @as(u64, 0x0)); var x60: u64 = undefined; var x61: u1 = undefined; - addcarryxU64(&x60, &x61, x59, x54, cast(u64, 0x0)); + addcarryxU64(&x60, &x61, x59, x54, @as(u64, 0x0)); var x62: u64 = undefined; var x63: u64 = undefined; mulxU64(&x62, &x63, x56, 0xccd1c8aaee00bc4f); @@ -1069,16 +1068,16 @@ pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDo addcarryxU64(&x82, &x83, x81, x60, x74); var x84: u64 = undefined; var x85: u1 = undefined; - addcarryxU64(&x84, &x85, x83, (cast(u64, x61) + (cast(u64, x55) + (cast(u64, x47) + x35))), x76); + addcarryxU64(&x84, &x85, x83, (@as(u64, x61) + (@as(u64, x55) + (@as(u64, x47) + x35))), x76); var x86: u64 = undefined; var x87: u1 = undefined; addcarryxU64(&x86, &x87, 0x0, x80, (arg1[3])); var x88: u64 = undefined; var x89: u1 = undefined; - addcarryxU64(&x88, &x89, x87, x82, cast(u64, 0x0)); + addcarryxU64(&x88, &x89, x87, x82, @as(u64, 0x0)); var x90: u64 = undefined; var x91: u1 = undefined; - addcarryxU64(&x90, &x91, x89, x84, cast(u64, 0x0)); + addcarryxU64(&x90, &x91, x89, x84, @as(u64, 0x0)); var x92: u64 = undefined; var x93: u64 = undefined; mulxU64(&x92, &x93, x86, 0xccd1c8aaee00bc4f); @@ -1114,8 +1113,8 @@ pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDo addcarryxU64(&x112, &x113, x111, x90, x104); var x114: u64 = undefined; var x115: u1 = undefined; - addcarryxU64(&x114, &x115, x113, (cast(u64, x91) + (cast(u64, x85) + (cast(u64, x77) + x65))), x106); - const x116 = (cast(u64, x115) + (cast(u64, x107) + x95)); + addcarryxU64(&x114, &x115, x113, (@as(u64, x91) + (@as(u64, x85) + (@as(u64, x77) + x65))), x106); + const x116 = (@as(u64, x115) + (@as(u64, x107) + x95)); var x117: u64 = undefined; var x118: u1 = undefined; subborrowxU64(&x117, &x118, 0x0, x110, 0xf3b9cac2fc632551); @@ -1130,7 +1129,7 @@ pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDo subborrowxU64(&x123, &x124, x122, x116, 0xffffffff00000000); var x125: u64 = undefined; var x126: u1 = undefined; - subborrowxU64(&x125, &x126, x124, cast(u64, 0x0), cast(u64, 0x0)); + subborrowxU64(&x125, &x126, x124, @as(u64, 0x0), @as(u64, 0x0)); var x127: u64 = undefined; cmovznzU64(&x127, x126, x117, x110); var x128: u64 = undefined; @@ -1219,7 +1218,7 @@ pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDoma addcarryxU64(&x41, &x42, x40, x17, x33); var x43: u64 = undefined; var x44: u1 = undefined; - addcarryxU64(&x43, &x44, x42, (cast(u64, x18) + x6), (cast(u64, x34) + x22)); + addcarryxU64(&x43, &x44, x42, (@as(u64, x18) + x6), (@as(u64, x34) + x22)); var x45: u64 = undefined; var x46: u64 = undefined; mulxU64(&x45, &x46, x1, 0x66e12d94f3d95620); @@ -1291,7 +1290,7 @@ pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDoma addcarryxU64(&x89, &x90, x88, x65, x81); var x91: u64 = undefined; var x92: u1 = undefined; - addcarryxU64(&x91, &x92, x90, ((cast(u64, x66) + cast(u64, x44)) + (cast(u64, x58) + x46)), (cast(u64, x82) + x70)); + addcarryxU64(&x91, &x92, x90, ((@as(u64, x66) + @as(u64, x44)) + (@as(u64, x58) + x46)), (@as(u64, x82) + x70)); var x93: u64 = undefined; var x94: u64 = undefined; mulxU64(&x93, &x94, x2, 0x66e12d94f3d95620); @@ -1363,7 +1362,7 @@ pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDoma addcarryxU64(&x137, &x138, x136, x113, x129); var x139: u64 = undefined; var x140: u1 = undefined; - addcarryxU64(&x139, &x140, x138, ((cast(u64, x114) + cast(u64, x92)) + (cast(u64, x106) + x94)), (cast(u64, x130) + x118)); + addcarryxU64(&x139, &x140, x138, ((@as(u64, x114) + @as(u64, x92)) + (@as(u64, x106) + x94)), (@as(u64, x130) + x118)); var x141: u64 = undefined; var x142: u64 = undefined; mulxU64(&x141, &x142, x3, 0x66e12d94f3d95620); @@ -1435,7 +1434,7 @@ pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDoma addcarryxU64(&x185, &x186, x184, x161, x177); var x187: u64 = undefined; var x188: u1 = undefined; - addcarryxU64(&x187, &x188, x186, ((cast(u64, x162) + cast(u64, x140)) + (cast(u64, x154) + x142)), (cast(u64, x178) + x166)); + addcarryxU64(&x187, &x188, x186, ((@as(u64, x162) + @as(u64, x140)) + (@as(u64, x154) + x142)), (@as(u64, x178) + x166)); var x189: u64 = undefined; var x190: u1 = undefined; subborrowxU64(&x189, &x190, 0x0, x181, 0xf3b9cac2fc632551); @@ -1450,7 +1449,7 @@ pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDoma subborrowxU64(&x195, &x196, x194, x187, 0xffffffff00000000); var x197: u64 = undefined; var x198: u1 = undefined; - subborrowxU64(&x197, &x198, x196, cast(u64, x188), cast(u64, 0x0)); + subborrowxU64(&x197, &x198, x196, @as(u64, x188), @as(u64, 0x0)); var x199: u64 = undefined; cmovznzU64(&x199, x198, x189, x181); var x200: u64 = undefined; @@ -1529,62 +1528,62 @@ pub fn toBytes(out1: *[32]u8, arg1: [4]u64) void { const x2 = (arg1[2]); const x3 = (arg1[1]); const x4 = (arg1[0]); - const x5 = cast(u8, (x4 & cast(u64, 0xff))); + const x5 = @truncate(u8, (x4 & @as(u64, 0xff))); const x6 = (x4 >> 8); - const x7 = cast(u8, (x6 & cast(u64, 0xff))); + const x7 = @truncate(u8, (x6 & @as(u64, 0xff))); const x8 = (x6 >> 8); - const x9 = cast(u8, (x8 & cast(u64, 0xff))); + const x9 = @truncate(u8, (x8 & @as(u64, 0xff))); const x10 = (x8 >> 8); - const x11 = cast(u8, (x10 & cast(u64, 0xff))); + const x11 = @truncate(u8, (x10 & @as(u64, 0xff))); const x12 = (x10 >> 8); - const x13 = cast(u8, (x12 & cast(u64, 0xff))); + const x13 = @truncate(u8, (x12 & @as(u64, 0xff))); const x14 = (x12 >> 8); - const x15 = cast(u8, (x14 & cast(u64, 0xff))); + const x15 = @truncate(u8, (x14 & @as(u64, 0xff))); const x16 = (x14 >> 8); - const x17 = cast(u8, (x16 & cast(u64, 0xff))); - const x18 = cast(u8, (x16 >> 8)); - const x19 = cast(u8, (x3 & cast(u64, 0xff))); + const x17 = @truncate(u8, (x16 & @as(u64, 0xff))); + const x18 = @truncate(u8, (x16 >> 8)); + const x19 = @truncate(u8, (x3 & @as(u64, 0xff))); const x20 = (x3 >> 8); - const x21 = cast(u8, (x20 & cast(u64, 0xff))); + const x21 = @truncate(u8, (x20 & @as(u64, 0xff))); const x22 = (x20 >> 8); - const x23 = cast(u8, (x22 & cast(u64, 0xff))); + const x23 = @truncate(u8, (x22 & @as(u64, 0xff))); const x24 = (x22 >> 8); - const x25 = cast(u8, (x24 & cast(u64, 0xff))); + const x25 = @truncate(u8, (x24 & @as(u64, 0xff))); const x26 = (x24 >> 8); - const x27 = cast(u8, (x26 & cast(u64, 0xff))); + const x27 = @truncate(u8, (x26 & @as(u64, 0xff))); const x28 = (x26 >> 8); - const x29 = cast(u8, (x28 & cast(u64, 0xff))); + const x29 = @truncate(u8, (x28 & @as(u64, 0xff))); const x30 = (x28 >> 8); - const x31 = cast(u8, (x30 & cast(u64, 0xff))); - const x32 = cast(u8, (x30 >> 8)); - const x33 = cast(u8, (x2 & cast(u64, 0xff))); + const x31 = @truncate(u8, (x30 & @as(u64, 0xff))); + const x32 = @truncate(u8, (x30 >> 8)); + const x33 = @truncate(u8, (x2 & @as(u64, 0xff))); const x34 = (x2 >> 8); - const x35 = cast(u8, (x34 & cast(u64, 0xff))); + const x35 = @truncate(u8, (x34 & @as(u64, 0xff))); const x36 = (x34 >> 8); - const x37 = cast(u8, (x36 & cast(u64, 0xff))); + const x37 = @truncate(u8, (x36 & @as(u64, 0xff))); const x38 = (x36 >> 8); - const x39 = cast(u8, (x38 & cast(u64, 0xff))); + const x39 = @truncate(u8, (x38 & @as(u64, 0xff))); const x40 = (x38 >> 8); - const x41 = cast(u8, (x40 & cast(u64, 0xff))); + const x41 = @truncate(u8, (x40 & @as(u64, 0xff))); const x42 = (x40 >> 8); - const x43 = cast(u8, (x42 & cast(u64, 0xff))); + const x43 = @truncate(u8, (x42 & @as(u64, 0xff))); const x44 = (x42 >> 8); - const x45 = cast(u8, (x44 & cast(u64, 0xff))); - const x46 = cast(u8, (x44 >> 8)); - const x47 = cast(u8, (x1 & cast(u64, 0xff))); + const x45 = @truncate(u8, (x44 & @as(u64, 0xff))); + const x46 = @truncate(u8, (x44 >> 8)); + const x47 = @truncate(u8, (x1 & @as(u64, 0xff))); const x48 = (x1 >> 8); - const x49 = cast(u8, (x48 & cast(u64, 0xff))); + const x49 = @truncate(u8, (x48 & @as(u64, 0xff))); const x50 = (x48 >> 8); - const x51 = cast(u8, (x50 & cast(u64, 0xff))); + const x51 = @truncate(u8, (x50 & @as(u64, 0xff))); const x52 = (x50 >> 8); - const x53 = cast(u8, (x52 & cast(u64, 0xff))); + const x53 = @truncate(u8, (x52 & @as(u64, 0xff))); const x54 = (x52 >> 8); - const x55 = cast(u8, (x54 & cast(u64, 0xff))); + const x55 = @truncate(u8, (x54 & @as(u64, 0xff))); const x56 = (x54 >> 8); - const x57 = cast(u8, (x56 & cast(u64, 0xff))); + const x57 = @truncate(u8, (x56 & @as(u64, 0xff))); const x58 = (x56 >> 8); - const x59 = cast(u8, (x58 & cast(u64, 0xff))); - const x60 = cast(u8, (x58 >> 8)); + const x59 = @truncate(u8, (x58 & @as(u64, 0xff))); + const x60 = @truncate(u8, (x58 >> 8)); out1[0] = x5; out1[1] = x7; out1[2] = x9; @@ -1634,60 +1633,60 @@ pub fn toBytes(out1: *[32]u8, arg1: [4]u64) void { pub fn fromBytes(out1: *[4]u64, arg1: [32]u8) void { @setRuntimeSafety(mode == .Debug); - const x1 = (cast(u64, (arg1[31])) << 56); - const x2 = (cast(u64, (arg1[30])) << 48); - const x3 = (cast(u64, (arg1[29])) << 40); - const x4 = (cast(u64, (arg1[28])) << 32); - const x5 = (cast(u64, (arg1[27])) << 24); - const x6 = (cast(u64, (arg1[26])) << 16); - const x7 = (cast(u64, (arg1[25])) << 8); + const x1 = (@as(u64, (arg1[31])) << 56); + const x2 = (@as(u64, (arg1[30])) << 48); + const x3 = (@as(u64, (arg1[29])) << 40); + const x4 = (@as(u64, (arg1[28])) << 32); + const x5 = (@as(u64, (arg1[27])) << 24); + const x6 = (@as(u64, (arg1[26])) << 16); + const x7 = (@as(u64, (arg1[25])) << 8); const x8 = (arg1[24]); - const x9 = (cast(u64, (arg1[23])) << 56); - const x10 = (cast(u64, (arg1[22])) << 48); - const x11 = (cast(u64, (arg1[21])) << 40); - const x12 = (cast(u64, (arg1[20])) << 32); - const x13 = (cast(u64, (arg1[19])) << 24); - const x14 = (cast(u64, (arg1[18])) << 16); - const x15 = (cast(u64, (arg1[17])) << 8); + const x9 = (@as(u64, (arg1[23])) << 56); + const x10 = (@as(u64, (arg1[22])) << 48); + const x11 = (@as(u64, (arg1[21])) << 40); + const x12 = (@as(u64, (arg1[20])) << 32); + const x13 = (@as(u64, (arg1[19])) << 24); + const x14 = (@as(u64, (arg1[18])) << 16); + const x15 = (@as(u64, (arg1[17])) << 8); const x16 = (arg1[16]); - const x17 = (cast(u64, (arg1[15])) << 56); - const x18 = (cast(u64, (arg1[14])) << 48); - const x19 = (cast(u64, (arg1[13])) << 40); - const x20 = (cast(u64, (arg1[12])) << 32); - const x21 = (cast(u64, (arg1[11])) << 24); - const x22 = (cast(u64, (arg1[10])) << 16); - const x23 = (cast(u64, (arg1[9])) << 8); + const x17 = (@as(u64, (arg1[15])) << 56); + const x18 = (@as(u64, (arg1[14])) << 48); + const x19 = (@as(u64, (arg1[13])) << 40); + const x20 = (@as(u64, (arg1[12])) << 32); + const x21 = (@as(u64, (arg1[11])) << 24); + const x22 = (@as(u64, (arg1[10])) << 16); + const x23 = (@as(u64, (arg1[9])) << 8); const x24 = (arg1[8]); - const x25 = (cast(u64, (arg1[7])) << 56); - const x26 = (cast(u64, (arg1[6])) << 48); - const x27 = (cast(u64, (arg1[5])) << 40); - const x28 = (cast(u64, (arg1[4])) << 32); - const x29 = (cast(u64, (arg1[3])) << 24); - const x30 = (cast(u64, (arg1[2])) << 16); - const x31 = (cast(u64, (arg1[1])) << 8); + const x25 = (@as(u64, (arg1[7])) << 56); + const x26 = (@as(u64, (arg1[6])) << 48); + const x27 = (@as(u64, (arg1[5])) << 40); + const x28 = (@as(u64, (arg1[4])) << 32); + const x29 = (@as(u64, (arg1[3])) << 24); + const x30 = (@as(u64, (arg1[2])) << 16); + const x31 = (@as(u64, (arg1[1])) << 8); const x32 = (arg1[0]); - const x33 = (x31 + cast(u64, x32)); + const x33 = (x31 + @as(u64, x32)); const x34 = (x30 + x33); const x35 = (x29 + x34); const x36 = (x28 + x35); const x37 = (x27 + x36); const x38 = (x26 + x37); const x39 = (x25 + x38); - const x40 = (x23 + cast(u64, x24)); + const x40 = (x23 + @as(u64, x24)); const x41 = (x22 + x40); const x42 = (x21 + x41); const x43 = (x20 + x42); const x44 = (x19 + x43); const x45 = (x18 + x44); const x46 = (x17 + x45); - const x47 = (x15 + cast(u64, x16)); + const x47 = (x15 + @as(u64, x16)); const x48 = (x14 + x47); const x49 = (x13 + x48); const x50 = (x12 + x49); const x51 = (x11 + x50); const x52 = (x10 + x51); const x53 = (x9 + x52); - const x54 = (x7 + cast(u64, x8)); + const x54 = (x7 + @as(u64, x8)); const x55 = (x6 + x54); const x56 = (x5 + x55); const x57 = (x4 + x56); @@ -1711,7 +1710,7 @@ pub fn setOne(out1: *MontgomeryDomainFieldElement) void { out1[0] = 0xc46353d039cdaaf; out1[1] = 0x4319055258e8617b; - out1[2] = cast(u64, 0x0); + out1[2] = @as(u64, 0x0); out1[3] = 0xffffffff; } @@ -1730,7 +1729,7 @@ pub fn msat(out1: *[5]u64) void { out1[1] = 0xbce6faada7179e84; out1[2] = 0xffffffffffffffff; out1[3] = 0xffffffff00000000; - out1[4] = cast(u64, 0x0); + out1[4] = @as(u64, 0x0); } /// The function divstep computes a divstep. @@ -1766,11 +1765,11 @@ pub fn divstep(out1: *u64, out2: *[5]u64, out3: *[5]u64, out4: *[4]u64, out5: *[ var x1: u64 = undefined; var x2: u1 = undefined; - addcarryxU64(&x1, &x2, 0x0, (~arg1), cast(u64, 0x1)); - const x3 = (cast(u1, (x1 >> 63)) & cast(u1, ((arg3[0]) & cast(u64, 0x1)))); + addcarryxU64(&x1, &x2, 0x0, (~arg1), @as(u64, 0x1)); + const x3 = (@as(u1, (x1 >> 63)) & @as(u1, ((arg3[0]) & @as(u64, 0x1)))); var x4: u64 = undefined; var x5: u1 = undefined; - addcarryxU64(&x4, &x5, 0x0, (~arg1), cast(u64, 0x1)); + addcarryxU64(&x4, &x5, 0x0, (~arg1), @as(u64, 0x1)); var x6: u64 = undefined; cmovznzU64(&x6, x3, arg1, x4); var x7: u64 = undefined; @@ -1785,19 +1784,19 @@ pub fn divstep(out1: *u64, out2: *[5]u64, out3: *[5]u64, out4: *[4]u64, out5: *[ cmovznzU64(&x11, x3, (arg2[4]), (arg3[4])); var x12: u64 = undefined; var x13: u1 = undefined; - addcarryxU64(&x12, &x13, 0x0, cast(u64, 0x1), (~(arg2[0]))); + addcarryxU64(&x12, &x13, 0x0, @as(u64, 0x1), (~(arg2[0]))); var x14: u64 = undefined; var x15: u1 = undefined; - addcarryxU64(&x14, &x15, x13, cast(u64, 0x0), (~(arg2[1]))); + addcarryxU64(&x14, &x15, x13, @as(u64, 0x0), (~(arg2[1]))); var x16: u64 = undefined; var x17: u1 = undefined; - addcarryxU64(&x16, &x17, x15, cast(u64, 0x0), (~(arg2[2]))); + addcarryxU64(&x16, &x17, x15, @as(u64, 0x0), (~(arg2[2]))); var x18: u64 = undefined; var x19: u1 = undefined; - addcarryxU64(&x18, &x19, x17, cast(u64, 0x0), (~(arg2[3]))); + addcarryxU64(&x18, &x19, x17, @as(u64, 0x0), (~(arg2[3]))); var x20: u64 = undefined; var x21: u1 = undefined; - addcarryxU64(&x20, &x21, x19, cast(u64, 0x0), (~(arg2[4]))); + addcarryxU64(&x20, &x21, x19, @as(u64, 0x0), (~(arg2[4]))); var x22: u64 = undefined; cmovznzU64(&x22, x3, (arg3[0]), x12); var x23: u64 = undefined; @@ -1842,25 +1841,25 @@ pub fn divstep(out1: *u64, out2: *[5]u64, out3: *[5]u64, out4: *[4]u64, out5: *[ subborrowxU64(&x45, &x46, x44, x37, 0xffffffff00000000); var x47: u64 = undefined; var x48: u1 = undefined; - subborrowxU64(&x47, &x48, x46, cast(u64, x38), cast(u64, 0x0)); + subborrowxU64(&x47, &x48, x46, @as(u64, x38), @as(u64, 0x0)); const x49 = (arg4[3]); const x50 = (arg4[2]); const x51 = (arg4[1]); const x52 = (arg4[0]); var x53: u64 = undefined; var x54: u1 = undefined; - subborrowxU64(&x53, &x54, 0x0, cast(u64, 0x0), x52); + subborrowxU64(&x53, &x54, 0x0, @as(u64, 0x0), x52); var x55: u64 = undefined; var x56: u1 = undefined; - subborrowxU64(&x55, &x56, x54, cast(u64, 0x0), x51); + subborrowxU64(&x55, &x56, x54, @as(u64, 0x0), x51); var x57: u64 = undefined; var x58: u1 = undefined; - subborrowxU64(&x57, &x58, x56, cast(u64, 0x0), x50); + subborrowxU64(&x57, &x58, x56, @as(u64, 0x0), x50); var x59: u64 = undefined; var x60: u1 = undefined; - subborrowxU64(&x59, &x60, x58, cast(u64, 0x0), x49); + subborrowxU64(&x59, &x60, x58, @as(u64, 0x0), x49); var x61: u64 = undefined; - cmovznzU64(&x61, x60, cast(u64, 0x0), 0xffffffffffffffff); + cmovznzU64(&x61, x60, @as(u64, 0x0), 0xffffffffffffffff); var x62: u64 = undefined; var x63: u1 = undefined; addcarryxU64(&x62, &x63, 0x0, x53, (x61 & 0xf3b9cac2fc632551)); @@ -1881,17 +1880,17 @@ pub fn divstep(out1: *u64, out2: *[5]u64, out3: *[5]u64, out4: *[4]u64, out5: *[ cmovznzU64(&x72, x3, (arg5[2]), x66); var x73: u64 = undefined; cmovznzU64(&x73, x3, (arg5[3]), x68); - const x74 = cast(u1, (x22 & cast(u64, 0x1))); + const x74 = @as(u1, (x22 & @as(u64, 0x1))); var x75: u64 = undefined; - cmovznzU64(&x75, x74, cast(u64, 0x0), x7); + cmovznzU64(&x75, x74, @as(u64, 0x0), x7); var x76: u64 = undefined; - cmovznzU64(&x76, x74, cast(u64, 0x0), x8); + cmovznzU64(&x76, x74, @as(u64, 0x0), x8); var x77: u64 = undefined; - cmovznzU64(&x77, x74, cast(u64, 0x0), x9); + cmovznzU64(&x77, x74, @as(u64, 0x0), x9); var x78: u64 = undefined; - cmovznzU64(&x78, x74, cast(u64, 0x0), x10); + cmovznzU64(&x78, x74, @as(u64, 0x0), x10); var x79: u64 = undefined; - cmovznzU64(&x79, x74, cast(u64, 0x0), x11); + cmovznzU64(&x79, x74, @as(u64, 0x0), x11); var x80: u64 = undefined; var x81: u1 = undefined; addcarryxU64(&x80, &x81, 0x0, x22, x75); @@ -1908,13 +1907,13 @@ pub fn divstep(out1: *u64, out2: *[5]u64, out3: *[5]u64, out4: *[4]u64, out5: *[ var x89: u1 = undefined; addcarryxU64(&x88, &x89, x87, x26, x79); var x90: u64 = undefined; - cmovznzU64(&x90, x74, cast(u64, 0x0), x27); + cmovznzU64(&x90, x74, @as(u64, 0x0), x27); var x91: u64 = undefined; - cmovznzU64(&x91, x74, cast(u64, 0x0), x28); + cmovznzU64(&x91, x74, @as(u64, 0x0), x28); var x92: u64 = undefined; - cmovznzU64(&x92, x74, cast(u64, 0x0), x29); + cmovznzU64(&x92, x74, @as(u64, 0x0), x29); var x93: u64 = undefined; - cmovznzU64(&x93, x74, cast(u64, 0x0), x30); + cmovznzU64(&x93, x74, @as(u64, 0x0), x30); var x94: u64 = undefined; var x95: u1 = undefined; addcarryxU64(&x94, &x95, 0x0, x70, x90); @@ -1941,10 +1940,10 @@ pub fn divstep(out1: *u64, out2: *[5]u64, out3: *[5]u64, out4: *[4]u64, out5: *[ subborrowxU64(&x108, &x109, x107, x100, 0xffffffff00000000); var x110: u64 = undefined; var x111: u1 = undefined; - subborrowxU64(&x110, &x111, x109, cast(u64, x101), cast(u64, 0x0)); + subborrowxU64(&x110, &x111, x109, @as(u64, x101), @as(u64, 0x0)); var x112: u64 = undefined; var x113: u1 = undefined; - addcarryxU64(&x112, &x113, 0x0, x6, cast(u64, 0x1)); + addcarryxU64(&x112, &x113, 0x0, x6, @as(u64, 0x1)); const x114 = ((x80 >> 1) | ((x82 << 63) & 0xffffffffffffffff)); const x115 = ((x82 >> 1) | ((x84 << 63) & 0xffffffffffffffff)); const x116 = ((x84 >> 1) | ((x86 << 63) & 0xffffffffffffffff));