@@ -23,7 +23,7 @@ use crate::constants;
2323/// The `Scalar52` struct represents an element in
2424/// \\(\mathbb Z / \ell \mathbb Z\\) as 5 \\(52\\)-bit limbs.
2525#[ derive( Copy , Clone ) ]
26- pub struct Scalar52 ( pub [ u64 ; 5 ] ) ;
26+ pub ( crate ) struct Scalar52 ( pub [ u64 ; 5 ] ) ;
2727
2828impl Debug for Scalar52 {
2929 fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
@@ -59,11 +59,11 @@ fn m(x: u64, y: u64) -> u128 {
5959
6060impl Scalar52 {
6161 /// The scalar \\( 0 \\).
62- pub const ZERO : Scalar52 = Scalar52 ( [ 0 , 0 , 0 , 0 , 0 ] ) ;
62+ pub ( crate ) const ZERO : Scalar52 = Scalar52 ( [ 0 , 0 , 0 , 0 , 0 ] ) ;
6363
6464 /// Unpack a 32 byte / 256 bit scalar into 5 52-bit limbs.
6565 #[ rustfmt:: skip] // keep alignment of s[*] calculations
66- pub fn from_bytes ( bytes : & [ u8 ; 32 ] ) -> Scalar52 {
66+ pub ( crate ) fn from_bytes ( bytes : & [ u8 ; 32 ] ) -> Scalar52 {
6767 let mut words = [ 0u64 ; 4 ] ;
6868 for i in 0 ..4 {
6969 for j in 0 ..8 {
@@ -86,7 +86,7 @@ impl Scalar52 {
8686
8787 /// Reduce a 64 byte / 512 bit scalar mod l
8888 #[ rustfmt:: skip] // keep alignment of lo[*] and hi[*] calculations
89- pub fn from_bytes_wide ( bytes : & [ u8 ; 64 ] ) -> Scalar52 {
89+ pub ( crate ) fn from_bytes_wide ( bytes : & [ u8 ; 64 ] ) -> Scalar52 {
9090 let mut words = [ 0u64 ; 8 ] ;
9191 for i in 0 ..8 {
9292 for j in 0 ..8 {
@@ -118,7 +118,7 @@ impl Scalar52 {
118118 /// Pack the limbs of this `Scalar52` into 32 bytes
119119 #[ rustfmt:: skip] // keep alignment of s[*] calculations
120120 #[ allow( clippy:: identity_op) ]
121- pub fn to_bytes ( self ) -> [ u8 ; 32 ] {
121+ pub ( crate ) fn to_bytes ( self ) -> [ u8 ; 32 ] {
122122 let mut s = [ 0u8 ; 32 ] ;
123123
124124 s[ 0 ] = ( self . 0 [ 0 ] >> 0 ) as u8 ;
@@ -158,7 +158,7 @@ impl Scalar52 {
158158 }
159159
160160 /// Compute `a + b` (mod l)
161- pub fn add ( a : & Scalar52 , b : & Scalar52 ) -> Scalar52 {
161+ pub ( crate ) fn add ( a : & Scalar52 , b : & Scalar52 ) -> Scalar52 {
162162 let mut sum = Scalar52 :: ZERO ;
163163 let mask = ( 1u64 << 52 ) - 1 ;
164164
@@ -174,7 +174,7 @@ impl Scalar52 {
174174 }
175175
176176 /// Compute `a - b` (mod l)
177- pub fn sub ( a : & Scalar52 , b : & Scalar52 ) -> Scalar52 {
177+ pub ( crate ) fn sub ( a : & Scalar52 , b : & Scalar52 ) -> Scalar52 {
178178 let mut difference = Scalar52 :: ZERO ;
179179 let mask = ( 1u64 << 52 ) - 1 ;
180180
@@ -299,41 +299,41 @@ impl Scalar52 {
299299
300300 /// Compute `a * b` (mod l)
301301 #[ inline( never) ]
302- pub fn mul ( a : & Scalar52 , b : & Scalar52 ) -> Scalar52 {
302+ pub ( crate ) fn mul ( a : & Scalar52 , b : & Scalar52 ) -> Scalar52 {
303303 let ab = Scalar52 :: montgomery_reduce ( & Scalar52 :: mul_internal ( a, b) ) ;
304304 Scalar52 :: montgomery_reduce ( & Scalar52 :: mul_internal ( & ab, & constants:: RR ) )
305305 }
306306
307307 /// Compute `a^2` (mod l)
308308 #[ inline( never) ]
309309 #[ allow( dead_code) ] // XXX we don't expose square() via the Scalar API
310- pub fn square ( & self ) -> Scalar52 {
310+ pub ( crate ) fn square ( & self ) -> Scalar52 {
311311 let aa = Scalar52 :: montgomery_reduce ( & Scalar52 :: square_internal ( self ) ) ;
312312 Scalar52 :: montgomery_reduce ( & Scalar52 :: mul_internal ( & aa, & constants:: RR ) )
313313 }
314314
315315 /// Compute `(a * b) / R` (mod l), where R is the Montgomery modulus 2^260
316316 #[ inline( never) ]
317- pub fn montgomery_mul ( a : & Scalar52 , b : & Scalar52 ) -> Scalar52 {
317+ pub ( crate ) fn montgomery_mul ( a : & Scalar52 , b : & Scalar52 ) -> Scalar52 {
318318 Scalar52 :: montgomery_reduce ( & Scalar52 :: mul_internal ( a, b) )
319319 }
320320
321321 /// Compute `(a^2) / R` (mod l) in Montgomery form, where R is the Montgomery modulus 2^260
322322 #[ inline( never) ]
323- pub fn montgomery_square ( & self ) -> Scalar52 {
323+ pub ( crate ) fn montgomery_square ( & self ) -> Scalar52 {
324324 Scalar52 :: montgomery_reduce ( & Scalar52 :: square_internal ( self ) )
325325 }
326326
327327 /// Puts a Scalar52 in to Montgomery form, i.e. computes `a*R (mod l)`
328328 #[ inline( never) ]
329- pub fn as_montgomery ( & self ) -> Scalar52 {
329+ pub ( crate ) fn as_montgomery ( & self ) -> Scalar52 {
330330 Scalar52 :: montgomery_mul ( self , & constants:: RR )
331331 }
332332
333333 /// Takes a Scalar52 out of Montgomery form, i.e. computes `a/R (mod l)`
334334 #[ allow( clippy:: wrong_self_convention) ]
335335 #[ inline( never) ]
336- pub fn from_montgomery ( & self ) -> Scalar52 {
336+ pub ( crate ) fn from_montgomery ( & self ) -> Scalar52 {
337337 let mut limbs = [ 0u128 ; 9 ] ;
338338 for i in 0 ..5 {
339339 limbs[ i] = self [ i] as u128 ;
@@ -352,7 +352,7 @@ mod test {
352352 /// x = 14474011154664524427946373126085988481658748083205070504932198000989141204991
353353 /// x = 7237005577332262213973186563042994240801631723825162898930247062703686954002 mod l
354354 /// x = 3057150787695215392275360544382990118917283750546154083604586903220563173085*R mod l in Montgomery form
355- pub static X : Scalar52 = Scalar52 ( [
355+ pub ( super ) static X : Scalar52 = Scalar52 ( [
356356 0x000fffffffffffff ,
357357 0x000fffffffffffff ,
358358 0x000fffffffffffff ,
@@ -361,7 +361,7 @@ mod test {
361361 ] ) ;
362362
363363 /// x^2 = 3078544782642840487852506753550082162405942681916160040940637093560259278169 mod l
364- pub static XX : Scalar52 = Scalar52 ( [
364+ pub ( super ) static XX : Scalar52 = Scalar52 ( [
365365 0x0001668020217559 ,
366366 0x000531640ffd0ec0 ,
367367 0x00085fd6f9f38a31 ,
@@ -370,7 +370,7 @@ mod test {
370370 ] ) ;
371371
372372 /// x^2 = 4413052134910308800482070043710297189082115023966588301924965890668401540959*R mod l in Montgomery form
373- pub static XX_MONT : Scalar52 = Scalar52 ( [
373+ pub ( super ) static XX_MONT : Scalar52 = Scalar52 ( [
374374 0x000c754eea569a5c ,
375375 0x00063b6ed36cb215 ,
376376 0x0008ffa36bf25886 ,
@@ -379,7 +379,7 @@ mod test {
379379 ] ) ;
380380
381381 /// y = 6145104759870991071742105800796537629880401874866217824609283457819451087098
382- pub static Y : Scalar52 = Scalar52 ( [
382+ pub ( super ) static Y : Scalar52 = Scalar52 ( [
383383 0x000b75071e1458fa ,
384384 0x000bf9d75e1ecdac ,
385385 0x000433d2baf0672b ,
@@ -388,7 +388,7 @@ mod test {
388388 ] ) ;
389389
390390 /// x*y = 36752150652102274958925982391442301741 mod l
391- pub static XY : Scalar52 = Scalar52 ( [
391+ pub ( super ) static XY : Scalar52 = Scalar52 ( [
392392 0x000ee6d76ba7632d ,
393393 0x000ed50d71d84e02 ,
394394 0x00000000001ba634 ,
@@ -397,7 +397,7 @@ mod test {
397397 ] ) ;
398398
399399 /// x*y = 658448296334113745583381664921721413881518248721417041768778176391714104386*R mod l in Montgomery form
400- pub static XY_MONT : Scalar52 = Scalar52 ( [
400+ pub ( super ) static XY_MONT : Scalar52 = Scalar52 ( [
401401 0x0006d52bf200cfd5 ,
402402 0x00033fb1d7021570 ,
403403 0x000f201bc07139d8 ,
@@ -406,7 +406,7 @@ mod test {
406406 ] ) ;
407407
408408 /// a = 2351415481556538453565687241199399922945659411799870114962672658845158063753
409- pub static A : Scalar52 = Scalar52 ( [
409+ pub ( super ) static A : Scalar52 = Scalar52 ( [
410410 0x0005236c07b3be89 ,
411411 0x0001bc3d2a67c0c4 ,
412412 0x000a4aa782aae3ee ,
@@ -415,7 +415,7 @@ mod test {
415415 ] ) ;
416416
417417 /// b = 4885590095775723760407499321843594317911456947580037491039278279440296187236
418- pub static B : Scalar52 = Scalar52 ( [
418+ pub ( super ) static B : Scalar52 = Scalar52 ( [
419419 0x000d3fae55421564 ,
420420 0x000c2df24f65a4bc ,
421421 0x0005b5587d69fb0b ,
@@ -425,7 +425,7 @@ mod test {
425425
426426 /// a+b = 0
427427 /// a-b = 4702830963113076907131374482398799845891318823599740229925345317690316127506
428- pub static AB : Scalar52 = Scalar52 ( [
428+ pub ( super ) static AB : Scalar52 = Scalar52 ( [
429429 0x000a46d80f677d12 ,
430430 0x0003787a54cf8188 ,
431431 0x0004954f0555c7dc ,
@@ -434,7 +434,7 @@ mod test {
434434 ] ) ;
435435
436436 // c = (2^512 - 1) % l = 1627715501170711445284395025044413883736156588369414752970002579683115011840
437- pub static C : Scalar52 = Scalar52 ( [
437+ pub ( super ) static C : Scalar52 = Scalar52 ( [
438438 0x000611e3449c0f00 ,
439439 0x000a768859347a40 ,
440440 0x0007f5be65d00e1b ,
0 commit comments