From 1d02c22e78783913aab22d42fef8e2b824e5ebf5 Mon Sep 17 00:00:00 2001 From: danieljperry Date: Thu, 14 Mar 2024 15:31:58 +0800 Subject: [PATCH 1/5] Open new CHIP for signer protocol serialization --- CHIPs/chip-wallet_api_serialization.md | 61 ++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 CHIPs/chip-wallet_api_serialization.md diff --git a/CHIPs/chip-wallet_api_serialization.md b/CHIPs/chip-wallet_api_serialization.md new file mode 100644 index 00000000..c430e12a --- /dev/null +++ b/CHIPs/chip-wallet_api_serialization.md @@ -0,0 +1,61 @@ +CHIP Number | < Creator must leave this blank. Editor will assign a number.> +:-------------|:---- +Title | Signer Protocol Serialization +Description | A JSON-CLVM-binary serialization technique for the wallet signer protocol +Author | [Matt Hauff](https://github.com/Quexington) +Editor | [Dan Perry](https://github.com/danieljperry) +Comments-URI | < Creator must leave this blank. Editor will assign a URI.> +Status | < Creator must leave this blank. Editor will assign a status.> +Category | Process +Sub-Category | Tooling +Created | 2024-03-14 +Requires | [0027](https://github.com/Chia-Network/chips/pull/102) +Replaces | None +Superseded-By | None + + +## Abstract + +This CHIP provides a standard method for serializing the APIs presented in `CHIP-0027` from JSON to binary. + +## Motivation + +The APIs from `CHIP-0027` are listed in JSON, but the wallet signer protocol only recognizes binary large objects (BLOBs). Therefore, this CHIP is needed as a standard method for serializing the APIS from JSON into bytes. + +## Backwards Compatibility + +This CHIP does not introduce any backwards incompatibilities. + +## Rationale + +This CHIP creates a standard method of converting JSON to CLVM, and later to binary. The reason to implement serialization in this way is to minimize the number of required dependencies. By definition, every type of signer (with the exception of blind signers) must examine the spends it is signing. Therefore, CLVM is required. With the design of this CHIP, JSON libraries become extra dependencies. Effectively, this design keeps the potential attack surface as small as possible. + +## Specification + +Prior to serialization, the JSON will be converted to CLVM according to the following rules: +1. Each dictionary (which the top layer of JSON must be) will be converted to a nil-terminated CLVM list of key/value pairs, where: + * The keys must be strings + * The values will be serialized recursively +2. Each list will be converted to a nil-terminated CLVM list. The elements of the list will be serialized recursively. +3. Anything that is neither a dictionary, nor a list, must be a string. The string will be interpreted using conventional CLVM syntax (`0x` for bytes, an additional pair of quote marks for strings, etc). + +At this point, the JSON will have been converted into a CLVM tree. That tree will then be serialized in the consensus format specified in the [Chialisp documentation](https://chialisp.com/clvm#serialization). + +## Test Cases + +[todo] + +## Reference Implementation + +[todo] + +## Security + +CNI plans to conduct an internal audit of this code when it is ready. + +## Additional Assets + +None + +## Copyright +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). From aa32220dbcabd60e6f66312f234d87308901198d Mon Sep 17 00:00:00 2001 From: danieljperry Date: Thu, 14 Mar 2024 15:36:02 +0800 Subject: [PATCH 2/5] Assign CHIP 29 --- CHIPs/{chip-wallet_api_serialization.md => chip-0029.md} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename CHIPs/{chip-wallet_api_serialization.md => chip-0029.md} (91%) diff --git a/CHIPs/chip-wallet_api_serialization.md b/CHIPs/chip-0029.md similarity index 91% rename from CHIPs/chip-wallet_api_serialization.md rename to CHIPs/chip-0029.md index c430e12a..e05e474e 100644 --- a/CHIPs/chip-wallet_api_serialization.md +++ b/CHIPs/chip-0029.md @@ -1,11 +1,11 @@ -CHIP Number | < Creator must leave this blank. Editor will assign a number.> +CHIP Number | 0029 :-------------|:---- Title | Signer Protocol Serialization Description | A JSON-CLVM-binary serialization technique for the wallet signer protocol Author | [Matt Hauff](https://github.com/Quexington) Editor | [Dan Perry](https://github.com/danieljperry) -Comments-URI | < Creator must leave this blank. Editor will assign a URI.> -Status | < Creator must leave this blank. Editor will assign a status.> +Comments-URI | [CHIPs repo, PR #104](https://github.com/Chia-Network/chips/pull/104) +Status | Draft Category | Process Sub-Category | Tooling Created | 2024-03-14 From bb0dabd1600c406afbcef7093abe21571c118fda Mon Sep 17 00:00:00 2001 From: danieljperry Date: Fri, 6 Sep 2024 16:20:35 +0800 Subject: [PATCH 3/5] Add link to reference implementation --- CHIPs/chip-0029.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CHIPs/chip-0029.md b/CHIPs/chip-0029.md index e05e474e..de1c6a51 100644 --- a/CHIPs/chip-0029.md +++ b/CHIPs/chip-0029.md @@ -41,13 +41,9 @@ Prior to serialization, the JSON will be converted to CLVM according to the foll At this point, the JSON will have been converted into a CLVM tree. That tree will then be serialized in the consensus format specified in the [Chialisp documentation](https://chialisp.com/clvm#serialization). -## Test Cases - -[todo] - ## Reference Implementation -[todo] +This CHIP is implemented in [clvm_streamable.py](https://github.com/Chia-Network/chia-blockchain/blob/385916a6a29c5124155b43cb7cfe48c6ec7b3590/chia/wallet/util/clvm_streamable.py). ## Security From f57171244ef83db9e951ad1900238e687b79f99f Mon Sep 17 00:00:00 2001 From: danieljperry Date: Fri, 6 Sep 2024 16:23:15 +0800 Subject: [PATCH 4/5] Add new link --- CHIPs/chip-0029.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHIPs/chip-0029.md b/CHIPs/chip-0029.md index de1c6a51..fee89a26 100644 --- a/CHIPs/chip-0029.md +++ b/CHIPs/chip-0029.md @@ -43,7 +43,9 @@ At this point, the JSON will have been converted into a CLVM tree. That tree wil ## Reference Implementation -This CHIP is implemented in [clvm_streamable.py](https://github.com/Chia-Network/chia-blockchain/blob/385916a6a29c5124155b43cb7cfe48c6ec7b3590/chia/wallet/util/clvm_streamable.py). +This CHIP is implemented in the following locations: +* [clvm_streamable.py](https://github.com/Chia-Network/chia-blockchain/blob/385916a6a29c5124155b43cb7cfe48c6ec7b3590/chia/wallet/util/clvm_streamable.py). +* [hsms](https://github.com/Chia-Network/hsms/blob/8cd5a44ad83c1d7f525a13c8ceb734f2ead89e6e/hsms/clvm_serde/__init__.py) ## Security From bb6263f085e6f3a4db419f66521ce2a1869be052 Mon Sep 17 00:00:00 2001 From: danieljperry Date: Fri, 6 Sep 2024 16:34:38 +0800 Subject: [PATCH 5/5] Move CHIP-29 to Review --- CHIPs/chip-0029.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHIPs/chip-0029.md b/CHIPs/chip-0029.md index fee89a26..b5e5c8e1 100644 --- a/CHIPs/chip-0029.md +++ b/CHIPs/chip-0029.md @@ -5,7 +5,7 @@ Description | A JSON-CLVM-binary serialization technique for the wallet signer Author | [Matt Hauff](https://github.com/Quexington) Editor | [Dan Perry](https://github.com/danieljperry) Comments-URI | [CHIPs repo, PR #104](https://github.com/Chia-Network/chips/pull/104) -Status | Draft +Status | Review Category | Process Sub-Category | Tooling Created | 2024-03-14 @@ -49,7 +49,7 @@ This CHIP is implemented in the following locations: ## Security -CNI plans to conduct an internal audit of this code when it is ready. +Chia Network, Inc. has conducted an internal review of the code involved with this CHIP. ## Additional Assets