diff --git a/Cargo.lock b/Cargo.lock index 2f44fb65..515f48b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1146,7 +1146,7 @@ dependencies = [ [[package]] name = "dalek-ff-group" version = "0.4.1" -source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" +source = "git+https://github.com/Cuprate/serai.git?rev=7f52b95#7f52b95b38a1fce01ee9d74353786f4007aba77a" dependencies = [ "crypto-bigint", "curve25519-dalek", @@ -1311,7 +1311,7 @@ dependencies = [ [[package]] name = "flexible-transcript" version = "0.3.2" -source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" +source = "git+https://github.com/Cuprate/serai.git?rev=7f52b95#7f52b95b38a1fce01ee9d74353786f4007aba77a" dependencies = [ "blake2", "digest", @@ -2002,7 +2002,7 @@ dependencies = [ [[package]] name = "monero-address" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" +source = "git+https://github.com/Cuprate/serai.git?rev=7f52b95#7f52b95b38a1fce01ee9d74353786f4007aba77a" dependencies = [ "curve25519-dalek", "monero-io", @@ -2015,7 +2015,7 @@ dependencies = [ [[package]] name = "monero-borromean" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" +source = "git+https://github.com/Cuprate/serai.git?rev=7f52b95#7f52b95b38a1fce01ee9d74353786f4007aba77a" dependencies = [ "curve25519-dalek", "monero-generators", @@ -2028,7 +2028,7 @@ dependencies = [ [[package]] name = "monero-bulletproofs" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" +source = "git+https://github.com/Cuprate/serai.git?rev=7f52b95#7f52b95b38a1fce01ee9d74353786f4007aba77a" dependencies = [ "curve25519-dalek", "monero-generators", @@ -2043,7 +2043,7 @@ dependencies = [ [[package]] name = "monero-clsag" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" +source = "git+https://github.com/Cuprate/serai.git?rev=7f52b95#7f52b95b38a1fce01ee9d74353786f4007aba77a" dependencies = [ "curve25519-dalek", "dalek-ff-group", @@ -2063,7 +2063,7 @@ dependencies = [ [[package]] name = "monero-generators" version = "0.4.0" -source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" +source = "git+https://github.com/Cuprate/serai.git?rev=7f52b95#7f52b95b38a1fce01ee9d74353786f4007aba77a" dependencies = [ "curve25519-dalek", "dalek-ff-group", @@ -2077,7 +2077,7 @@ dependencies = [ [[package]] name = "monero-io" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" +source = "git+https://github.com/Cuprate/serai.git?rev=7f52b95#7f52b95b38a1fce01ee9d74353786f4007aba77a" dependencies = [ "curve25519-dalek", "std-shims", @@ -2086,7 +2086,7 @@ dependencies = [ [[package]] name = "monero-mlsag" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" +source = "git+https://github.com/Cuprate/serai.git?rev=7f52b95#7f52b95b38a1fce01ee9d74353786f4007aba77a" dependencies = [ "curve25519-dalek", "monero-generators", @@ -2100,7 +2100,7 @@ dependencies = [ [[package]] name = "monero-primitives" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" +source = "git+https://github.com/Cuprate/serai.git?rev=7f52b95#7f52b95b38a1fce01ee9d74353786f4007aba77a" dependencies = [ "curve25519-dalek", "monero-generators", @@ -2113,7 +2113,7 @@ dependencies = [ [[package]] name = "monero-rpc" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" +source = "git+https://github.com/Cuprate/serai.git?rev=7f52b95#7f52b95b38a1fce01ee9d74353786f4007aba77a" dependencies = [ "curve25519-dalek", "hex", @@ -2129,7 +2129,7 @@ dependencies = [ [[package]] name = "monero-serai" version = "0.1.4-alpha" -source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" +source = "git+https://github.com/Cuprate/serai.git?rev=7f52b95#7f52b95b38a1fce01ee9d74353786f4007aba77a" dependencies = [ "curve25519-dalek", "hex-literal", @@ -2147,7 +2147,7 @@ dependencies = [ [[package]] name = "monero-simple-request-rpc" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" +source = "git+https://github.com/Cuprate/serai.git?rev=7f52b95#7f52b95b38a1fce01ee9d74353786f4007aba77a" dependencies = [ "digest_auth", "hex", @@ -2844,7 +2844,7 @@ dependencies = [ [[package]] name = "simple-request" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" +source = "git+https://github.com/Cuprate/serai.git?rev=7f52b95#7f52b95b38a1fce01ee9d74353786f4007aba77a" dependencies = [ "http-body-util", "hyper", @@ -2910,7 +2910,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "std-shims" version = "0.1.1" -source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" +source = "git+https://github.com/Cuprate/serai.git?rev=7f52b95#7f52b95b38a1fce01ee9d74353786f4007aba77a" dependencies = [ "hashbrown 0.14.5", "spin", diff --git a/Cargo.toml b/Cargo.toml index 86470f65..4992a0b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -121,7 +121,7 @@ futures = { version = "0.3", default-features = false } hex = { version = "0.4", default-features = false } hex-literal = { version = "0.4", default-features = false } indexmap = { version = "2", default-features = false } -monero-serai = { git = "https://github.com/Cuprate/serai.git", rev = "e6fdef6", default-features = false } +monero-serai = { git = "https://github.com/Cuprate/serai.git", rev = "7f52b95", default-features = false } paste = { version = "1", default-features = false } pin-project = { version = "1", default-features = false } randomx-rs = { git = "https://github.com/Cuprate/randomx-rs.git", rev = "0028464", default-features = false } @@ -144,8 +144,8 @@ tracing-subscriber = { version = "0.3", default-features = false } tracing = { version = "0.1", default-features = false } ## workspace.dev-dependencies -monero-rpc = { git = "https://github.com/Cuprate/serai.git", rev = "e6fdef6" } -monero-simple-request-rpc = { git = "https://github.com/Cuprate/serai.git", rev = "e6fdef6" } +monero-rpc = { git = "https://github.com/Cuprate/serai.git", rev = "7f52b95" } +monero-simple-request-rpc = { git = "https://github.com/Cuprate/serai.git", rev = "7f52b95" } tempfile = { version = "3" } pretty_assertions = { version = "1" } proptest = { version = "1" } diff --git a/binaries/cuprated/src/blockchain/manager/handler.rs b/binaries/cuprated/src/blockchain/manager/handler.rs index e9d59d02..21f9b537 100644 --- a/binaries/cuprated/src/blockchain/manager/handler.rs +++ b/binaries/cuprated/src/blockchain/manager/handler.rs @@ -170,6 +170,7 @@ impl super::BlockchainManager { batch_prepare_main_chain_blocks(batch.blocks, &mut self.blockchain_context_service, self.blockchain_read_handle.clone()) .await else { + panic!(); batch.peer_handle.ban_peer(LONG_BAN); self.stop_current_block_downloader.notify_one(); return; @@ -185,6 +186,7 @@ impl super::BlockchainManager { ) .await else { + panic!(); batch.peer_handle.ban_peer(LONG_BAN); self.stop_current_block_downloader.notify_one(); return; @@ -433,7 +435,7 @@ impl super::BlockchainManager { .iter() .flat_map(|tx| { tx.tx.prefix().inputs.iter().map(|input| match input { - Input::ToKey { key_image, .. } => key_image.compress().0, + Input::ToKey { key_image, .. } => key_image.0, Input::Gen(_) => unreachable!(), }) }) diff --git a/consensus/rules/src/transactions.rs b/consensus/rules/src/transactions.rs index b4eac191..2e280f0c 100644 --- a/consensus/rules/src/transactions.rs +++ b/consensus/rules/src/transactions.rs @@ -4,7 +4,7 @@ use monero_serai::{ ringct::RctType, transaction::{Input, Output, Timelock, Transaction}, }; - +use monero_serai::io::decompress_point; pub use cuprate_types::TxVersion; use crate::{ @@ -327,7 +327,7 @@ fn check_key_images(input: &Input) -> Result<(), TransactionError> { match input { Input::ToKey { key_image, .. } => { // this happens in monero-serai but we may as well duplicate the check. - if !key_image.is_torsion_free() { + if decompress_point(*key_image).is_none_or(|p| !p.is_torsion_free()) { return Err(TransactionError::KeyImageIsNotInPrimeSubGroup); } } @@ -388,7 +388,7 @@ fn check_ring_members_unique(input: &Input, hf: HardFork) -> Result<(), Transact /// ref: <https://monero-book.cuprate.org/consensus_rules/transactions/inputs.html#sorted-inputs> fn check_inputs_sorted(inputs: &[Input], hf: HardFork) -> Result<(), TransactionError> { let get_ki = |inp: &Input| match inp { - Input::ToKey { key_image, .. } => Ok(key_image.compress().to_bytes()), + Input::ToKey { key_image, .. } => Ok(key_image.to_bytes()), Input::Gen(_) => Err(TransactionError::IncorrectInputType), }; diff --git a/consensus/rules/src/transactions/ring_ct.rs b/consensus/rules/src/transactions/ring_ct.rs index 32cedd47..f0fefad6 100644 --- a/consensus/rules/src/transactions/ring_ct.rs +++ b/consensus/rules/src/transactions/ring_ct.rs @@ -74,9 +74,9 @@ fn simple_type_balances(rct_sig: &RctProofs) -> Result<(), RingCTError> { } }; - let sum_inputs = pseudo_outs.iter().sum::<EdwardsPoint>(); + let sum_inputs = pseudo_outs.iter().map(|p| p.decompress().unwrap()).sum::<EdwardsPoint>(); let sum_outputs = - rct_sig.base.commitments.iter().sum::<EdwardsPoint>() + Scalar::from(rct_sig.base.fee) * *H; + rct_sig.base.commitments.iter().map(|p| p.decompress().unwrap()).sum::<EdwardsPoint>() + Scalar::from(rct_sig.base.fee) * *H; if sum_inputs == sum_outputs { Ok(()) @@ -101,7 +101,7 @@ fn check_output_range_proofs( | RctPrunable::AggregateMlsagBorromean { borromean, .. } => try_par_iter(borromean) .zip(commitments) .try_for_each(|(borro, commitment)| { - if borro.verify(commitment) { + if borro.verify(&commitment.decompress().unwrap()) { Ok(()) } else { Err(RingCTError::BorromeanRangeInvalid) @@ -173,12 +173,12 @@ pub(crate) fn check_input_signatures( let Input::ToKey { key_image, .. } = inp else { panic!("How did we build a ring with no decoys?"); }; - *key_image + key_image.decompress().unwrap() }) .collect::<Vec<_>>(); let mut matrix = - AggregateRingMatrixBuilder::new(&proofs.base.commitments, proofs.base.fee); + AggregateRingMatrixBuilder::new(&proofs.base.commitments.iter().map(|p| p.decompress().unwrap()).collect::<Vec<_>>(), proofs.base.fee); rings.iter().try_for_each(|ring| matrix.push_ring(ring))?; @@ -195,10 +195,11 @@ pub(crate) fn check_input_signatures( panic!("How did we build a ring with no decoys?"); }; + // TODO: change monero-serai API Ok(mlsag.verify( msg, - &RingMatrix::individual(ring, *pseudo_out)?, - &[*key_image], + &RingMatrix::individual(ring, pseudo_out.decompress().unwrap())?, + &[key_image.decompress().unwrap()], )?) }), RctPrunable::Clsag { clsags, .. } => try_par_iter(clsags) diff --git a/consensus/rules/src/transactions/ring_signatures.rs b/consensus/rules/src/transactions/ring_signatures.rs index a226f5e3..d7336ec5 100644 --- a/consensus/rules/src/transactions/ring_signatures.rs +++ b/consensus/rules/src/transactions/ring_signatures.rs @@ -39,7 +39,8 @@ pub(crate) fn check_input_signatures( panic!("How did we build a ring with no decoys?"); }; - if !sig.verify(tx_sig_hash, ring, key_image) { + // TODO: change monero-serai API + if !sig.verify(tx_sig_hash, ring, &key_image.decompress().unwrap()) { return Err(TransactionError::RingSignatureIncorrect); } Ok(()) diff --git a/consensus/src/transactions.rs b/consensus/src/transactions.rs index 774f75c4..819710a1 100644 --- a/consensus/src/transactions.rs +++ b/consensus/src/transactions.rs @@ -281,7 +281,7 @@ async fn check_kis_unique<D: Database>( txs.iter().try_for_each(|tx| { tx.tx.prefix().inputs.iter().try_for_each(|input| { if let Input::ToKey { key_image, .. } = input { - if !spent_kis.insert(key_image.compress().0) { + if !spent_kis.insert(key_image.0) { tracing::debug!("Duplicate key image found in batch."); return Err(ConsensusError::Transaction(TransactionError::KeyImageSpent)); } diff --git a/storage/blockchain/src/ops/tx.rs b/storage/blockchain/src/ops/tx.rs index 0312f215..add5afd9 100644 --- a/storage/blockchain/src/ops/tx.rs +++ b/storage/blockchain/src/ops/tx.rs @@ -96,7 +96,7 @@ pub fn add_tx( match inputs { // Key images. Input::ToKey { key_image, .. } => { - add_key_image(key_image.compress().as_bytes(), tables.key_images_mut())?; + add_key_image(key_image.as_bytes(), tables.key_images_mut())?; } // This is a miner transaction, set it for later use. Input::Gen(_) => miner_tx = true, @@ -138,7 +138,7 @@ pub fn add_tx( // Create commitment. let commitment = if miner_tx { - compute_zero_commitment(output.amount.unwrap_or(0)) + compute_zero_commitment(output.amount.unwrap_or(0)).compress() } else { proofs .as_ref() @@ -154,7 +154,7 @@ pub fn add_tx( height, output_flags, tx_idx: tx_id, - commitment: commitment.compress().0, + commitment: commitment.0, }, tables.rct_outputs_mut(), ) @@ -219,7 +219,7 @@ pub fn remove_tx(tx_hash: &TxHash, tables: &mut impl TablesMut) -> DbResult<(TxI match inputs { // Key images. Input::ToKey { key_image, .. } => { - remove_key_image(key_image.compress().as_bytes(), tables.key_images_mut())?; + remove_key_image(key_image.as_bytes(), tables.key_images_mut())?; } // This is a miner transaction, set it for later use. Input::Gen(_) => miner_tx = true, diff --git a/storage/txpool/src/ops/key_images.rs b/storage/txpool/src/ops/key_images.rs index 76cae141..7933f3af 100644 --- a/storage/txpool/src/ops/key_images.rs +++ b/storage/txpool/src/ops/key_images.rs @@ -48,7 +48,7 @@ pub(super) fn remove_tx_key_images( /// This function will panic if the [`Input`] is not [`Input::ToKey`] fn ki_from_input(input: &Input) -> [u8; 32] { match input { - Input::ToKey { key_image, .. } => key_image.compress().0, + Input::ToKey { key_image, .. } => key_image.0, Input::Gen(_) => panic!("miner tx cannot be added to the txpool"), } } diff --git a/types/src/json/tx.rs b/types/src/json/tx.rs index a18dc89a..8aa6b20b 100644 --- a/types/src/json/tx.rs +++ b/types/src/json/tx.rs @@ -71,7 +71,7 @@ impl From<transaction::Transaction> for Transaction { let key = Key { amount: amount.unwrap_or(0), key_offsets, - k_image: HexBytes::<32>(key_image.compress().0), + k_image: HexBytes::<32>(key_image.0), }; Some(Input { key }) @@ -169,7 +169,7 @@ impl From<transaction::Transaction> for Transaction { .base .commitments .into_iter() - .map(|point| HexBytes::<32>(point.compress().0)) + .map(|point| HexBytes::<32>(point.0)) .collect(); let rct_signatures = RctSignatures::NonCoinbase {