From 8d357faf735cb9c21effb882c9c90f6159626820 Mon Sep 17 00:00:00 2001 From: Deirdre Connolly Date: Sun, 4 Apr 2021 23:23:21 -0400 Subject: [PATCH] Tried and discarded lazy_static! of value commitment generator points --- zebra-chain/src/orchard/commitment.rs | 6 ++---- zebra-chain/src/orchard/sinsemilla.rs | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/zebra-chain/src/orchard/commitment.rs b/zebra-chain/src/orchard/commitment.rs index 3adf0c313..72a07c3bc 100644 --- a/zebra-chain/src/orchard/commitment.rs +++ b/zebra-chain/src/orchard/commitment.rs @@ -321,13 +321,11 @@ impl ValueCommitment { /// https://zips.z.cash/protocol/protocol.pdf#concretehomomorphiccommit #[allow(non_snake_case)] pub fn new(rcv: pallas::Scalar, value: Amount) -> Self { - let v = pallas::Scalar::from(value); - - // TODO: These generator points can be generated once somewhere else to - // avoid having to recompute them on every new commitment. let V = pallas_group_hash(b"z.cash:Orchard-cv", b"v"); let R = pallas_group_hash(b"z.cash:Orchard-cv", b"r"); + let v = pallas::Scalar::from(value); + Self::from(V * v + R * rcv) } } diff --git a/zebra-chain/src/orchard/sinsemilla.rs b/zebra-chain/src/orchard/sinsemilla.rs index 1528a14b8..8d53efaab 100644 --- a/zebra-chain/src/orchard/sinsemilla.rs +++ b/zebra-chain/src/orchard/sinsemilla.rs @@ -12,7 +12,6 @@ use halo2::{ /// P → B^[l^Orchard_Merkle] /// /// [concreteextractorpallas]: https://zips.z.cash/protocol/nu5.pdf#concreteextractorpallas -// TODO: should this return the basefield element type, or the bytes? pub fn extract_p(point: pallas::Point) -> pallas::Base { match pallas::Affine::from(point).get_xy().into() { // If Some, it's not the identity.