Add `OrchardFixedBasesFull::{generator, u}` methods

Using these in `OrchardFixedBases::{generator, u}` instead of the
`impl From<OrchardFixedBasesFull> for OrchardFixedBase` means we avoid
computing the Lagrange coefficients for the generator (which were then
immediately dropped).

This decreases proving time in the Action circuit by 53%.
This commit is contained in:
Jack Grigg 2021-06-16 16:01:30 +01:00 committed by therealyingtong
parent 09b4da197d
commit b15343f6f7
2 changed files with 24 additions and 8 deletions

View File

@ -48,20 +48,14 @@ impl OrchardFixedBases {
pub fn generator(self) -> pallas::Affine {
match self {
Self::ValueCommitV => constants::value_commit_v::generator(),
Self::Full(base) => {
let base: OrchardFixedBase = base.into();
base.generator
}
Self::Full(base) => base.generator(),
}
}
pub fn u(self) -> Vec<WindowUs> {
match self {
Self::ValueCommitV => ValueCommitV::get().u_short.0.as_ref().to_vec(),
Self::Full(base) => {
let base: OrchardFixedBase = base.into();
base.u.0.as_ref().to_vec()
}
Self::Full(base) => base.u().0.as_ref().to_vec(),
}
}
}

View File

@ -12,6 +12,28 @@ pub enum OrchardFixedBasesFull {
SpendAuthG,
}
impl OrchardFixedBasesFull {
pub fn generator(&self) -> pallas::Affine {
match self {
OrchardFixedBasesFull::CommitIvkR => super::commit_ivk_r::generator(),
OrchardFixedBasesFull::NoteCommitR => super::note_commit_r::generator(),
OrchardFixedBasesFull::NullifierK => super::nullifier_k::generator(),
OrchardFixedBasesFull::ValueCommitR => super::value_commit_r::generator(),
OrchardFixedBasesFull::SpendAuthG => super::spend_auth_g::generator(),
}
}
pub fn u(&self) -> U {
match self {
OrchardFixedBasesFull::CommitIvkR => super::commit_ivk_r::U.into(),
OrchardFixedBasesFull::NoteCommitR => super::note_commit_r::U.into(),
OrchardFixedBasesFull::NullifierK => super::nullifier_k::U.into(),
OrchardFixedBasesFull::ValueCommitR => super::value_commit_r::U.into(),
OrchardFixedBasesFull::SpendAuthG => super::spend_auth_g::U.into(),
}
}
}
/// A fixed base to be used in scalar multiplication with a full-width scalar.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct OrchardFixedBase {