Serialization for cryptonums.

This commit is contained in:
2018-03-06 19:22:57 -08:00
parent f89e3e5ca4
commit f3d4b102c0
2 changed files with 52 additions and 2 deletions

View File

@@ -1,5 +1,12 @@
pub trait CryptoNum {
/// Simultaneously compute the quotient and remainder of this number and
/// the given divisor.
fn divmod(&self, a: &Self, q: &mut Self, r: &mut Self);
/// Convert a number to a series of bytes, in standard order (most to
/// least significant)
fn to_bytes(&self) -> Vec<u8>;
/// Convert a series of bytes into the number. The size of the given slice
/// must be greater than or equal to the size of the number, and must be
/// a multiple of 8 bytes long. Unused bytes should be ignored.
fn from_bytes(&[u8]) -> Self;
}