From<Nullifier> for [u8; 32]
@@ -43,7 +43,7 @@ fn prf_nf(a_sk: [u8; 32], rho: [u8; 32]) -> [u8; 32] {
/// [ps]: https://zips.z.cash/protocol/protocol.pdf#sproutkeycomponents
#[derive(Clone, Copy, Debug)]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
-pub struct NullifierSeed([u8; 32]);
+pub struct NullifierSeed(pub(crate) [u8; 32]);
impl AsRef<[u8]> for NullifierSeed {
fn as_ref(&self) -> &[u8] {
@@ -57,14 +57,20 @@ impl From<[u8; 32]> for NullifierSeed {
}
}
+impl From<NullifierSeed> for [u8; 32] {
+ fn from(rho: NullifierSeed) -> Self {
+ rho.0
+ }
+}
+
/// A Nullifier for Sprout transactions
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
-pub struct Nullifier([u8; 32]);
+pub struct Nullifier(pub(crate) [u8; 32]);
-impl From<NullifierSeed> for [u8; 32] {
- fn from(rho: NullifierSeed) -> Self {
- rho.0
+impl From<[u8; 32]> for Nullifier {
+ fn from(bytes: [u8; 32]) -> Self {
+ Self(bytes)
}
}
@@ -74,6 +80,12 @@ impl From<(SpendingKey, NullifierSeed)> for Nullifier {
}
}
+impl From<Nullifier> for [u8; 32] {
+ fn from(n: Nullifier) -> Self {
+ n.0
+ }
+}
+
impl ZcashDeserialize for Nullifier {
fn zcash_deserialize<R: io::Read>(mut reader: R) -> Result<Self, SerializationError> {
let bytes = reader.read_32_bytes()?;
