[][src]Trait amcl_wrapper::group_elem::GroupElement

pub trait GroupElement: Clone + Sized {
    fn new() -> Self;
fn identity() -> Self;
fn generator() -> Self;
fn is_identity(&self) -> bool;
fn set_to_identity(&mut self);
fn from_msg_hash(msg: &[u8]) -> Self;
fn to_bytes(&self, compress: bool) -> Vec<u8>;
fn from_bytes(bytes: &[u8]) -> Result<Self, SerzDeserzError>;
fn write_to_slice(
        &self,
        target: &mut [u8],
        compress: bool
    ) -> Result<(), SerzDeserzError>;
fn write_to_slice_unchecked(&self, target: &mut [u8], compress: bool);
fn add_assign_(&mut self, b: &Self);
fn sub_assign_(&mut self, b: &Self);
fn plus(&self, b: &Self) -> Self;
fn minus(&self, b: &Self) -> Self;
fn scalar_mul_const_time(&self, a: &FieldElement) -> Self;
fn double(&self) -> Self;
fn double_mut(&mut self);
fn to_hex(&self) -> String;
fn from_hex(s: String) -> Result<Self, SerzDeserzError>;
fn negation(&self) -> Self;
fn is_extension() -> bool;
fn has_correct_order(&self) -> bool; fn random() -> Self { ... }
fn random_using_rng<R: RngCore + CryptoRng>(rng: &mut R) -> Self { ... } }

Required methods

fn new() -> Self

fn identity() -> Self

Return the identity element

fn generator() -> Self

Return a group generator.

fn is_identity(&self) -> bool

Check if the the point is the identity element of the group

fn set_to_identity(&mut self)

Set the point to the identity element of the group

fn from_msg_hash(msg: &[u8]) -> Self

Hash an arbitrary sized message using SHAKE and return output as group element

fn to_bytes(&self, compress: bool) -> Vec<u8>

Return byte representation as vector. If compress is true, compresses the point before serializing to bytes.

fn from_bytes(bytes: &[u8]) -> Result<Self, SerzDeserzError>

Create an element from a byte representation. Handles both compressed as well as uncompressed

fn write_to_slice(
    &self,
    target: &mut [u8],
    compress: bool
) -> Result<(), SerzDeserzError>

Writes bytes to given slice. If compress is true, compresses the point before serializing to bytes. Raises exception when given slice is not of desired length.

fn write_to_slice_unchecked(&self, target: &mut [u8], compress: bool)

Writes bytes to given slice. If compress is true, compresses the point before serializing to bytes. Will panic when given slice is not of desired length.

fn add_assign_(&mut self, b: &Self)

Add a group element to itself. self = self + b

fn sub_assign_(&mut self, b: &Self)

Subtract a group element from itself. self = self - b

fn plus(&self, b: &Self) -> Self

Return sum of a group element and itself. self + b

fn minus(&self, b: &Self) -> Self

Return difference of a group element and itself. self - b

fn scalar_mul_const_time(&self, a: &FieldElement) -> Self

Multiply point on the curve (element of group G1) with a scalar. Constant time operation. self * field_element_a.

fn double(&self) -> Self

Return the double of the group element

fn double_mut(&mut self)

fn to_hex(&self) -> String

Returns hex string as a sequence of FPs or FP2s enclosed by parenthesis. Each FP is itself a 2-tuple of strings separated by whitespace, 1st string is the excess and 2nd is a BigNum

fn from_hex(s: String) -> Result<Self, SerzDeserzError>

Returns a group element by parsing the hex representation of itself. The hex representation should match the one from to_hex

fn negation(&self) -> Self

Returns negation of this element

fn is_extension() -> bool

fn has_correct_order(&self) -> bool

Checks if the element has correct order by checking if self * group order (curve order) == Identity element (point at infinity). Uses constant time scalar multiplication. Question: But since we always know the multiplicand (group order) is there a faster way?

Loading content...

Provided methods

fn random() -> Self

Return a random group element

fn random_using_rng<R: RngCore + CryptoRng>(rng: &mut R) -> Self

Return a random group element using the given random number generator

Loading content...

Implementors

impl GroupElement for G1[src]

fn generator() -> Self[src]

This is an arbitrary choice. Any group element can be a generator

fn to_hex(&self) -> String[src]

Returns the string infinity if the element corresponds to a point at infinity Returns (x) or (x,y) depending on the curve being a Montgomery curve or not. x and y are hex representations of FP

impl GroupElement for G2[src]

fn generator() -> Self[src]

This is an arbitrary choice. Any group element can be a generator

fn to_hex(&self) -> String[src]

Returns the string infinity if the element corresponds to a point at infinity Returns (x,y) where both x and y are hex representations of FP2

Loading content...