Merge branch 'hex-debug' into base-zcash-test-block-template
This commit is contained in:
commit
a243549d69
|
@ -74,8 +74,8 @@ impl Arbitrary for Signature<SpendAuth> {
|
||||||
fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
|
fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
|
||||||
(array::uniform32(any::<u8>()), array::uniform32(any::<u8>()))
|
(array::uniform32(any::<u8>()), array::uniform32(any::<u8>()))
|
||||||
.prop_map(|(r_bytes, s_bytes)| Self {
|
.prop_map(|(r_bytes, s_bytes)| Self {
|
||||||
r_bytes,
|
r_bytes: r_bytes.into(),
|
||||||
s_bytes,
|
s_bytes: s_bytes.into(),
|
||||||
_marker: PhantomData,
|
_marker: PhantomData,
|
||||||
})
|
})
|
||||||
.boxed()
|
.boxed()
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
//! BCTV14 proofs for Zebra.
|
||||||
|
|
||||||
use std::{fmt, io};
|
use std::{fmt, io};
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
//! Groth16 proofs for Zebra.
|
||||||
|
|
||||||
use std::{fmt, io};
|
use std::{fmt, io};
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
|
@ -229,7 +229,7 @@ impl Verifier {
|
||||||
|
|
||||||
let s = {
|
let s = {
|
||||||
// XXX-pallas: should not use CtOption here
|
// XXX-pallas: should not use CtOption here
|
||||||
let maybe_scalar = pallas::Scalar::from_repr(s_bytes);
|
let maybe_scalar = pallas::Scalar::from_repr(*s_bytes);
|
||||||
if maybe_scalar.is_some().into() {
|
if maybe_scalar.is_some().into() {
|
||||||
maybe_scalar.unwrap()
|
maybe_scalar.unwrap()
|
||||||
} else {
|
} else {
|
||||||
|
@ -258,10 +258,10 @@ impl Verifier {
|
||||||
//
|
//
|
||||||
// This validates the `rk` element, whose type is
|
// This validates the `rk` element, whose type is
|
||||||
// SpendAuthSig^{Orchard}.Public, i.e. ℙ.
|
// SpendAuthSig^{Orchard}.Public, i.e. ℙ.
|
||||||
VerificationKey::<SpendAuth>::try_from(vk_bytes.bytes)?.point
|
VerificationKey::<SpendAuth>::try_from(*vk_bytes.bytes)?.point
|
||||||
}
|
}
|
||||||
Inner::Binding { vk_bytes, .. } => {
|
Inner::Binding { vk_bytes, .. } => {
|
||||||
VerificationKey::<Binding>::try_from(vk_bytes.bytes)?.point
|
VerificationKey::<Binding>::try_from(*vk_bytes.bytes)?.point
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,16 @@ use std::{io, marker::PhantomData};
|
||||||
|
|
||||||
use super::SigType;
|
use super::SigType;
|
||||||
|
|
||||||
use crate::serialization::{ReadZcashExt, SerializationError, ZcashDeserialize, ZcashSerialize};
|
use crate::{
|
||||||
|
fmt::HexDebug,
|
||||||
|
serialization::{ReadZcashExt, SerializationError, ZcashDeserialize, ZcashSerialize},
|
||||||
|
};
|
||||||
|
|
||||||
/// A RedPallas signature.
|
/// A RedPallas signature.
|
||||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
|
||||||
pub struct Signature<T: SigType> {
|
pub struct Signature<T: SigType> {
|
||||||
pub(crate) r_bytes: [u8; 32],
|
pub(crate) r_bytes: HexDebug<[u8; 32]>,
|
||||||
pub(crate) s_bytes: [u8; 32],
|
pub(crate) s_bytes: HexDebug<[u8; 32]>,
|
||||||
pub(crate) _marker: PhantomData<T>,
|
pub(crate) _marker: PhantomData<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +32,8 @@ impl<T: SigType> From<[u8; 64]> for Signature<T> {
|
||||||
let mut s_bytes = [0; 32];
|
let mut s_bytes = [0; 32];
|
||||||
s_bytes.copy_from_slice(&bytes[32..64]);
|
s_bytes.copy_from_slice(&bytes[32..64]);
|
||||||
Signature {
|
Signature {
|
||||||
r_bytes,
|
r_bytes: r_bytes.into(),
|
||||||
s_bytes,
|
s_bytes: s_bytes.into(),
|
||||||
_marker: PhantomData,
|
_marker: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use std::convert::{TryFrom, TryInto};
|
//! Redpallas signing keys for Zebra.
|
||||||
|
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use group::{ff::PrimeField, GroupEncoding};
|
use group::{ff::PrimeField, GroupEncoding};
|
||||||
|
@ -117,8 +118,8 @@ impl<T: SigType> SigningKey<T> {
|
||||||
let s_bytes = (nonce + (c * self.sk)).to_repr();
|
let s_bytes = (nonce + (c * self.sk)).to_repr();
|
||||||
|
|
||||||
Signature {
|
Signature {
|
||||||
r_bytes,
|
r_bytes: r_bytes.into(),
|
||||||
s_bytes,
|
s_bytes: s_bytes.into(),
|
||||||
_marker: PhantomData,
|
_marker: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
|
//! Redpallas verification keys for Zebra.
|
||||||
|
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use group::{cofactor::CofactorGroup, ff::PrimeField, GroupEncoding};
|
use group::{cofactor::CofactorGroup, ff::PrimeField, GroupEncoding};
|
||||||
use halo2::pasta::pallas;
|
use halo2::pasta::pallas;
|
||||||
|
|
||||||
|
use crate::fmt::HexDebug;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
/// A refinement type for `[u8; 32]` indicating that the bytes represent
|
/// A refinement type for `[u8; 32]` indicating that the bytes represent
|
||||||
|
@ -13,14 +17,14 @@ use super::*;
|
||||||
/// used in signature verification.
|
/// used in signature verification.
|
||||||
#[derive(Copy, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
#[derive(Copy, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||||
pub struct VerificationKeyBytes<T: SigType> {
|
pub struct VerificationKeyBytes<T: SigType> {
|
||||||
pub(crate) bytes: [u8; 32],
|
pub(crate) bytes: HexDebug<[u8; 32]>,
|
||||||
pub(crate) _marker: PhantomData<T>,
|
pub(crate) _marker: PhantomData<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: SigType> From<[u8; 32]> for VerificationKeyBytes<T> {
|
impl<T: SigType> From<[u8; 32]> for VerificationKeyBytes<T> {
|
||||||
fn from(bytes: [u8; 32]) -> VerificationKeyBytes<T> {
|
fn from(bytes: [u8; 32]) -> VerificationKeyBytes<T> {
|
||||||
VerificationKeyBytes {
|
VerificationKeyBytes {
|
||||||
bytes,
|
bytes: bytes.into(),
|
||||||
_marker: PhantomData,
|
_marker: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +32,7 @@ impl<T: SigType> From<[u8; 32]> for VerificationKeyBytes<T> {
|
||||||
|
|
||||||
impl<T: SigType> From<VerificationKeyBytes<T>> for [u8; 32] {
|
impl<T: SigType> From<VerificationKeyBytes<T>> for [u8; 32] {
|
||||||
fn from(refined: VerificationKeyBytes<T>) -> [u8; 32] {
|
fn from(refined: VerificationKeyBytes<T>) -> [u8; 32] {
|
||||||
refined.bytes
|
*refined.bytes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +69,7 @@ impl<T: SigType> From<VerificationKey<T>> for VerificationKeyBytes<T> {
|
||||||
|
|
||||||
impl<T: SigType> From<VerificationKey<T>> for [u8; 32] {
|
impl<T: SigType> From<VerificationKey<T>> for [u8; 32] {
|
||||||
fn from(pk: VerificationKey<T>) -> [u8; 32] {
|
fn from(pk: VerificationKey<T>) -> [u8; 32] {
|
||||||
pk.bytes.bytes
|
*pk.bytes.bytes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +111,7 @@ impl VerificationKey<SpendAuth> {
|
||||||
use super::private::Sealed;
|
use super::private::Sealed;
|
||||||
let point = self.point + (SpendAuth::basepoint() * randomizer);
|
let point = self.point + (SpendAuth::basepoint() * randomizer);
|
||||||
let bytes = VerificationKeyBytes {
|
let bytes = VerificationKeyBytes {
|
||||||
bytes: point.to_bytes(),
|
bytes: point.to_bytes().into(),
|
||||||
_marker: PhantomData,
|
_marker: PhantomData,
|
||||||
};
|
};
|
||||||
VerificationKey { point, bytes }
|
VerificationKey { point, bytes }
|
||||||
|
@ -118,7 +122,7 @@ impl<T: SigType> VerificationKey<T> {
|
||||||
pub(crate) fn from_scalar(s: &pallas::Scalar) -> VerificationKey<T> {
|
pub(crate) fn from_scalar(s: &pallas::Scalar) -> VerificationKey<T> {
|
||||||
let point = T::basepoint() * s;
|
let point = T::basepoint() * s;
|
||||||
let bytes = VerificationKeyBytes {
|
let bytes = VerificationKeyBytes {
|
||||||
bytes: point.to_bytes(),
|
bytes: point.to_bytes().into(),
|
||||||
_marker: PhantomData,
|
_marker: PhantomData,
|
||||||
};
|
};
|
||||||
VerificationKey { point, bytes }
|
VerificationKey { point, bytes }
|
||||||
|
@ -154,7 +158,7 @@ impl<T: SigType> VerificationKey<T> {
|
||||||
|
|
||||||
let s = {
|
let s = {
|
||||||
// XXX-pasta_curves: should not use CtOption here
|
// XXX-pasta_curves: should not use CtOption here
|
||||||
let maybe_scalar = pallas::Scalar::from_repr(signature.s_bytes);
|
let maybe_scalar = pallas::Scalar::from_repr(*signature.s_bytes);
|
||||||
if maybe_scalar.is_some().into() {
|
if maybe_scalar.is_some().into() {
|
||||||
maybe_scalar.unwrap()
|
maybe_scalar.unwrap()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,22 +1,24 @@
|
||||||
//! Sapling nullifiers.
|
//! Sapling nullifiers.
|
||||||
|
|
||||||
|
use crate::fmt::HexDebug;
|
||||||
|
|
||||||
/// A Nullifier for Sapling transactions
|
/// A Nullifier for Sapling transactions
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
any(test, feature = "proptest-impl"),
|
any(test, feature = "proptest-impl"),
|
||||||
derive(proptest_derive::Arbitrary)
|
derive(proptest_derive::Arbitrary)
|
||||||
)]
|
)]
|
||||||
pub struct Nullifier(pub [u8; 32]);
|
pub struct Nullifier(pub HexDebug<[u8; 32]>);
|
||||||
|
|
||||||
impl From<[u8; 32]> for Nullifier {
|
impl From<[u8; 32]> for Nullifier {
|
||||||
fn from(buf: [u8; 32]) -> Self {
|
fn from(buf: [u8; 32]) -> Self {
|
||||||
Self(buf)
|
Self(buf.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Nullifier> for [u8; 32] {
|
impl From<Nullifier> for [u8; 32] {
|
||||||
fn from(n: Nullifier) -> Self {
|
fn from(n: Nullifier) -> Self {
|
||||||
n.0
|
*n.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
|
|
||||||
|
use crate::fmt::HexDebug;
|
||||||
|
|
||||||
use super::note::Note;
|
use super::note::Note;
|
||||||
|
|
||||||
/// The randomness used in the Pedersen Hash for note commitment.
|
/// The randomness used in the Pedersen Hash for note commitment.
|
||||||
|
@ -10,11 +12,11 @@ use super::note::Note;
|
||||||
any(test, feature = "proptest-impl"),
|
any(test, feature = "proptest-impl"),
|
||||||
derive(proptest_derive::Arbitrary)
|
derive(proptest_derive::Arbitrary)
|
||||||
)]
|
)]
|
||||||
pub struct CommitmentRandomness(pub [u8; 32]);
|
pub struct CommitmentRandomness(pub HexDebug<[u8; 32]>);
|
||||||
|
|
||||||
impl AsRef<[u8]> for CommitmentRandomness {
|
impl AsRef<[u8]> for CommitmentRandomness {
|
||||||
fn as_ref(&self) -> &[u8] {
|
fn as_ref(&self) -> &[u8] {
|
||||||
&self.0
|
self.0.as_ref()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,11 +26,11 @@ impl AsRef<[u8]> for CommitmentRandomness {
|
||||||
any(test, feature = "proptest-impl"),
|
any(test, feature = "proptest-impl"),
|
||||||
derive(proptest_derive::Arbitrary)
|
derive(proptest_derive::Arbitrary)
|
||||||
)]
|
)]
|
||||||
pub struct NoteCommitment(pub(crate) [u8; 32]);
|
pub struct NoteCommitment(pub(crate) HexDebug<[u8; 32]>);
|
||||||
|
|
||||||
impl From<[u8; 32]> for NoteCommitment {
|
impl From<[u8; 32]> for NoteCommitment {
|
||||||
fn from(bytes: [u8; 32]) -> Self {
|
fn from(bytes: [u8; 32]) -> Self {
|
||||||
Self(bytes)
|
Self(bytes.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,18 +46,20 @@ impl From<Note> for NoteCommitment {
|
||||||
hasher.update(note.value.to_bytes());
|
hasher.update(note.value.to_bytes());
|
||||||
hasher.update(note.rho);
|
hasher.update(note.rho);
|
||||||
hasher.update(note.rcm);
|
hasher.update(note.rcm);
|
||||||
NoteCommitment(hasher.finalize().into())
|
|
||||||
|
let commitment: [u8; 32] = hasher.finalize().into();
|
||||||
|
NoteCommitment(commitment.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<NoteCommitment> for [u8; 32] {
|
impl From<NoteCommitment> for [u8; 32] {
|
||||||
fn from(cm: NoteCommitment) -> [u8; 32] {
|
fn from(cm: NoteCommitment) -> [u8; 32] {
|
||||||
cm.0
|
*cm.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&NoteCommitment> for [u8; 32] {
|
impl From<&NoteCommitment> for [u8; 32] {
|
||||||
fn from(cm: &NoteCommitment) -> [u8; 32] {
|
fn from(cm: &NoteCommitment) -> [u8; 32] {
|
||||||
cm.0
|
*cm.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use crate::{
|
use crate::{
|
||||||
amount::{Amount, NegativeAllowed, NonNegative},
|
amount::{Amount, NegativeAllowed, NonNegative},
|
||||||
block::MAX_BLOCK_BYTES,
|
block::MAX_BLOCK_BYTES,
|
||||||
|
fmt::HexDebug,
|
||||||
primitives::{x25519, Bctv14Proof, Groth16Proof, ZkSnarkProof},
|
primitives::{x25519, Bctv14Proof, Groth16Proof, ZkSnarkProof},
|
||||||
serialization::{
|
serialization::{
|
||||||
ReadZcashExt, SerializationError, TrustedPreallocate, WriteZcashExt, ZcashDeserialize,
|
ReadZcashExt, SerializationError, TrustedPreallocate, WriteZcashExt, ZcashDeserialize,
|
||||||
|
@ -25,17 +26,17 @@ use super::{commitment, note, tree};
|
||||||
any(test, feature = "proptest-impl"),
|
any(test, feature = "proptest-impl"),
|
||||||
derive(proptest_derive::Arbitrary)
|
derive(proptest_derive::Arbitrary)
|
||||||
)]
|
)]
|
||||||
pub struct RandomSeed([u8; 32]);
|
pub struct RandomSeed(HexDebug<[u8; 32]>);
|
||||||
|
|
||||||
impl From<[u8; 32]> for RandomSeed {
|
impl From<[u8; 32]> for RandomSeed {
|
||||||
fn from(bytes: [u8; 32]) -> Self {
|
fn from(bytes: [u8; 32]) -> Self {
|
||||||
Self(bytes)
|
Self(bytes.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<RandomSeed> for [u8; 32] {
|
impl From<RandomSeed> for [u8; 32] {
|
||||||
fn from(rt: RandomSeed) -> [u8; 32] {
|
fn from(rt: RandomSeed) -> [u8; 32] {
|
||||||
rt.0
|
*rt.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
use crate::serialization::{ReadZcashExt, SerializationError, ZcashDeserialize, ZcashSerialize};
|
//! Sprout message authentication codes.
|
||||||
|
|
||||||
use std::io::{self, Read};
|
use std::io::{self, Read};
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
fmt::HexDebug,
|
||||||
|
serialization::{ReadZcashExt, SerializationError, ZcashDeserialize, ZcashSerialize},
|
||||||
|
};
|
||||||
|
|
||||||
/// A sequence of message authentication tags ...
|
/// A sequence of message authentication tags ...
|
||||||
///
|
///
|
||||||
/// binding h_sig to each a_sk of the JoinSplit description, computed as
|
/// binding h_sig to each a_sk of the JoinSplit description, computed as
|
||||||
|
@ -10,17 +16,17 @@ use std::io::{self, Read};
|
||||||
any(test, feature = "proptest-impl"),
|
any(test, feature = "proptest-impl"),
|
||||||
derive(proptest_derive::Arbitrary)
|
derive(proptest_derive::Arbitrary)
|
||||||
)]
|
)]
|
||||||
pub struct Mac([u8; 32]);
|
pub struct Mac(HexDebug<[u8; 32]>);
|
||||||
|
|
||||||
impl From<[u8; 32]> for Mac {
|
impl From<[u8; 32]> for Mac {
|
||||||
fn from(bytes: [u8; 32]) -> Self {
|
fn from(bytes: [u8; 32]) -> Self {
|
||||||
Self(bytes)
|
Self(bytes.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Mac> for [u8; 32] {
|
impl From<Mac> for [u8; 32] {
|
||||||
fn from(rt: Mac) -> [u8; 32] {
|
fn from(rt: Mac) -> [u8; 32] {
|
||||||
rt.0
|
*rt.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +40,7 @@ impl ZcashDeserialize for Mac {
|
||||||
fn zcash_deserialize<R: Read>(mut reader: R) -> Result<Self, SerializationError> {
|
fn zcash_deserialize<R: Read>(mut reader: R) -> Result<Self, SerializationError> {
|
||||||
let bytes = reader.read_32_bytes()?;
|
let bytes = reader.read_32_bytes()?;
|
||||||
|
|
||||||
Ok(Self(bytes))
|
Ok(Self(bytes.into()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::fmt::HexDebug;
|
||||||
|
|
||||||
/// Nullifier seed, named rho in the [spec][ps].
|
/// Nullifier seed, named rho in the [spec][ps].
|
||||||
///
|
///
|
||||||
/// [ps]: https://zips.z.cash/protocol/protocol.pdf#sproutkeycomponents
|
/// [ps]: https://zips.z.cash/protocol/protocol.pdf#sproutkeycomponents
|
||||||
|
@ -11,23 +13,23 @@ use serde::{Deserialize, Serialize};
|
||||||
any(test, feature = "proptest-impl"),
|
any(test, feature = "proptest-impl"),
|
||||||
derive(proptest_derive::Arbitrary)
|
derive(proptest_derive::Arbitrary)
|
||||||
)]
|
)]
|
||||||
pub struct NullifierSeed(pub(crate) [u8; 32]);
|
pub struct NullifierSeed(pub(crate) HexDebug<[u8; 32]>);
|
||||||
|
|
||||||
impl AsRef<[u8]> for NullifierSeed {
|
impl AsRef<[u8]> for NullifierSeed {
|
||||||
fn as_ref(&self) -> &[u8] {
|
fn as_ref(&self) -> &[u8] {
|
||||||
&self.0
|
self.0.as_ref()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<[u8; 32]> for NullifierSeed {
|
impl From<[u8; 32]> for NullifierSeed {
|
||||||
fn from(bytes: [u8; 32]) -> Self {
|
fn from(bytes: [u8; 32]) -> Self {
|
||||||
Self(bytes)
|
Self(bytes.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<NullifierSeed> for [u8; 32] {
|
impl From<NullifierSeed> for [u8; 32] {
|
||||||
fn from(rho: NullifierSeed) -> Self {
|
fn from(rho: NullifierSeed) -> Self {
|
||||||
rho.0
|
*rho.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,22 +39,22 @@ impl From<NullifierSeed> for [u8; 32] {
|
||||||
any(test, feature = "proptest-impl"),
|
any(test, feature = "proptest-impl"),
|
||||||
derive(proptest_derive::Arbitrary)
|
derive(proptest_derive::Arbitrary)
|
||||||
)]
|
)]
|
||||||
pub struct Nullifier(pub [u8; 32]);
|
pub struct Nullifier(pub HexDebug<[u8; 32]>);
|
||||||
|
|
||||||
impl From<[u8; 32]> for Nullifier {
|
impl From<[u8; 32]> for Nullifier {
|
||||||
fn from(bytes: [u8; 32]) -> Self {
|
fn from(bytes: [u8; 32]) -> Self {
|
||||||
Self(bytes)
|
Self(bytes.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Nullifier> for [u8; 32] {
|
impl From<Nullifier> for [u8; 32] {
|
||||||
fn from(n: Nullifier) -> Self {
|
fn from(n: Nullifier) -> Self {
|
||||||
n.0
|
*n.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&Nullifier> for [u8; 32] {
|
impl From<&Nullifier> for [u8; 32] {
|
||||||
fn from(n: &Nullifier) -> Self {
|
fn from(n: &Nullifier) -> Self {
|
||||||
n.0
|
*n.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -963,7 +963,7 @@ fn v4_transaction_with_conflicting_sprout_nullifier_across_joinsplits_is_rejecte
|
||||||
// Add a new joinsplit with the duplicate nullifier
|
// Add a new joinsplit with the duplicate nullifier
|
||||||
let mut new_joinsplit = joinsplit_data.first.clone();
|
let mut new_joinsplit = joinsplit_data.first.clone();
|
||||||
new_joinsplit.nullifiers[0] = duplicate_nullifier;
|
new_joinsplit.nullifiers[0] = duplicate_nullifier;
|
||||||
new_joinsplit.nullifiers[1] = sprout::note::Nullifier([2u8; 32]);
|
new_joinsplit.nullifiers[1] = sprout::note::Nullifier([2u8; 32].into());
|
||||||
|
|
||||||
joinsplit_data.rest.push(new_joinsplit);
|
joinsplit_data.rest.push(new_joinsplit);
|
||||||
|
|
||||||
|
@ -1981,8 +1981,8 @@ fn mock_sprout_join_split_data() -> (JoinSplitData<Groth16Proof>, ed25519::Signi
|
||||||
.try_into()
|
.try_into()
|
||||||
.expect("Invalid JoinSplit transparent input");
|
.expect("Invalid JoinSplit transparent input");
|
||||||
let anchor = sprout::tree::Root::default();
|
let anchor = sprout::tree::Root::default();
|
||||||
let first_nullifier = sprout::note::Nullifier([0u8; 32]);
|
let first_nullifier = sprout::note::Nullifier([0u8; 32].into());
|
||||||
let second_nullifier = sprout::note::Nullifier([1u8; 32]);
|
let second_nullifier = sprout::note::Nullifier([1u8; 32].into());
|
||||||
let commitment = sprout::commitment::NoteCommitment::from([0u8; 32]);
|
let commitment = sprout::commitment::NoteCommitment::from([0u8; 32]);
|
||||||
let ephemeral_key = x25519::PublicKey::from(&x25519::EphemeralSecret::new(rand::thread_rng()));
|
let ephemeral_key = x25519::PublicKey::from(&x25519::EphemeralSecret::new(rand::thread_rng()));
|
||||||
let random_seed = sprout::RandomSeed::from([0u8; 32]);
|
let random_seed = sprout::RandomSeed::from([0u8; 32]);
|
||||||
|
|
|
@ -15,7 +15,7 @@ impl IntoDisk for sprout::Nullifier {
|
||||||
type Bytes = [u8; 32];
|
type Bytes = [u8; 32];
|
||||||
|
|
||||||
fn as_bytes(&self) -> Self::Bytes {
|
fn as_bytes(&self) -> Self::Bytes {
|
||||||
self.0
|
*self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ impl IntoDisk for sapling::Nullifier {
|
||||||
type Bytes = [u8; 32];
|
type Bytes = [u8; 32];
|
||||||
|
|
||||||
fn as_bytes(&self) -> Self::Bytes {
|
fn as_bytes(&self) -> Self::Bytes {
|
||||||
self.0
|
*self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue