Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

Commit

Permalink
Make the field module a bit more public (paritytech#38)
Browse files Browse the repository at this point in the history
Exports the field_const and field_const_raw macros.
Sets the Field struct fields n, magnitude, and normalized to public.
  • Loading branch information
tuxxy authored and trevor-crypto committed May 31, 2022
1 parent 3425d07 commit 5cf80bd
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,22 @@ macro_rules! debug_assert_bits {
}
}

#[macro_export]
macro_rules! field_const_raw {
($d9: expr, $d8: expr, $d7: expr, $d6: expr, $d5: expr, $d4: expr, $d3: expr, $d2: expr,
$d1: expr, $d0: expr) => {
$crate::field::Field {
$crate::curve::Field {
n: [$d0, $d1, $d2, $d3, $d4, $d5, $d6, $d7, $d8, $d9],
magnitude: 1,
normalized: false
}
}
}

#[macro_export]
macro_rules! field_const {
($d7: expr, $d6: expr, $d5: expr, $d4: expr, $d3: expr, $d2: expr, $d1: expr, $d0: expr) => {
$crate::field::Field {
$crate::curve::Field {
n: [
$d0 & 0x3ffffff,
($d0 >> 26) | (($d1 & 0xfffff) << 6),
Expand Down Expand Up @@ -48,9 +50,9 @@ macro_rules! field_storage_const {
#[derive(Debug, Clone)]
/// Field element for secp256k1.
pub struct Field {
pub(crate) n: [u32; 10],
pub(crate) magnitude: u32,
pub(crate) normalized: bool,
pub n: [u32; 10],
pub magnitude: u32,
pub normalized: bool,
}

impl Field {
Expand Down

0 comments on commit 5cf80bd

Please sign in to comment.