Skip to content

Commit

Permalink
minor cleanup for public vals
Browse files Browse the repository at this point in the history
  • Loading branch information
essamhassan committed Aug 16, 2023
1 parent e25856a commit 6c4c771
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/lib/public_params.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use num_bigint::BigInt;
use num_traits::Num;

pub struct PublicParams;

// https://datatracker.ietf.org/doc/html/rfc3526#section-3
const P_PRIME: &str = "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff";
const Q_SUBPRIME: &str = "7fffffffffffffffe487ed5110b4611a62633145c06e0e68948127044533e63a0105df531d89cd9128a5043cc71a026ef7ca8cd9e69d218d98158536f92f8a1ba7f09ab6b6a8e122f242dabb312f3f637a262174d31bf6b585ffae5b7a035bf6f71c35fdad44cfd2d74f9208be258ff324943328f6722d9ee1003e5c50b1df82cc6d241b0e2ae9cd348b1fd47e9267afc1b2ae91ee51d6cb0e3179ab1042a95dcf6a9483b84b4b36b3861aa7255e4c0278ba3604650c10be19482f23171b671df1cf3b960c074301cd93c1d17603d147dae2aef837a62964ef15e5fb4aac0b8c1ccaa4be754ab5728ae9130c4c7d02880ab9472d455655347fffffffffffffff";

impl PublicParams {
pub fn g() -> BigInt {
BigInt::from(4)
Expand All @@ -13,10 +16,10 @@ impl PublicParams {
}

pub fn p() -> BigInt {
BigInt::from_str_radix("32317006071311007300338913926423828248817941241140239112842009751400741706634354222619689417363569347117901737909704191754605873209195028853758986185622153212175412514901774520270235796078236248884246189477587641105928646099411723245426622522193230540919037680524235519125679715870117001058055877651038861847280257976054903569732561526167081339361799541336476559160368317896729073178384589680639671900977202194168647225871031411336429319536193471636533209717077448227988588565369208645296636077250268955505928362751121174096972998068410554359584866583291642136218231078990999448652468262416972035911852507045361090559", 10).unwrap()
BigInt::parse_bytes(P_PRIME.as_bytes(), 16).unwrap()
}

pub fn q() -> BigInt {
BigInt::from_str_radix("16158503035655503650169456963211914124408970620570119556421004875700370853317177111309844708681784673558950868954852095877302936604597514426879493092811076606087706257450887260135117898039118124442123094738793820552964323049705861622713311261096615270459518840262117759562839857935058500529027938825519430923640128988027451784866280763083540669680899770668238279580184158948364536589192294840319835950488601097084323612935515705668214659768096735818266604858538724113994294282684604322648318038625134477752964181375560587048486499034205277179792433291645821068109115539495499724326234131208486017955926253522680545279", 10).unwrap()
BigInt::parse_bytes(Q_SUBPRIME.as_bytes(), 16).unwrap()
}
}

0 comments on commit 6c4c771

Please sign in to comment.