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

feat!: add payment id #6340

Merged
merged 13 commits into from
Jun 3, 2024
Merged

Conversation

SWvheerden
Copy link
Collaborator

Description

Add payment id as buckets into encrypted data field

Motivation and Context

Allows wallets to send encrypted data via the block chain to other wallets

@SWvheerden SWvheerden requested a review from a team as a code owner May 16, 2024 11:18
Copy link

github-actions bot commented May 16, 2024

Test Results (CI)

    3 files    120 suites   38m 59s ⏱️
1 295 tests 1 295 ✅ 0 💤 0 ❌
3 877 runs  3 877 ✅ 0 💤 0 ❌

Results for commit 7ad53c8.

♻️ This comment has been updated with latest results.

@ghpbot-tari-project ghpbot-tari-project added P-acks_required Process - Requires more ACKs or utACKs P-reviews_required Process - Requires a review from a lead maintainer to be merged labels May 16, 2024
Copy link

github-actions bot commented May 16, 2024

Test Results (Integration tests)

 2 files  + 2   1 errors  9 suites  +9   10m 46s ⏱️ + 10m 46s
18 tests +18  13 ✅ +13  0 💤 ±0   5 ❌ + 5 
27 runs  +27  14 ✅ +14  0 💤 ±0  13 ❌ +13 

For more details on these parsing errors and failures, see this check.

Results for commit 7ad53c8. ± Comparison against base commit 0fd2efe.

♻️ This comment has been updated with latest results.

@SWvheerden SWvheerden changed the title [wip]feat!: add payment id feat!: add payment id May 19, 2024
@ghpbot-tari-project ghpbot-tari-project added the P-conflicts Process - The PR has merge conflicts that need to be resolved label May 19, 2024
@ghpbot-tari-project ghpbot-tari-project removed the P-conflicts Process - The PR has merge conflicts that need to be resolved label May 19, 2024
Copy link
Contributor

@hansieodendaal hansieodendaal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, some comments relating to the interpretation of the requirement for a payment ID.

Comment on lines 350 to 353
let payment_id_u64: u64 = payment_id_hex
.parse::<u64>()
.map_err(|_| UiError::HexError("Could not convert payment_id to bytes".to_string()))?;
let payment_id = PaymentId::U64(payment_id_u64);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should allow 256 bytes, not only 8.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just UI support for now, in CW to only support u64

Comment on lines +388 to +391
let payment_id_u64: u64 = payment_id_hex
.parse::<u64>()
.map_err(|_| UiError::HexError("Could not convert payment_id to bytes".to_string()))?;
let payment_id = PaymentId::U64(payment_id_u64);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto size

Comment on lines 79 to 88
pub enum PaymentId {
Zero,
U32(u32),
U64(u64),
U256(U256),
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the brackets are a good idea instead of a perfect variable length.

  • I propose these brackets:
    • 8 bytes
    • 16 bytes
    • 32 bytes
    • 16-byte increments up to 256 bytes (48, 64, 80, ..., 256)

@@ -397,6 +404,7 @@ impl ConsensusConstants {
faucet_value: 0.into(),
transaction_weight: TransactionWeight::latest(),
max_script_byte_size: 2048,
max_encrypted_data_byte_size: 32, // U256 size
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the current EncryptedData::data: [u8; SIZE_TOTAL] plus 256 bytes,

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was debating about making it max_encrypted_data_byte_size or max_payment_id_size
Its currently max payment id in effect, but not name

@@ -461,6 +469,7 @@ impl ConsensusConstants {
faucet_value: 0.into(), // IGOR_FAUCET_VALUE.into(),
transaction_weight: TransactionWeight::v1(),
max_script_byte_size: 2048,
max_encrypted_data_byte_size: 32, // U256 size
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto size

@SWvheerden SWvheerden force-pushed the sw_paymetnid branch 2 times, most recently from f5c471a to c8fa3de Compare May 30, 2024 13:34
applications/minotari_app_grpc/proto/wallet.proto Outdated Show resolved Hide resolved
@@ -29,6 +29,7 @@ pub struct SendTab {
send_input_mode: SendInputMode,
show_contacts: bool,
to_field: String,
payment_id_field: String,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might be good in future to include a drop down for "Custom Text", "Custom binary", "Sender Address"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as well as some other options in future. Exchanges might want a specific field in here.

let mut bytes = Zeroizing::new([0u8; SIZE_VALUE + SIZE_MASK]);
bytes.clone_from_slice(&encrypted_data.as_bytes()[SIZE_NONCE..SIZE_NONCE + SIZE_VALUE + SIZE_MASK]);
let tag = Tag::from_slice(&encrypted_data.as_bytes()[SIZE_NONCE + SIZE_VALUE + SIZE_MASK..]);
let tag = Tag::from_slice(&encrypted_data.as_bytes()[..SIZE_TAG]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Watch out for buffer overrun. Possibly fuzz this with quicktest

Copy link
Collaborator Author

@SWvheerden SWvheerden Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those should all be a constant size, and there min size checks

@ghpbot-tari-project ghpbot-tari-project removed the P-reviews_required Process - Requires a review from a lead maintainer to be merged label Jun 3, 2024
@SWvheerden SWvheerden merged commit ec4e5e9 into tari-project:development Jun 3, 2024
14 of 16 checks passed
@SWvheerden SWvheerden deleted the sw_paymetnid branch June 3, 2024 12:42
SWvheerden added a commit that referenced this pull request Jun 3, 2024
Description
---
Add payment id as buckets into encrypted data field

Motivation and Context
---
Allows wallets to send encrypted data via the block chain to other
wallets

---------

Co-authored-by: stringhandler <[email protected]>
Comment on lines +238 to 241
let mut data = vec![0; bytes.len()];
data.copy_from_slice(bytes);
Ok(Self { data })
}
Copy link
Member

@sdbondi sdbondi Jul 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


        Ok(Self { data: bytes.to_vec() })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-acks_required Process - Requires more ACKs or utACKs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants