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

Export Signer to WASM #314

Merged
merged 47 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
0f04381
stateless signer
SupremoUGH Jan 31, 2023
8dcc1a6
added file
SupremoUGH Jan 31, 2023
ac0d107
docs
SupremoUGH Jan 31, 2023
4848e1e
exposed methods
SupremoUGH Jan 31, 2023
cb28bc5
changelog
SupremoUGH Jan 31, 2023
e55c943
docs
SupremoUGH Jan 31, 2023
4ece585
features
SupremoUGH Feb 1, 2023
e393cb6
removed useless pub use
SupremoUGH Feb 1, 2023
6c36193
features
SupremoUGH Feb 1, 2023
0c17f02
removed unnecessary trait
SupremoUGH Feb 1, 2023
bc59651
utxo utilities removed
SupremoUGH Feb 1, 2023
44e83e7
comments addressed
SupremoUGH Feb 2, 2023
ec09c16
updated dependency
SupremoUGH Feb 2, 2023
02b0b24
chaged hashmap to btreemap
SupremoUGH Feb 2, 2023
cdd9d32
serialize and deserialize for parameters
SupremoUGH Feb 2, 2023
552cb7d
fixed encryption serialize
SupremoUGH Feb 3, 2023
867940a
derived traits utxo_commitment scheme
SupremoUGH Feb 3, 2023
a99ac72
impls for Mnemonic and keysecret
SupremoUGH Feb 3, 2023
0cf7d51
hash for proof
SupremoUGH Feb 3, 2023
90a6f9e
derive traits for proving context
SupremoUGH Feb 3, 2023
c7b3d1a
option to result
SupremoUGH Feb 3, 2023
8295d72
fake u8
SupremoUGH Feb 3, 2023
165c86f
Identifier Type
SupremoUGH Feb 3, 2023
ba1650d
back to option
SupremoUGH Feb 3, 2023
9da8d73
filename change
SupremoUGH Feb 6, 2023
a8ed6bb
new method
SupremoUGH Feb 6, 2023
befee29
wallet and walleterror exposed
SupremoUGH Feb 6, 2023
11e5a10
sign with transaction data
SupremoUGH Feb 6, 2023
8230a55
docs
SupremoUGH Feb 6, 2023
cf252e0
hash method
SupremoUGH Feb 6, 2023
d03fa2e
sign with data response exposed type
SupremoUGH Feb 6, 2023
6a1c4b5
docs
SupremoUGH Feb 6, 2023
f078959
feature issue solved
SupremoUGH Feb 7, 2023
0f32df5
small changes
SupremoUGH Feb 7, 2023
535b4d4
transaction data test
SupremoUGH Feb 7, 2023
39ce356
removed network feature
SupremoUGH Feb 7, 2023
afc6ba6
u8 to usize
SupremoUGH Feb 7, 2023
5e6bb3a
network error
SupremoUGH Feb 7, 2023
029b0a0
improved transactiondata verification
SupremoUGH Feb 8, 2023
992f5e5
Apply suggestions from code review
SupremoUGH Feb 9, 2023
f658ce8
storage API + signer from mnemonic
SupremoUGH Feb 9, 2023
61db421
Merge branch 'feat/good_stateless_signer' of https://github.com/Manta…
SupremoUGH Feb 9, 2023
1f93fd7
reverted bip32 to 0.3.0
SupremoUGH Feb 10, 2023
25d021d
new_signer_from_model
SupremoUGH Feb 12, 2023
d794d55
fmt
SupremoUGH Feb 12, 2023
baf6aa0
chore: fix docs CI
bhgomes Feb 13, 2023
0d11e7f
new_signer_from_model calls new_signer and clippy issues
SupremoUGH Feb 13, 2023
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
- [\#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
39 changes: 39 additions & 0 deletions manta-accounting/src/transfer/canonical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,4 +738,43 @@ where
{
self.reconstruct_utxo(parameters, address).eq(utxos)
}

/// Returns the [`TransferShape`] of `self`.
#[inline]
pub fn shape(&self) -> TransferShape {
match self {
Self::ToPrivate(_, _) => TransferShape::ToPrivate,
Self::PrivateTransfer(_) => TransferShape::PrivateTransfer,
Self::ToPublic(_, _) => TransferShape::ToPublic,
}
}

/// Verifies `self` against `transferpost`.
#[inline]
pub fn verify(
&self,
parameters: &Parameters<C>,
address: &Address<C>,
transferpost: TransferPost<C>,
) -> bool
where
Utxo<C>: PartialEq,
{
if !TransferShape::from_post(&transferpost)
SupremoUGH marked this conversation as resolved.
Show resolved Hide resolved
.map(|shape| shape.eq(&self.shape()))
.unwrap_or(false)
{
return false;
}
self.check_transaction_data(
parameters,
address,
&transferpost
.body
.receiver_posts
.into_iter()
.map(|receiver_post| receiver_post.utxo)
.collect(),
)
}
}
4 changes: 3 additions & 1 deletion manta-accounting/src/transfer/utxo/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2397,9 +2397,11 @@ where
Default(bound = "UtxoCommitmentRandomness<C>: Default"),
Eq(bound = "UtxoCommitmentRandomness<C>: Eq"),
Hash(bound = "UtxoCommitmentRandomness<C>: Hash"),
Ord(bound = "UtxoCommitmentRandomness<C>: Ord"),
PartialEq(
bound = "UtxoCommitmentRandomness<C>: core::cmp::PartialEq<UtxoCommitmentRandomness<C>>"
)
),
PartialOrd(bound = "UtxoCommitmentRandomness<C>: PartialOrd")
)]
pub struct Identifier<C>
where
Expand Down
30 changes: 27 additions & 3 deletions manta-accounting/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ use crate::{
ledger::ReadResponse,
signer::{
BalanceUpdate, IdentityRequest, IdentityResponse, SignError, SignRequest, SignResponse,
SyncData, SyncError, SyncRequest, SyncResponse, TransactionDataRequest,
TransactionDataResponse,
SignWithTransactionDataResponse, SyncData, SyncError, SyncRequest, SyncResponse,
TransactionDataRequest, TransactionDataResponse,
},
},
};
Expand Down Expand Up @@ -386,7 +386,8 @@ where
.map_err(Error::SignError)
}

/// Attempts to process TransferPosts and returns the corresponding TransactionData.
/// Attempts to process [`TransferPost`]s and returns the corresponding
/// [`TransactionData`](crate::transfer::canonical::TransactionData).
#[inline]
pub async fn transaction_data(
&mut self,
Expand Down Expand Up @@ -456,6 +457,29 @@ where
pub async fn address(&mut self) -> Result<Address<C>, S::Error> {
self.signer.address().await
}

/// Signs `transaction` and returns the [`TransferPost`]s and the
/// associated [`TransactionData`](crate::transfer::canonical::TransactionData) if successful.
#[inline]
pub async fn sign_with_transaction_data(
&mut self,
transaction: Transaction<C>,
metadata: Option<S::AssetMetadata>,
) -> Result<SignWithTransactionDataResponse<C>, Error<C, L, S>>
where
TransferPost<C>: Clone,
{
self.check(&transaction)
.map_err(Error::InsufficientBalance)?;
self.signer
.sign_with_transaction_data(SignRequest {
transaction,
metadata,
})
.await
.map_err(Error::SignerConnectionError)?
.map_err(Error::SignError)
}
}

/// Inconsistency Error
Expand Down
Loading