Skip to content

WebAuthn key format #1318

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

Merged
merged 36 commits into from
Nov 22, 2023
Merged

WebAuthn key format #1318

merged 36 commits into from
Nov 22, 2023

Conversation

edmundnoble
Copy link
Contributor

@edmundnoble edmundnoble commented Nov 13, 2023

This PR allows WebAuthn keys in keysets.

Public keys of different formats are distinguished by their prefix.

  • Ed25519 keys have no prefix
  • Public keys for WebAuthn appearing in keysets must be prefixed with "WEBAUTHN-".

The new enum DynKeyPair ranges over Ed25519 keypairs and WebAuthn keypairs. Our client-side function for building commands (mkCommand, mkCommand') have counterparts that accept DynKeyPair instead of Ed25519KeyPair: mkCommandWithDynKeys. The new command generators will perform different signing algorithms and produce different signatures, depending on the type of keypair used. This distinction is only meaningful in tests, because real users will never have a WebAuthn private key. Real users using WebAuthn-signed transactions would be using a web client and an authenticator device that hold the secret key on the user's behalf.

The PR adds a lot of new functions for generating, parsing and printing WebAuthn keys. The functions applying to WebAuthn private keys are only used for testing.

The following repl session demonstrates that "WEBAUTHN-" prefixed keys pass format enforcement and are usable as keyset guards:

pact> (env-exec-config ["EnforceKeyFormats"])
["EnforceKeyFormats"]
pact> (env-data {"k": ["WEBAUTHN-a4010103272006215820c18831c6f15306d6271e154842906b68f26c1af79b132dde6f6add79710303bf"]})
"Setting transaction data"
pact> (env-sigs [{"key": "WEBAUTHN-a4010103272006215820c18831c6f15306d6271e154842906b68f26c1af79b132dde6f6add79710303bf", "caps": []}])
"Setting transaction signatures/caps"
pact> (enforce-keyset (read-keyset 'k))
true

PR checklist:

  • Test coverage for the proposed changes
  • PR description contains example output from repl interaction or a snippet from unit test output
  • Documentation has been updated if new natives or FV properties have been added. To generate new documentation, issue cabal run tests. If they pass locally, docs are generated.
  • Any changes that could be relevant to users have been recorded in the changelog

Additionally, please justify why you should or should not do the following:

  • Confirm replay/back compat
    • (I am running a partial replay back to when webauthn sigs were enabled on mainnet)
  • Benchmark regressions
    • Seems unnecessary
  • (For Kadena engineers) Run integration-tests against a Chainweb built with this version of Pact

@@ -95,7 +102,7 @@ data Command a = Command
, _cmdSigs :: ![UserSig]
, _cmdHash :: !PactHash
} deriving (Eq,Show,Ord,Generic,Functor,Foldable,Traversable)
instance (Serialize a) => Serialize (Command a)
-- instance (Serialize a) => Serialize (Command a)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This instance seemed unused, and it's very risky to provide this instance, but I don't want to break downstream if I don't have to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jmcardon do you want this instance back? If so maybe we should write up a ticket for adding this back and using an explicit definition instead of using deriving.

@imalsogreg imalsogreg force-pushed the mlep/webauthn-jwk-formats branch from eebc66a to bfd8ee1 Compare November 15, 2023 23:04
@imalsogreg imalsogreg force-pushed the mlep/webauthn-jwk-formats branch from bfd8ee1 to b0456fd Compare November 15, 2023 23:10
@imalsogreg imalsogreg force-pushed the mlep/webauthn-jwk-formats branch from affb653 to ad875c6 Compare November 21, 2023 19:42
@@ -95,7 +102,7 @@ data Command a = Command
, _cmdSigs :: ![UserSig]
, _cmdHash :: !PactHash
} deriving (Eq,Show,Ord,Generic,Functor,Foldable,Traversable)
instance (Serialize a) => Serialize (Command a)
-- instance (Serialize a) => Serialize (Command a)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jmcardon do you want this instance back? If so maybe we should write up a ticket for adding this back and using an explicit definition instead of using deriving.

Copy link
Contributor

@imalsogreg imalsogreg left a comment

Choose a reason for hiding this comment

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

LGTM

@imalsogreg imalsogreg merged commit 79bf626 into master Nov 22, 2023
@jmcardon jmcardon deleted the mlep/webauthn-jwk-formats branch May 10, 2024 16:24
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