Skip to content
This repository was archived by the owner on Dec 18, 2023. It is now read-only.

Commit ada1fda

Browse files
Fix Bls12-377 scalar group generator (#60)
* Fix Bls12-377 scalar group generator Previously we used 11 as a generator, which has order (p-1)/35. Now we use 22, which has the right order. Fixed the two-adic root of unity in accordance with the new generator. fixes #47 * add the CHANGE LOG Co-authored-by: weikeng <[email protected]>
1 parent 8c795ec commit ada1fda

File tree

2 files changed

+42
-10
lines changed

2 files changed

+42
-10
lines changed

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## Pending
2+
3+
### Breaking changes
4+
- [\#60](https://github.com/arkworks-rs/curves/pull/60) Change the scalar group generator of `Fr` of `bls12_377` Fr from `11` to `22`.
5+
6+
### Features
7+
8+
### Improvements
9+
10+
### Bug fixes
11+
112
## v0.2.0
213

314
### Breaking changes

bls12_377/src/fields/fr.rs

+31-10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
///! Bls12-377 scalar field.
2+
///
3+
/// Roots of unity computed from modulus and R using this sage code:
4+
///
5+
/// ```ignore
6+
/// q = 8444461749428370424248824938781546531375899335154063827935233455917409239041
7+
/// R = 6014086494747379908336260804527802945383293308637734276299549080986809532403 # Montgomery R
8+
/// s = 47
9+
/// o = q - 1
10+
/// F = GF(q)
11+
/// g = F.multiplicative_generator()
12+
/// g = F.multiplicative_generator()
13+
/// assert g.multiplicative_order() == o
14+
/// g2 = g ** (o/2**s)
15+
/// assert g2.multiplicative_order() == 2**s
16+
/// def into_chunks(val, width, n):
17+
/// return [int(int(val) // (2 ** (width * i)) % 2 ** width) for i in range(n)]
18+
/// print("Gen: ", g * R % q)
19+
/// print("Gen: ", into_chunks(g * R % q, 64, 4))
20+
/// print("2-adic gen: ", into_chunks(g2 * R % q, 64, 4))
21+
/// ```
122
use ark_ff::{biginteger::BigInteger256 as BigInteger, fields::*};
223

324
pub type Fr = Fp256<FrParameters>;
@@ -12,10 +33,10 @@ impl FftParameters for FrParameters {
1233

1334
#[rustfmt::skip]
1435
const TWO_ADIC_ROOT_OF_UNITY: BigInteger = BigInteger([
15-
0x3c3d3ca739381fb2,
16-
0x9a14cda3ec99772b,
17-
0xd7aacc7c59724826,
18-
0xd1ba211c5cc349c,
36+
12646347781564978760u64,
37+
6783048705277173164u64,
38+
268534165941069093u64,
39+
1121515446318641358u64,
1940
]);
2041
}
2142
impl FpParameters for FrParameters {
@@ -53,15 +74,15 @@ impl FpParameters for FrParameters {
5374

5475
const INV: u64 = 725501752471715839u64;
5576

56-
/// GENERATOR = 11
77+
/// GENERATOR = 22
5778
/// Encoded in Montgomery form, so the value is
58-
/// (11 * R) % q = 7043719196222586021957094278335006679584931048936630243748405699433040183146
79+
/// (22 * R) % q = 5642976643016801619665363617888466827793962762719196659561577942948671127251
5980
#[rustfmt::skip]
6081
const GENERATOR: BigInteger = BigInteger([
61-
1855201571499933546u64,
62-
8511318076631809892u64,
63-
6222514765367795509u64,
64-
1122129207579058019u64,
82+
2984901390528151251u64,
83+
10561528701063790279u64,
84+
5476750214495080041u64,
85+
898978044469942640u64,
6586
]);
6687

6788
/// (r - 1)/2 =

0 commit comments

Comments
 (0)