pub trait Fp2:
Fq
+ FqExp
+ FqRoots
+ FqRnd {
type BaseField: Fq;
const ZETA: Self;
const MINUS_ZETA: Self;
Show 14 methods
// Required methods
fn set_x0_small(&mut self, x: i32);
fn set_x1_small(&mut self, x: i32);
fn from_i32_pair(x0: i32, x1: i32) -> Self;
fn from_u32_pair(x0: u32, x1: u32) -> Self;
fn from_i64_pair(x0: i64, x1: i64) -> Self;
fn from_u64_pair(x0: u64, x1: u64) -> Self;
fn x0(self) -> Self::BaseField;
fn x1(self) -> Self::BaseField;
fn xi(self) -> (Self::BaseField, Self::BaseField);
fn set_conjugate(&mut self);
fn conjugate(self) -> Self;
fn is_square_base_field(self) -> u32;
fn precompute_dlp_tables(self, n: usize) -> (Vec<usize>, Vec<Self>, u32);
fn solve_dlp_2e(
self,
x: &Self,
e: usize,
precomputed_tables: Option<(&Vec<usize>, &Vec<Self>)>,
) -> (Vec<u8>, u32);
}Expand description
Trait for Finite field arithmetic for the extension field GF(p^2) with modulus x^2 + 1. Extends the Fq trait with additional methods specialised for the degree two extension. As all Fp2 types are expected to be created using this crate’s macro, there’s no smaller extension traits.
Required Associated Constants§
Sourceconst ZETA: Self
const ZETA: Self
Predefined constant element representing the value 0 + i such that i^2 = -1, a fourth-root of unity.
Sourceconst MINUS_ZETA: Self
const MINUS_ZETA: Self
Predefined constant element representing the value 0 - i such that i^2 = -1, a fourth-root of unity.
Required Associated Types§
Required Methods§
Sourcefn set_x0_small(&mut self, x: i32)
fn set_x0_small(&mut self, x: i32)
Set the “real” component of self to an integer of type i32 in place.
Sourcefn set_x1_small(&mut self, x: i32)
fn set_x1_small(&mut self, x: i32)
Set the “imaginary” component of self to an integer of type i32 in place.
Sourcefn from_i32_pair(x0: i32, x1: i32) -> Self
fn from_i32_pair(x0: i32, x1: i32) -> Self
Return the value x0 + i*x1 for a given two integers of type i32.
Sourcefn from_u32_pair(x0: u32, x1: u32) -> Self
fn from_u32_pair(x0: u32, x1: u32) -> Self
Return the value x0 + i*x1 for a given two integers of type u32.
Sourcefn from_i64_pair(x0: i64, x1: i64) -> Self
fn from_i64_pair(x0: i64, x1: i64) -> Self
Return the value x0 + i*x1 for a given two integers of type i64.
Sourcefn from_u64_pair(x0: u64, x1: u64) -> Self
fn from_u64_pair(x0: u64, x1: u64) -> Self
Return the value x0 + i*x1 for a given two integers of type u64.
Sourcefn xi(self) -> (Self::BaseField, Self::BaseField)
fn xi(self) -> (Self::BaseField, Self::BaseField)
Return the x0 and x1 values such that self = x0 + i*x1
Sourcefn set_conjugate(&mut self)
fn set_conjugate(&mut self)
Negate the imaginary part of this value
Sourcefn is_square_base_field(self) -> u32
fn is_square_base_field(self) -> u32
Return 0xFFFFFFFF when this value is a square in GF(p) and
0x00000000 otherwise.
Sourcefn precompute_dlp_tables(self, n: usize) -> (Vec<usize>, Vec<Self>, u32)
fn precompute_dlp_tables(self, n: usize) -> (Vec<usize>, Vec<Self>, u32)
Precompute two vectors of values used to optimally solve the dlog for elements of order 2^n exactly.
Explicitly, this involves computing:
- A table dlog_table of indicies corresponding to where to split
the dlog recursively of type Vec
- A table of Fp2 elements
gpp[j] = g^(2^dlog_table[j])of type of typeVec<Self>
Note that the first value (gpp[0]) is g itself, and the last one must
be -1 (otherwise, g does not have order exactly 2^e).
Sourcefn solve_dlp_2e(
self,
x: &Self,
e: usize,
precomputed_tables: Option<(&Vec<usize>, &Vec<Self>)>,
) -> (Vec<u8>, u32)
fn solve_dlp_2e( self, x: &Self, e: usize, precomputed_tables: Option<(&Vec<usize>, &Vec<Self>)>, ) -> (Vec<u8>, u32)
Find integer v (modulo 2^e) such that x = self^v. If self
has order exactly 2^e, and there is a solution v, then this
function returns (v, 0xFFFFFFFF). If self does not have order
exactly 2^e (including if self^(2^(e-1)) = 1, i.e. the order of
self is a strict divisor or 2^e), or if there is no solution,
then this function returns ([0], 0).
Optionally include precomputed values from the method precompute_dlp_tables otherwise these are computed at runtime.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".