Differences between debug and release versions in ct_eq

未关闭
#1,982 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
28/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
rust
领域
cryptography

调研方向

Start with the sqrt_ratio_3mod4_one test in k256/src/arithmetic/hash2curve.rs, run it with and without --release as the issue shows, then read the ct_eq comparison near line 82 of primeorder/src/osswu.rs. Done means the test gives the same result in both builds and the constant-time comparison is fixed. This is cryptographic code, so a maintainer should review any change.

由索引模型根据 Issue 内容生成。

描述

See tests below:

diff --git a/k256/src/arithmetic/hash2curve.rs b/k256/src/arithmetic/hash2curve.rs
index 0ef28ebb..602c7603 100644
--- a/k256/src/arithmetic/hash2curve.rs
+++ b/k256/src/arithmetic/hash2curve.rs
@@ -289,6 +289,17 @@ mod tests {
     use hex_literal::hex;
     use proptest::{num::u64::ANY, prelude::ProptestConfig, proptest};

+    #[test]
+    fn sqrt_ratio_3mod4_one() {
+        use primeorder::osswu::OsswuMap;
+
+        let (is_square, root) =
+            FieldElement::sqrt_ratio_3mod4(FieldElement::ONE, FieldElement::ONE);
+
+        assert!(bool::from(is_square), "1 / 1 must be a quadratic residue");
+        assert_eq!(root.square().normalize(), FieldElement::ONE);
+    }
+

The release differs from the debug version:

cargo test -p k256 --features hash2curve --release sqrt_ratio_3mod4_one
cargo test -p k256 --features hash2curve sqrt_ratio_3mod4_one

It affects this line: https://github.com/RustCrypto/elliptic-curves/blob/189246045ba2ab93b68111dc4be30ba825eb93df/primeorder/src/osswu.rs#L82

主要语言
Rust
星标
884
派生
319
平均合并
18 小时 34 分钟
30 天内合并 PR
7

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

RustCrypto/elliptic-curves 的其他 Issue

查看 RustCrypto/elliptic-curves 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。