Skip to content

Commit

Permalink
feat: gen rand dbc id src from public address
Browse files Browse the repository at this point in the history
  • Loading branch information
oetyng committed Apr 11, 2023
1 parent e8f60d1 commit 6beae69
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/dbc_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ impl PublicAddress {
pub fn new(public_key: PublicKey) -> Self {
Self(public_key)
}

/// A random derivation index and the public address.
/// The random index will be used to derive a DbcId out of the public address.
pub fn random_dbc_id_src(&self, rng: &mut impl RngCore) -> DbcIdSource {
DbcIdSource {
public_address: *self,
derivation_index: random_derivation_index(rng),
}
}

/// Generate a new DbcId from provided DerivationIndex.
/// This is supposed to be a unique identifier of a Dbc.
/// A new Dbc id is generated by someone who wants to send tokens to the PublicAddress.
Expand Down

0 comments on commit 6beae69

Please sign in to comment.