diff --git a/Cargo.toml b/Cargo.toml index 9ca5024..fe4006f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["plonk", "kzg", "fri"] +members = ["plonk", "kzg", "fri", "frost"] resolver = "2" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html \ No newline at end of file diff --git a/frost/Cargo.toml b/frost/Cargo.toml new file mode 100644 index 0000000..fb45bfd --- /dev/null +++ b/frost/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "frost" +version = "0.1.0" +edition = "2021" + +[dependencies] +rand_core = "0.9.0-alpha.2" \ No newline at end of file diff --git a/frost/src/core/error.rs b/frost/src/core/error.rs new file mode 100644 index 0000000..f226efd --- /dev/null +++ b/frost/src/core/error.rs @@ -0,0 +1,3 @@ +pub enum FieldError { + +} \ No newline at end of file diff --git a/frost/src/core/mod.rs b/frost/src/core/mod.rs new file mode 100644 index 0000000..2a4ecaf --- /dev/null +++ b/frost/src/core/mod.rs @@ -0,0 +1,2 @@ +mod r#trait; +mod error; \ No newline at end of file diff --git a/frost/src/core/trait.rs b/frost/src/core/trait.rs new file mode 100644 index 0000000..4703683 --- /dev/null +++ b/frost/src/core/trait.rs @@ -0,0 +1,59 @@ +use core::{ + ops::{Add, Mul, Sub} +}; +use std::fmt::Debug; +use rand_core::{CryptoRng, RngCore}; + +use crate::core::error::FieldError; + +/// A prime order finite field +pub trait Field: Copy + Clone { + type Scalar: Add + + Mul + + Sub + + Eq + PartialEq + Copy + Clone; + + /// The additive identity + fn zero() -> Self::Scalar; + + /// The multiplicative identity + fn one() -> Self::Scalar; + + /// The inversion + fn invert(number: Self::Scalar) -> Result; + + /// Random function + fn random(rng: &mut R) -> Self::Scalar; +} + +/// A prime-order group +pub trait Group: Copy + Clone + PartialEq { + type Field: Field; + + // Element in group + type Element: Add + + Mul<::Scalar, Output = Self::Element> + + Sub + + Eq + PartialEq + Clone + Copy; + + /// The cofactor is the order of the entire group (number of points on the curve) + /// divided by the order of the subgroup generated by your basepoint. + /// + /// If using a prime order elliptic curve, the cofactor should be 1 in the scalar field. + fn cofactor() -> ::Scalar; + + /// Additive identity of the prime order group + fn identity() -> Self::Element; + + /// The generator of the prime order group + fn generator() -> Self::Element; + +} + +pub trait Frost: Copy + Clone + PartialEq + Debug + 'static { + type Group: Group; + type HashFunction; + + fn hash_function_1(m: &[u8]) -> <::Field as Field>::Scalar; + fn hash_function_2(m: &[u8]) -> ::Element; +} \ No newline at end of file diff --git a/frost/src/lib.rs b/frost/src/lib.rs new file mode 100644 index 0000000..6924867 --- /dev/null +++ b/frost/src/lib.rs @@ -0,0 +1,2 @@ +mod core; +