Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key Dependent Signer Function APIs #319

Merged
merged 9 commits into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]
### Added
- [\#319](https://github.com/Manta-Network/manta-rs/pull/319) Key-dependent signer function APIs.
- [\#314](https://github.com/Manta-Network/manta-rs/pull/314) Prepares the signer export to wasm.
- [\#289](https://github.com/Manta-Network/manta-rs/pull/289) AssetMetadata upgrade and NFT support.
- [\#310](https://github.com/Manta-Network/manta-rs/pull/310) Add identity verification algorithm using ToPublic circuit
Expand Down
7 changes: 7 additions & 0 deletions manta-accounting/src/transfer/utxo/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2256,6 +2256,13 @@ where
}
}

impl<C> cmp::Eq for AuthorizationContext<C>
where
C: BaseConfiguration<Bool = bool>,
C::Group: cmp::PartialEq,
{
}

impl<C, COM> Variable<Secret, COM> for AuthorizationContext<C, COM>
where
COM: Has<bool, Type = C::Bool>,
Expand Down
11 changes: 10 additions & 1 deletion manta-accounting/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ where
InconsistencyError::SignerSynchronization,
))
}
Err(SyncError::MissingProofAuthorizationKey) => {
Err(Error::MissingProofAuthorizationKey)
}
}
}

Expand Down Expand Up @@ -454,7 +457,7 @@ where

/// Returns the address.
#[inline]
pub async fn address(&mut self) -> Result<Address<C>, S::Error> {
pub async fn address(&mut self) -> Result<Option<Address<C>>, S::Error> {
self.signer.address().await
}

Expand Down Expand Up @@ -577,6 +580,12 @@ where

/// Ledger Connection Error
LedgerConnectionError(L::Error),

/// Missing Spending Key Error
MissingSpendingKey,

/// Missing Proof Authorization Key Error
MissingProofAuthorizationKey,
}

impl<C, L, S> From<InconsistencyError> for Error<C, L, S>
Expand Down
15 changes: 7 additions & 8 deletions manta-accounting/src/wallet/signer/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ where

/// Returns the default authorization context for `accounts`.
#[inline]
fn default_authorization_context<C>(
pub fn default_authorization_context<C>(
accounts: &AccountTable<C>,
parameters: &C::Parameters,
) -> AuthorizationContext<C>
Expand Down Expand Up @@ -198,7 +198,7 @@ where
#[allow(clippy::too_many_arguments)]
#[inline]
fn sync_with<C, I>(
accounts: &AccountTable<C>,
authorization_context: &mut AuthorizationContext<C>,
assets: &mut C::AssetMap,
checkpoint: &mut C::Checkpoint,
utxo_accumulator: &mut C::UtxoAccumulator,
Expand All @@ -215,13 +215,12 @@ where
let nullifier_count = nullifiers.len();
let mut deposit = Vec::new();
let mut withdraw = Vec::new();
let mut authorization_context = default_authorization_context::<C>(accounts, parameters);
let decryption_key = parameters.derive_decryption_key(&mut authorization_context);
let decryption_key = parameters.derive_decryption_key(authorization_context);
for (utxo, note) in inserts {
if let Some((identifier, asset)) = parameters.open_with_check(&decryption_key, &utxo, note)
{
insert_next_item::<C>(
&mut authorization_context,
authorization_context,
utxo_accumulator,
assets,
parameters,
Expand All @@ -238,7 +237,7 @@ where
assets.retain(|identifier, assets| {
assets.retain(|asset| {
is_asset_unspent::<C>(
&mut authorization_context,
authorization_context,
utxo_accumulator,
parameters,
identifier.clone(),
Expand Down Expand Up @@ -604,7 +603,7 @@ where
#[inline]
pub fn sync<C>(
parameters: &SignerParameters<C>,
accounts: &AccountTable<C>,
authorization_context: &mut AuthorizationContext<C>,
assets: &mut C::AssetMap,
checkpoint: &mut C::Checkpoint,
utxo_accumulator: &mut C::UtxoAccumulator,
Expand Down Expand Up @@ -633,7 +632,7 @@ where
nullifier_data,
} = request.data;
let response = sync_with::<C, _>(
accounts,
authorization_context,
assets,
checkpoint,
utxo_accumulator,
Expand Down
Loading