-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
major cleanup; doc example now works
- Loading branch information
Showing
18 changed files
with
159 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
mod extensions; | ||
pub(crate) mod fp; | ||
pub(crate) mod fp12; | ||
pub(crate) mod fp2; | ||
pub(crate) mod fp6; | ||
pub(crate) mod utils; | ||
pub mod fp; | ||
pub mod fp12; | ||
pub mod fp2; | ||
pub mod fp6; | ||
pub mod utils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
use crypto_bigint::{Encoding, U1024, U2048, U256, U4096, U512}; | ||
use crypto_bigint::{Encoding, U256, U512}; | ||
|
||
pub(crate) fn to_larger_uint<const N: usize, const M: usize>(smaller_bytes: &[u8; N]) -> [u8; M] { | ||
pub fn to_larger_uint<const N: usize, const M: usize>(smaller_bytes: &[u8; N]) -> [u8; M] { | ||
assert!(M > N, "Target size must be larger than source size"); | ||
let mut larger_bytes = [0u8; M]; | ||
larger_bytes[M - N..].copy_from_slice(smaller_bytes); | ||
larger_bytes | ||
} | ||
|
||
// Specific conversion functions | ||
pub(crate) fn u256_to_u512(u256: &U256) -> U512 { | ||
pub fn u256_to_u512(u256: &U256) -> U512 { | ||
U512::from_be_bytes(to_larger_uint::<32, 64>(&u256.to_be_bytes())) | ||
} | ||
|
||
pub(crate) fn u256_to_u1024(u256: &U256) -> U1024 { | ||
U1024::from_be_bytes(to_larger_uint::<32, 128>(&u256.to_be_bytes())) | ||
} | ||
|
||
pub(crate) fn u256_to_u2048(u256: &U256) -> U2048 { | ||
U2048::from_be_bytes(to_larger_uint::<32, 256>(&u256.to_be_bytes())) | ||
} | ||
|
||
pub(crate) fn u256_to_u4096(u256: &U256) -> U4096 { | ||
U4096::from_be_bytes(to_larger_uint::<32, 512>(&u256.to_be_bytes())) | ||
} | ||
// | ||
// pub fn u256_to_u1024(u256: &U256) -> U1024 { | ||
// U1024::from_be_bytes(to_larger_uint::<32, 128>(&u256.to_be_bytes())) | ||
// } | ||
// | ||
// pub fn u256_to_u2048(u256: &U256) -> U2048 { | ||
// U2048::from_be_bytes(to_larger_uint::<32, 256>(&u256.to_be_bytes())) | ||
// } | ||
// | ||
// pub fn u256_to_u4096(u256: &U256) -> U4096 { | ||
// U4096::from_be_bytes(to_larger_uint::<32, 512>(&u256.to_be_bytes())) | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.