author: Chiachi, YunYan, GA date: 2021/03/18
https://gitlab.com/marigold/tezos/-/tree/marigold@bakingaccount
This draft states only the very first step of the Baking Account. Further Baking Account features can be built upon this. The goal is to allow users to register public keys as master key and spending key.
The idea is as follows:
update_keychain
, which requires revealed key/keyhash.
We define keychain
as
type keychain = {
master_key : key;
spending_key : key;
next_key : (key * cycle) option;
forsaken_key : key list;
}
Where, the master key
is just like a manager key and has all manager rights; and, the spending key
can only do the transfer.
Whenever a master key updating is requested, the new key will be stored in the next key
, along with a corresponding cycle number
where this updating will happen. The replaced key will be stored in forsaken_key
as a history. Any forsaken key cannot be used as a master key again.
The number of cycles for the delayed update is defined as a parameter: master_key_delay_cycles
. Currently, it's fixed to 8
cycles.
There is an invariant that public key
and public key hash
are tied to each other so we can use any of them to indicate an account. The keychain, however, will break this presumption.
So it's important to make sure no module in protocol will use a public key
for identifying an account. As an example, the owner of rolls was changed to a public key hash
.
After separating key-keyhash and running testing for each ops, it boils down to:
The update_keychain
op is defined as
type 'kind operation += {
| Update_keychain : {
master_key : Signature.Public_key.t option;
spending_key: Signature.Public_key.t option;
}
-> Kind.update_keychain manager_operation
If the given keyhash has been converted to a keychain, the operation will update master_key or spending_key. If not, the applied rules for updating a keychain are as follows:
Basic notations:
K
: represent a public key in TezosKH
: represent a key hash, i.e. tz{1,2,…} accountKm
: represent master keyKs
: represent spending keyKn
: represent the next consensus key waiting to be updateda|b
: means a
or b
{key, value}
: a key-value recordhash
: a function for computing KH
from a given K
init
: given K
Ks
, Km
and KH = hash(K)
, if KH
doesn't exist in storage, init
will create a key-value record, {KH, (Km, Ks)}
, into storageinit(K, Km, Ks) ->
let KH = hash(K)
if (KH exists in storage)
reject
else
// save record
{KHc, (Km, Ks)}
update (Km'|Ks', Km, KH) ->
if ( Km is the master key of KH
& Km' <> km
& km' not any old master keys of the same KH )
case
updating spending key ->
{KH, (Km, Ks')}
updating master key ->
{KH, (Km, Ks, Kn = Km')}
// the Kc will be replaced by Kc' after 8 cycles
else
reject
No implementation.
delete (KH, Km) ->
delete {KH, (Km, Ks)} from stoarge
No implementation.
print_KH(KHi) -> { KHi, (Kmi, Ksi) }
perform_operation(KH, Km|Ks, op) ->
case
KH maps to km|ks ->
if km|ks has correct op permission && signature checked
then exec operation
else reject
KH maps no keys ->
if signature checked
then exec operation
else reject
otherwise -> reject
This change was tested in three perspectives:
update_keychain
update_keychain
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing