Add zone funds spending logic

First iteration of the death constraint for spending zone funds
This commit is contained in:
Giacomo Pasini 2024-07-16 16:56:28 +02:00
parent e517ca9f00
commit 201c3810d3
No known key found for this signature in database
GPG Key ID: FC08489D2D895D4B
4 changed files with 18 additions and 3 deletions

View File

@ -51,6 +51,10 @@ impl NullifierSecret {
let commit_bytes: [u8; 32] = hasher.finalize().into();
NullifierCommitment(commit_bytes)
}
pub fn from_bytes(bytes: [u8; 16]) -> Self {
Self(bytes)
}
}
impl NullifierCommitment {
@ -73,6 +77,10 @@ impl NullifierNonce {
pub fn as_bytes(&self) -> &[u8; 16] {
&self.0
}
pub fn from_bytes(bytes: [u8; 16]) -> Self {
Self(bytes)
}
}
impl Nullifier {
@ -86,7 +94,7 @@ impl Nullifier {
Self(nf_bytes)
}
pub(crate) fn as_bytes(&self) -> &[u8; 32] {
pub fn as_bytes(&self) -> &[u8; 32] {
&self.0
}
}

View File

@ -12,9 +12,15 @@ const MAX_OUTPUTS: usize = 8;
/// The partial transaction commitment couples an input to a partial transaction.
/// Prevents partial tx unbundling.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct PtxRoot(pub [u8; 32]);
impl From<[u8; 32]> for PtxRoot {
fn from(bytes: [u8; 32]) -> Self {
Self(bytes)
}
}
impl PtxRoot {
pub fn random(mut rng: impl RngCore) -> Self {
let mut sk = [0u8; 32];

View File

@ -1 +1,2 @@
pub mod input;
pub mod zone_funds;

View File

@ -7,5 +7,5 @@ edition = "2021"
risc0-build = { version = "1.0" }
[package.metadata.risc0]
methods = ["input"]
methods = ["input", "withdraw"]