diff --git a/zebra-chain/src/orchard/commitment.rs b/zebra-chain/src/orchard/commitment.rs index cc146ffbec6..b09721172e7 100644 --- a/zebra-chain/src/orchard/commitment.rs +++ b/zebra-chain/src/orchard/commitment.rs @@ -301,17 +301,16 @@ impl ValueCommitment { /// #[allow(non_snake_case)] pub fn new(rcv: pallas::Scalar, value: Amount) -> Self { - lazy_static! { - static ref V: pallas::Point = pallas_group_hash(b"z.cash:Orchard-cv", b"v"); - static ref R: pallas::Point = pallas_group_hash(b"z.cash:Orchard-cv", b"r"); - } - let v = pallas::Scalar::from(value); - Self::from(*V * v + *R * rcv) } } +lazy_static! { + static ref V: pallas::Point = pallas_group_hash(b"z.cash:Orchard-cv", b"v"); + static ref R: pallas::Point = pallas_group_hash(b"z.cash:Orchard-cv", b"r"); +} + #[cfg(test)] mod tests { diff --git a/zebra-chain/src/sapling/commitment.rs b/zebra-chain/src/sapling/commitment.rs index 0f33cab1ac1..0a1d389129c 100644 --- a/zebra-chain/src/sapling/commitment.rs +++ b/zebra-chain/src/sapling/commitment.rs @@ -12,6 +12,7 @@ use std::{ use bitvec::prelude::*; use jubjub::ExtendedPoint; +use lazy_static::lazy_static; use rand_core::{CryptoRng, RngCore}; use crate::{ @@ -279,16 +280,15 @@ impl ValueCommitment { #[allow(non_snake_case)] pub fn new(rcv: jubjub::Fr, value: Amount) -> Self { let v = jubjub::Fr::from(value); - - // TODO: These generator points can be generated once somewhere else to - // avoid having to recompute them on every new commitment. - let V = find_group_hash(*b"Zcash_cv", b"v"); - let R = find_group_hash(*b"Zcash_cv", b"r"); - - Self::from(V * v + R * rcv) + Self::from(*V * v + *R * rcv) } } +lazy_static! { + static ref V: ExtendedPoint = find_group_hash(*b"Zcash_cv", b"v"); + static ref R: ExtendedPoint = find_group_hash(*b"Zcash_cv", b"r"); +} + /// A Homomorphic Pedersen commitment to the value of a note, used in Spend and /// Output descriptions. ///