use super::*;
impl<E: Environment> FromField for Group<E> {
type Field = Field<E>;
fn from_field(field: &Self::Field) -> Result<Self> {
Group::from_x_coordinate(*field)
}
}
#[cfg(test)]
mod tests {
use super::*;
use snarkvm_console_network_environment::Console;
type CurrentEnvironment = Console;
const ITERATIONS: u64 = 10_000;
fn check_from_field() -> Result<()> {
let mut rng = TestRng::default();
for _ in 0..ITERATIONS {
let expected = Group::<CurrentEnvironment>::new(Uniform::rand(&mut rng));
let candidate = Group::<CurrentEnvironment>::from_field(&expected.to_field()?)?;
assert_eq!(expected, candidate);
}
Ok(())
}
#[test]
fn test_from_field() -> Result<()> {
check_from_field()
}
}