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.
This commit is contained in:
Jack Grigg 2022-02-15 22:47:05 +00:00
parent 17ad25ee35
commit b1d7787ab6
1 changed files with 10 additions and 0 deletions

View File

@ -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 {