Skip to content

Capture hpke reply key in session event#762

Merged
arminsabouri merged 1 commit intopayjoin:masterfrom
arminsabouri:unchecked-proposal-hpke-pk
Jun 12, 2025
Merged

Capture hpke reply key in session event#762
arminsabouri merged 1 commit intopayjoin:masterfrom
arminsabouri:unchecked-proposal-hpke-pk

Conversation

@arminsabouri
Copy link
Collaborator

The session reply key stays None until we parse it from an UncheckedProposal. We lose this information because we don’t store an updated SessionContext in the UncheckedProposal session event and we don’t want to store the full updated context either. Instead, we stick to storing only what the session learns at that point. In this case, that’s the proposal itself and the optional HPKE reply key.

This change is cherry-picked off #750

@arminsabouri arminsabouri requested a review from spacebear21 June 11, 2025 18:00
pub enum SessionEvent {
Created(SessionContext),
UncheckedProposal(v1::UncheckedProposal),
UncheckedProposal((v1::UncheckedProposal, Option<crate::HpkePublicKey>)),
Copy link
Contributor

@DanGould DanGould Jun 11, 2025

Choose a reason for hiding this comment

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

This 2-state type is misuse of Option IMO. If this is really what the type is, it should be a variant with Publickey and without public key

see misuse resistance here: https://youtu.be/qfknfCsICUM?si=tEqhp50GxCiYwwuZ&t=2142

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed. But doesnt this line of thinking apply to SessionContext as well?

e: Option<HpkePublicKey>,

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 2-state type is misuse of Option IMO.

This is not 2 states. The tuple represents what information was learned by handling the state transition.

Copy link
Contributor

@DanGould DanGould Jun 11, 2025

Choose a reason for hiding this comment

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

But doesnt this line of thinking apply to SessionContext as well?

Yes, perhaps SessionContext should be 2 separate structs

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 actually had it as 2 structs in the sketch branch but removed to reduce the diff.
How would you prioritize this? Techdebt or needs to be fixed now

Copy link
Contributor

Choose a reason for hiding this comment

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

can you point me to your fix?

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 just checked the branch. It looks like I revereted that change. Might be somewhere in the history.
It was essentially a wrapper around session context with the reply key. Deref trick can be employed to get rid of the wrapper.session_context.X boilerplate.

Copy link
Collaborator

Choose a reason for hiding this comment

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

git reflog is your friend :)

@coveralls
Copy link
Collaborator

coveralls commented Jun 11, 2025

Pull Request Test Coverage Report for Build 15598397011

Details

  • 5 of 5 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.007%) to 85.633%

Totals Coverage Status
Change from base Build 15598235145: 0.007%
Covered Lines: 7033
Relevant Lines: 8213

💛 - Coveralls

The session reply key stays `None` until we parse it from an
`UncheckedProposal`. We lose this information because we don’t store an
updated `SessionContext` in the `UncheckedProposal` session event and we
don’t want to store the full updated context either. Instead, we stick
to storing only what the session learns at that point. In this case,
that’s the proposal itself and the optional HPKE reply key.
@arminsabouri arminsabouri force-pushed the unchecked-proposal-hpke-pk branch from 7cd9382 to 320a9b8 Compare June 12, 2025 00:10
@arminsabouri
Copy link
Collaborator Author

Rebased against master

@spacebear21
Copy link
Collaborator

spacebear21 commented Jun 12, 2025

The outstanding comment on Option doesn't seem to introduce a bad practice we're not already doing, so I'm inclined to merge this as-is to unblock SEL.

Let's make a follow-up issue to maybe refactor SessionContext's use of Option

Copy link
Collaborator

@spacebear21 spacebear21 left a comment

Choose a reason for hiding this comment

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

ACK 320a9b8

@arminsabouri arminsabouri merged commit 9070bb2 into payjoin:master Jun 12, 2025
7 checks passed
@arminsabouri arminsabouri deleted the unchecked-proposal-hpke-pk branch June 12, 2025 16:35
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

Successfully merging this pull request may close these issues.

4 participants