Skip to main content

Fp2

Trait Fp2 

Source
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§

Source

const ZETA: Self

Predefined constant element representing the value 0 + i such that i^2 = -1, a fourth-root of unity.

Source

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§

Source

type BaseField: Fq

The base type Fp of the extension Fp2

Required Methods§

Source

fn set_x0_small(&mut self, x: i32)

Set the “real” component of self to an integer of type i32 in place.

Source

fn set_x1_small(&mut self, x: i32)

Set the “imaginary” component of self to an integer of type i32 in place.

Source

fn from_i32_pair(x0: i32, x1: i32) -> Self

Return the value x0 + i*x1 for a given two integers of type i32.

Source

fn from_u32_pair(x0: u32, x1: u32) -> Self

Return the value x0 + i*x1 for a given two integers of type u32.

Source

fn from_i64_pair(x0: i64, x1: i64) -> Self

Return the value x0 + i*x1 for a given two integers of type i64.

Source

fn from_u64_pair(x0: u64, x1: u64) -> Self

Return the value x0 + i*x1 for a given two integers of type u64.

Source

fn x0(self) -> Self::BaseField

Return the x0 value such that self = x0 + i*x1

Source

fn x1(self) -> Self::BaseField

Return the x1 value such that self = x0 + i*x1

Source

fn xi(self) -> (Self::BaseField, Self::BaseField)

Return the x0 and x1 values such that self = x0 + i*x1

Source

fn set_conjugate(&mut self)

Negate the imaginary part of this value

Source

fn conjugate(self) -> Self

Compute the complex conjugate of the value a + ib, i.e. a - ib.

Source

fn is_square_base_field(self) -> u32

Return 0xFFFFFFFF when this value is a square in GF(p) and 0x00000000 otherwise.

Source

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 type Vec<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).

Source

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".

Implementors§