From 8a2a16a0999f7bbc132b10e66847f0f99b3747bf Mon Sep 17 00:00:00 2001 From: Michael Turner Date: Sun, 19 Feb 2023 11:27:21 -0500 Subject: [PATCH] Add Aleo cryptography crate --- Cargo.toml | 2 +- .../aleo-cryptography/Cargo.toml | 7 +++++ .../aleo-cryptography/src/algebra.rs | 29 +++++++++++++++++++ .../aleo-cryptography/src/lib.rs | 1 + 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 applied-crypto-references/aleo-cryptography/Cargo.toml create mode 100644 applied-crypto-references/aleo-cryptography/src/algebra.rs create mode 100644 applied-crypto-references/aleo-cryptography/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index c704176..4f1feb4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,9 @@ [workspace] members = [ + "applied-crypto-references/aleo-cryptography", "applied-crypto-references", "applied-crypto-references/curve-operations", "applied-crypto-references/merlin-transcripts", "applied-crypto-references/zksnarks", - "proving-libraries" ] diff --git a/applied-crypto-references/aleo-cryptography/Cargo.toml b/applied-crypto-references/aleo-cryptography/Cargo.toml new file mode 100644 index 0000000..6b41595 --- /dev/null +++ b/applied-crypto-references/aleo-cryptography/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "aleo-cryptography" +version = "0.1.0" +edition = "2021" + +[dependencies] +snarkvm = { version = "0.9.13", features = [ "utilities", "curves" ] } \ No newline at end of file diff --git a/applied-crypto-references/aleo-cryptography/src/algebra.rs b/applied-crypto-references/aleo-cryptography/src/algebra.rs new file mode 100644 index 0000000..cfdb791 --- /dev/null +++ b/applied-crypto-references/aleo-cryptography/src/algebra.rs @@ -0,0 +1,29 @@ +///! This module explores Aleo's basic algebraic structures and their properties + +//Field and Ring elements +use snarkvm::utilities::{ + BigInteger384, BigInteger +}; + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn additions_overflow() { + let mut a = BigInteger384::new([u64::MAX, u64::MAX, u64::MAX, u64::MAX, u64::MAX, u64::MAX]); + let mut b = BigInteger384::from(7); + a.add_nocarry(&b); + let d = BigInteger384::from(6); + assert_eq!(a, d); + } + + #[test] + fn subs_overflow() { + let mut a = BigInteger384::from(0); + let mut b = BigInteger384::from(1); + a.sub_noborrow(&b); + let d = BigInteger384::new([u64::MAX, u64::MAX, u64::MAX, u64::MAX, u64::MAX, u64::MAX]); + assert_eq!(a, d); + } +} \ No newline at end of file diff --git a/applied-crypto-references/aleo-cryptography/src/lib.rs b/applied-crypto-references/aleo-cryptography/src/lib.rs new file mode 100644 index 0000000..a6ebe65 --- /dev/null +++ b/applied-crypto-references/aleo-cryptography/src/lib.rs @@ -0,0 +1 @@ +mod algebra; \ No newline at end of file