Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: unify one/ones #160

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions starky/src/f3g.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ impl FieldExtension for F3G {
dim: 1,
};

const ZEROS: Self = F3G {
cube: [Fr::ZERO, Fr::ZERO, Fr::ZERO],
dim: 3,
};
const ONES: Self = F3G {
cube: [Fr::ONE, Fr::ZERO, Fr::ZERO],
dim: 3,
};
#[inline(always)]
fn dim(&self) -> usize {
self.dim
Expand Down Expand Up @@ -256,18 +264,12 @@ impl ::rand::Rand for F3G {
impl plonky::Field for F3G {
#[inline(always)]
fn zero() -> Self {
F3G {
cube: [Fr::ZERO, Fr::ZERO, Fr::ZERO],
dim: 3,
}
Self::ZEROS
}

#[inline(always)]
fn one() -> Self {
F3G {
cube: [Fr::ONE, Fr::ZERO, Fr::ZERO],
dim: 3,
}
Self::ONES
}

#[inline(always)]
Expand Down Expand Up @@ -730,7 +732,7 @@ pub mod tests {

let b = a.inv();
let c = a.mul(b);
assert_eq!(c, F3G::one());
assert_eq!(c, F3G::ONES);
}

#[test]
Expand Down
20 changes: 11 additions & 9 deletions starky/src/f5g.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::hash::{Hash, Hasher};
use std::slice;

use core::fmt::{Display, Formatter};

/// Prime: 0xFFFFFFFF00000001
/// Irreducible polynomial: x^5-3
#[repr(C)]
Expand Down Expand Up @@ -47,7 +48,14 @@ impl FieldExtension for F5G {
cube: [Fr::ONE, Fr::ZERO, Fr::ZERO, Fr::ZERO, Fr::ZERO],
dim: 1,
};

const ZEROS: Self = F5G {
cube: [Fr::ZERO, Fr::ZERO, Fr::ZERO, Fr::ZERO, Fr::ZERO],
dim: 5,
};
const ONES: Self = F5G {
cube: [Fr::ONE, Fr::ZERO, Fr::ZERO, Fr::ZERO, Fr::ZERO],
dim: 1,
SuccinctPaul marked this conversation as resolved.
Show resolved Hide resolved
};
#[inline(always)]
fn dim(&self) -> usize {
self.dim
Expand Down Expand Up @@ -229,18 +237,12 @@ impl ::rand::Rand for F5G {
impl plonky::Field for F5G {
#[inline(always)]
fn zero() -> Self {
F5G {
cube: [Fr::ZERO, Fr::ZERO, Fr::ZERO, Fr::ZERO, Fr::ZERO],
dim: 1,
}
Self::ZEROS
}

#[inline(always)]
fn one() -> Self {
F5G {
cube: [Fr::ONE, Fr::ZERO, Fr::ZERO, Fr::ZERO, Fr::ZERO],
dim: 1,
}
Self::ONES
}

#[inline(always)]
Expand Down
3 changes: 3 additions & 0 deletions starky/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ pub trait FieldExtension:
const IS_CANONICAL: bool = false;
const ZERO: Self;
const ONE: Self;

const ZEROS: Self;
const ONES: Self;
const NEW_SIZE: u64 = 0;
fn dim(&self) -> usize;
fn from_vec(values: Vec<Fr>) -> Self;
Expand Down
Loading