mirror of https://github.com/zcash/halo2.git
Merge pull request #113 from zcash/constants-concrete-type
`constants::load.rs`: Use concrete `pallas::Affine` type for generators
This commit is contained in:
commit
4a52d771b1
|
@ -2,9 +2,10 @@
|
||||||
use arrayvec::ArrayVec;
|
use arrayvec::ArrayVec;
|
||||||
use ff::{Field, PrimeField};
|
use ff::{Field, PrimeField};
|
||||||
use group::Curve;
|
use group::Curve;
|
||||||
use halo2::{
|
use halo2::arithmetic::lagrange_interpolate;
|
||||||
arithmetic::{lagrange_interpolate, CurveAffine, FieldExt},
|
use pasta_curves::{
|
||||||
pasta::pallas,
|
arithmetic::{CurveAffine, FieldExt},
|
||||||
|
pallas,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod commit_ivk_r;
|
pub mod commit_ivk_r;
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
use halo2::arithmetic::{CurveAffine, FieldExt};
|
use pasta_curves::{
|
||||||
|
arithmetic::{CurveAffine, FieldExt},
|
||||||
|
pallas,
|
||||||
|
};
|
||||||
|
|
||||||
/// Generator used in SinsemillaCommit randomness for IVK commitment
|
/// Generator used in SinsemillaCommit randomness for IVK commitment
|
||||||
pub const GENERATOR: ([u8; 32], [u8; 32]) = (
|
pub const GENERATOR: ([u8; 32], [u8; 32]) = (
|
||||||
|
@ -2917,10 +2920,10 @@ pub const U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
pub fn generator<C: CurveAffine>() -> C {
|
pub fn generator() -> pallas::Affine {
|
||||||
C::from_xy(
|
pallas::Affine::from_xy(
|
||||||
C::Base::from_bytes(&GENERATOR.0).unwrap(),
|
pallas::Base::from_bytes(&GENERATOR.0).unwrap(),
|
||||||
C::Base::from_bytes(&GENERATOR.1).unwrap(),
|
pallas::Base::from_bytes(&GENERATOR.1).unwrap(),
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
@ -2933,9 +2936,9 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::primitives::sinsemilla::CommitDomain;
|
use crate::primitives::sinsemilla::CommitDomain;
|
||||||
use group::Curve;
|
use group::Curve;
|
||||||
use halo2::{
|
use pasta_curves::{
|
||||||
arithmetic::{CurveAffine, FieldExt},
|
arithmetic::{CurveAffine, FieldExt},
|
||||||
pasta::pallas,
|
pallas,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -2950,13 +2953,13 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lagrange_coeffs() {
|
fn lagrange_coeffs() {
|
||||||
let base = super::generator::<pallas::Affine>();
|
let base = super::generator();
|
||||||
test_lagrange_coeffs(base, NUM_WINDOWS);
|
test_lagrange_coeffs(base, NUM_WINDOWS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn z() {
|
fn z() {
|
||||||
let base = super::generator::<pallas::Affine>();
|
let base = super::generator();
|
||||||
test_zs_and_us(base, &Z, &U, NUM_WINDOWS);
|
test_zs_and_us(base, &Z, &U, NUM_WINDOWS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,51 +1,50 @@
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
use crate::constants::{self, compute_lagrange_coeffs, H, NUM_WINDOWS, NUM_WINDOWS_SHORT};
|
use crate::constants::{self, compute_lagrange_coeffs, H, NUM_WINDOWS, NUM_WINDOWS_SHORT};
|
||||||
use halo2::arithmetic::{CurveAffine, FieldExt};
|
use pasta_curves::{arithmetic::FieldExt, pallas};
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||||
pub enum OrchardFixedBasesFull<C: CurveAffine> {
|
pub enum OrchardFixedBasesFull {
|
||||||
CommitIvkR(PhantomData<C>),
|
CommitIvkR,
|
||||||
NoteCommitR(PhantomData<C>),
|
NoteCommitR,
|
||||||
NullifierK(PhantomData<C>),
|
NullifierK,
|
||||||
ValueCommitR(PhantomData<C>),
|
ValueCommitR,
|
||||||
SpendAuthG(PhantomData<C>),
|
SpendAuthG,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A fixed base to be used in scalar multiplication with a full-width scalar.
|
/// A fixed base to be used in scalar multiplication with a full-width scalar.
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct OrchardFixedBase<C: CurveAffine> {
|
pub struct OrchardFixedBase {
|
||||||
pub generator: C,
|
pub generator: pallas::Affine,
|
||||||
pub lagrange_coeffs: LagrangeCoeffs<C::Base>,
|
pub lagrange_coeffs: LagrangeCoeffs,
|
||||||
pub z: Z<C::Base>,
|
pub z: Z,
|
||||||
pub u: U<C::Base>,
|
pub u: U,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CurveAffine> From<OrchardFixedBasesFull<C>> for OrchardFixedBase<C> {
|
impl From<OrchardFixedBasesFull> for OrchardFixedBase {
|
||||||
fn from(base: OrchardFixedBasesFull<C>) -> Self {
|
fn from(base: OrchardFixedBasesFull) -> Self {
|
||||||
let (generator, z, u) = match base {
|
let (generator, z, u) = match base {
|
||||||
OrchardFixedBasesFull::CommitIvkR(_) => (
|
OrchardFixedBasesFull::CommitIvkR => (
|
||||||
super::commit_ivk_r::generator(),
|
super::commit_ivk_r::generator(),
|
||||||
super::commit_ivk_r::Z.into(),
|
super::commit_ivk_r::Z.into(),
|
||||||
super::commit_ivk_r::U.into(),
|
super::commit_ivk_r::U.into(),
|
||||||
),
|
),
|
||||||
OrchardFixedBasesFull::NoteCommitR(_) => (
|
OrchardFixedBasesFull::NoteCommitR => (
|
||||||
super::note_commit_r::generator(),
|
super::note_commit_r::generator(),
|
||||||
super::note_commit_r::Z.into(),
|
super::note_commit_r::Z.into(),
|
||||||
super::note_commit_r::U.into(),
|
super::note_commit_r::U.into(),
|
||||||
),
|
),
|
||||||
OrchardFixedBasesFull::NullifierK(_) => (
|
OrchardFixedBasesFull::NullifierK => (
|
||||||
super::nullifier_k::generator(),
|
super::nullifier_k::generator(),
|
||||||
super::nullifier_k::Z.into(),
|
super::nullifier_k::Z.into(),
|
||||||
super::nullifier_k::U.into(),
|
super::nullifier_k::U.into(),
|
||||||
),
|
),
|
||||||
OrchardFixedBasesFull::ValueCommitR(_) => (
|
OrchardFixedBasesFull::ValueCommitR => (
|
||||||
super::value_commit_r::generator(),
|
super::value_commit_r::generator(),
|
||||||
super::value_commit_r::Z.into(),
|
super::value_commit_r::Z.into(),
|
||||||
super::value_commit_r::U.into(),
|
super::value_commit_r::U.into(),
|
||||||
),
|
),
|
||||||
OrchardFixedBasesFull::SpendAuthG(_) => (
|
OrchardFixedBasesFull::SpendAuthG => (
|
||||||
super::spend_auth_g::generator(),
|
super::spend_auth_g::generator(),
|
||||||
super::spend_auth_g::Z.into(),
|
super::spend_auth_g::Z.into(),
|
||||||
super::spend_auth_g::U.into(),
|
super::spend_auth_g::U.into(),
|
||||||
|
@ -63,14 +62,14 @@ impl<C: CurveAffine> From<OrchardFixedBasesFull<C>> for OrchardFixedBase<C> {
|
||||||
|
|
||||||
/// A fixed base to be used in scalar multiplication with a short signed exponent.
|
/// A fixed base to be used in scalar multiplication with a short signed exponent.
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct ValueCommitV<C: CurveAffine> {
|
pub struct ValueCommitV {
|
||||||
pub generator: C,
|
pub generator: pallas::Affine,
|
||||||
pub lagrange_coeffs_short: LagrangeCoeffsShort<C::Base>,
|
pub lagrange_coeffs_short: LagrangeCoeffsShort,
|
||||||
pub z_short: ZShort<C::Base>,
|
pub z_short: ZShort,
|
||||||
pub u_short: UShort<C::Base>,
|
pub u_short: UShort,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CurveAffine> ValueCommitV<C> {
|
impl ValueCommitV {
|
||||||
pub fn get() -> Self {
|
pub fn get() -> Self {
|
||||||
let generator = super::value_commit_v::generator();
|
let generator = super::value_commit_v::generator();
|
||||||
Self {
|
Self {
|
||||||
|
@ -84,59 +83,57 @@ impl<C: CurveAffine> ValueCommitV<C> {
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
// 8 coefficients per window
|
// 8 coefficients per window
|
||||||
pub struct WindowLagrangeCoeffs<F: FieldExt>(pub Box<[F; H]>);
|
pub struct WindowLagrangeCoeffs(pub Box<[pallas::Base; H]>);
|
||||||
|
|
||||||
impl<F: FieldExt> From<&[F; H]> for WindowLagrangeCoeffs<F> {
|
impl From<&[pallas::Base; H]> for WindowLagrangeCoeffs {
|
||||||
fn from(array: &[F; H]) -> Self {
|
fn from(array: &[pallas::Base; H]) -> Self {
|
||||||
Self(Box::new(*array))
|
Self(Box::new(*array))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
// 85 windows per base (with the exception of ValueCommitV)
|
// 85 windows per base (with the exception of ValueCommitV)
|
||||||
pub struct LagrangeCoeffs<F: FieldExt>(pub Box<[WindowLagrangeCoeffs<F>; constants::NUM_WINDOWS]>);
|
pub struct LagrangeCoeffs(pub Box<[WindowLagrangeCoeffs; constants::NUM_WINDOWS]>);
|
||||||
|
|
||||||
impl<F: FieldExt> From<Vec<WindowLagrangeCoeffs<F>>> for LagrangeCoeffs<F> {
|
impl From<Vec<WindowLagrangeCoeffs>> for LagrangeCoeffs {
|
||||||
fn from(windows: Vec<WindowLagrangeCoeffs<F>>) -> Self {
|
fn from(windows: Vec<WindowLagrangeCoeffs>) -> Self {
|
||||||
Self(windows.into_boxed_slice().try_into().unwrap())
|
Self(windows.into_boxed_slice().try_into().unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F: FieldExt> From<Vec<[F; H]>> for LagrangeCoeffs<F> {
|
impl From<Vec<[pallas::Base; H]>> for LagrangeCoeffs {
|
||||||
fn from(arrays: Vec<[F; H]>) -> Self {
|
fn from(arrays: Vec<[pallas::Base; H]>) -> Self {
|
||||||
let windows: Vec<WindowLagrangeCoeffs<F>> =
|
let windows: Vec<WindowLagrangeCoeffs> = arrays.iter().map(|array| array.into()).collect();
|
||||||
arrays.iter().map(|array| array.into()).collect();
|
|
||||||
windows.into()
|
windows.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
// 22 windows for ValueCommitV
|
// 22 windows for ValueCommitV
|
||||||
pub struct LagrangeCoeffsShort<F: FieldExt>(pub Box<[WindowLagrangeCoeffs<F>; NUM_WINDOWS_SHORT]>);
|
pub struct LagrangeCoeffsShort(pub Box<[WindowLagrangeCoeffs; NUM_WINDOWS_SHORT]>);
|
||||||
|
|
||||||
impl<F: FieldExt> From<Vec<WindowLagrangeCoeffs<F>>> for LagrangeCoeffsShort<F> {
|
impl From<Vec<WindowLagrangeCoeffs>> for LagrangeCoeffsShort {
|
||||||
fn from(windows: Vec<WindowLagrangeCoeffs<F>>) -> Self {
|
fn from(windows: Vec<WindowLagrangeCoeffs>) -> Self {
|
||||||
Self(windows.into_boxed_slice().try_into().unwrap())
|
Self(windows.into_boxed_slice().try_into().unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F: FieldExt> From<Vec<[F; H]>> for LagrangeCoeffsShort<F> {
|
impl From<Vec<[pallas::Base; H]>> for LagrangeCoeffsShort {
|
||||||
fn from(arrays: Vec<[F; H]>) -> Self {
|
fn from(arrays: Vec<[pallas::Base; H]>) -> Self {
|
||||||
let windows: Vec<WindowLagrangeCoeffs<F>> =
|
let windows: Vec<WindowLagrangeCoeffs> = arrays.iter().map(|array| array.into()).collect();
|
||||||
arrays.iter().map(|array| array.into()).collect();
|
|
||||||
windows.into()
|
windows.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
// 85 Z's per base (with the exception of ValueCommitV)
|
// 85 Z's per base (with the exception of ValueCommitV)
|
||||||
pub struct Z<F: FieldExt>(pub Box<[F; NUM_WINDOWS]>);
|
pub struct Z(pub Box<[pallas::Base; NUM_WINDOWS]>);
|
||||||
|
|
||||||
impl<F: FieldExt> From<[u64; NUM_WINDOWS]> for Z<F> {
|
impl From<[u64; NUM_WINDOWS]> for Z {
|
||||||
fn from(zs: [u64; NUM_WINDOWS]) -> Self {
|
fn from(zs: [u64; NUM_WINDOWS]) -> Self {
|
||||||
Self(
|
Self(
|
||||||
zs.iter()
|
zs.iter()
|
||||||
.map(|z| F::from_u64(*z))
|
.map(|z| pallas::Base::from_u64(*z))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.into_boxed_slice()
|
.into_boxed_slice()
|
||||||
.try_into()
|
.try_into()
|
||||||
|
@ -147,13 +144,13 @@ impl<F: FieldExt> From<[u64; NUM_WINDOWS]> for Z<F> {
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
// 22 Z's for ValueCommitV
|
// 22 Z's for ValueCommitV
|
||||||
pub struct ZShort<F: FieldExt>(pub Box<[F; NUM_WINDOWS_SHORT]>);
|
pub struct ZShort(pub Box<[pallas::Base; NUM_WINDOWS_SHORT]>);
|
||||||
|
|
||||||
impl<F: FieldExt> From<[u64; NUM_WINDOWS_SHORT]> for ZShort<F> {
|
impl From<[u64; NUM_WINDOWS_SHORT]> for ZShort {
|
||||||
fn from(zs: [u64; NUM_WINDOWS_SHORT]) -> Self {
|
fn from(zs: [u64; NUM_WINDOWS_SHORT]) -> Self {
|
||||||
Self(
|
Self(
|
||||||
zs.iter()
|
zs.iter()
|
||||||
.map(|z| F::from_u64(*z))
|
.map(|z| pallas::Base::from_u64(*z))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.into_boxed_slice()
|
.into_boxed_slice()
|
||||||
.try_into()
|
.try_into()
|
||||||
|
@ -164,14 +161,14 @@ impl<F: FieldExt> From<[u64; NUM_WINDOWS_SHORT]> for ZShort<F> {
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
// 8 u's per window
|
// 8 u's per window
|
||||||
pub struct WindowUs<F: FieldExt>(pub Box<[F; H]>);
|
pub struct WindowUs(pub Box<[pallas::Base; H]>);
|
||||||
|
|
||||||
impl<F: FieldExt> From<&[[u8; 32]; H]> for WindowUs<F> {
|
impl From<&[[u8; 32]; H]> for WindowUs {
|
||||||
fn from(window_us: &[[u8; 32]; H]) -> Self {
|
fn from(window_us: &[[u8; 32]; H]) -> Self {
|
||||||
Self(
|
Self(
|
||||||
window_us
|
window_us
|
||||||
.iter()
|
.iter()
|
||||||
.map(|u| F::from_bytes(u).unwrap())
|
.map(|u| pallas::Base::from_bytes(u).unwrap())
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.into_boxed_slice()
|
.into_boxed_slice()
|
||||||
.try_into()
|
.try_into()
|
||||||
|
@ -182,34 +179,34 @@ impl<F: FieldExt> From<&[[u8; 32]; H]> for WindowUs<F> {
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
// 85 windows per base (with the exception of ValueCommitV)
|
// 85 windows per base (with the exception of ValueCommitV)
|
||||||
pub struct U<F: FieldExt>(pub Box<[WindowUs<F>; NUM_WINDOWS]>);
|
pub struct U(pub Box<[WindowUs; NUM_WINDOWS]>);
|
||||||
|
|
||||||
impl<F: FieldExt> From<Vec<WindowUs<F>>> for U<F> {
|
impl From<Vec<WindowUs>> for U {
|
||||||
fn from(windows: Vec<WindowUs<F>>) -> Self {
|
fn from(windows: Vec<WindowUs>) -> Self {
|
||||||
Self(windows.into_boxed_slice().try_into().unwrap())
|
Self(windows.into_boxed_slice().try_into().unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F: FieldExt> From<[[[u8; 32]; H]; NUM_WINDOWS]> for U<F> {
|
impl From<[[[u8; 32]; H]; NUM_WINDOWS]> for U {
|
||||||
fn from(window_us: [[[u8; 32]; H]; NUM_WINDOWS]) -> Self {
|
fn from(window_us: [[[u8; 32]; H]; NUM_WINDOWS]) -> Self {
|
||||||
let windows: Vec<WindowUs<F>> = window_us.iter().map(|us| us.into()).collect();
|
let windows: Vec<WindowUs> = window_us.iter().map(|us| us.into()).collect();
|
||||||
windows.into()
|
windows.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
// 22 windows for ValueCommitV
|
// 22 windows for ValueCommitV
|
||||||
pub struct UShort<F: FieldExt>(pub Box<[WindowUs<F>; NUM_WINDOWS_SHORT]>);
|
pub struct UShort(pub Box<[WindowUs; NUM_WINDOWS_SHORT]>);
|
||||||
|
|
||||||
impl<F: FieldExt> From<Vec<WindowUs<F>>> for UShort<F> {
|
impl From<Vec<WindowUs>> for UShort {
|
||||||
fn from(windows: Vec<WindowUs<F>>) -> Self {
|
fn from(windows: Vec<WindowUs>) -> Self {
|
||||||
Self(windows.into_boxed_slice().try_into().unwrap())
|
Self(windows.into_boxed_slice().try_into().unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F: FieldExt> From<[[[u8; 32]; H]; NUM_WINDOWS_SHORT]> for UShort<F> {
|
impl From<[[[u8; 32]; H]; NUM_WINDOWS_SHORT]> for UShort {
|
||||||
fn from(window_us: [[[u8; 32]; H]; NUM_WINDOWS_SHORT]) -> Self {
|
fn from(window_us: [[[u8; 32]; H]; NUM_WINDOWS_SHORT]) -> Self {
|
||||||
let windows: Vec<WindowUs<F>> = window_us.iter().map(|us| us.into()).collect();
|
let windows: Vec<WindowUs> = window_us.iter().map(|us| us.into()).collect();
|
||||||
windows.into()
|
windows.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
use halo2::arithmetic::{CurveAffine, FieldExt};
|
use pasta_curves::{
|
||||||
|
arithmetic::{CurveAffine, FieldExt},
|
||||||
|
pallas,
|
||||||
|
};
|
||||||
|
|
||||||
/// Generator used in SinsemillaCommit randomness for note commitment
|
/// Generator used in SinsemillaCommit randomness for note commitment
|
||||||
pub const GENERATOR: ([u8; 32], [u8; 32]) = (
|
pub const GENERATOR: ([u8; 32], [u8; 32]) = (
|
||||||
|
@ -2917,10 +2920,10 @@ pub const U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
pub fn generator<C: CurveAffine>() -> C {
|
pub fn generator() -> pallas::Affine {
|
||||||
C::from_xy(
|
pallas::Affine::from_xy(
|
||||||
C::Base::from_bytes(&GENERATOR.0).unwrap(),
|
pallas::Base::from_bytes(&GENERATOR.0).unwrap(),
|
||||||
C::Base::from_bytes(&GENERATOR.1).unwrap(),
|
pallas::Base::from_bytes(&GENERATOR.1).unwrap(),
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
@ -2933,9 +2936,9 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::primitives::sinsemilla::CommitDomain;
|
use crate::primitives::sinsemilla::CommitDomain;
|
||||||
use group::Curve;
|
use group::Curve;
|
||||||
use halo2::{
|
use pasta_curves::{
|
||||||
arithmetic::{CurveAffine, FieldExt},
|
arithmetic::{CurveAffine, FieldExt},
|
||||||
pasta::pallas,
|
pallas,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -2950,13 +2953,13 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lagrange_coeffs() {
|
fn lagrange_coeffs() {
|
||||||
let base = super::generator::<pallas::Affine>();
|
let base = super::generator();
|
||||||
test_lagrange_coeffs(base, NUM_WINDOWS);
|
test_lagrange_coeffs(base, NUM_WINDOWS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn z() {
|
fn z() {
|
||||||
let base = super::generator::<pallas::Affine>();
|
let base = super::generator();
|
||||||
test_zs_and_us(base, &Z, &U, NUM_WINDOWS);
|
test_zs_and_us(base, &Z, &U, NUM_WINDOWS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
use halo2::arithmetic::{CurveAffine, FieldExt};
|
use pasta_curves::{
|
||||||
|
arithmetic::{CurveAffine, FieldExt},
|
||||||
|
pallas,
|
||||||
|
};
|
||||||
|
|
||||||
pub const GENERATOR: ([u8; 32], [u8; 32]) = (
|
pub const GENERATOR: ([u8; 32], [u8; 32]) = (
|
||||||
[
|
[
|
||||||
|
@ -2916,10 +2919,10 @@ pub const U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
pub fn generator<C: CurveAffine>() -> C {
|
pub fn generator() -> pallas::Affine {
|
||||||
C::from_xy(
|
pallas::Affine::from_xy(
|
||||||
C::Base::from_bytes(&GENERATOR.0).unwrap(),
|
pallas::Base::from_bytes(&GENERATOR.0).unwrap(),
|
||||||
C::Base::from_bytes(&GENERATOR.1).unwrap(),
|
pallas::Base::from_bytes(&GENERATOR.1).unwrap(),
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
@ -2931,9 +2934,9 @@ mod tests {
|
||||||
};
|
};
|
||||||
use super::*;
|
use super::*;
|
||||||
use group::Curve;
|
use group::Curve;
|
||||||
use halo2::{
|
use pasta_curves::{
|
||||||
arithmetic::{CurveAffine, CurveExt, FieldExt},
|
arithmetic::{CurveExt, FieldExt},
|
||||||
pasta::pallas,
|
pallas,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -2948,13 +2951,13 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lagrange_coeffs() {
|
fn lagrange_coeffs() {
|
||||||
let base = super::generator::<pallas::Affine>();
|
let base = super::generator();
|
||||||
test_lagrange_coeffs(base, NUM_WINDOWS);
|
test_lagrange_coeffs(base, NUM_WINDOWS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn z() {
|
fn z() {
|
||||||
let base = super::generator::<pallas::Affine>();
|
let base = super::generator();
|
||||||
test_zs_and_us(base, &Z, &U, NUM_WINDOWS);
|
test_zs_and_us(base, &Z, &U, NUM_WINDOWS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
use halo2::arithmetic::{CurveAffine, FieldExt};
|
use pasta_curves::{
|
||||||
|
arithmetic::{CurveAffine, FieldExt},
|
||||||
|
pallas,
|
||||||
|
};
|
||||||
|
|
||||||
/// The value commitment is used to check balance between inputs and outputs. The value is
|
/// The value commitment is used to check balance between inputs and outputs. The value is
|
||||||
/// placed over this generator.
|
/// placed over this generator.
|
||||||
|
@ -2918,10 +2921,10 @@ pub const U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
pub fn generator<C: CurveAffine>() -> C {
|
pub fn generator() -> pallas::Affine {
|
||||||
C::from_xy(
|
pallas::Affine::from_xy(
|
||||||
C::Base::from_bytes(&GENERATOR.0).unwrap(),
|
pallas::Base::from_bytes(&GENERATOR.0).unwrap(),
|
||||||
C::Base::from_bytes(&GENERATOR.1).unwrap(),
|
pallas::Base::from_bytes(&GENERATOR.1).unwrap(),
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
@ -2933,9 +2936,9 @@ mod tests {
|
||||||
};
|
};
|
||||||
use super::*;
|
use super::*;
|
||||||
use group::Curve;
|
use group::Curve;
|
||||||
use halo2::{
|
use pasta_curves::{
|
||||||
arithmetic::{CurveAffine, CurveExt, FieldExt},
|
arithmetic::{CurveAffine, CurveExt, FieldExt},
|
||||||
pasta::pallas,
|
pallas,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -2950,13 +2953,13 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lagrange_coeffs() {
|
fn lagrange_coeffs() {
|
||||||
let base = super::generator::<pallas::Affine>();
|
let base = super::generator();
|
||||||
test_lagrange_coeffs(base, NUM_WINDOWS);
|
test_lagrange_coeffs(base, NUM_WINDOWS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn z() {
|
fn z() {
|
||||||
let base = super::generator::<pallas::Affine>();
|
let base = super::generator();
|
||||||
test_zs_and_us(base, &Z, &U, NUM_WINDOWS);
|
test_zs_and_us(base, &Z, &U, NUM_WINDOWS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
use halo2::arithmetic::{CurveAffine, FieldExt};
|
use pasta_curves::{
|
||||||
|
arithmetic::{CurveAffine, FieldExt},
|
||||||
|
pallas,
|
||||||
|
};
|
||||||
|
|
||||||
/// The value commitment is used to check balance between inputs and outputs. The value is
|
/// The value commitment is used to check balance between inputs and outputs. The value is
|
||||||
/// placed over this generator.
|
/// placed over this generator.
|
||||||
|
@ -2918,10 +2921,10 @@ pub const U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
pub fn generator<C: CurveAffine>() -> C {
|
pub fn generator() -> pallas::Affine {
|
||||||
C::from_xy(
|
pallas::Affine::from_xy(
|
||||||
C::Base::from_bytes(&GENERATOR.0).unwrap(),
|
pallas::Base::from_bytes(&GENERATOR.0).unwrap(),
|
||||||
C::Base::from_bytes(&GENERATOR.1).unwrap(),
|
pallas::Base::from_bytes(&GENERATOR.1).unwrap(),
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
@ -2933,9 +2936,9 @@ mod tests {
|
||||||
};
|
};
|
||||||
use super::*;
|
use super::*;
|
||||||
use group::Curve;
|
use group::Curve;
|
||||||
use halo2::{
|
use pasta_curves::{
|
||||||
arithmetic::{CurveAffine, CurveExt, FieldExt},
|
arithmetic::{CurveAffine, CurveExt, FieldExt},
|
||||||
pasta::pallas,
|
pallas,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -2950,13 +2953,13 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lagrange_coeffs() {
|
fn lagrange_coeffs() {
|
||||||
let base = super::generator::<pallas::Affine>();
|
let base = super::generator();
|
||||||
test_lagrange_coeffs(base, NUM_WINDOWS);
|
test_lagrange_coeffs(base, NUM_WINDOWS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn z() {
|
fn z() {
|
||||||
let base = super::generator::<pallas::Affine>();
|
let base = super::generator();
|
||||||
test_zs_and_us(base, &Z, &U, NUM_WINDOWS);
|
test_zs_and_us(base, &Z, &U, NUM_WINDOWS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
use halo2::arithmetic::{CurveAffine, FieldExt};
|
use pasta_curves::{
|
||||||
|
arithmetic::{CurveAffine, FieldExt},
|
||||||
|
pallas,
|
||||||
|
};
|
||||||
|
|
||||||
/// The value commitment is used to check balance between inputs and outputs. The value is
|
/// The value commitment is used to check balance between inputs and outputs. The value is
|
||||||
/// placed over this generator.
|
/// placed over this generator.
|
||||||
|
@ -771,10 +774,10 @@ pub const U_SHORT: [[[u8; 32]; super::H]; super::NUM_WINDOWS_SHORT] = [
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
pub fn generator<C: CurveAffine>() -> C {
|
pub fn generator() -> pallas::Affine {
|
||||||
C::from_xy(
|
pallas::Affine::from_xy(
|
||||||
C::Base::from_bytes(&GENERATOR.0).unwrap(),
|
pallas::Base::from_bytes(&GENERATOR.0).unwrap(),
|
||||||
C::Base::from_bytes(&GENERATOR.1).unwrap(),
|
pallas::Base::from_bytes(&GENERATOR.1).unwrap(),
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
@ -786,9 +789,9 @@ mod tests {
|
||||||
};
|
};
|
||||||
use super::*;
|
use super::*;
|
||||||
use group::Curve;
|
use group::Curve;
|
||||||
use halo2::{
|
use pasta_curves::{
|
||||||
arithmetic::{CurveAffine, CurveExt, FieldExt},
|
arithmetic::{CurveAffine, CurveExt, FieldExt},
|
||||||
pasta::pallas,
|
pallas,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -803,13 +806,13 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lagrange_coeffs_short() {
|
fn lagrange_coeffs_short() {
|
||||||
let base = super::generator::<pallas::Affine>();
|
let base = super::generator();
|
||||||
test_lagrange_coeffs(base, NUM_WINDOWS_SHORT);
|
test_lagrange_coeffs(base, NUM_WINDOWS_SHORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn z_short() {
|
fn z_short() {
|
||||||
let base = super::generator::<pallas::Affine>();
|
let base = super::generator();
|
||||||
test_zs_and_us(base, &Z_SHORT, &U_SHORT, NUM_WINDOWS_SHORT);
|
test_zs_and_us(base, &Z_SHORT, &U_SHORT, NUM_WINDOWS_SHORT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue