-
Notifications
You must be signed in to change notification settings - Fork 102
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
Enforce key format in keyset creation #918
Changes from all commits
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 |
---|---|---|
|
@@ -203,3 +203,54 @@ | |
"Scoped acquire of O succeeds" | ||
"Capability acquired" | ||
(test-capability (O))) | ||
|
||
;; | ||
;; keyset formats | ||
;; | ||
|
||
(env-exec-config ["EnforceKeyFormats"]) | ||
(env-data | ||
{ 'bad: ['foo] | ||
, 'short: ["12440d374865bdf0a3349634a70d1317fc279e7e13db98f2199ac5e7378975"] | ||
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. Should we add one character to this short test to cover the largest possible number of failure cases? 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. This PR has merged but I manually checked and that case works. |
||
, 'long: ["12440d374865bdf0a3349634a70d1317fc279e7e13db98f2199ac5e7378975eaea"] | ||
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. Ditto for shortening this long one by one character. Since we're operating in the string domain it's characters, not after-decoded bytes, that are the fundamental unit. 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. Manually checked. |
||
, 'badchars: ["x2440d374865bdf0a3349634a70 1317fc279e7e13db9!f2199ac5e7378975ea"] | ||
, 'ucase: ["12440D374865BDF0A3349634A70D1317FC279E7E13DB98F2199AC5E7378975EA"] | ||
, 'good: ["12440d374865bdf0a3349634a70d1317fc279e7e13db98f2199ac5e7378975ea"] | ||
, 'mixed: ['foo "12440d374865bdf0a3349634a70d1317fc279e7e13db98f2199ac5e7378975ea"] | ||
, 'good2: ["12440d374865bdf0a3349634a70d1317fc279e7e13db98f2199ac5e7378975ea" | ||
"fdd198807260fa07b86f97a918ff7fe3542d98b9ca41a76f509e886dba3ae177"] | ||
|
||
}) | ||
(expect-failure | ||
"enforce kadena key format with flag: fail single" | ||
"Invalid keyset" | ||
(read-keyset 'bad)) | ||
(expect-failure | ||
"enforce kadena key format with flag: fail short" | ||
"Invalid keyset" | ||
(read-keyset 'short)) | ||
(expect-failure | ||
"enforce kadena key format with flag: fail long" | ||
"Invalid keyset" | ||
(read-keyset 'long)) | ||
(expect-failure | ||
"enforce kadena key format with flag: fail badchars" | ||
"Invalid keyset" | ||
(read-keyset 'badchars)) | ||
(expect-failure | ||
"enforce kadena key format with flag: fail uppercase" | ||
"Invalid keyset" | ||
(read-keyset 'ucase)) | ||
|
||
(expect-failure | ||
"enforce kadena key format with flag: fail one bad one good" | ||
"Invalid keyset" | ||
(read-keyset 'mixed)) | ||
(expect-that | ||
"enforce kadena key format with flag: success single" | ||
(constantly true) | ||
(read-keyset 'good)) | ||
(expect-that | ||
"enforce kadena key format with flag: success 2" | ||
(constantly true) | ||
(read-keyset 'good2)) |
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.
Should these formats be scheme-aware?
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.
Schemes are not wallet-supported atm and with this change will need upgrades for support; they also need to be self-identifying so that e.g. an ETH sig will be smth like
eth:0xadf5adf4a...
at which point this mechanism will naturally support adding that.