From b1d7787ab67f7913f4eb7c1b1ef9f2f5ab87a996 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 15 Feb 2022 22:47:05 +0000 Subject: [PATCH] Re-introduce `ValueSum::from_raw` as a `pub(crate)` method We removed this in zcash/orchard#267 as it did not need to be part of the public API, but we do still need a way to convert the user-defined valueBalance type into a `ValueSum` when constructing `bvk`, and this method is preferable to exposing the `ValueSum` internals. --- src/value.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/value.rs b/src/value.rs index 1568a5ae..f4ebdeef 100644 --- a/src/value.rs +++ b/src/value.rs @@ -140,6 +140,16 @@ impl ValueSum { // Default for i64 is zero. Default::default() } + + /// Creates a value sum from its raw numeric value. + /// + /// This only enforces that the value is a signed 63-bit integer. We use it internally + /// in `Bundle::binding_validating_key`, where we are converting from the user-defined + /// `valueBalance` type that enforces any additional constraints on the value's valid + /// range. + pub(crate) fn from_raw(value: i64) -> Self { + ValueSum(value as i128) + } } impl Add for ValueSum {