Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Commit

Permalink
fix: add more wrapping_muls
Browse files Browse the repository at this point in the history
  • Loading branch information
shuklaayush committed Dec 2, 2023
1 parent 4bec17d commit 9a87629
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion crates/curves/src/ecdsa_secp256k1/fp.nr
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use dep::std;
use dep::std::println;

use dep::biguint::{BigUint56, utils};
Expand Down Expand Up @@ -175,7 +176,7 @@ impl PrimeField {

let mut carry2 = 0;
for i in 0..NUM_LIMBS {
let k = tmp[i] * PrimeField::P_INV();
let k = std::wrapping_mul(tmp[i], PrimeField::P_INV());
let mut carry = 0;
for j in 0..NUM_LIMBS {
let (prod, c) = utils::mac(tmp[i + j], k, modulus.limbs[j], carry);
Expand Down
3 changes: 2 additions & 1 deletion crates/curves/src/ecdsa_secp256k1/fq.nr
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use dep::std;
use dep::std::println;

use dep::biguint::{BigUint56, utils};
Expand Down Expand Up @@ -175,7 +176,7 @@ impl PrimeField {

let mut carry2 = 0;
for i in 0..NUM_LIMBS {
let k = tmp[i] * PrimeField::P_INV();
let k = std::wrapping_mul(tmp[i], PrimeField::P_INV());
let mut carry = 0;
for j in 0..NUM_LIMBS {
let (prod, c) = utils::mac(tmp[i + j], k, modulus.limbs[j], carry);
Expand Down
3 changes: 2 additions & 1 deletion crates/curves/src/ed25519/fp.nr
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use dep::std;
use dep::std::println;

use dep::biguint::{BigUint56, utils};
Expand Down Expand Up @@ -175,7 +176,7 @@ impl PrimeField {

let mut carry2 = 0;
for i in 0..NUM_LIMBS {
let k = tmp[i] * PrimeField::P_INV();
let k = std::wrapping_mul(tmp[i], PrimeField::P_INV());
let mut carry = 0;
for j in 0..NUM_LIMBS {
let (prod, c) = utils::mac(tmp[i + j], k, modulus.limbs[j], carry);
Expand Down
3 changes: 2 additions & 1 deletion crates/curves/src/ed25519/fq.nr
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use dep::std;
use dep::std::println;

use dep::biguint::{BigUint56, utils};
Expand Down Expand Up @@ -175,7 +176,7 @@ impl PrimeField {

let mut carry2 = 0;
for i in 0..NUM_LIMBS {
let k = tmp[i] * PrimeField::P_INV();
let k = std::wrapping_mul(tmp[i], PrimeField::P_INV());
let mut carry = 0;
for j in 0..NUM_LIMBS {
let (prod, c) = utils::mac(tmp[i + j], k, modulus.limbs[j], carry);
Expand Down

0 comments on commit 9a87629

Please sign in to comment.