Skip to content

Commit 652fa26

Browse files
committed
docs: HIP-792 proofreading edits
Signed-off-by: Brendan Graetz <bguiz@users.noreply.github.com>
1 parent d3d0737 commit 652fa26

1 file changed

Lines changed: 66 additions & 45 deletions

File tree

HIP/hip-792.md

Lines changed: 66 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,33 @@ status: Draft
1010
last-call-date-time: 2023-10-22T16:00:00Z
1111
created: 2023-08-21
1212
discussions-to: https://github.com/hashgraph/hedera-improvement-proposal/discussions/792
13-
updated: 2023-08-22
13+
updated: 2023-08-23
1414
requires: 632
1515
---
1616

1717
## Abstract
1818

1919
<!-- a short (~200 word) description of the technical issue being addressed. -->
2020

21-
HIP-632 adds a new system contract, `hederaAccountService` that exposes a method `isAuthorized(address, messageHash, signatureBlob)`. This HIP proposes a similar version of that which implements the same functionality, but restricted for use *only* on the current (in flight) transaction. This would expose a new method `isAuthorizedCurrentTransaction()`.
21+
HIP-632 adds a new system contract, `hederaAccountService` that exposes a method `isAuthorized(address, messageHash, signatureBlob)`. This HIP proposes a similar version of that function, which implements the same functionality, but restricted for use *only* on the current (in flight) transaction. This exposes a new method `isAuthorizedCurrentTransaction()`.
2222

2323
## Motivation
2424

2525
<!-- The motivation is critical for HIPs that want to change the Hedera codebase or ecosystem. It should clearly explain why the existing specification is inadequate to address the problem that the HIP solves. HIP submissions without sufficient motivation may be rejected outright. -->
2626

27-
`hederaAccountService.isAuthorized(address, messageHash, signatureBlob)` works for the following scenarios:
27+
`hederaAccountService.isAuthorized(address, messageHash, signatureBlob)` does work for the following scenarios:
2828

2929
- When an account's admin key is "simple", and is comprised of either a single EdDSA key, or a single ECDSA key
3030
- When an account's admin key is "complex", and is comprised of multiple EdDSA keys and/or ECDSA keys, combined using one or more `KeyList`s or `ThresholdKey`s.
3131

3232
`hederaAccountService.isAuthorized(address, messageHash, signatureBlob)` does **not** work for the following scenarios:
3333

34-
- When an account's admin key is "complex", and is comprised of multiple EdDSA keys and/or ECDSA keys and/or smart contract IDs, combined using one or more `KeyList`s or `ThresholdKey`s.
34+
- When an account's admin key is "complex", and is comprised of multiple EdDSA keys and/or ECDSA keys and/or **smart contract IDs**, combined using one or more `KeyList`s or `ThresholdKey`s.
3535

3636
The proposed `hederaAccountService.isAuthorizedCurrentTransaction()` method aims to fulfil the above scenario, and specific use cases pertaining to this scenario will be elaborated upon in the [use cases section](#use-cases) below.
3737

3838
Furthermore, Hedera Token Service exposes an authorization mechanism already,
39-
which is capable of handling this scenario that is presently unfulfilled by Hedera Account Service.
39+
which is capable of handling this scenario that is presently unfulfilled by Hedera Account Service as described in HIP-632.
4040
<!-- TODO links/ references that demonstrate this in HTS -->
4141

4242
> NOTE:
@@ -52,43 +52,49 @@ which is capable of handling this scenario that is presently unfulfilled by Hede
5252

5353
In existing code examples where `ecrecover` is used,
5454
a smart contract function is passed in the transaction data in its parameters.
55-
The design of both `isAuthorized(address, messageHash, signatureBlob)`
56-
and `isAuthorizedRaw(address, messageHash, signatureBlob)`,
55+
The design of both `hederaAcountService.isAuthorized(address, messageHash, signatureBlob)`
56+
and `hederaAcountService.isAuthorizedRaw(address, messageHash, signatureBlob)`
5757
in HIP-632 mimics this approach.
5858

59-
This approach is fine in in cases where we assume that:
59+
This approach is adequate in situations where we assume that:
6060

6161
(1) All authorization is performed using cryptographic signatures (EdDSA and/or ECDSA in the case of Hedera).
6262

63-
(2) All authorization is performed "off-chain", that is among clients, and not within or by smart contracts.
63+
(2) All authorization is performed "off-chain", that is among clients, and not within (or by) smart contracts.
6464

65-
While this approach is sufficient on Ethereum and other EVM-compatible networks,
66-
because Externally Owned Acounts (EOAs) are the only type of account
67-
that exists on, and is supported by the network,
68-
this is **not** the case for Hedera.
69-
Hedera, while EVM-compatible, has an account system that supports "simple" keys
70-
(which are approximately analogous to EOAs), **and**
71-
simultaneously supports "complex" keys on accounts.
65+
On Ethereum and other EVM-compatible networks,
66+
this approach is sufficient because Externally Owned Acounts (EOAs)
67+
are the only type of account that exists on,
68+
and is supported by the network.
69+
70+
However, this is **not** the case for Hedera.
71+
While EVM-compatible,
72+
Hedera has an account system that supports "simple" keys on acounts
73+
(which are approximately analogous to EOAs).
74+
Hedera simultaneously supports "complex" keys on accounts
75+
(which have no analogue on EVM-compatible networks).
7276
These complex accounts require special consideration as they support
73-
`KeyList`, `ThresholdKey` (which may be recursively nested),
74-
and whose "leaf nodes" may be comprised of any of
75-
EdDSA keys, ECDSA keys, and even smart contract IDs.
77+
`KeyList`s and `ThresholdKey`s (which may be recursively nested),
78+
and whose "leaf nodes" may be comprised of any of:
79+
EdDSA keys, ECDSA keys, and even **smart contract IDs**.
7680

7781
The authorization methods described in HIP-632 are sufficient to support
7882
the "complex" keys on accounts, as described above, with one exception:
79-
when the "leaf nodes" are smart contract IDs.
80-
In this scenario, both (1) and (2) listed above cannot be met:
83+
When the "leaf nodes" of a "complex" key include one or more **smart contract IDs**.
84+
In this situation, both assumptions (1) and (2) listed above can no longer be held true:
8185

8286
(1) Smart contracts do not have cryptographic keys,
8387
and therefore cannot sign a transaction in order to authorize it.
8488

8589
(2) Smart contract execution occurs exclusively "on-chain",
86-
and therefore a smart contract may not provide its authorisation of a transaction
87-
by any means other than its own execution when invoked within a transaction;
88-
in other words smart contract authorization must necessarily occur while a transaction is "in flight".
90+
and therefore a smart contract may not provide its authorization of a transaction
91+
by any means other than its own execution when invoked within a transaction.
92+
In other words smart contract authorization must necessarily occur while a transaction is "in flight",
93+
and therefore cannot occur client-side before being submitted to the network.
8994

90-
However the latter scenario **should** be supported,
91-
as noted in [Hedera's documentation on Keys](https://docs.hedera.com/hedera/sdks-and-apis/hedera-api/basic-types/key):
95+
However the latter scenario with smart contract IDs
96+
within "complex" keys **should** be supported, as noted in
97+
[Hedera's documentation on Keys](https://docs.hedera.com/hedera/sdks-and-apis/hedera-api/basic-types/key):
9298

9399
> Note that when a Key is a smart contract ID,
94100
> it doesn't mean the contract with that ID will actually create a cryptographic signature.
@@ -114,18 +120,20 @@ to verify authorization of a transaction that will work in the above scenarios.
114120

115121
<!-- Provide a list of “user stories” to express how this feature, functionality, improvement, or tool will be used by the end user. Template for user story: “As (user persona), I want (to perform this action) so that (I can accomplish this goal).” -->
116122

123+
(1)
117124
As a smart contract developer,
118-
I want to code a smart contract in solidity which is able to identify whether a transaction is authorized when sent from an account with a complex key where a smart contract ID is among its components,
125+
I want to code a smart contract in solidity which is able to identify whether a transaction is authorized when sent from an account with a complex key which contains a smart contract ID,
119126
so that I can implement advanced use cases including:
120127

121128
- implement flexible and customisable authorisation rules
122129
- implement advanced multisig use cases without the need to split across multiple transactions
123-
- implement atomic multisig uses cases
130+
- implement atomic multisig use cases
124131
- implement batch processing of multiple transactions
125132

133+
(2)
126134
As a user of Hedera networks,
127135
I want to create an 1-of-2 threshold key on my Hedera account where 1 component of my complex key is either an EdDSA key or an ECDSA key and the other component is a specified smart contract ID,
128-
so that when this smart contract specified in my threshold key can perform actions on behalf of my account.
136+
so that the particular smart contract specified in my threshold key can perform actions on behalf of my account.
129137

130138
## Specification
131139

@@ -137,19 +145,24 @@ This will aid developers who were limited to `ECRECOVER` authorization flows, an
137145

138146
| hash | signature | return | description |
139147
| --- | --- | --- | --- |
140-
| | isAuthorizedCurrentTransaction() | bool | `true`` if account is authorized to carry out transaction execution on account. Accepts protobuf key signature blobs. May be used for ECDSA, EdDSA simple key flows, and complex key flows which include any of ECDSA keys, EdDSA keys, and smart contract IDs. |
148+
| | isAuthorizedCurrentTransaction() | bool | `true` if account is authorized to carry out transaction execution on account. Accepts protobuf key signature blobs. May be used for ECDSA, EdDSA simple key flows, and complex key flows which include any of ECDSA keys, EdDSA keys, and smart contract IDs. |
141149

142150
### `isAuthorizedCurrentTransaction()` Function Usage
143151

144152
This function behaves identically to `isAuthorized(address, messageHash, signatureBlob)` as defined in HIP-632, with the following key differences:
145153

146154
- It is called without specifying any parameters
147155
- This function extracts the values that it needs in order to validate if a transaction is authorized from the current transaction
148-
- Therefore it designed to be used exclusively on the current transaction, which is still in-flight (as clearly communicated by the `CurrentTransaction` suffix in the function name)
156+
- Therefore it designed to be used exclusively on the current transaction, which is still in-flight
157+
- This is clearly communicated by the `CurrentTransaction` suffix in the function name
149158

150-
No new protocol buffer schema definitions are needed as there are no parameters. Internal protocol buffers schema definitions that need to be used to process this function would be existing ones already present in Hedera's base account system, such as `Key`, `ContractID`, `KeyList` and `ThresholdKey`. Potentially this function may also use `SignatureMap` and `SignaturePair` as defined in HIP-632, if necessary.
159+
No new protocol buffer schema definitions are needed as there are no parameters for this function.
160+
Internal protocol buffer schema definitions that need to be used to process this function
161+
would be the existing ones already present in Hedera's base account system,
162+
such as `Key`, `ContractID`, `KeyList` and `ThresholdKey`. Potentially, this function may also use `SignatureMap` and `SignaturePair`,
163+
as defined in HIP-632, if deemed necessary during implementation.
151164

152-
### Examples
165+
### Example usage flows
153166

154167
Happy path example:
155168

@@ -161,14 +174,16 @@ Happy path example:
161174
- `tx` is also subsequently signed by `ecDsaKey`, client-side
162175
- `tx` is executed by submitting it to the network
163176
- HSCS' EVM parses `tx` and invokes the function `customSc.foo`
164-
- This in tun invokes `hederaAcountService.isAuthorizedCurrentTransaction()`
165-
- `hederaAcountService` invokes the system contract implementation
166-
- The system contract uses `TxnAwareEvmSigsVerifier` to determine that `tx` is authorised, because:
177+
- This in turn invokes the system contract function
178+
`hederaAcountService.isAuthorizedCurrentTransaction()`
179+
- `hederaAcountService` invokes the system contract implementation,
180+
which uses `TxnAwareEvmSigsVerifier` to determine that `tx` is authorised, because:
167181
- `tx` has been signed by `edDsaKey`, which is a member of account `0.0.12345`'s `ThresholdKey`
168182
- `tx` has also been signed by `ecDsaKey`, which is a member of account `0.0.12345`'s `ThresholdKey`
169183
- `tx` invokes `customSc`, which is a member of account `0.0.12345`'s `ThresholdKey`
184+
- Put together, all 3 out of the required threshold of 3 have been met
170185
- A `true` return value from `hederaAcountService.isAuthorizedCurrentTransaction()` is obtained within `customSc.foo`
171-
- `customSc.foo` uses this return value to determine that the transaction is authorized, and therefore should execute the happy path for the remainder of its function
186+
- `customSc.foo` uses this return value to determine that the transaction is indeed **authorized**, and therefore should execute the **happy path** for the remainder of its function
172187

173188
Error path example:
174189

@@ -180,30 +195,36 @@ Error path example:
180195
- `tx` is also subsequently signed by `ecDsaKey`, client-side
181196
- `tx` is executed by submitting it to the network
182197
- HSCS' EVM parses `tx` and invokes the function `customScOther.foo`
183-
- This in tun invokes `hederaAcountService.isAuthorizedCurrentTransaction()`
184-
- `hederaAcountService` invokes the system contract implementation
185-
- The system contract uses `TxnAwareEvmSigsVerifier` to determine that `tx` is **not** authorised, because:
198+
- This in turn invokes the system contract function
199+
`hederaAcountService.isAuthorizedCurrentTransaction()`
200+
- `hederaAcountService` invokes the system contract implementation,
201+
which uses `TxnAwareEvmSigsVerifier` to determine that `tx` is **not** authorised, because:
186202
- `tx` has been signed by `edDsaKey`, which is a member of account `0.0.12345`'s `ThresholdKey`
187203
- `tx` has also been signed by `ecDsaKey`, which is a member of account `0.0.12345`'s `ThresholdKey`
188204
- `tx` invokes `customScOther`, which is **not** a member of account `0.0.12345`'s `ThresholdKey`
205+
- Put together, only 2 out of the required threshold of 3 have been met
189206
- A `false` return value from `hederaAcountService.isAuthorizedCurrentTransaction()` is obtained within `customScOther.foo`
190-
- `customScOther.foo` uses this return value to determine that the transaction is **not** authorized, and therefore should execute the error path for the remainder of its function
207+
- `customScOther.foo` uses this return value to determine that the transaction is indeed **unauthorized**, and therefore should execute the **error path** for the remainder of its function.
191208

192209
## Backwards compatibility
193210

194211
<!-- All HIPs that introduce backward incompatibilities must include a section describing these incompatibilities and their severity. The HIP must explain how the author proposes to deal with these incompatibilities. HIP submissions without a sufficient backward compatibility treatise may be rejected outright. -->
195212

196213
This functionality is newly proposed and thus does not overwrite or alter existing functionality.
197214

198-
Notably, this HIP proposes changes to neither `isAuthorized(address, messageHash, signatureBlob)` nor `isAuthorizedRaw(address, messageHash, signatureBlob)`.
215+
Notably, this HIP proposes changes to
216+
neither `isAuthorized(address, messageHash, signatureBlob)`
217+
nor `isAuthorizedRaw(address, messageHash, signatureBlob)`
218+
from HIP-632.
199219

200220
## Security implications
201221

202222
<!-- If there are security concerns in relation to the HIP, those concerns should be explicitly addressed to make sure reviewers of the HIP are aware of them. -->
203223

204-
Ensure that this proposal considers
224+
It vital that this proposal considers
205225
the [new model (v2) boundaries](https://docs.hedera.com/hedera/core-concepts/smart-contracts/security#new-model-v2-boundaries)
206226
and does not break its stipulations.
227+
207228
Specifically:
208229

209230
- Consider that top-level signatures are not supported
@@ -221,12 +242,12 @@ These could imply the user has given their authorization for all such combinatio
221242
<!-- For a HIP that adds new functionality or changes interface behaviors, it is helpful to include a section on how to teach users, new and experienced, how to apply the HIP to their work. -->
222243

223244
Provide a [short, self contained, correct code example](http://sscce.org/)
224-
which demonstrates this HIP, with both error-path and happy-path examples.
245+
which demonstrates this HIP, with both happy path and error path examples.
225246
This will be in the style of existing work:
226247

227248
- [Multisig Account](https://github.com/hedera-dev/hedera-code-snippets/tree/main/multisig-account)
228249

229-
Provide sufficient warnings about improper use of `isAuthorizesCurrentTransaction` in a tutorial,
250+
Provide sufficient warnings about improper use of `isAuthorizedCurrentTransaction` in a tutorial,
230251
at minimum including a list of "Do's and Don'ts".
231252

232253
## Reference Implementations

0 commit comments

Comments
 (0)