mirror of
https://github.com/Cuprate/cuprate.git
synced 2025-04-06 14:27:28 +00:00
new monero-serai
This commit is contained in:
parent
918d818581
commit
fe3f6acc67
10 changed files with 42 additions and 38 deletions
30
Cargo.lock
generated
30
Cargo.lock
generated
|
@ -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",
|
||||
|
|
|
@ -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" }
|
||||
|
|
|
@ -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!(),
|
||||
})
|
||||
})
|
||||
|
|
|
@ -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),
|
||||
};
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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(())
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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"),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue