From 7d8cdee15c57cfbc0dd21cf408df4a41e26fc45c Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 19 Nov 2024 19:49:08 +0000 Subject: [PATCH] Add `ValueCommitTrapdoor::to_bytes` This is necessary to encode `bsk` into a PCZT. --- CHANGELOG.md | 3 +++ src/value.rs | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0232412f6..c3294170d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to Rust's notion of ## [Unreleased] +### Added +- `orchard::value::ValueCommitTrapdoor::to_bytes` + ## [0.10.0] - 2024-10-02 ### Changed diff --git a/src/value.rs b/src/value.rs index 9ac440eeb..e33c2d43b 100644 --- a/src/value.rs +++ b/src/value.rs @@ -232,6 +232,16 @@ impl ValueCommitTrapdoor { pub fn from_bytes(bytes: [u8; 32]) -> CtOption { pallas::Scalar::from_repr(bytes).map(ValueCommitTrapdoor) } + + /// Returns the byte encoding of this trapdoor. + /// + /// This is a low-level API, requiring a detailed understanding of the + /// [use of value commitment trapdoors][orchardbalance] in the Zcash protocol + /// to use correctly and securely. It is intended to be used in combination + /// with [`ValueCommitment::derive`], and PCZTs. + pub fn to_bytes(&self) -> [u8; 32] { + self.0.to_repr() + } } impl Add<&ValueCommitTrapdoor> for ValueCommitTrapdoor {