1
- use ark_ff:: { biginteger:: BigInteger256 as BigInteger , FftParameters , Fp256Parameters , NewFp256 } ;
1
+ use ark_ff:: { biginteger:: BigInteger256 as BigInteger , FftParameters , Fp256Parameters , Fp256 } ;
2
2
3
- pub type Fp = NewFp256 < FpParameters > ;
3
+ pub type Fp = Fp256 < FpParameters > ;
4
4
5
5
#[ derive( Debug , Clone , Copy , Default , Eq , PartialEq , PartialOrd , Ord , Hash ) ]
6
6
pub struct FpParameters ;
@@ -19,49 +19,93 @@ impl FftParameters for FpParameters {
19
19
} ;
20
20
}
21
21
22
- #[ rustfmt:: skip]
23
- impl ark_ff:: FpParameters for FpParameters {
24
- // 28948022309329048855892746252171976963363056481941560715954676764349967630337
25
- const MODULUS : BigInteger = BigInteger ( [
26
- 0x1 , 0x9698768 , 0x133e46e6 , 0xd31f812 , 0x224 , 0x0 , 0x0 , 0x0 , 0x400000 ,
27
- ] ) ;
28
-
29
- const R : BigInteger = BigInteger ( [
30
- 0x1fffff81 , 0x14a5d367 , 0x141ad3c0 , 0x1435eec5 , 0x1ffeefef , 0x1fffffff , 0x1fffffff ,
31
- 0x1fffffff , 0x3fffff ,
32
- ] ) ;
33
-
34
- const R2 : BigInteger = BigInteger ( [
35
- 0x3b6a , 0x19c10910 , 0x1a6a0188 , 0x12a4fd88 , 0x634b36d , 0x178792ba , 0x7797a99 , 0x1dce5b8a ,
36
- 0x3506bd ,
37
- ] ) ;
38
-
39
- // TODO
40
- const MODULUS_MINUS_ONE_DIV_TWO : BigInteger = BigInteger ( [
41
- 0x0 , 0x4b4c3b4 , 0x99f2373 , 0x698fc09 , 0x112 , 0x0 , 0x0 , 0x0 , 0x200000 ,
42
- ] ) ;
43
-
44
- // T and T_MINUS_ONE_DIV_TWO, where MODULUS - 1 = 2^S * T
45
- const T : BigInteger = BigInteger ( [
46
- 0x192d30ed , 0xa67c8dc , 0x11a63f02 , 0x44 , 0x0 , 0x0 , 0x0 , 0x80000 , 0x0 ,
47
- ] ) ;
48
-
49
- const T_MINUS_ONE_DIV_TWO : BigInteger = BigInteger ( [
50
- 0xc969876 , 0x533e46e , 0x8d31f81 , 0x22 , 0x0 , 0x0 , 0x0 , 0x40000 , 0x0 ,
51
- ] ) ;
52
-
53
- // GENERATOR = 5
54
- const GENERATOR : BigInteger = {
55
- const FIVE : Fp = ark_ff:: field_new!( Fp , "5" ) ;
56
- FIVE . 0
57
- } ;
58
-
59
- const MODULUS_BITS : u32 = 255 ;
60
-
61
- const CAPACITY : u32 = Self :: MODULUS_BITS - 1 ;
62
-
63
- const REPR_SHAVE_BITS : u32 = 1 ;
22
+ #[ cfg( not( any( target_family = "wasm" , feature = "32x9" ) ) ) ]
23
+ pub mod native {
24
+ use super :: * ;
25
+
26
+ impl ark_ff:: FpParameters for FpParameters {
27
+ // 28948022309329048855892746252171976963363056481941560715954676764349967630337
28
+ const MODULUS : BigInteger = BigInteger :: new ( [
29
+ 0x992d30ed00000001 ,
30
+ 0x224698fc094cf91b ,
31
+ 0x0 ,
32
+ 0x4000000000000000 ,
33
+ ] ) ;
34
+ const R : BigInteger = BigInteger :: new ( [
35
+ 0x34786d38fffffffd ,
36
+ 0x992c350be41914ad ,
37
+ 0xffffffffffffffff ,
38
+ 0x3fffffffffffffff ,
39
+ ] ) ;
40
+ const R2 : BigInteger = BigInteger :: new ( [
41
+ 0x8c78ecb30000000f ,
42
+ 0xd7d30dbd8b0de0e7 ,
43
+ 0x7797a99bc3c95d18 ,
44
+ 0x96d41af7b9cb714 ,
45
+ ] ) ;
46
+ const MODULUS_MINUS_ONE_DIV_TWO : BigInteger = BigInteger :: new ( [
47
+ 0xcc96987680000000 ,
48
+ 0x11234c7e04a67c8d ,
49
+ 0x0 ,
50
+ 0x2000000000000000 ,
51
+ ] ) ;
52
+ // T and T_MINUS_ONE_DIV_TWO, where MODULUS - 1 = 2^S * T
53
+ const T : BigInteger = BigInteger :: new ( [ 0x94cf91b992d30ed , 0x224698fc , 0x0 , 0x40000000 ] ) ;
54
+ const T_MINUS_ONE_DIV_TWO : BigInteger =
55
+ BigInteger :: new ( [ 0x4a67c8dcc969876 , 0x11234c7e , 0x0 , 0x20000000 ] ) ;
56
+ // GENERATOR = 5
57
+ const GENERATOR : BigInteger = BigInteger :: new ( [
58
+ 0xa1a55e68ffffffed ,
59
+ 0x74c2a54b4f4982f3 ,
60
+ 0xfffffffffffffffd ,
61
+ 0x3fffffffffffffff ,
62
+ ] ) ;
63
+ const MODULUS_BITS : u32 = 255 ;
64
+ const CAPACITY : u32 = Self :: MODULUS_BITS - 1 ;
65
+ const REPR_SHAVE_BITS : u32 = 1 ;
66
+ // -(MODULUS^{-1} mod 2^64) mod 2^64
67
+ const INV : u64 = 11037532056220336127 ;
68
+ }
69
+ }
64
70
65
- // -(MODULUS^{-1} mod 2^64) mod 2^64
66
- const INV : u64 = 0x1fffffff ;
71
+ #[ cfg( any( target_family = "wasm" , feature = "32x9" ) ) ]
72
+ pub mod x32x9 {
73
+ use super :: * ;
74
+
75
+ #[ rustfmt:: skip]
76
+ impl ark_ff:: FpParameters for FpParameters {
77
+ // 28948022309329048855892746252171976963363056481941560715954676764349967630337
78
+ const MODULUS : BigInteger = BigInteger :: new ( [
79
+ 0x1 , 0x9698768 , 0x133e46e6 , 0xd31f812 , 0x224 , 0x0 , 0x0 , 0x0 , 0x400000 ,
80
+ ] ) ;
81
+ const R : BigInteger = BigInteger :: new ( [
82
+ 0x1fffff81 , 0x14a5d367 , 0x141ad3c0 , 0x1435eec5 , 0x1ffeefef , 0x1fffffff , 0x1fffffff ,
83
+ 0x1fffffff , 0x3fffff ,
84
+ ] ) ;
85
+ const R2 : BigInteger = BigInteger :: new ( [
86
+ 0x3b6a , 0x19c10910 , 0x1a6a0188 , 0x12a4fd88 , 0x634b36d , 0x178792ba , 0x7797a99 , 0x1dce5b8a ,
87
+ 0x3506bd ,
88
+ ] ) ;
89
+ // TODO
90
+ const MODULUS_MINUS_ONE_DIV_TWO : BigInteger = BigInteger :: new ( [
91
+ 0x0 , 0x4b4c3b4 , 0x99f2373 , 0x698fc09 , 0x112 , 0x0 , 0x0 , 0x0 , 0x200000 ,
92
+ ] ) ;
93
+ // T and T_MINUS_ONE_DIV_TWO, where MODULUS - 1 = 2^S * T
94
+ const T : BigInteger = BigInteger :: new ( [
95
+ 0x192d30ed , 0xa67c8dc , 0x11a63f02 , 0x44 , 0x0 , 0x0 , 0x0 , 0x80000 , 0x0 ,
96
+ ] ) ;
97
+ const T_MINUS_ONE_DIV_TWO : BigInteger = BigInteger :: new ( [
98
+ 0xc969876 , 0x533e46e , 0x8d31f81 , 0x22 , 0x0 , 0x0 , 0x0 , 0x40000 , 0x0 ,
99
+ ] ) ;
100
+ // GENERATOR = 5
101
+ const GENERATOR : BigInteger = {
102
+ const FIVE : Fp = ark_ff:: field_new!( Fp , "5" ) ;
103
+ FIVE . 0
104
+ } ;
105
+ const MODULUS_BITS : u32 = 255 ;
106
+ const CAPACITY : u32 = Self :: MODULUS_BITS - 1 ;
107
+ const REPR_SHAVE_BITS : u32 = 1 ;
108
+ // -(MODULUS^{-1} mod 2^64) mod 2^64
109
+ const INV : u64 = 0x1fffffff ;
110
+ }
67
111
}
0 commit comments