Skip to content

Commit 2d8e025

Browse files
authored
primefield: conversions to/from MontyFieldElement (#1421)
The `monty_field_element!` macro writes a newtype for `MontyFieldElement`. This commit changes those macros to write `From` impls for converting those newtypes to/from `MontyFieldelement`.
1 parent 7ae747d commit 2d8e025

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

primefield/src/macros.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,18 @@ macro_rules! monty_field_element {
446446
}
447447
}
448448

449+
impl From<$crate::MontyFieldElement::<$params, { <$params>::LIMBS }>> for $fe {
450+
fn from(fe: $crate::MontyFieldElement::<$params, { <$params>::LIMBS }>) -> $fe {
451+
$fe(fe)
452+
}
453+
}
454+
455+
impl From<$fe> for $crate::MontyFieldElement<$params, { <$params>::LIMBS }> {
456+
fn from(fe: $fe) -> $crate::MontyFieldElement<$params, { <$params>::LIMBS }> {
457+
fe.0
458+
}
459+
}
460+
449461
impl From<$fe> for $uint {
450462
fn from(fe: $fe) -> $uint {
451463
<$uint>::from(&fe)

0 commit comments

Comments
 (0)