From 18b845d69bb27ad22b78fc2904494bf1dc30ba6c Mon Sep 17 00:00:00 2001 From: Angelos Stylianidis Date: Wed, 20 Nov 2024 09:53:21 +0200 Subject: [PATCH] keep only MessageIdFormat. Make a generic bech32m MessageIdFormat --- Cargo.lock | 18 +---- Cargo.toml | 1 - ampd/Cargo.toml | 1 - contracts/voting-verifier/Cargo.toml | 2 +- contracts/voting-verifier/src/contract.rs | 12 +++- contracts/voting-verifier/src/events.rs | 8 +-- packages/aleo-types/Cargo.toml | 19 ------ packages/aleo-types/src/address.rs | 68 ------------------- packages/aleo-types/src/lib.rs | 38 ----------- packages/aleo-types/src/transaction.rs | 67 ------------------ packages/aleo-types/src/transition.rs | 67 ------------------ packages/axelar-wasm-std/Cargo.toml | 2 +- packages/axelar-wasm-std/src/address.rs | 6 -- .../src/msg_id/aleo_message_id.rs | 64 ----------------- .../axelar-wasm-std/src/msg_id/bech32m.rs | 68 +++++++++++++++++++ packages/axelar-wasm-std/src/msg_id/mod.rs | 54 ++++----------- 16 files changed, 102 insertions(+), 393 deletions(-) delete mode 100644 packages/aleo-types/Cargo.toml delete mode 100644 packages/aleo-types/src/address.rs delete mode 100644 packages/aleo-types/src/lib.rs delete mode 100644 packages/aleo-types/src/transaction.rs delete mode 100644 packages/aleo-types/src/transition.rs delete mode 100644 packages/axelar-wasm-std/src/msg_id/aleo_message_id.rs create mode 100644 packages/axelar-wasm-std/src/msg_id/bech32m.rs diff --git a/Cargo.lock b/Cargo.lock index 025f20ae2..e03a1badb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -105,19 +105,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "aleo-types" -version = "0.1.0" -dependencies = [ - "assert_ok", - "axelar-wasm-std", - "bech32 0.11.0", - "error-stack", - "serde", - "serde_json", - "thiserror", -] - [[package]] name = "aliasable" version = "0.1.3" @@ -235,7 +222,6 @@ dependencies = [ name = "ampd" version = "1.2.0" dependencies = [ - "aleo-types", "async-trait", "axelar-wasm-std", "axum 0.7.5", @@ -848,10 +834,10 @@ dependencies = [ name = "axelar-wasm-std" version = "1.0.0" dependencies = [ - "aleo-types", "alloy-primitives", "assert_ok", "axelar-wasm-std-derive", + "bech32 0.11.0", "bs58 0.5.1", "cosmwasm-schema", "cosmwasm-std", @@ -9423,10 +9409,10 @@ checksum = "2e4fe92cfc1bad19c19925d5eee4b30584dbbdee4ff10183b261acccbef74e2d" name = "voting-verifier" version = "1.0.0" dependencies = [ - "aleo-types", "alloy-primitives", "assert_ok", "axelar-wasm-std", + "bech32 0.11.0", "client", "cosmwasm-schema", "cosmwasm-std", diff --git a/Cargo.toml b/Cargo.toml index 1951ebe38..5c9c646f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,6 @@ rust-version = "1.78.0" # be sure there is an optimizer release supporting this edition = "2021" [workspace.dependencies] -aleo-types = { path = "packages/aleo-types" } alloy-primitives = { version = "0.7.6", default-features = false, features = ["std"] } alloy-sol-types = { version = "0.7.6", default-features = false, features = ["std"] } anyhow = "1.0.89" diff --git a/ampd/Cargo.toml b/ampd/Cargo.toml index 3e66875f8..d8f7659d9 100644 --- a/ampd/Cargo.toml +++ b/ampd/Cargo.toml @@ -6,7 +6,6 @@ rust-version = { workspace = true } # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aleo-types = { workspace = true } async-trait = "0.1.59" axelar-wasm-std = { workspace = true } axum = "0.7.5" diff --git a/contracts/voting-verifier/Cargo.toml b/contracts/voting-verifier/Cargo.toml index a987090dc..ad0c4cbb3 100644 --- a/contracts/voting-verifier/Cargo.toml +++ b/contracts/voting-verifier/Cargo.toml @@ -32,7 +32,6 @@ optimize = """docker run --rm -v "$(pwd)":/code \ """ [dependencies] -aleo-types = { workspace = true } axelar-wasm-std = { workspace = true, features = ["derive"] } client = { workspace = true } cosmwasm-schema = { workspace = true } @@ -54,6 +53,7 @@ thiserror = { workspace = true } [dev-dependencies] alloy-primitives = { version = "0.7.7", features = ["getrandom"] } assert_ok = { workspace = true } +bech32 = { workspace = true } cw-multi-test = "0.15.1" goldie = { workspace = true } integration-tests = { workspace = true } diff --git a/contracts/voting-verifier/src/contract.rs b/contracts/voting-verifier/src/contract.rs index f6a982479..3af8930a9 100644 --- a/contracts/voting-verifier/src/contract.rs +++ b/contracts/voting-verifier/src/contract.rs @@ -129,6 +129,7 @@ mod test { assert_err_contains, err_contains, nonempty, MajorityThreshold, Threshold, VerificationStatus, }; + use bech32::{Bech32m, Hrp}; use cosmwasm_std::testing::{ mock_dependencies, mock_env, mock_info, MockApi, MockQuerier, MockStorage, }; @@ -263,7 +264,16 @@ mod test { .to_string() .parse() .unwrap(), - MessageIdFormat::AleoTransaction => unreachable!(), + MessageIdFormat::Bech32m => { + let data = format!("{id}-{index}"); + let prefix = "bech32m"; + let hrp = Hrp::parse(prefix).expect("valid hrp"); + bech32::encode::(hrp, data.as_bytes()) + .unwrap() + .to_string() + .parse() + .unwrap() + } } } diff --git a/contracts/voting-verifier/src/events.rs b/contracts/voting-verifier/src/events.rs index ebaf87947..51ced71f6 100644 --- a/contracts/voting-verifier/src/events.rs +++ b/contracts/voting-verifier/src/events.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use std::vec::Vec; use axelar_wasm_std::msg_id::{ - AleoMessageId, Base58SolanaTxSignatureAndEventIndex, Base58TxDigestAndEventIndex, HexTxHash, + Base58SolanaTxSignatureAndEventIndex, Base58TxDigestAndEventIndex, Bech32mFormat, HexTxHash, HexTxHashAndEventIndex, MessageIdFormat, }; use axelar_wasm_std::voting::{PollId, Vote}; @@ -186,10 +186,10 @@ fn parse_message_id( Ok((id.tx_hash_as_hex(), 0)) } - MessageIdFormat::AleoTransaction => { - let aleo_message_id = AleoMessageId::from_str(message_id) + MessageIdFormat::Bech32m => { + let bech32m_message_id = Bech32mFormat::from_str(message_id) .map_err(|_| ContractError::InvalidMessageID(message_id.into()))?; - Ok((aleo_message_id.to_string().try_into()?, 0)) + Ok((bech32m_message_id.to_string().try_into()?, 0)) } } } diff --git a/packages/aleo-types/Cargo.toml b/packages/aleo-types/Cargo.toml deleted file mode 100644 index e482b033d..000000000 --- a/packages/aleo-types/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "aleo-types" -version = "0.1.0" -edition = { workspace = true } -rust-version = { workspace = true } - -[dependencies] -error-stack = { workspace = true } -serde = { workspace = true } -serde_json = { workspace = true } -thiserror = { workspace = true } -bech32 = { workspace = true } - -[dev-dependencies] -axelar-wasm-std = { workspace = true } -assert_ok = { workspace = true } - -[lints] -workspace = true diff --git a/packages/aleo-types/src/address.rs b/packages/aleo-types/src/address.rs deleted file mode 100644 index 7b585db98..000000000 --- a/packages/aleo-types/src/address.rs +++ /dev/null @@ -1,68 +0,0 @@ -use std::str::FromStr; - -use error_stack::{Report, Result, ResultExt}; -use serde::{Deserialize, Serialize}; - -use crate::Error; - -#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)] -pub struct Address { - address: String, -} - -impl FromStr for Address { - type Err = Report; - - fn from_str(address: &str) -> Result - where - Self: Sized, - { - const ADDRESS_PREFIX: &str = "aleo"; - - crate::verify_bech32m(address, ADDRESS_PREFIX) - .change_context(Error::InvalidAddress(address.to_string()))?; - - Ok(Self { - address: address.to_string(), - }) - } -} - -#[cfg(test)] -mod tests { - use assert_ok::assert_ok; - use axelar_wasm_std::assert_err_contains; - - use super::*; - - #[test] - fn validate_aleo_address() { - let addr = "aleo1pqgvl3prke38qwyywqhgd0qu44msp3wks4cqpk3d8m8vxu30wvfql7nmvs"; - assert_ok!(Address::from_str(addr)); - } - - #[test] - fn validate_aleo_address_errors() { - let addr = "aleo1pqgvl3prke38qwyywqhgd0qu44msp3wks4cqpk3d8m8vxu30wvfql7nmv"; - assert_err_contains!( - Address::from_str(addr), - crate::Error, - crate::Error::InvalidAddress(..) - ); - - let addr = "aleo2pqgvl3prke38qwyywqhgd0qu44msp3wks4cqpk3d8m8vxu30wvfql7nmvs"; - assert_err_contains!( - Address::from_str(addr), - crate::Error, - crate::Error::InvalidAddress(..) - ); - - // test empty data part - let addr = "aleo1gufq6k"; - assert_err_contains!( - Address::from_str(addr), - crate::Error, - crate::Error::InvalidAddress(..) - ); - } -} diff --git a/packages/aleo-types/src/lib.rs b/packages/aleo-types/src/lib.rs deleted file mode 100644 index c3b026252..000000000 --- a/packages/aleo-types/src/lib.rs +++ /dev/null @@ -1,38 +0,0 @@ -pub mod address; -pub mod transaction; -pub mod transition; - -use bech32::primitives::decode::CheckedHrpstring; -use bech32::Bech32m; -use error_stack::{bail, ensure, Report}; -use thiserror::Error; - -#[derive(Error, Debug)] -pub enum Error { - #[error("invalid aleo address: {0}")] - InvalidAddress(String), - #[error("invalid aleo transition id: {0}")] - InvalidAleoTransition(String), - #[error("invalid aleo transaction id: {0}")] - InvalidAleoTransaction(String), - #[error("Bech32m error: {0}")] - Bech32m(String), -} - -fn verify_bech32m(input: &str, prefix: &str) -> Result<(), Report> { - let checked = - CheckedHrpstring::new::(input).map_err(|e| Error::Bech32m(e.to_string()))?; - - ensure!( - checked.hrp().as_str() == prefix, - Error::Bech32m(format!( - "Failed to match prefix. Input '{input}' is missing '{prefix}'" - )) - ); - - if checked.data_part_ascii_no_checksum().is_empty() { - bail!(Error::Bech32m(format!("Input '{input}' has no data part"))); - } - - Ok(()) -} diff --git a/packages/aleo-types/src/transaction.rs b/packages/aleo-types/src/transaction.rs deleted file mode 100644 index 408f34262..000000000 --- a/packages/aleo-types/src/transaction.rs +++ /dev/null @@ -1,67 +0,0 @@ -use std::fmt::Display; -use std::str::FromStr; - -use error_stack::{Report, ResultExt}; -use serde::{Deserialize, Serialize}; - -use crate::Error; - -const TRANSACTION_PREFIX: &str = "at"; - -#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash, Clone)] -pub struct Transaction { - transaction_id: String, -} - -impl FromStr for Transaction { - type Err = Report; - - fn from_str(transaction_id: &str) -> Result - where - Self: Sized, - { - crate::verify_bech32m(transaction_id, TRANSACTION_PREFIX) - .change_context(Error::InvalidAleoTransaction(transaction_id.to_string()))?; - - Ok(Self { - transaction_id: transaction_id.to_string(), - }) - } -} - -impl Display for Transaction { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.transaction_id) - } -} - -#[cfg(test)] -mod tests { - use assert_ok::assert_ok; - use axelar_wasm_std::assert_err_contains; - - use super::*; - - #[test] - fn validate_aleo_transaction() { - let addr = "at1pvhkv0gt5qfnljte2nlav7u9rqrafgf04hzwkfu97sctynwghvqskfua6g"; - assert_ok!(Transaction::from_str(addr)); - } - - #[test] - fn validate_aleo_transaction_errors() { - let addr = "au1pvhkv0gt5qfnljte2nlav7u9rqrafgf04hzwkfu97sctynwghvqskfua6g"; - assert_err_contains!( - Transaction::from_str(addr), - crate::Error, - crate::Error::InvalidAleoTransaction(..) - ); - - let addr = "at1fnywazjhsvpvga7yszfhye3ftnsd6q35qpmuw4ugl9sghqtmucxqk4ksv9"; - assert_err_contains!( - Transaction::from_str(addr), - crate::Error, - crate::Error::InvalidAleoTransaction(..) - ); - } -} diff --git a/packages/aleo-types/src/transition.rs b/packages/aleo-types/src/transition.rs deleted file mode 100644 index 80994dce4..000000000 --- a/packages/aleo-types/src/transition.rs +++ /dev/null @@ -1,67 +0,0 @@ -use std::fmt::Display; -use std::str::FromStr; - -use error_stack::{Report, ResultExt}; -use serde::{Deserialize, Serialize}; - -use crate::Error; - -const TRANSITION_PREFIX: &str = "au"; - -#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash, Clone)] -pub struct Transition { - transition_id: String, -} - -impl FromStr for Transition { - type Err = Report; - - fn from_str(transition_id: &str) -> Result - where - Self: Sized, - { - crate::verify_bech32m(transition_id, TRANSITION_PREFIX) - .change_context(Error::InvalidAleoTransition(transition_id.to_string()))?; - - Ok(Self { - transition_id: transition_id.to_string(), - }) - } -} - -impl Display for Transition { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.transition_id) - } -} - -#[cfg(test)] -mod tests { - use assert_ok::assert_ok; - use axelar_wasm_std::assert_err_contains; - - use super::*; - - #[test] - fn validate_aleo_transition() { - let addr = "au1fnywazjhsvpvga7yszfhye3ftnsd6q35qpmuw4ugl9sghqtmucxqk4ksv8"; - assert_ok!(Transition::from_str(addr)); - } - - #[test] - fn validate_aleo_transition_errors() { - let addr = "at1fnywazjhsvpvga7yszfhye3ftnsd6q35qpmuw4ugl9sghqtmucxqk4ksv8"; - assert_err_contains!( - Transition::from_str(addr), - crate::Error, - crate::Error::InvalidAleoTransition(..) - ); - - let addr = "au1fnywazjhsvpvga7yszfhye3ftnsd6q35qpmuw4ugl9sghqtmucxqk4ksv9"; - assert_err_contains!( - Transition::from_str(addr), - crate::Error, - crate::Error::InvalidAleoTransition(..) - ); - } -} diff --git a/packages/axelar-wasm-std/Cargo.toml b/packages/axelar-wasm-std/Cargo.toml index ca9001475..e70de054b 100644 --- a/packages/axelar-wasm-std/Cargo.toml +++ b/packages/axelar-wasm-std/Cargo.toml @@ -27,9 +27,9 @@ optimize = """docker run --rm -v "$(pwd)":/code \ """ [dependencies] -aleo-types = { workspace = true } alloy-primitives = { workspace = true } axelar-wasm-std-derive = { workspace = true, optional = true } +bech32 = { workspace = true } bs58 = "0.5.1" cosmwasm-schema = { workspace = true } cosmwasm-std = { workspace = true } diff --git a/packages/axelar-wasm-std/src/address.rs b/packages/axelar-wasm-std/src/address.rs index 45289a0c5..ea1544c44 100644 --- a/packages/axelar-wasm-std/src/address.rs +++ b/packages/axelar-wasm-std/src/address.rs @@ -1,6 +1,5 @@ use std::str::FromStr; -use aleo_types::address::Address as AleoAddress; use alloy_primitives::Address; use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, Api}; @@ -20,7 +19,6 @@ pub enum AddressFormat { Eip55, Sui, Stellar, - Aleo, } pub fn validate_address(address: &str, format: &AddressFormat) -> Result<(), Error> { @@ -40,10 +38,6 @@ pub fn validate_address(address: &str, format: &AddressFormat) -> Result<(), Err ScAddress::from_str(address) .change_context(Error::InvalidAddress(address.to_string()))?; } - AddressFormat::Aleo => { - AleoAddress::from_str(address) - .change_context(Error::InvalidAddress(address.to_string()))?; - } } Ok(()) diff --git a/packages/axelar-wasm-std/src/msg_id/aleo_message_id.rs b/packages/axelar-wasm-std/src/msg_id/aleo_message_id.rs deleted file mode 100644 index 35d9a9c70..000000000 --- a/packages/axelar-wasm-std/src/msg_id/aleo_message_id.rs +++ /dev/null @@ -1,64 +0,0 @@ -use std::fmt::{self, Display}; -use std::str::FromStr; - -use aleo_types::transaction::Transaction; -use aleo_types::transition::Transition; -use error_stack::Report; -use lazy_static::lazy_static; -use regex::Regex; - -use super::Error; - -pub struct AleoMessageId { - pub transaction_id: Transaction, - pub transition_id: Transition, -} - -impl AleoMessageId { - pub fn new(transaction_id: Transaction, transition_id: Transition) -> Self { - Self { - transaction_id, - transition_id, - } - } -} - -const PATTERN: &str = "^(at1[02-9ac-hj-np-z]{58})-(au1[02-9ac-hj-np-z]{58})$"; - -lazy_static! { - static ref REGEX: Regex = Regex::new(PATTERN).expect("invalid regex"); -} - -impl FromStr for AleoMessageId { - type Err = Report; - - fn from_str(message_id: &str) -> Result - where - Self: Sized, - { - let (_, [transaction, transition]) = REGEX - .captures(message_id) - .ok_or(Error::InvalidMessageID { - id: message_id.to_string(), - expected_format: "AleoTransactionId-AleoTransitionId".to_string(), - })? - .extract(); - - let transaction_id = Transaction::from_str(transaction) - .map_err(|e| e.change_context(Error::InvalidAleoMessageId(message_id.to_string())))?; - - let transition_id = Transition::from_str(transition) - .map_err(|e| e.change_context(Error::InvalidAleoMessageId(message_id.to_string())))?; - - Ok(Self { - transaction_id, - transition_id, - }) - } -} - -impl Display for AleoMessageId { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}-{}", self.transaction_id, self.transition_id) - } -} diff --git a/packages/axelar-wasm-std/src/msg_id/bech32m.rs b/packages/axelar-wasm-std/src/msg_id/bech32m.rs new file mode 100644 index 000000000..35c39d444 --- /dev/null +++ b/packages/axelar-wasm-std/src/msg_id/bech32m.rs @@ -0,0 +1,68 @@ +use std::fmt::{self, Display}; +use std::str::FromStr; + +use bech32::primitives::decode::CheckedHrpstring; +use bech32::Bech32m; +use error_stack::{bail, Report, ResultExt}; +use lazy_static::lazy_static; +use regex::Regex; + +use super::Error; + +pub struct Bech32mFormat { + pub encoded: String, +} + +impl Bech32mFormat { + pub fn new(encoded: String) -> Self { + Self { encoded } + } +} + +const PATTERN: &str = "^([0-9ac-hj-np-z]{8,90})$"; + +lazy_static! { + static ref REGEX: Regex = Regex::new(PATTERN).expect("invalid regex"); +} + +impl FromStr for Bech32mFormat { + type Err = Report; + + fn from_str(message_id: &str) -> Result + where + Self: Sized, + { + let (_, [string]) = REGEX + .captures(message_id) + .ok_or(Error::InvalidMessageID { + id: message_id.to_string(), + expected_format: "Bech32m".to_string(), + })? + .extract(); + + verify_bech32m(string)?; + + Ok(Self { + encoded: string.to_string(), + }) + } +} + +impl Display for Bech32mFormat { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.encoded) + } +} + +fn verify_bech32m(input: &str) -> Result<(), Report> { + let checked = CheckedHrpstring::new::(input) + .change_context(Error::InvalidBech32m(input.to_string()))?; + + if checked.data_part_ascii_no_checksum().is_empty() { + bail!(Error::InvalidBech32m(format!( + "Message Id is missing the data part: '{input}'" + ))); + } + + Ok(()) +} diff --git a/packages/axelar-wasm-std/src/msg_id/mod.rs b/packages/axelar-wasm-std/src/msg_id/mod.rs index 2ee058009..f890f0d3a 100644 --- a/packages/axelar-wasm-std/src/msg_id/mod.rs +++ b/packages/axelar-wasm-std/src/msg_id/mod.rs @@ -4,15 +4,15 @@ use std::str::FromStr; use cosmwasm_schema::cw_serde; use error_stack::Report; -pub use self::aleo_message_id::AleoMessageId; pub use self::base_58_event_index::Base58TxDigestAndEventIndex; pub use self::base_58_solana_event_index::Base58SolanaTxSignatureAndEventIndex; +pub use self::bech32m::Bech32mFormat; pub use self::tx_hash::HexTxHash; pub use self::tx_hash_event_index::HexTxHashAndEventIndex; -mod aleo_message_id; mod base_58_event_index; mod base_58_solana_event_index; +mod bech32m; mod tx_hash; mod tx_hash_event_index; @@ -27,10 +27,8 @@ pub enum Error { InvalidTxHash(String), #[error("invalid tx digest in message id '{0}'")] InvalidTxDigest(String), - #[error("Invalid Aleo message Id: '{0}'")] - InvalidAleoMessageId(String), - #[error("Expected format: 'AleoTransactionId-AleoTransitionId', '{0}'")] - InvalidAleoMessageIdFormat(String), + #[error("Invalid bech32m: '{0}'")] + InvalidBech32m(String), } /// Any message id format must implement this trait. @@ -51,7 +49,7 @@ pub enum MessageIdFormat { Base58TxDigestAndEventIndex, Base58SolanaTxSignatureAndEventIndex, HexTxHash, - AleoTransaction, + Bech32m, } // function the router calls to verify msg ids @@ -67,7 +65,7 @@ pub fn verify_msg_id(message_id: &str, format: &MessageIdFormat) -> Result<(), R Base58SolanaTxSignatureAndEventIndex::from_str(message_id).map(|_| ()) } MessageIdFormat::HexTxHash => HexTxHash::from_str(message_id).map(|_| ()), - MessageIdFormat::AleoTransaction => AleoMessageId::from_str(message_id).map(|_| ()), + MessageIdFormat::Bech32m => Bech32mFormat::from_str(message_id).map(|_| ()), } } @@ -121,39 +119,17 @@ mod test { } #[test] - fn should_verify_aleo_transaction() { - let message_id = "at1hs0xk375g4kvw53rcem9nyjsdw5lsv94fl065n77cpt0774nsyysdecaju-au1d6952458dhu835xt4dk4mmyjrs7vrg30guv6eupryfq8mhajxqzqym3al9"; - assert!(verify_msg_id(message_id, &MessageIdFormat::AleoTransaction).is_ok()); + fn should_verify_bech32m() { + let message_id = "at1hs0xk375g4kvw53rcem9nyjsdw5lsv94fl065n77cpt0774nsyysdecaju"; + assert!(verify_msg_id(message_id, &MessageIdFormat::Bech32m).is_ok()); } #[test] - fn should_not_verify_aleo_transaction() { - // invalid transaction hrp - let message_id = "a1hs0xk375g4kvw53rcem9nyjsdw5lsv94fl065n77cpt0774nsyysdecaju-au1d6952458dhu835xt4dk4mmyjrs7vrg30guv6eupryfq8mhajxqzqym3al9"; - assert!(verify_msg_id(message_id, &MessageIdFormat::AleoTransaction).is_err()); - - // invalid transition hrp - let message_id = "at1hs0xk375g4kvw53rcem9nyjsdw5lsv94fl065n77cpt0774nsyysdecaju-a1d6952458dhu835xt4dk4mmyjrs7vrg30guv6eupryfq8mhajxqzqym3al9"; - assert!(verify_msg_id(message_id, &MessageIdFormat::AleoTransaction).is_err()); - - // invalid pattern, has extra "-foo" - let message_id = "at1hs0xk375g4kvw53rcem9nyjsdw5lsv94fl065n77cpt0774nsyysdecaju-au1d6952458dhu835xt4dk4mmyjrs7vrg30guv6eupryfq8mhajxqzqym3al9-foo"; - assert!(verify_msg_id(message_id, &MessageIdFormat::AleoTransaction).is_err()); - - // invalid pattern, has extra "-" prefix - let message_id = "-at1hs0xk375g4kvw53rcem9nyjsdw5lsv94fl065n77cpt0774nsyysdecaju-au1d6952458dhu835xt4dk4mmyjrs7vrg30guv6eupryfq8mhajxqzqym3al9"; - assert!(verify_msg_id(message_id, &MessageIdFormat::AleoTransaction).is_err()); - - // invalid pattern, has double "--" - let message_id = "at1hs0xk375g4kvw53rcem9nyjsdw5lsv94fl065n77cpt0774nsyysdecaju--au1d6952458dhu835xt4dk4mmyjrs7vrg30guv6eupryfq8mhajxqzqym3al9"; - assert!(verify_msg_id(message_id, &MessageIdFormat::AleoTransaction).is_err()); - - // invalid transition checksum - let message_id = "at1hs0xk375g4kvw53rcem9nyjsdw5lsv94fl065n77cpt0774nsyysdecaju--au1d6952458dhu835xt4dk4mmyjrs7vrg30guv6eupryfq8mhajxqzqym3al0"; - assert!(verify_msg_id(message_id, &MessageIdFormat::AleoTransaction).is_err()); - - // invalid transition checksum - let message_id = "at1hs0xk375g4kvw53rcem9nyjsdw5lsv94fl065n77cpt0774nsyysdecaju--au1d6952458dhu835xt4dk5mmyjrs7vrg30guv6eupryfq8mhajxqzqym3al9"; - assert!(verify_msg_id(message_id, &MessageIdFormat::AleoTransaction).is_err()); + fn should_not_verify_bech32m() { + let message_id = "aths0xk375g4kvw53rcem9nyjsdw5lsv94fl065n77cpt0774nsyysdecaju"; + assert!(verify_msg_id(message_id, &MessageIdFormat::Bech32m).is_err()); + + let message_id = "ath1s0xk375g4kvw53rcem9nyjsdw5lsv94fl065n77cpt0774nsyysdecaj"; + assert!(verify_msg_id(message_id, &MessageIdFormat::Bech32m).is_err()); } }