From 35df009837adbf53fa0093bda3ce1aa4dd085c29 Mon Sep 17 00:00:00 2001 From: Artem Gureev Date: Fri, 3 Jul 2026 14:03:53 +0000 Subject: [PATCH] feat(lee): add for_dummy nullifier and commitment derivations --- lee/state_machine/core/src/commitment.rs | 14 +++++++++++++- lee/state_machine/core/src/nullifier.rs | 8 ++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lee/state_machine/core/src/commitment.rs b/lee/state_machine/core/src/commitment.rs index 92085d7d..79e73e7f 100644 --- a/lee/state_machine/core/src/commitment.rs +++ b/lee/state_machine/core/src/commitment.rs @@ -2,7 +2,10 @@ use borsh::{BorshDeserialize, BorshSerialize}; use risc0_zkvm::sha::{Impl, Sha256 as _}; use serde::{Deserialize, Serialize}; -use crate::account::{Account, AccountId}; +use crate::{ + Nullifier, + account::{Account, AccountId}, +}; /// A commitment to all zero data. /// ```python @@ -78,6 +81,15 @@ impl Commitment { bytes.extend_from_slice(&account_bytes_with_hashed_data); Self(Impl::hash_bytes(&bytes).as_bytes().try_into().unwrap()) } + + #[must_use] + pub fn for_dummy(nullifier: &Nullifier, commitment_seed: &[u8; 32]) -> Self { + const DUMMY_PREFIX: &[u8; 32] = b"/LEE/v0.3/Commitment/Dummy/\x00\x00\x00\x00\x00"; + let mut bytes = DUMMY_PREFIX.to_vec(); + bytes.extend_from_slice(&nullifier.0); + bytes.extend_from_slice(commitment_seed); + Self(Impl::hash_bytes(&bytes).as_bytes().try_into().unwrap()) + } } pub type CommitmentSetDigest = [u8; 32]; diff --git a/lee/state_machine/core/src/nullifier.rs b/lee/state_machine/core/src/nullifier.rs index 0374a31a..b7f86289 100644 --- a/lee/state_machine/core/src/nullifier.rs +++ b/lee/state_machine/core/src/nullifier.rs @@ -109,6 +109,14 @@ impl Nullifier { bytes.extend_from_slice(account_id.value()); Self(Impl::hash_bytes(&bytes).as_bytes().try_into().unwrap()) } + + #[must_use] + pub fn for_dummy(nullifier_seed: &[u8; 32]) -> Self { + const DUMMY_PREFIX: &[u8; 32] = b"/LEE/v0.3/Nullifier/Dummy/\x00\x00\x00\x00\x00\x00"; + let mut bytes = DUMMY_PREFIX.to_vec(); + bytes.extend_from_slice(nullifier_seed); + Self(Impl::hash_bytes(&bytes).as_bytes().try_into().unwrap()) + } } #[cfg(test)]