Skip to content

Commit

Permalink
new_signer_from_model
Browse files Browse the repository at this point in the history
  • Loading branch information
SupremoUGH committed Feb 12, 2023
1 parent 1f93fd7 commit 25d021d
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion manta-pay/src/signer/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::{
},
};
use manta_accounting::wallet::signer::{functions, StorageState};
use manta_crypto::rand::FromEntropy;
use manta_crypto::{accumulator::Accumulator, rand::FromEntropy};

/// Builds a new [`Signer`] from `mnemonic`, `password`, `parameters`, `proving_context`
/// and `utxo_accumulator`.
Expand All @@ -49,6 +49,31 @@ pub fn new_signer(
)
}

/// Builds a new [`Signer`] from `mnemonic`, `password`, `parameters`, `proving_context`
/// and `utxo_accumulator_model`.
///
/// # Implementation Note
///
/// The signer initialized in this way has an empty state and must be synchronized from scratch,
/// which is a time-consuming operation. One should favor the `new_signer` and
/// `initialize_signer_from_storage` functions when possible.
#[inline]
pub fn new_signer_from_model(
mnemonic: Mnemonic,
password: &str,
parameters: Parameters,
proving_context: MultiProvingContext,
utxo_accumulator_model: &UtxoAccumulatorModel,
) -> Signer {
Signer::new(
AccountTable::new(KeySecret::new(mnemonic, password)),
parameters,
proving_context,
Accumulator::empty(utxo_accumulator_model),
FromEntropy::from_entropy(),
)
}

/// Initializes a [`Signer`] from `storage_state`, `mnemonic`, `password`,
/// `parameters` and `proving_context`.
pub fn initialize_signer_from_storage(
Expand Down

0 comments on commit 25d021d

Please sign in to comment.