From fd9ae8cd9aea2d1766369ab79c248711a751ce08 Mon Sep 17 00:00:00 2001 From: h4sh3d Date: Wed, 10 Nov 2021 16:32:36 +0100 Subject: [PATCH 1/3] Use base58 monero to print and parse the public offer --- Cargo.toml | 1 + src/negotiation.rs | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e7b79329..c83efe7f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,7 @@ default = ["experimental", "taproot"] [dependencies] amplify = "3" +base58-monero = { version = "0.3.1", default-features = false, features = ["check"] } bitcoin_hashes = { version = "0.10.0" } bitvec = { version = "0.22.3" } fixed-hash = { version = "0.7.0", default-features = false } diff --git a/src/negotiation.rs b/src/negotiation.rs index 819afef2..7102ef5d 100644 --- a/src/negotiation.rs +++ b/src/negotiation.rs @@ -471,7 +471,9 @@ where Ctx: Swap, { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", consensus::serialize_hex(self)) + let encoded = base58_monero::encode_check(consensus::serialize(self).as_ref()) + .expect("Encoding in base58 check works"); + write!(f, "{}", encoded) } } @@ -482,7 +484,7 @@ where type Err = consensus::Error; fn from_str(s: &str) -> Result { - let decoded = hex::decode(s).map_err(consensus::Error::new)?; + let decoded = base58_monero::decode_check(s).map_err(consensus::Error::new)?; let mut res = std::io::Cursor::new(decoded); Decodable::consensus_decode(&mut res) } From 39cd075b1cf7b9efec5bfc3a8e1eabf4b5f57041 Mon Sep 17 00:00:00 2001 From: h4sh3d Date: Wed, 10 Nov 2021 16:33:03 +0100 Subject: [PATCH 2/3] Fix issue in deps for secp256kfun --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index c83efe7f..4ecf3d3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,6 +52,7 @@ rand = { version = "0.8.4", optional = true } rand_alt = { package = "rand", version = "0.7.3", features = ["std"] } rand_chacha = { version = "0.3.1", optional = true } secp256kfun = { version = "0.6", default-features = false, features = ["std", "serde", "libsecp_compat"], optional = true } +secp256kfun_parity_backend = "=0.1.5" sha2 = { version = "0.9", optional = true } sha3 = "0.9.1" From f285eaec9a1e9840c1402abdcc29e992c2169942 Mon Sep 17 00:00:00 2001 From: h4sh3d Date: Wed, 10 Nov 2021 16:37:47 +0100 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2533937b..f24fc2c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Switch from hex format to base58 (monero) format with checksum verification ([#171](https://github.com/farcaster-project/farcaster-core/pull/171)) + ## [0.3.0] - 2021-11-01 ### Added