Duplicate proposals catch in ns1r#642
Conversation
1a26e6e to
a6259b0
Compare
Pull Request Test Coverage Report for Build 14669174853Details
💛 - Coveralls |
18104a2 to
3d19905
Compare
3a220fc to
93d5518
Compare
93d5518 to
c563761
Compare
arminsabouri
left a comment
There was a problem hiding this comment.
Core logic looks correct to me. I just had a couple nits. Mainly around test related code.
Thanks for picking this one up 🚀
payjoin/src/receive/v2/mod.rs
Outdated
| e: None, | ||
| }); | ||
|
|
||
| pub(crate) static MULTIPARTY_CONTEXT: Lazy<SessionContext> = Lazy::new(|| SessionContext { |
There was a problem hiding this comment.
Is there anything that makes this MULTIPARTY specific? If not maybe we label this SHARED_CONTEXT_2 .
Or should we have a common test util to create hpke session contexts?
payjoin-test-utils/src/lib.rs
Outdated
| pub const MULTIPARTY_SENDER_ONE: &str = "cHNidP8BAMMCAAAAA9cTcqYjSnJdteUn3Re12vFuVb5xPypYheHze74WBW8EAAAAAAD+////6JHS6JgYdav7tr+Q5bWk95C2aA4AudqZnjeRF0hx33gBAAAAAP7///+d/1mRjJ6snVe9o0EfMM8bIExdlwfaig1j/JnUupqIWwAAAAAA/v///wJO4wtUAgAAABYAFGAEc6cWf7z5a97Xxulg+S7JZyg/kvEFKgEAAAAWABQexWFsGEdXxYNTJLJ1qBCO0nXELwAAAAAAAQCaAgAAAAKa/zFrWjicRDNVCehGj/2jdXGKuZLMzLNUo+uj7PBW8wAAAAAA/v///4HkRlmU9FA3sHckkCQMjGrabNpgAw37XaqUItNFjR5rAAAAAAD+////AgDyBSoBAAAAFgAUGPI/E9xCHmaL6DIsjkaD8LX2mpLg6QUqAQAAABYAFH6MyygysrAmk/nunEFuGGDLf244aAAAAAEBHwDyBSoBAAAAFgAUGPI/E9xCHmaL6DIsjkaD8LX2mpIBCGsCRzBEAiBLJUhV7tja6FdELXDcB6Q3Gd+BMBpkjdHpj3DLnbL6AAIgJmFl3kpWBzkO8yDDl73BMMalSlAOQvfY+hqFRos5DhQBIQLfeq7CCftNEUHcRLZniJOq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3uHxAJYASECkzTDZYWXDR6Drhmnc97JGbGX/tYYdQQPxSX9pfUWJMEAAQCaAgAAAAIKOB8lY4eoEupDnxviz0/nAuR2biNFKbdkvckiW5ioPAAAAAAA/v///w0g/mj67592vy29xhnZMGeVtEXN1jD4lU/SMZM8oStqAAAAAAD+////AgDyBSoBAAAAFgAUC3r4YzVSpsWp3knMxbgWIx2R36/g6QUqAQAAABYAFMGlw3hwcx1b+KQGWIfOUxzwrwWkaAAAAAEBHwDyBSoBAAAAFgAUC3r4YzVSpsWp3knMxbgWIx2R368BCGsCRzBEAiA//JH+jonzbzqnKI0Uti16iJcdsXI+6Zu0IAZKlOq6AwIgP0XawCCH73uXKilFqSXQQQrBvmi/Sx44D/A+/MQ/mJYBIQIekOyEpJKpFQd7eHuY6Vt4Qlf0+00Wp529I23hl/EpcQAAAA=="; |
There was a problem hiding this comment.
Nit: If these are PSBTs I would add a _PSBT suffix. Additionally, instead of SENDER I would use ORIGINAL to match the pattern in the rest of this file. Original implies sender psbt
e.g
MULTIPARTY_ORIGINAL_PSBT_ONE.
| } | ||
| } | ||
|
|
||
| fn multiparty_proposal_two() -> v1::UncheckedProposal { |
There was a problem hiding this comment.
More of a question: is it worth it to just consolidate this method with the one above and return a Vec of test vectors? I only say this because they seem to share some boilerplate code.
fn multiparty_proposals() -> Vec<v1::UncheckedProposal> {
let query = "v=2&optimisticmerge=true";
let pairs = url::form_urlencoded::parse(query.as_bytes());
let params = Params::from_query_pairs(pairs, SUPPORTED_VERSIONS)
.expect("Could not parse from query pairs");
[MULTIPARTY_SENDER_ONE, MULTIPARTY_SENDER_TWO]
.iter()
.map(|psbt_str| v1::UncheckedProposal {
psbt: Psbt::from_str(psbt_str).expect("known psbt should parse"),
params,
})
.collect()
}|
CI failures seems related to #658 which just got merged. So this branch just needs a rebase |
c563761 to
459e657
Compare
arminsabouri
left a comment
There was a problem hiding this comment.
LGMT. Just one small comment about some commented out code.
|
Whoops, good catch. As for the failing CI should we not display the session context in the error? |
Perhaps just a top level identifier would work fine. The short id should work fine |
10093ba to
58cb52b
Compare
|
I kept the SessionContext as what is displayed, I just no longer leak it as accessible in the pub error interface and instead just stringify it |
The SessionContext does include the hpke keypair. Can you confirm that secret key material is redacted when its stringified. |
| "Two sender psbts are identical\n left: {}\n right: {}", | ||
| current_psbt, incoming_psbt | ||
| ), | ||
| #[cfg(feature = "v2")] |
There was a problem hiding this comment.
Do we need this feature flag?
|
yes the hpke keypair is redacted in the stringify method. But the symmetric pk is not... I think I am just not going to expose the session context after all, what do you think? |
58cb52b to
2e4baf2
Compare
I think short id is fine. |
2e4baf2 to
88591af
Compare
|
Ended up adding a new |
88591af to
7550506
Compare
|
Lint is failing. Need #667 to go in first |
The Receiver Struct has a way of getting the short id but the UncheckedProposal does not. This adds a similar id method for getting the short id instead for the session context instead of exposing the whole context.
7550506 to
d3108b3
Compare
When building a multiparty proposal we did not have a catch to make sure that the proposals were all unique and as such a multiparty could be built by just adding the same proposal over and over. This creates a new error IdenticalProposals that checks to make sure the contexts are not matching when adding to a multiparty.
d1efc03 to
587af2d
Compare
arminsabouri
left a comment
There was a problem hiding this comment.
Ack 587af2d
My only other peice of feedback would be to expose the short id method on session context instead of any particular receiver type state. This out of the scope of this PR but worth noting.
When building a multiparty proposal we did not have a catch to make sure that the proposals were all unique and as such a multiparty could be built by just adding the same proposal over and over. This creates a new error IdenticalProposals that checks to make sure the contexts are not matching when adding to a multiparty.
Closes #640