Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
0a6f16f
Add FMD flag ciphertext sechash to transfer data
sug0 Mar 24, 2025
bf818ef
Add flag ciphertexts domain type
sug0 Apr 15, 2025
1398d69
Allow large client ctx enum variant
sug0 Apr 16, 2025
f2a0b7d
Extend IBC shielding data with flag ciphertext
sug0 Apr 16, 2025
1e9c6c2
Import FMD dependency to workspace
sug0 Apr 23, 2025
402c423
Move FMD code to new module
sug0 Apr 23, 2025
3420539
Import new deps
sug0 Apr 23, 2025
0ca4b48
Wrap polyfuzzy's flag ciphertext type
sug0 Apr 23, 2025
0ced13a
Improve parameter docs
sug0 Apr 23, 2025
8d25a74
Improve default implementation of flag ciphertext
sug0 Apr 23, 2025
2fa1459
Validate compressed bit ciphertexts
sug0 Apr 23, 2025
1ad37fd
Export flag ciphertext from sdk
sug0 Apr 24, 2025
34f2a3c
Create tx data section from borsh encodable data
sug0 Apr 24, 2025
93e8838
Extended bench txs with fmd flag section
sug0 Apr 24, 2025
6f488d9
Switch to transparent repr in flag ciphertext
sug0 Apr 30, 2025
efcb4a9
Improve flag ciphertext PartialEq impl
sug0 Apr 30, 2025
3dc53d6
Test if flag ciphertext is valid
sug0 Apr 30, 2025
4aa8067
Generate random flag ciphertext
sug0 Apr 30, 2025
2982e9b
Impl conversion traits between polyfuzzy and namada_core
sug0 Apr 30, 2025
7399e2a
Refactor FMD borsh impls
sug0 Apr 30, 2025
840e2c8
Test fmd flag ciphertext borsh roundtrip
sug0 Apr 30, 2025
d77876e
Derive FMD secret keys from input vks
sug0 Apr 30, 2025
569134b
Derive FMD secret key from extended spending key
sug0 Apr 30, 2025
a92d2c5
Move polyfuzzy imports
sug0 Apr 30, 2025
b7d3391
Remove unnecessary bounds on secret keys
sug0 Apr 30, 2025
397d77d
Add FMD public keys
sug0 Apr 30, 2025
65e06a4
Export FMD keys
sug0 Apr 30, 2025
724ec42
Define HRP of fmd payment addrs
sug0 May 5, 2025
241bb19
Add domain type for fmd pubkey bytes
sug0 May 5, 2025
336eadd
Add payment addrs with fmd pubkeys
sug0 May 5, 2025
e2c6792
Add new payment addrs to wallet
sug0 May 6, 2025
3a5c41f
Generate v0 payment addrs
sug0 May 6, 2025
bfd957c
Add flag ciphertexts to txs
sug0 May 6, 2025
70eaa07
Validate flag ciphertexts in MASP VP
sug0 May 8, 2025
bf609fe
Emit FMD flag ciphertext tx events
sug0 May 13, 2025
d7d744c
Fix MASP integration test gas costs
sug0 May 14, 2025
113d025
Fix benchmarks
sug0 May 15, 2025
aef297b
Store FMD flag ciphertexts in extra data secs
sug0 May 19, 2025
a90febc
Update tx test vector generation code
sug0 May 20, 2025
e8b2722
Temporarily switch to forked ledger app
sug0 May 19, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ env:
AWS_REGION: us-west-2
NIGHTLY: nightly-2025-03-27
NAMADA_MASP_PARAMS_DIR: /masp/.masp-params
LEDGER_APP_VERSION: "3.0.4"
LEDGER_APP_VERSION: "3.1.3.heliax"
ROLE: arn:aws:iam::375643557360:role/github-runners-ci-shared
SCCACHE_ERROR_LOG: /tmp/sccache_log.txt

Expand Down Expand Up @@ -601,7 +601,7 @@ jobs:
- name: Checkout ledger-namada
run: |
echo "Using Namada Ledger App version: v${LEDGER_APP_VERSION}"
git clone 'https://github.com/Zondax/ledger-namada' ../ledger-namada
git clone 'https://github.com/anoma/ledger-namada' ../ledger-namada
cd ../ledger-namada
git checkout "v$LEDGER_APP_VERSION"
git submodule update --init --recursive
Expand Down
17 changes: 17 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,14 @@ base58 = "0.2"
base64 = "0.22"
bech32 = "0.11"
bimap = {version = "0.6", features = ["serde"]}
bincode = "1.3.3"
bit-set = "0.8"
bitflags = { version = "2.5", features = ["serde"] }
blake2b-rs = "0.2"
borsh = {version = "1.2", features = ["unstable__schema", "derive"]}
byte-unit = "5.1"
byteorder = "1.4"
bytes = "1.1"
borsh = {version = "1.2", features = ["unstable__schema", "derive"]}
cargo_metadata = "0.19"
chrono = {version = "0.4", default-features = false, features = ["clock", "std"]}
circular-queue = "0.2"
Expand Down Expand Up @@ -204,6 +205,7 @@ owo-colors = "4.1"
parity-wasm = { version = "0.45", features = ["sign_ext"] }
paste = "1.0"
patricia_tree = "0.8"
polyfuzzy = "0.5.0"
pretty_assertions = "1.4"
primitive-types = "0.13"
proc-macro2 = "1.0"
Expand Down Expand Up @@ -246,7 +248,7 @@ test-log = {version = "0.2", default-features = false, features = ["trace"]}
textwrap-macros = "0.3"
tiny-bip39 = {version = "2.0"}
tiny-hderive = {package = "nam-tiny-hderive", version = "0.3.1-nam.0"}
tiny-keccak = { version = "2.0", features = ["keccak"] }
tiny-keccak = { version = "2.0", features = ["keccak", "k12"] }
thiserror = "2.0"
tokio = {version = "1.8", default-features = false}
tokio-test = "0.4"
Expand Down
18 changes: 15 additions & 3 deletions crates/apps_lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ pub mod cmds {
}

#[derive(Clone, Debug)]
#[allow(clippy::large_enum_variant)]
pub enum NamadaClientWithContext {
// Ledger cmds
TxCustom(TxCustom),
Expand Down Expand Up @@ -3401,7 +3402,9 @@ pub mod args {

use data_encoding::HEXUPPER;
use either::Either;
use namada_core::masp::{DiversifierIndex, MaspEpoch, PaymentAddress};
use namada_core::masp::{
DiversifierIndex, MaspEpoch, UnifiedPaymentAddress,
};
use namada_sdk::address::{Address, EstablishedAddress};
pub use namada_sdk::args::*;
use namada_sdk::chain::{ChainId, ChainIdPrefix};
Expand Down Expand Up @@ -3628,6 +3631,7 @@ pub mod args {
pub const PAYMENT_ADDRESS_TARGET: Arg<WalletPaymentAddr> = arg("target");
pub const PAYMENT_ADDRESS_TARGET_OPT: ArgOpt<WalletPaymentAddr> =
arg_opt("target-pa");
pub const PAYMENT_ADDRESS_V0: ArgFlag = flag("v0");
pub const PORT_ID: ArgDefault<PortId> = arg_default(
"port-id",
DefaultFn(|| PortId::from_str("transfer").unwrap()),
Expand All @@ -3652,8 +3656,9 @@ pub mod args {
pub const RAW_ADDRESS_ESTABLISHED: Arg<EstablishedAddress> = arg("address");
pub const RAW_ADDRESS_OPT: ArgOpt<Address> = RAW_ADDRESS.opt();
pub const RAW_KEY_GEN: ArgFlag = flag("raw");
pub const RAW_PAYMENT_ADDRESS: Arg<PaymentAddress> = arg("payment-address");
pub const RAW_PAYMENT_ADDRESS_OPT: ArgOpt<PaymentAddress> =
pub const RAW_PAYMENT_ADDRESS: Arg<UnifiedPaymentAddress> =
arg("payment-address");
pub const RAW_PAYMENT_ADDRESS_OPT: ArgOpt<UnifiedPaymentAddress> =
RAW_PAYMENT_ADDRESS.opt();
pub const RAW_PUBLIC_KEY: Arg<common::PublicKey> = arg("public-key");
pub const RAW_PUBLIC_KEY_OPT: ArgOpt<common::PublicKey> =
Expand Down Expand Up @@ -7976,6 +7981,7 @@ pub mod args {
_ctx: &mut Context,
) -> Result<PayAddressGen, Self::Error> {
Ok(PayAddressGen {
v0: self.v0,
alias: self.alias,
alias_force: self.alias_force,
viewing_key: self.viewing_key,
Expand All @@ -7990,11 +7996,13 @@ pub mod args {
let alias_force = ALIAS_FORCE.parse(matches);
let diversifier_index = DIVERSIFIER_INDEX.parse(matches);
let viewing_key = VIEWING_KEY_ALIAS.parse(matches);
let v0 = PAYMENT_ADDRESS_V0.parse(matches);
Self {
alias,
alias_force,
diversifier_index,
viewing_key,
v0,
}
}

Expand All @@ -8009,6 +8017,10 @@ pub mod args {
"Set the viewing key's current diversifier index beforehand."
)))
.arg(VIEWING_KEY.def().help(wrap!("The viewing key.")))
.arg(PAYMENT_ADDRESS_V0.def().help(wrap!(
"Force generating a v0 payment address. Not compatible with \
FMD."
)))
}
}

Expand Down
20 changes: 11 additions & 9 deletions crates/apps_lib/src/cli/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use masp_primitives::zip32::{
ExtendedSpendingKey as MaspExtendedSpendingKey,
};
use namada_core::masp::{
BalanceOwner, ExtendedSpendingKey, ExtendedViewingKey, PaymentAddress,
TransferSource, TransferTarget,
BalanceOwner, ExtendedSpendingKey, ExtendedViewingKey, TransferSource,
TransferTarget, UnifiedPaymentAddress,
};
use namada_sdk::address::{Address, InternalAddress};
use namada_sdk::chain::ChainId;
Expand Down Expand Up @@ -60,7 +60,7 @@ pub type WalletDatedSpendingKey = FromContext<DatedSpendingKey>;

/// A raw payment address (bech32m encoding) or an alias of a payment address
/// in the wallet
pub type WalletPaymentAddr = FromContext<PaymentAddress>;
pub type WalletPaymentAddr = FromContext<UnifiedPaymentAddress>;

/// A raw full viewing key (bech32m encoding) or an alias of a full viewing key
/// in the wallet
Expand Down Expand Up @@ -388,10 +388,11 @@ impl FromContext<TransferTarget> {
}
}

/// Converts this TransferTarget argument to a PaymentAddress. Call this
/// function only when certain that raw represents a PaymentAddress.
pub fn to_payment_address(&self) -> FromContext<PaymentAddress> {
FromContext::<PaymentAddress> {
/// Converts this TransferTarget argument to a UnifiedPaymentAddress. Call
/// this function only when certain that raw represents a
/// UnifiedPaymentAddress.
pub fn to_payment_address(&self) -> FromContext<UnifiedPaymentAddress> {
FromContext::<UnifiedPaymentAddress> {
raw: self.raw.clone(),
phantom: PhantomData,
}
Expand Down Expand Up @@ -690,7 +691,7 @@ impl ArgFromMutContext for DatedViewingKey {
}
}

impl ArgFromContext for PaymentAddress {
impl ArgFromContext for UnifiedPaymentAddress {
fn arg_from_ctx(
ctx: &ChainContext,
raw: impl AsRef<str>,
Expand Down Expand Up @@ -743,7 +744,8 @@ impl ArgFromContext for TransferTarget {
Address::arg_from_ctx(ctx, raw)
.map(Self::Address)
.or_else(|_| {
PaymentAddress::arg_from_ctx(ctx, raw).map(Self::PaymentAddress)
UnifiedPaymentAddress::arg_from_ctx(ctx, raw)
.map(Self::PaymentAddress)
})
}
}
Expand Down
25 changes: 12 additions & 13 deletions crates/apps_lib/src/cli/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use ledger_transport_hid::hidapi::HidApi;
use masp_primitives::zip32::ExtendedFullViewingKey;
use namada_core::chain::BlockHeight;
use namada_core::masp::{
DiversifierIndex, ExtendedSpendingKey, MaspValue, PaymentAddress,
ExtendedSpendingKey, MaspValue, UnifiedPaymentAddress,
};
use namada_sdk::address::{Address, DecodeError};
use namada_sdk::borsh::{BorshDeserialize, BorshSerializeExt};
Expand Down Expand Up @@ -403,6 +403,7 @@ fn payment_address_gen(
alias_force,
viewing_key: viewing_key_alias,
diversifier_index,
v0,
}: args::PayAddressGen,
) {
let mut wallet = load_wallet(ctx);
Expand All @@ -421,23 +422,21 @@ fn payment_address_gen(
.copied()
.unwrap_or_default()
});
let (diversifier_index, masp_payment_addr) =
ExtendedFullViewingKey::from(viewing_key)
.find_address(diversifier_index.into())
.expect("exhausted payment addresses");
let (diversifier_index, payment_addr) = if v0 {
UnifiedPaymentAddress::v0_from_zip32(viewing_key, diversifier_index)
} else {
UnifiedPaymentAddress::v1_from_zip32(viewing_key, diversifier_index)
};
let mut next_div_idx = diversifier_index;
next_div_idx
.increment()
.expect("exhausted payment addresses");
let payment_addr = PaymentAddress::from(masp_payment_addr);
next_div_idx.increment();
let alias = wallet
.insert_payment_addr(alias, payment_addr, alias_force)
.insert_payment_addr(alias, payment_addr.clone(), alias_force)
.unwrap_or_else(|| {
edisplay_line!(io, "Payment address not added");
cli::safe_exit(1);
});
wallet
.insert_diversifier_index(viewing_key_alias, next_div_idx.into())
.insert_diversifier_index(viewing_key_alias, next_div_idx)
.expect(
"must be able to save next diversifier index under the alias of \
the viewing key",
Expand All @@ -447,7 +446,7 @@ fn payment_address_gen(
io,
"Successfully generated payment address {} at index {} with alias {}",
payment_addr,
DiversifierIndex::from(diversifier_index),
diversifier_index,
alias,
);
}
Expand Down Expand Up @@ -1095,7 +1094,7 @@ fn payment_address_or_alias_find(
ctx: Context,
io: &impl Io,
alias: Option<String>,
payment_address: Option<PaymentAddress>,
payment_address: Option<UnifiedPaymentAddress>,
) {
let wallet = load_wallet(ctx);
if payment_address.is_some() && alias.is_some() {
Expand Down
5 changes: 3 additions & 2 deletions crates/apps_lib/src/client/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1935,7 +1935,8 @@ pub async fn gen_ibc_shielding_transfer(
) -> Result<(), error::Error> {
let output_folder = args.output_folder.clone();

if let Some(masp_tx) = tx::gen_ibc_shielding_transfer(context, args).await?
if let Some((masp_tx, fmd_flags)) =
tx::gen_ibc_shielding_transfer(context, args).await?
{
let tx_id = masp_tx.txid().to_string();
let filename = format!("ibc_masp_tx_{}.memo", tx_id);
Expand All @@ -1945,7 +1946,7 @@ pub async fn gen_ibc_shielding_transfer(
};
let mut out = File::create(&output_path)
.expect("Creating a new file for IBC MASP transaction failed.");
let bytes = convert_masp_tx_to_ibc_memo(&masp_tx);
let bytes = convert_masp_tx_to_ibc_memo(masp_tx, fmd_flags);
out.write_all(bytes.as_bytes())
.expect("Writing IBC MASP transaction file failed.");
println!(
Expand Down
2 changes: 1 addition & 1 deletion crates/benches/native_vps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ fn setup_storage_for_masp_verification(
let (shielded_ctx, shield_tx) = shielded_ctx.generate_masp_tx(
amount,
TransferSource::Address(defaults::albert_address()),
TransferTarget::PaymentAddress(albert_payment_addr),
TransferTarget::PaymentAddress(albert_payment_addr.clone()),
);

shielded_ctx.shell.write().execute_tx(&shield_tx.to_ref());
Expand Down
7 changes: 5 additions & 2 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ rust-version.workspace = true
[features]
default = []
mainnet = []
rand = ["dep:rand", "rand_core"]
rand = ["dep:rand", "dep:rand_core", "polyfuzzy/random-flag-ciphertexts"]
default-flag-ciphertext = ["rand"]
ethers-derive = ["ethbridge-structs/ethers-derive"]
# for tests and test utilities
testing = ["rand", "proptest"]
migrations = ["namada_migrations", "linkme"]
benches = ["proptest"]
control_flow = ["lazy_static", "tokio", "wasmtimer"]
control_flow = ["dep:lazy_static", "tokio", "wasmtimer"]
arbitrary = [
"dep:arbitrary",
"chrono/arbitrary",
Expand All @@ -39,6 +40,7 @@ namada_migrations = { workspace = true, optional = true }
arbitrary = { workspace = true, optional = true }
arse-merkle-tree.workspace = true
bech32.workspace = true
bincode.workspace = true
borsh.workspace = true
chrono.workspace = true
data-encoding.workspace = true
Expand All @@ -60,6 +62,7 @@ num_enum.workspace = true
num-integer.workspace = true
num-rational.workspace = true
num-traits.workspace = true
polyfuzzy = { workspace = true, features = ["serde"] }
primitive-types.workspace = true
proptest = { workspace = true, optional = true }
prost-types.workspace = true
Expand Down
Loading
Loading