-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CHIA-1722] Add a version of a passkey puzzle that only asserts puzzl…
…e hash (#18886) Mostly a duplication of the passkey member puzzle but with `ASSERT_MY_PUZZLE_HASH` instead.
- Loading branch information
Showing
5 changed files
with
183 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
chia/wallet/puzzles/custody/member_puzzles/passkey_member_puzzle_assert.clsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
; member puzzle with SECP256-R1 signature provided by a passkey (ie Yubikey) | ||
|
||
(mod (GENESIS_CHALLENGE SECP_PK | ||
Delegated_Puzzle_Hash | ||
; The WebAuthn authenticator data. | ||
; See https://www.w3.org/TR/webauthn-2/#dom-authenticatorassertionresponse-authenticatordata. | ||
authenticator_data | ||
; The WebAuthn client data JSON. | ||
; See https://www.w3.org/TR/webauthn-2/#dom-authenticatorresponse-clientdatajson. | ||
client_data_json | ||
; The index at which "challenge":"..." occurs in `clientDataJSON`. | ||
challenge_index | ||
; the signature returned by the authenticator | ||
signature | ||
; my puzzle hash | ||
puzzle_hash | ||
) | ||
|
||
(include *standard-cl-23*) | ||
(include condition_codes.clib) | ||
(include sha256tree.clib) | ||
|
||
(defconstant b64-charset "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_") | ||
|
||
(defun map-triples (fun n blob) | ||
(if (any (= n (strlen blob)) (> n (strlen blob))) | ||
() | ||
(c (a fun (list (substr blob n (+ n 3)))) (map-triples fun (+ n 3) blob)) | ||
) | ||
) | ||
|
||
(defun flat-map (fun lst) | ||
(if lst | ||
(if (f lst) | ||
(c (a fun (list (f (f lst)))) (flat-map fun (c (r (f lst)) (r lst)))) | ||
(flat-map fun (r lst)) | ||
) | ||
() | ||
) | ||
) | ||
|
||
(defun lookup-b64 (byte) | ||
(substr b64-charset byte (+ byte 1)) | ||
) | ||
|
||
(defun-inline trim-padding (plen output) | ||
(substr output 0 (- (strlen output) plen)) | ||
) | ||
|
||
(defun-inline convert (int) | ||
(if (> int -1) int (+ int 256)) | ||
) | ||
|
||
(defun b64-encode-blob (blob) | ||
(assign | ||
pad_mod (r (divmod (strlen blob) 3)) | ||
padding (if pad_mod (- 3 pad_mod) 0) | ||
bytes (concat blob (substr 0x000000 0 padding)) | ||
sextets | ||
(map-triples (lambda ((& padding) bytes) | ||
(assign | ||
(fb_upper . fb_lower) (divmod (convert (substr bytes 0 1)) 4) | ||
(sb_upper . sb_lower) (divmod (convert (substr bytes 1 2)) 16) | ||
(tb_upper . tb_lower) (divmod (convert (substr bytes 2 3)) 64) | ||
(list | ||
fb_upper | ||
(logior (ash fb_lower 4) sb_upper) | ||
(logior (ash sb_lower 2) tb_upper) | ||
tb_lower | ||
) | ||
) | ||
) | ||
0 | ||
bytes | ||
) | ||
(trim-padding padding (a (c (list 14) (flat-map lookup-b64 sextets)) ())) | ||
) | ||
) | ||
|
||
(assign | ||
message (b64-encode-blob (sha256 Delegated_Puzzle_Hash puzzle_hash GENESIS_CHALLENGE)) | ||
challenge (concat '"challenge":"' message '"') | ||
(if (= (substr client_data_json challenge_index (+ challenge_index (strlen challenge))) challenge) | ||
(c | ||
(list ASSERT_MY_PUZZLEHASH puzzle_hash) | ||
(secp256r1_verify SECP_PK (sha256 authenticator_data (sha256 client_data_json)) signature) | ||
) | ||
(x) | ||
) | ||
) | ||
) |
1 change: 1 addition & 0 deletions
1
chia/wallet/puzzles/custody/member_puzzles/passkey_member_puzzle_assert.clsp.hex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ff02ffff01ff02ff3effff04ff02ffff04ff03ffff04ffff02ff2cffff04ff02ffff04ffff0bff17ff8202ffff0580ff80808080ff8080808080ffff04ffff01ffffffff02ffff03ffff21ffff09ff0bffff0dff178080ffff15ff0bffff0dff17808080ffff01ff0180ffff01ff04ffff02ff05ffff04ffff0cff17ff0bffff10ff0bffff01038080ff808080ffff02ff10ffff04ff02ffff04ff05ffff04ffff10ff0bffff010380ffff04ff17ff8080808080808080ff0180ff02ffff03ff0bffff01ff02ffff03ff13ffff01ff04ffff02ff05ffff04ff23ff808080ffff02ff18ffff04ff02ffff04ff05ffff04ffff04ff33ff1b80ff808080808080ffff01ff02ff18ffff04ff02ffff04ff05ffff04ff1bff808080808080ff0180ffff01ff018080ff0180ffff0cffff01c0404142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5fff05ffff10ff05ffff01018080ffff02ff3cffff04ff02ffff04ff03ffff04ffff06ffff14ffff0dff0580ffff01038080ff8080808080ff02ff12ffff04ff02ffff04ff03ffff04ffff02ffff03ff0bffff01ff11ffff0103ff0b80ffff01ff018080ff0180ff8080808080ffffff02ff2affff04ff02ffff04ff03ffff04ffff0eff11ffff0cffff0183000000ff80ff0b8080ff8080808080ffff02ff2effff04ff02ffff04ff03ffff04ffff02ff10ffff04ff02ffff04ffff04ffff0102ffff04ffff04ffff0101ffff04ffff0102ffff04ffff04ffff0101ff1680ffff04ffff04ffff0104ffff04ffff04ffff0101ff0280ffff04ffff0101ff80808080ff8080808080ffff04ffff04ffff0104ffff04ffff04ffff0101ffff04ff15ff808080ffff04ffff0101ff80808080ff80808080ffff04ff80ffff04ff0bff808080808080ff8080808080ff04ff4fffff04ffff19ffff16ff6fffff010480ff2780ffff04ffff19ffff16ff37ffff010280ff1380ffff04ff1bff8080808080ffff02ff3affff04ff02ffff04ffff04ffff04ff09ff8080ffff04ff0bff808080ffff04ffff14ffff02ffff03ffff15ffff0cff0bffff0102ffff010380ffff0181ff80ffff01ff0cff0bffff0102ffff010380ffff01ff10ffff0cff0bffff0102ffff010380ffff018201008080ff0180ffff014080ffff04ffff14ffff02ffff03ffff15ffff0cff0bffff0101ffff010280ffff0181ff80ffff01ff0cff0bffff0101ffff010280ffff01ff10ffff0cff0bffff0101ffff010280ffff018201008080ff0180ffff011080ffff04ffff14ffff02ffff03ffff15ffff0cff0bff80ffff010180ffff0181ff80ffff01ff0cff0bff80ffff010180ffff01ff10ffff0cff0bff80ffff010180ffff018201008080ff0180ffff010480ff80808080808080ffff0cffff02ffff04ffff04ffff010eff8080ffff02ff18ffff04ff02ffff04ffff04ffff0102ffff04ffff04ffff0101ff1480ffff04ffff04ffff0104ffff04ffff04ffff0101ff0280ffff04ffff0101ff80808080ff80808080ffff04ff0bff808080808080ff8080ff80ffff11ffff0dffff02ffff04ffff04ffff010eff8080ffff02ff18ffff04ff02ffff04ffff04ffff0102ffff04ffff04ffff0101ff1480ffff04ffff04ffff0104ffff04ffff04ffff0101ff0280ffff04ffff0101ff80808080ff80808080ffff04ff0bff808080808080ff808080ff298080ff02ffff03ffff09ffff0cff8200bdff82017dffff10ff82017dffff0dffff0effff018d226368616c6c656e6765223a22ff0bffff012280808080ffff0effff018d226368616c6c656e6765223a22ff0bffff01228080ffff01ff04ffff04ffff0148ffff04ff8205fdff808080ffff841c3a8f00ff15ffff0bff5dffff0bff8200bd8080ff8202fd8080ffff01ff088080ff0180ff018080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters