summaryrefslogtreecommitdiffstats
path: root/vendor/fiat-crypto/src/curve25519_32.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/fiat-crypto/src/curve25519_32.rs
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/fiat-crypto/src/curve25519_32.rs')
-rw-r--r--vendor/fiat-crypto/src/curve25519_32.rs80
1 files changed, 58 insertions, 22 deletions
diff --git a/vendor/fiat-crypto/src/curve25519_32.rs b/vendor/fiat-crypto/src/curve25519_32.rs
index 0a48a8a97..41b890248 100644
--- a/vendor/fiat-crypto/src/curve25519_32.rs
+++ b/vendor/fiat-crypto/src/curve25519_32.rs
@@ -15,18 +15,54 @@
#![allow(unused_parens)]
#![allow(non_camel_case_types)]
+/** fiat_25519_u1 represents values of 1 bits, stored in one byte. */
pub type fiat_25519_u1 = u8;
+/** fiat_25519_i1 represents values of 1 bits, stored in one byte. */
pub type fiat_25519_i1 = i8;
+/** fiat_25519_u2 represents values of 2 bits, stored in one byte. */
pub type fiat_25519_u2 = u8;
+/** fiat_25519_i2 represents values of 2 bits, stored in one byte. */
pub type fiat_25519_i2 = i8;
-/* The type fiat_25519_loose_field_element is a field element with loose bounds. */
-/* Bounds: [[0x0 ~> 0xc000000], [0x0 ~> 0x6000000], [0x0 ~> 0xc000000], [0x0 ~> 0x6000000], [0x0 ~> 0xc000000], [0x0 ~> 0x6000000], [0x0 ~> 0xc000000], [0x0 ~> 0x6000000], [0x0 ~> 0xc000000], [0x0 ~> 0x6000000]] */
-pub type fiat_25519_loose_field_element = [u32; 10];
+/** The type fiat_25519_loose_field_element is a field element with loose bounds. */
+/** Bounds: [[0x0 ~> 0xc000000], [0x0 ~> 0x6000000], [0x0 ~> 0xc000000], [0x0 ~> 0x6000000], [0x0 ~> 0xc000000], [0x0 ~> 0x6000000], [0x0 ~> 0xc000000], [0x0 ~> 0x6000000], [0x0 ~> 0xc000000], [0x0 ~> 0x6000000]] */
+#[derive(Clone, Copy)]
+pub struct fiat_25519_loose_field_element(pub [u32; 10]);
-/* The type fiat_25519_tight_field_element is a field element with tight bounds. */
-/* Bounds: [[0x0 ~> 0x4000000], [0x0 ~> 0x2000000], [0x0 ~> 0x4000000], [0x0 ~> 0x2000000], [0x0 ~> 0x4000000], [0x0 ~> 0x2000000], [0x0 ~> 0x4000000], [0x0 ~> 0x2000000], [0x0 ~> 0x4000000], [0x0 ~> 0x2000000]] */
-pub type fiat_25519_tight_field_element = [u32; 10];
+impl core::ops::Index<usize> for fiat_25519_loose_field_element {
+ type Output = u32;
+ #[inline]
+ fn index(&self, index: usize) -> &Self::Output {
+ &self.0[index]
+ }
+}
+
+impl core::ops::IndexMut<usize> for fiat_25519_loose_field_element {
+ #[inline]
+ fn index_mut(&mut self, index: usize) -> &mut Self::Output {
+ &mut self.0[index]
+ }
+}
+
+/** The type fiat_25519_tight_field_element is a field element with tight bounds. */
+/** Bounds: [[0x0 ~> 0x4000000], [0x0 ~> 0x2000000], [0x0 ~> 0x4000000], [0x0 ~> 0x2000000], [0x0 ~> 0x4000000], [0x0 ~> 0x2000000], [0x0 ~> 0x4000000], [0x0 ~> 0x2000000], [0x0 ~> 0x4000000], [0x0 ~> 0x2000000]] */
+#[derive(Clone, Copy)]
+pub struct fiat_25519_tight_field_element(pub [u32; 10]);
+
+impl core::ops::Index<usize> for fiat_25519_tight_field_element {
+ type Output = u32;
+ #[inline]
+ fn index(&self, index: usize) -> &Self::Output {
+ &self.0[index]
+ }
+}
+
+impl core::ops::IndexMut<usize> for fiat_25519_tight_field_element {
+ #[inline]
+ fn index_mut(&mut self, index: usize) -> &mut Self::Output {
+ &mut self.0[index]
+ }
+}
/// The function fiat_25519_addcarryx_u26 is an addition with carry.
@@ -43,7 +79,7 @@ pub type fiat_25519_tight_field_element = [u32; 10];
/// out1: [0x0 ~> 0x3ffffff]
/// out2: [0x0 ~> 0x1]
#[inline]
-pub fn fiat_25519_addcarryx_u26(out1: &mut u32, out2: &mut fiat_25519_u1, arg1: fiat_25519_u1, arg2: u32, arg3: u32) -> () {
+pub fn fiat_25519_addcarryx_u26(out1: &mut u32, out2: &mut fiat_25519_u1, arg1: fiat_25519_u1, arg2: u32, arg3: u32) {
let x1: u32 = (((arg1 as u32) + arg2) + arg3);
let x2: u32 = (x1 & 0x3ffffff);
let x3: fiat_25519_u1 = ((x1 >> 26) as fiat_25519_u1);
@@ -65,7 +101,7 @@ pub fn fiat_25519_addcarryx_u26(out1: &mut u32, out2: &mut fiat_25519_u1, arg1:
/// out1: [0x0 ~> 0x3ffffff]
/// out2: [0x0 ~> 0x1]
#[inline]
-pub fn fiat_25519_subborrowx_u26(out1: &mut u32, out2: &mut fiat_25519_u1, arg1: fiat_25519_u1, arg2: u32, arg3: u32) -> () {
+pub fn fiat_25519_subborrowx_u26(out1: &mut u32, out2: &mut fiat_25519_u1, arg1: fiat_25519_u1, arg2: u32, arg3: u32) {
let x1: i32 = ((((((arg2 as i64) - (arg1 as i64)) as i32) as i64) - (arg3 as i64)) as i32);
let x2: fiat_25519_i1 = ((x1 >> 26) as fiat_25519_i1);
let x3: u32 = (((x1 as i64) & (0x3ffffff as i64)) as u32);
@@ -87,7 +123,7 @@ pub fn fiat_25519_subborrowx_u26(out1: &mut u32, out2: &mut fiat_25519_u1, arg1:
/// out1: [0x0 ~> 0x1ffffff]
/// out2: [0x0 ~> 0x1]
#[inline]
-pub fn fiat_25519_addcarryx_u25(out1: &mut u32, out2: &mut fiat_25519_u1, arg1: fiat_25519_u1, arg2: u32, arg3: u32) -> () {
+pub fn fiat_25519_addcarryx_u25(out1: &mut u32, out2: &mut fiat_25519_u1, arg1: fiat_25519_u1, arg2: u32, arg3: u32) {
let x1: u32 = (((arg1 as u32) + arg2) + arg3);
let x2: u32 = (x1 & 0x1ffffff);
let x3: fiat_25519_u1 = ((x1 >> 25) as fiat_25519_u1);
@@ -109,7 +145,7 @@ pub fn fiat_25519_addcarryx_u25(out1: &mut u32, out2: &mut fiat_25519_u1, arg1:
/// out1: [0x0 ~> 0x1ffffff]
/// out2: [0x0 ~> 0x1]
#[inline]
-pub fn fiat_25519_subborrowx_u25(out1: &mut u32, out2: &mut fiat_25519_u1, arg1: fiat_25519_u1, arg2: u32, arg3: u32) -> () {
+pub fn fiat_25519_subborrowx_u25(out1: &mut u32, out2: &mut fiat_25519_u1, arg1: fiat_25519_u1, arg2: u32, arg3: u32) {
let x1: i32 = ((((((arg2 as i64) - (arg1 as i64)) as i32) as i64) - (arg3 as i64)) as i32);
let x2: fiat_25519_i1 = ((x1 >> 25) as fiat_25519_i1);
let x3: u32 = (((x1 as i64) & (0x1ffffff as i64)) as u32);
@@ -129,7 +165,7 @@ pub fn fiat_25519_subborrowx_u25(out1: &mut u32, out2: &mut fiat_25519_u1, arg1:
/// Output Bounds:
/// out1: [0x0 ~> 0xffffffff]
#[inline]
-pub fn fiat_25519_cmovznz_u32(out1: &mut u32, arg1: fiat_25519_u1, arg2: u32, arg3: u32) -> () {
+pub fn fiat_25519_cmovznz_u32(out1: &mut u32, arg1: fiat_25519_u1, arg2: u32, arg3: u32) {
let x1: fiat_25519_u1 = (!(!arg1));
let x2: u32 = ((((((0x0 as fiat_25519_i2) - (x1 as fiat_25519_i2)) as fiat_25519_i1) as i64) & (0xffffffff as i64)) as u32);
let x3: u32 = ((x2 & arg3) | ((!x2) & arg2));
@@ -142,7 +178,7 @@ pub fn fiat_25519_cmovznz_u32(out1: &mut u32, arg1: fiat_25519_u1, arg2: u32, ar
/// eval out1 mod m = (eval arg1 * eval arg2) mod m
///
#[inline]
-pub fn fiat_25519_carry_mul(out1: &mut fiat_25519_tight_field_element, arg1: &fiat_25519_loose_field_element, arg2: &fiat_25519_loose_field_element) -> () {
+pub fn fiat_25519_carry_mul(out1: &mut fiat_25519_tight_field_element, arg1: &fiat_25519_loose_field_element, arg2: &fiat_25519_loose_field_element) {
let x1: u64 = (((arg1[9]) as u64) * (((arg2[9]) * 0x26) as u64));
let x2: u64 = (((arg1[9]) as u64) * (((arg2[8]) * 0x13) as u64));
let x3: u64 = (((arg1[9]) as u64) * (((arg2[7]) * 0x26) as u64));
@@ -308,7 +344,7 @@ pub fn fiat_25519_carry_mul(out1: &mut fiat_25519_tight_field_element, arg1: &fi
/// eval out1 mod m = (eval arg1 * eval arg1) mod m
///
#[inline]
-pub fn fiat_25519_carry_square(out1: &mut fiat_25519_tight_field_element, arg1: &fiat_25519_loose_field_element) -> () {
+pub fn fiat_25519_carry_square(out1: &mut fiat_25519_tight_field_element, arg1: &fiat_25519_loose_field_element) {
let x1: u32 = ((arg1[9]) * 0x13);
let x2: u32 = (x1 * 0x2);
let x3: u32 = ((arg1[9]) * 0x2);
@@ -447,7 +483,7 @@ pub fn fiat_25519_carry_square(out1: &mut fiat_25519_tight_field_element, arg1:
/// eval out1 mod m = eval arg1 mod m
///
#[inline]
-pub fn fiat_25519_carry(out1: &mut fiat_25519_tight_field_element, arg1: &fiat_25519_loose_field_element) -> () {
+pub fn fiat_25519_carry(out1: &mut fiat_25519_tight_field_element, arg1: &fiat_25519_loose_field_element) {
let x1: u32 = (arg1[0]);
let x2: u32 = ((x1 >> 26) + (arg1[1]));
let x3: u32 = ((x2 >> 25) + (arg1[2]));
@@ -488,7 +524,7 @@ pub fn fiat_25519_carry(out1: &mut fiat_25519_tight_field_element, arg1: &fiat_2
/// eval out1 mod m = (eval arg1 + eval arg2) mod m
///
#[inline]
-pub fn fiat_25519_add(out1: &mut fiat_25519_loose_field_element, arg1: &fiat_25519_tight_field_element, arg2: &fiat_25519_tight_field_element) -> () {
+pub fn fiat_25519_add(out1: &mut fiat_25519_loose_field_element, arg1: &fiat_25519_tight_field_element, arg2: &fiat_25519_tight_field_element) {
let x1: u32 = ((arg1[0]) + (arg2[0]));
let x2: u32 = ((arg1[1]) + (arg2[1]));
let x3: u32 = ((arg1[2]) + (arg2[2]));
@@ -517,7 +553,7 @@ pub fn fiat_25519_add(out1: &mut fiat_25519_loose_field_element, arg1: &fiat_255
/// eval out1 mod m = (eval arg1 - eval arg2) mod m
///
#[inline]
-pub fn fiat_25519_sub(out1: &mut fiat_25519_loose_field_element, arg1: &fiat_25519_tight_field_element, arg2: &fiat_25519_tight_field_element) -> () {
+pub fn fiat_25519_sub(out1: &mut fiat_25519_loose_field_element, arg1: &fiat_25519_tight_field_element, arg2: &fiat_25519_tight_field_element) {
let x1: u32 = ((0x7ffffda + (arg1[0])) - (arg2[0]));
let x2: u32 = ((0x3fffffe + (arg1[1])) - (arg2[1]));
let x3: u32 = ((0x7fffffe + (arg1[2])) - (arg2[2]));
@@ -546,7 +582,7 @@ pub fn fiat_25519_sub(out1: &mut fiat_25519_loose_field_element, arg1: &fiat_255
/// eval out1 mod m = -eval arg1 mod m
///
#[inline]
-pub fn fiat_25519_opp(out1: &mut fiat_25519_loose_field_element, arg1: &fiat_25519_tight_field_element) -> () {
+pub fn fiat_25519_opp(out1: &mut fiat_25519_loose_field_element, arg1: &fiat_25519_tight_field_element) {
let x1: u32 = (0x7ffffda - (arg1[0]));
let x2: u32 = (0x3fffffe - (arg1[1]));
let x3: u32 = (0x7fffffe - (arg1[2]));
@@ -581,7 +617,7 @@ pub fn fiat_25519_opp(out1: &mut fiat_25519_loose_field_element, arg1: &fiat_255
/// Output Bounds:
/// out1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
#[inline]
-pub fn fiat_25519_selectznz(out1: &mut [u32; 10], arg1: fiat_25519_u1, arg2: &[u32; 10], arg3: &[u32; 10]) -> () {
+pub fn fiat_25519_selectznz(out1: &mut [u32; 10], arg1: fiat_25519_u1, arg2: &[u32; 10], arg3: &[u32; 10]) {
let mut x1: u32 = 0;
fiat_25519_cmovznz_u32(&mut x1, arg1, (arg2[0]), (arg3[0]));
let mut x2: u32 = 0;
@@ -622,7 +658,7 @@ pub fn fiat_25519_selectznz(out1: &mut [u32; 10], arg1: fiat_25519_u1, arg2: &[u
/// Output Bounds:
/// out1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0x7f]]
#[inline]
-pub fn fiat_25519_to_bytes(out1: &mut [u8; 32], arg1: &fiat_25519_tight_field_element) -> () {
+pub fn fiat_25519_to_bytes(out1: &mut [u8; 32], arg1: &fiat_25519_tight_field_element) {
let mut x1: u32 = 0;
let mut x2: fiat_25519_u1 = 0;
fiat_25519_subborrowx_u26(&mut x1, &mut x2, 0x0, (arg1[0]), 0x3ffffed);
@@ -803,7 +839,7 @@ pub fn fiat_25519_to_bytes(out1: &mut [u8; 32], arg1: &fiat_25519_tight_field_el
/// Input Bounds:
/// arg1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0x7f]]
#[inline]
-pub fn fiat_25519_from_bytes(out1: &mut fiat_25519_tight_field_element, arg1: &[u8; 32]) -> () {
+pub fn fiat_25519_from_bytes(out1: &mut fiat_25519_tight_field_element, arg1: &[u8; 32]) {
let x1: u32 = (((arg1[31]) as u32) << 18);
let x2: u32 = (((arg1[30]) as u32) << 10);
let x3: u32 = (((arg1[29]) as u32) << 2);
@@ -900,7 +936,7 @@ pub fn fiat_25519_from_bytes(out1: &mut fiat_25519_tight_field_element, arg1: &[
/// out1 = arg1
///
#[inline]
-pub fn fiat_25519_relax(out1: &mut fiat_25519_loose_field_element, arg1: &fiat_25519_tight_field_element) -> () {
+pub fn fiat_25519_relax(out1: &mut fiat_25519_loose_field_element, arg1: &fiat_25519_tight_field_element) {
let x1: u32 = (arg1[0]);
let x2: u32 = (arg1[1]);
let x3: u32 = (arg1[2]);
@@ -929,7 +965,7 @@ pub fn fiat_25519_relax(out1: &mut fiat_25519_loose_field_element, arg1: &fiat_2
/// eval out1 mod m = (121666 * eval arg1) mod m
///
#[inline]
-pub fn fiat_25519_carry_scmul_121666(out1: &mut fiat_25519_tight_field_element, arg1: &fiat_25519_loose_field_element) -> () {
+pub fn fiat_25519_carry_scmul_121666(out1: &mut fiat_25519_tight_field_element, arg1: &fiat_25519_loose_field_element) {
let x1: u64 = ((0x1db42 as u64) * ((arg1[9]) as u64));
let x2: u64 = ((0x1db42 as u64) * ((arg1[8]) as u64));
let x3: u64 = ((0x1db42 as u64) * ((arg1[7]) as u64));