-
Notifications
You must be signed in to change notification settings - Fork 2
[ALPHANET] P256 #29
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
base: develop
Are you sure you want to change the base?
[ALPHANET] P256 #29
Changes from all commits
92cea3d
f9e3c92
4f482ea
c0fc1d2
d9bd28a
29b8b25
3a59e35
7eaec81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ namespace xrpl { | |
| enum class KeyType { | ||
| Secp256k1 = 0, | ||
| Ed25519 = 1, | ||
| P256 = 2, | ||
| }; | ||
|
|
||
| inline std::optional<KeyType> | ||
|
|
@@ -19,6 +20,9 @@ keyTypeFromString(std::string const& s) | |
| if (s == "ed25519") | ||
| return KeyType::Ed25519; | ||
|
|
||
| if (s == "p256") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. keyTypeFromString now returns KeyType::P256 for the string "p256", but the entire downstream signing pipeline — publicKeyType(), verifySigObject(), checkSingleSign(), and checkMultiSign() in both STTx.cpp and Transactor.cpp — accepts P256 keys without ever consulting featurePasskey. The Passkey amendment only gates the PasskeyListSet transaction type, so any other transaction (Payment, TrustSet, OfferCreate) can be signed with a P256 key and accepted by nodes running this code regardless of whether the amendment has activated. Nodes that have not adopted this build will reject those transactions as invalid-signature, causing a ledger fork. Every P256 recognition point in publicKeyType(), verifySigObject(), and Transactor::checkSingleSign() must be gated behind rules.enabled(featurePasskey). Suggested fixGate P256 key recognition inside publicKeyType() behind a Rules parameter checked against featurePasskey — returning nullopt when the amendment is not active causes the entire signing pipeline to reject P256 keys as malformed without needing changes throughout verifySigObject or checkSingleSign. Alternatively, add rules.enabled(featurePasskey) guards in verifySigObject and Transactor::checkSingleSign before the P256 routing branches. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding Suggested fixIn RPCHelpers.cpp |
||
| return KeyType::P256; | ||
|
|
||
| return {}; | ||
| } | ||
|
|
||
|
|
@@ -31,6 +35,9 @@ to_string(KeyType type) | |
| if (type == KeyType::Ed25519) | ||
| return "ed25519"; | ||
|
|
||
| if (type == KeyType::P256) | ||
| return "p256"; | ||
|
|
||
| return "INVALID"; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function silently truncates output when it encounters invalid base64url characters — the underlying decoder breaks on the first unrecognized byte and returns a shorter string with no indication of failure. Because the return type is
std::string, callers cannot distinguish a valid empty decode from a malformed input that produced zero bytes. The current WebAuthn call site inverifyPasskeySignatureis safe because it compares both size and content againstexpectedSigningData, but any future caller that only checks for a non-empty result will silently accept malformed input. Returnstd::optional<std::string>(nullopt on error) or throw on invalid characters to make failure observable at the API boundary.Suggested fix
Change the signature to
std::optional<std::string> base64urlDecode(std::string_view data)and returnstd::nulloptif, after character substitution and padding, the decoded byte count is not consistent with the padded input length (i.e., ifbase64::decodeconsumed fewer characters than expected). Alternatively, validate that every character in the input is a member of the base64url alphabet (A-Z,a-z,0-9,-,_) before decoding and return an error for any violation. Update the sole call site inverifyPasskeySignatureto treatstd::nulloptas a verification failure.