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

MantaPay v1 #286

Merged
merged 36 commits into from
Dec 3, 2022
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
33e76eb
utxo protocol
SupremoUGH Nov 24, 2022
7b5f578
utxo finished
SupremoUGH Nov 24, 2022
7d2874d
sender and receiver
SupremoUGH Nov 24, 2022
5896feb
transfer mod finished
SupremoUGH Nov 24, 2022
d762ad6
wallet done
SupremoUGH Nov 25, 2022
19c49ea
mantapay config
SupremoUGH Nov 25, 2022
d5a9e62
mantapay config works
SupremoUGH Nov 25, 2022
63a3de4
tests
SupremoUGH Nov 25, 2022
b2720e2
signer base fixed
SupremoUGH Nov 29, 2022
2e1a03b
signer client
SupremoUGH Nov 29, 2022
4f9a6bb
parameters + testing
SupremoUGH Nov 29, 2022
eed927e
parameters, test, simulation and binaries
SupremoUGH Nov 29, 2022
f5d957e
benchmark
SupremoUGH Nov 29, 2022
9905cde
sdk
SupremoUGH Nov 29, 2022
4a714cf
re-exports in manta-pay
SupremoUGH Nov 29, 2022
7eda1b1
feature issue solved
SupremoUGH Nov 29, 2022
9853cdf
docs
SupremoUGH Nov 29, 2022
9fbbdf5
changelog
SupremoUGH Nov 29, 2022
c4e0eec
sample impls revised
SupremoUGH Nov 30, 2022
a451d2e
sample issue solved in tests
SupremoUGH Nov 30, 2022
83ba1dd
balance tests
SupremoUGH Nov 30, 2022
5ce37e4
DEFAULT_BRANCH changed
SupremoUGH Nov 30, 2022
ce575e7
zero signature issue tested and fixed
SupremoUGH Nov 30, 2022
7d31418
Apply suggestions from code review
SupremoUGH Dec 1, 2022
1982dd6
some comments addressed
SupremoUGH Dec 1, 2022
5b811bc
more comments addressed
SupremoUGH Dec 1, 2022
655b194
sample issue solved
SupremoUGH Dec 1, 2022
e481aec
public fields made private again
SupremoUGH Dec 1, 2022
c7b1e94
compat deleted
SupremoUGH Dec 1, 2022
6142d47
FIXME
SupremoUGH Dec 1, 2022
cc64ef9
parameters branch changed to main + feature issue solved
SupremoUGH Dec 1, 2022
563e95d
feature issue solved
SupremoUGH Dec 1, 2022
814f082
Apply suggestions from code review
bhgomes Dec 3, 2022
aa1f3fd
fix: use corrections from PR review
bhgomes Dec 3, 2022
e34f844
chore: remove extra FIXME
bhgomes Dec 3, 2022
c0e7876
chore: fix test dependencies
bhgomes Dec 3, 2022
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
- [\#286](https://github.com/Manta-Network/manta-rs/pull/286) MantaPay v1.0.0

### Changed
- [\#283](https://github.com/Manta-Network/manta-rs/pull/283) Upgrade asset system.
Expand Down
6 changes: 2 additions & 4 deletions manta-accounting/src/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -879,9 +879,8 @@ impl<K, I, V> AssetMap<I, V> for BTreeAssetMap<K, I, V>
where
K: Clone + Ord,
I: Clone + Ord,
V: AddAssign + Clone + Default + Ord + Sub<Output = V>,
V: AddAssign + Clone + Default + Ord + Sub<Output = V> + for<'v> AddAssign<&'v V>,
for<'v> &'v V: Sub<Output = V>,
for<'v> &'v V: AddAssign<&'v V>,
{
impl_asset_map_for_maps_body! { K, I, V, BTreeMapEntry }
}
Expand All @@ -897,9 +896,8 @@ impl<K, I, V, S> AssetMap<I, V> for HashAssetMap<K, I, V, S>
where
K: Clone + Hash + Eq,
I: Clone + Ord,
V: AddAssign + Clone + Default + Ord + Sub<Output = V>,
V: AddAssign + Clone + Default + Ord + Sub<Output = V> + for<'v> AddAssign<&'v V>,
for<'v> &'v V: Sub<Output = V>,
for<'v> &'v V: AddAssign<&'v V>,
S: BuildHasher + Default,
{
impl_asset_map_for_maps_body! { K, I, V, HashMapEntry }
Expand Down
2 changes: 1 addition & 1 deletion manta-accounting/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ where
M: AccountMap<Account = AccountIndex>,
{
/// Account Collection
keys: H,
pub keys: H, // This has been made public because of compatibility issues with sdk.
SupremoUGH marked this conversation as resolved.
Show resolved Hide resolved

/// Account Map
accounts: M,
Expand Down
66 changes: 54 additions & 12 deletions manta-accounting/src/transfer/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,43 @@

// TODO: Move more of the batching algorithm here to improve library interfaces.

use crate::transfer::{Asset, Configuration, Parameters, PreSender, Receiver, SpendingKey, Utxo};
use crate::transfer::{
internal_pair, internal_zero_pair, Address, Asset, AuthorizationContext, Configuration,
Parameters, PreSender, Receiver, UtxoAccumulatorItem, UtxoAccumulatorModel,
};
use alloc::vec::Vec;
use core::{fmt::Debug, hash::Hash};
use manta_crypto::{
accumulator::Accumulator,
rand::{CryptoRng, Rand, RngCore},
rand::{CryptoRng, RngCore},
};
use manta_util::into_array_unchecked;

#[cfg(feature = "serde")]
use manta_util::serde::{Deserialize, Serialize};

/// Batch Join Structure
#[cfg_attr(
feature = "serde",
derive(Deserialize, Serialize),
serde(
bound(
deserialize = "PreSender<C>: Deserialize<'de>",
serialize = "PreSender<C>: Serialize",
),
crate = "manta_util::serde",
deny_unknown_fields
)
)]
#[derive(derivative::Derivative)]
#[derivative(
Clone(bound = "PreSender<C>: Clone"),
Debug(bound = "PreSender<C>: Debug"),
Default(bound = "PreSender<C>: Default"),
Eq(bound = "PreSender<C>: Eq"),
Hash(bound = "PreSender<C>: Hash"),
PartialEq(bound = "PreSender<C>: PartialEq")
)]
pub struct Join<C>
where
C: Configuration,
Expand All @@ -42,25 +70,39 @@ impl<C> Join<C>
where
C: Configuration,
{
/// Builds a new [`Join`] for `asset` using `spending_key` and `zero_key`.
/// Builds a new [`Join`] for `asset` using `address`.
#[inline]
pub fn new<R, const RECEIVERS: usize>(
parameters: &Parameters<C>,
authorization_context: &mut AuthorizationContext<C>,
address: Address<C>,
asset: Asset<C>,
spending_key: &SpendingKey<C>,
rng: &mut R,
) -> ([Receiver<C>; RECEIVERS], Self)
where
R: CryptoRng + RngCore + ?Sized,
{
let mut receivers = Vec::with_capacity(RECEIVERS);
let mut zeroes = Vec::with_capacity(RECEIVERS - 1);
let (receiver, pre_sender) =
spending_key.internal_pair(parameters, rng.gen(), asset.clone());
let asset_id = asset.id.clone();
let (receiver, pre_sender) = internal_pair::<C, _>(
parameters,
authorization_context,
address.clone(),
asset,
Default::default(),
rng,
);
receivers.push(receiver);
for _ in 1..RECEIVERS {
let (receiver, pre_sender) =
spending_key.internal_zero_pair(parameters, rng.gen(), asset.id.clone());
let (receiver, pre_sender) = internal_zero_pair::<C, _>(
parameters,
authorization_context,
address.clone(),
asset_id.clone(),
Default::default(),
rng,
);
receivers.push(receiver);
zeroes.push(pre_sender);
}
Expand All @@ -69,13 +111,13 @@ where

/// Inserts UTXOs for each sender in `self` into the `utxo_accumulator` for future proof selection.
#[inline]
pub fn insert_utxos<A>(&self, utxo_accumulator: &mut A)
pub fn insert_utxos<A>(&self, parameters: &Parameters<C>, utxo_accumulator: &mut A)
where
A: Accumulator<Item = Utxo<C>, Model = C::UtxoAccumulatorModel>,
A: Accumulator<Item = UtxoAccumulatorItem<C>, Model = UtxoAccumulatorModel<C>>,
{
self.pre_sender.insert_utxo(utxo_accumulator);
self.pre_sender.insert_utxo(parameters, utxo_accumulator);
for zero in &self.zeroes {
zero.insert_utxo(utxo_accumulator);
zero.insert_utxo(parameters, utxo_accumulator);
}
}
}
Loading