Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decrypting payment id in Monero_Cryptonote results in infinite loop #81

Open
Olsm opened this issue May 2, 2019 · 0 comments
Open

Decrypting payment id in Monero_Cryptonote results in infinite loop #81

Olsm opened this issue May 2, 2019 · 0 comments
Assignees

Comments

@Olsm
Copy link

Olsm commented May 2, 2019

On xmrchain.net it says “payment_id8” instead of the previous “payment_id”. The “payment_id8” is the short payment id and in encrypted form. We need to decrypt the encrypted payment id to compare it with the real payment id (which was used when generating the integrated address. I think I found a function for this in monerowp called stealth_payment_id with comment this is a one way function used for both encrypting and decrypting 8 byte payment IDs

I called said function like so:

monero_cryptonote()->stealth_payment_id( $tx['payment_id8'], monero_cryptonote()->txpub_from_extra( $tx['extra'] ), $options[ 'xmr_view_key' ] )

However it ends up in an infinite loop in function scalarmult at line 181 in monerowp/include/crypto/ed25519.php

The code below works and this is actually what monero_payments in monerowp is doing with function verify_non_rpc but this is a horrible way to do it for performance. Every single tx in a block is making an api call to xmrchain in the $tools->check_tx function. and that took almost 1 second per tx in the last test I did. For this reason previously I made it so it would check if the tx has a matching payment id before it calls check_tx, rather than calling it for every single tx block by block. As soon as we manage to decrypt the payment_id so we can match it, we can continue having this performance benefit.

	$tools    = new NodeTools();
	$tx_found = false;

	foreach ( $txs as $tx ) {
	    // TODO: Only call check_tx if payment id is found
		//$decrypted_payment_id = $tx['payment_id8'] ? monero_cryptonote()->stealth_payment_id( $tx['payment_id8'], $tx['tx_hash'], $options[ 'xmr_view_key' ] ) : '';
	    //if ( $decrypted_payment_id == $payment_id ) {
			$tx_hash = $tx[ 'tx_hash' ];
			$result  = $tools->check_tx( $tx_hash, $order->address, $options[ 'xmr_view_key' ] );
			if ( $result ) {
				$tx_found             = $tx;
				$tx_found[ 'output' ] = $result;
				break;
			}
		//}
	}
@serhack serhack self-assigned this May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants