G1Projective

Type Alias G1Projective 

Source
pub type G1Projective = GroupProjective<1, 1, Fp>;
Expand description

Projective representation of a point in the 𝔾₁ group

Aliased Type§

pub struct G1Projective { /* private fields */ }

Implementations§

Source§

impl G1Projective

Source

pub fn new(v: [Fp; 3]) -> Result<Self, GroupError>

Instantiates a new element in projective coordinates in 𝔾₁.

The input values must pass the curve equation checks in projective form: Y²Z = X³ + 3Z³

§Arguments
  • v - An array of three field elements representing the X, Y, and Z coordinates of the point
§Returns
  • Result<Self, GroupError> - A new point if the coordinates satisfy the curve equation, or an error if they don’t
§Examples
use sylow::*;
let generator = G1Projective::new([Fp::ONE, Fp::TWO, Fp::ONE]);

Trait Implementations§

Source§

impl<'a> From<&'a [Fp; 2]> for G1Projective

Source§

fn from(value: &'a [Fp; 2]) -> Self

Converts an array of two field elements (representing affine coordinates) to a projective point.

§Arguments
  • value - A reference to an array of two field elements [x, y]
§Returns
  • G1Projective - The corresponding point in projective coordinates
§Panics

If the affine coordinates do not represent a valid point on the curve.

Source§

impl From<[Fp; 2]> for G1Projective

Source§

fn from(value: [Fp; 2]) -> Self

Converts an array of two field elements (representing affine coordinates) to a projective point.

This is a convenience wrapper around the implementation of From<&[Fp; 2]>.

§Arguments
  • value - An array of two field elements [x, y]
§Returns
  • G1Projective - The corresponding point in projective coordinates
§Panics

If the affine coordinates do not represent a valid point on the curve.

Source§

impl GroupTrait<1, 1, Fp> for G1Projective

Source§

fn generator() -> Self

Returns the generator point for 𝔾₁ in projective coordinates

Source§

fn endomorphism(&self) -> Self

Note: The endomorphism is not used for 𝔾₁, so this just returns the generator

Source§

fn rand<R: CryptoRngCore>(rng: &mut R) -> Self

Generates a random point in the 𝔾₁ group

Source§

fn hash_to_curve<E: Expander>(exp: &E, msg: &[u8]) -> Result<Self, GroupError>

Hashes a message to a point on the 𝔾₁ group

This process involves two steps:

  1. Hash the message to two field elements using the expand_message function
  2. Map these field elements to curve points and combine them

See hasher.rs and svdw.rs for more details on the underlying algorithms.

Source§

fn sign_message<E: Expander>( exp: &E, msg: &[u8], private_key: Fp, ) -> Result<Self, GroupError>

Signs a message using a private key in the base field [Fp], returning a point on the 𝔾₁ group

§Examples
use sylow::*;
use crypto_bigint::rand_core::OsRng;
use sha3::Keccak256;

const DST: &[u8; 30] = b"WARLOCK-CHAOS-V01-CS01-SHA-256";
const MSG: &[u8; 4] = &20_i32.to_be_bytes();
const K: u64 = 128;

let expander = XMDExpander::<Keccak256>::new(DST, K);
let rando = <Fp as FieldExtensionTrait<1, 1>>::rand(&mut OsRng);

if let Ok(d) = G1Projective::sign_message(&expander, MSG, rando) {
    println!("DST: {:?}", String::from_utf8_lossy(DST));
    println!("Message: {:?}", String::from_utf8_lossy(MSG));
    println!("private key: {:?}", rando.value());
}