summaryrefslogtreecommitdiffstats
path: root/vendor/primeorder/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/primeorder/src
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/primeorder/src')
-rw-r--r--vendor/primeorder/src/affine.rs7
-rw-r--r--vendor/primeorder/src/dev.rs2
-rw-r--r--vendor/primeorder/src/field.rs23
-rw-r--r--vendor/primeorder/src/lib.rs4
4 files changed, 30 insertions, 6 deletions
diff --git a/vendor/primeorder/src/affine.rs b/vendor/primeorder/src/affine.rs
index e7f2feccd..3fb01d905 100644
--- a/vendor/primeorder/src/affine.rs
+++ b/vendor/primeorder/src/affine.rs
@@ -182,8 +182,11 @@ where
}
sec1::Coordinates::Uncompressed { x, y } => {
C::FieldElement::from_repr(*y).and_then(|y| {
- Self::decompress(x, y.is_odd())
- .and_then(|point| CtOption::new(point, point.y.ct_eq(&y)))
+ C::FieldElement::from_repr(*x).and_then(|x| {
+ let lhs = y * &y;
+ let rhs = x * &x * &x + &(C::EQUATION_A * &x) + &C::EQUATION_B;
+ CtOption::new(Self { x, y, infinity: 0 }, lhs.ct_eq(&rhs))
+ })
})
}
}
diff --git a/vendor/primeorder/src/dev.rs b/vendor/primeorder/src/dev.rs
index 67877aa74..77f563fa0 100644
--- a/vendor/primeorder/src/dev.rs
+++ b/vendor/primeorder/src/dev.rs
@@ -1,5 +1,7 @@
//! Development-related functionality.
+// TODO(tarcieri): move all development-related macros into this module
+
/// Implement projective arithmetic tests.
#[macro_export]
macro_rules! impl_projective_arithmetic_tests {
diff --git a/vendor/primeorder/src/field.rs b/vendor/primeorder/src/field.rs
index a347f0bb1..9a3b6eade 100644
--- a/vendor/primeorder/src/field.rs
+++ b/vendor/primeorder/src/field.rs
@@ -261,6 +261,25 @@ macro_rules! impl_mont_field_element {
}
}
+ $crate::impl_mont_field_element_arithmetic!(
+ $fe, $bytes, $uint, $arr, $add, $sub, $mul, $neg
+ );
+ };
+}
+
+/// Add arithmetic impls to the given field element.
+#[macro_export]
+macro_rules! impl_mont_field_element_arithmetic {
+ (
+ $fe:tt,
+ $bytes:ty,
+ $uint:ty,
+ $arr:ty,
+ $add:ident,
+ $sub:ident,
+ $mul:ident,
+ $neg:ident
+ ) => {
impl AsRef<$arr> for $fe {
fn as_ref(&self) -> &$arr {
self.0.as_ref()
@@ -491,7 +510,7 @@ macro_rules! impl_bernstein_yang_invert {
$d:expr,
$nlimbs:expr,
$word:ty,
- $from_montgomery:ident,
+ $from_mont:ident,
$mul:ident,
$neg:ident,
$divstep_precomp:ident,
@@ -502,7 +521,7 @@ macro_rules! impl_bernstein_yang_invert {
// See Bernstein-Yang 2019 p.366
const ITERATIONS: usize = (49 * $d + 57) / 17;
- let a = $from_montgomery($a);
+ let a = $from_mont($a);
let mut d = 1;
let mut f = $msat();
let mut g = [0; $nlimbs + 1];
diff --git a/vendor/primeorder/src/lib.rs b/vendor/primeorder/src/lib.rs
index 0847a995a..8c515a148 100644
--- a/vendor/primeorder/src/lib.rs
+++ b/vendor/primeorder/src/lib.rs
@@ -8,11 +8,11 @@
#![warn(missing_docs, rust_2018_idioms, unused_qualifications)]
#![doc = include_str!("../README.md")]
-#[cfg(feature = "dev")]
-pub mod dev;
pub mod point_arithmetic;
mod affine;
+#[cfg(feature = "dev")]
+mod dev;
mod field;
mod projective;