From 25d021d54a197931baa88a6da96e8b38cfe0bb9a Mon Sep 17 00:00:00 2001 From: SupremoUGH Date: Sun, 12 Feb 2023 11:52:47 +0100 Subject: [PATCH] new_signer_from_model --- manta-pay/src/signer/functions.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/manta-pay/src/signer/functions.rs b/manta-pay/src/signer/functions.rs index 83e66a64b..e14155885 100644 --- a/manta-pay/src/signer/functions.rs +++ b/manta-pay/src/signer/functions.rs @@ -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`. @@ -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(