From 961885bd7f0d30f32a759089ee077a32b1325dbf Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Mon, 16 Dec 2024 16:59:23 +0100 Subject: [PATCH] seals: add nonce to seal constructor this should allow creating different seals when the same outpoint is used --- seals/src/txout.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/seals/src/txout.rs b/seals/src/txout.rs index 6e9ea361..dcaea7c7 100644 --- a/seals/src/txout.rs +++ b/seals/src/txout.rs @@ -183,11 +183,16 @@ impl Ord for TxoSeal { } impl TxoSeal { - pub fn vout_no_fallback(vout: Vout, noise_engine: Sha256) -> Self { - Self::no_fallback(Outpoint::new(Txid::from([0xFFu8; 32]), vout), noise_engine) + /// `nonce` is a deterministic incremental number, preventing from creating the same seal if the + /// same output is used. + pub fn vout_no_fallback(vout: Vout, noise_engine: Sha256, nonce: u64) -> Self { + Self::no_fallback(Outpoint::new(Txid::from([0xFFu8; 32]), vout), noise_engine, nonce) } - pub fn no_fallback(outpoint: Outpoint, mut noise_engine: Sha256) -> Self { + /// `nonce` is a deterministic incremental number, preventing from creating the same seal if the + /// same output is used. + pub fn no_fallback(outpoint: Outpoint, mut noise_engine: Sha256, nonce: u64) -> Self { + noise_engine.input_raw(&nonce.to_be_bytes()); noise_engine.input_raw(outpoint.txid.as_ref()); noise_engine.input_raw(&outpoint.vout.to_u32().to_be_bytes()); let mut noise = [0xFFu8; 40];