Skip to content

Commit

Permalink
Upgraded the version of the MASP crate that is used.
Browse files Browse the repository at this point in the history
  • Loading branch information
Murisi Tarusenga committed Apr 14, 2023
1 parent d2c9e45 commit e5b5d8b
Show file tree
Hide file tree
Showing 29 changed files with 942 additions and 960 deletions.
499 changes: 233 additions & 266 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ rand_core = {version = "0.6", default-features = false}
rayon = "=1.5.3"
regex = "1.4.5"
reqwest = "0.11.4"
ripemd = "0.1"
rlimit = "0.5.4"
rocksdb = {version = "0.19.0", features = ['zstd', 'jemalloc'], default-features = false}
rpassword = "5.0.1"
Expand Down Expand Up @@ -145,9 +146,8 @@ tracing-log = "0.1.2"
tracing-subscriber = {version = "0.3.7", features = ["env-filter", "json"]}
websocket = "0.26.2"
winapi = "0.3.9"
#libmasp = { git = "https://github.com/anoma/masp", branch = "murisi/masp-incentive" }
masp_primitives = { git = "https://github.com/anoma/masp", rev = "bee40fc465f6afbd10558d12fe96eb1742eee45c", features = ["transparent-inputs"] }
masp_proofs = { git = "https://github.com/anoma/masp", rev = "bee40fc465f6afbd10558d12fe96eb1742eee45c", features = ["bundled-prover", "download-params"] }
masp_primitives = { git = "https://github.com/anoma/masp", branch = "murisi/namada-integration", features = ["transparent-inputs"] }
masp_proofs = { git = "https://github.com/anoma/masp", branch = "murisi/namada-integration", features = ["bundled-prover", "download-params"] }
bimap = {version = "0.6.2", features = ["serde"]}
rust_decimal = "1.26.1"
rust_decimal_macros = "1.26.1"
Expand Down
2 changes: 1 addition & 1 deletion apps/src/lib/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use eyre::{eyre, Context as EyreContext};
use itertools::Itertools;
use masp_primitives::asset_type::AssetType;
use masp_primitives::merkle_tree::MerklePath;
use masp_primitives::primitives::ViewingKey;
use masp_primitives::sapling::ViewingKey;
use masp_primitives::sapling::Node;
use masp_primitives::transaction::components::Amount;
use masp_primitives::zip32::ExtendedFullViewingKey;
Expand Down
4 changes: 0 additions & 4 deletions apps/src/lib/client/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ pub async fn tx_signer(
signing_key
}
TxSigningKey::SecretKey(signing_key) => {
// Check if the signing key needs to reveal its PK first
let pk: common::PublicKey = signing_key.ref_to();
super::tx::reveal_pk_if_needed(ctx, &pk, args).await;
signing_key
}
TxSigningKey::None => {
Expand Down Expand Up @@ -270,7 +267,6 @@ pub async fn sign_wrapper(
tx.add_section(Section::Signature(Signature::new(&tx.header_hash(), keypair)));
// Encrypt all sections not relating to the header
tx.encrypt(&Default::default());

// We use this to determine when the wrapper tx makes it on-chain
let wrapper_hash = tx.header_hash().to_string();
// We use this to determine when the decrypted inner tx makes it
Expand Down
206 changes: 95 additions & 111 deletions apps/src/lib/client/tx.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/src/lib/client/types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use async_trait::async_trait;
use masp_primitives::merkle_tree::MerklePath;
use masp_primitives::primitives::{Diversifier, Note, ViewingKey};
use masp_primitives::sapling::{Diversifier, Note, ViewingKey};
use masp_primitives::sapling::Node;
use masp_primitives::transaction::components::Amount;
use namada::types::address::Address;
Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ ics23 = "0.7.0"
index-set = {git = "https://github.com/heliaxdev/index-set", tag = "v0.7.1", features = ["serialize-borsh", "serialize-serde"]}
itertools = "0.10.0"
libsecp256k1 = {git = "https://github.com/heliaxdev/libsecp256k1", rev = "bbb3bd44a49db361f21d9db80f9a087c194c0ae9", default-features = false, features = ["std", "static-context"]}
masp_primitives = { git = "https://github.com/anoma/masp", rev = "bee40fc465f6afbd10558d12fe96eb1742eee45c" }
masp_primitives = { git = "https://github.com/anoma/masp", branch = "murisi/namada-integration" }
proptest = {git = "https://github.com/heliaxdev/proptest", branch = "tomas/sm", optional = true}
prost = "0.9.0"
prost-types = "0.9.0"
Expand Down
38 changes: 38 additions & 0 deletions core/src/proto/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use crate::types::transaction::WrapperTx;
use sha2::{Digest, Sha256};
use crate::types::transaction::WrapperTxErr;
use masp_primitives::transaction::Transaction;
use serde::de::Error as SerdeError;

#[derive(Error, Debug)]
pub enum Error {
Expand Down Expand Up @@ -298,6 +299,39 @@ impl From<SerializedCiphertext> for Ciphertext {
}
}

#[derive(serde::Serialize, serde::Deserialize)]
struct TransactionSerde(Vec<u8>);

impl From<Vec<u8>> for TransactionSerde {
fn from(tx: Vec<u8>) -> Self {
Self(tx)
}
}

impl Into<Vec<u8>> for TransactionSerde {
fn into(self) -> Vec<u8> {
self.0
}
}

fn borsh_serde<T, S>(obj: &impl BorshSerialize, ser: S) -> std::result::Result<S::Ok, S::Error> where
S: serde::Serializer,
T: From<Vec<u8>>,
T: serde::Serialize,
{
Into::<T>::into(obj.try_to_vec().unwrap()).serialize(ser)
}

fn serde_borsh<'de, T, S, U>(ser: S) -> std::result::Result<U, S::Error> where
S: serde::Deserializer<'de>,
T: Into<Vec<u8>>,
T: serde::Deserialize<'de>,
U: BorshDeserialize,
{
BorshDeserialize::try_from_slice(&Into::<Vec<u8>>::into(T::deserialize(ser)?))
.map_err(S::Error::custom)
}

/// A section of a transaction. Carries an independent piece of information
/// necessary for the processing of a transaction.
#[derive(
Expand All @@ -315,6 +349,10 @@ pub enum Section {
/// Ciphertext obtained by encrypting arbitrary transaction sections
Ciphertext(Ciphertext),
/// Embedded MASP transaction section
#[serde(
serialize_with = "borsh_serde::<TransactionSerde, _>",
deserialize_with = "serde_borsh::<TransactionSerde, _, _>",
)]
MaspTx(Transaction),
}

Expand Down
10 changes: 5 additions & 5 deletions core/src/types/masp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl<'de> serde::Deserialize<'de> for ExtendedViewingKey {
BorshSerialize,
BorshDeserialize,
)]
pub struct PaymentAddress(masp_primitives::primitives::PaymentAddress, bool);
pub struct PaymentAddress(masp_primitives::sapling::PaymentAddress, bool);

impl PaymentAddress {
/// Turn this PaymentAddress into a pinned/unpinned one
Expand All @@ -157,14 +157,14 @@ impl PaymentAddress {
}
}

impl From<PaymentAddress> for masp_primitives::primitives::PaymentAddress {
impl From<PaymentAddress> for masp_primitives::sapling::PaymentAddress {
fn from(addr: PaymentAddress) -> Self {
addr.0
}
}

impl From<masp_primitives::primitives::PaymentAddress> for PaymentAddress {
fn from(addr: masp_primitives::primitives::PaymentAddress) -> Self {
impl From<masp_primitives::sapling::PaymentAddress> for PaymentAddress {
fn from(addr: masp_primitives::sapling::PaymentAddress) -> Self {
Self(addr, false)
}
}
Expand Down Expand Up @@ -222,7 +222,7 @@ impl FromStr for PaymentAddress {
};
let bytes: Vec<u8> = FromBase32::from_base32(&base32)
.map_err(DecodeError::DecodeBase32)?;
masp_primitives::primitives::PaymentAddress::from_bytes(
masp_primitives::sapling::PaymentAddress::from_bytes(
&bytes.try_into().map_err(addr_len_err)?,
)
.ok_or_else(addr_data_err)
Expand Down
6 changes: 3 additions & 3 deletions shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ proptest = {git = "https://github.com/heliaxdev/proptest", branch = "tomas/sm",
prost = "0.9.0"
pwasm-utils = {git = "https://github.com/heliaxdev/wasm-utils", tag = "v0.20.0", features = ["sign_ext"], optional = true}
rayon = {version = "=1.5.3", optional = true}
ripemd = "0.1"
rust_decimal = "1.26.1"
serde_json = "1.0.62"
sha2 = "0.9.3"
Expand All @@ -125,9 +126,8 @@ wasmer-engine-dylib = {version = "=2.2.0", optional = true}
wasmer-engine-universal = {version = "=2.2.0", optional = true}
wasmer-vm = {version = "2.2.0", optional = true}
wasmparser = "0.83.0"
#libmasp = { git = "https://github.com/anoma/masp", branch = "murisi/masp-incentive" }
masp_primitives = { git = "https://github.com/anoma/masp", rev = "bee40fc465f6afbd10558d12fe96eb1742eee45c" }
masp_proofs = { git = "https://github.com/anoma/masp", rev = "bee40fc465f6afbd10558d12fe96eb1742eee45c" }
masp_primitives = { git = "https://github.com/anoma/masp", branch = "murisi/namada-integration" }
masp_proofs = { git = "https://github.com/anoma/masp", branch = "murisi/namada-integration" }
zeroize = "1.5.5"

[dev-dependencies]
Expand Down
Loading

0 comments on commit e5b5d8b

Please sign in to comment.