Skip to content

Commit

Permalink
seals: add nonce to seal constructor
Browse files Browse the repository at this point in the history
this should allow creating different seals when the same outpoint is used
  • Loading branch information
dr-orlovsky committed Dec 16, 2024
1 parent eadb08c commit 961885b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions seals/src/txout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,16 @@ impl<D: dbc::Proof> Ord for TxoSeal<D> {
}

impl<D: dbc::Proof> TxoSeal<D> {
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)
}

Check warning on line 190 in seals/src/txout.rs

View check run for this annotation

Codecov / codecov/patch

seals/src/txout.rs#L188-L190

Added lines #L188 - L190 were not covered by tests

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];
Expand Down

0 comments on commit 961885b

Please sign in to comment.