Skip to content
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

Multibase, multikey and multihash #1015

Open
matteo-cristino opened this issue Jan 21, 2025 · 5 comments
Open

Multibase, multikey and multihash #1015

matteo-cristino opened this issue Jan 21, 2025 · 5 comments
Assignees

Comments

@matteo-cristino
Copy link
Collaborator

General multi* flow:

  • save the detected base in the codec so that it can be used during the export
  • save in ACK the raw value
  • use the CODEC when printing to print it as it was in input

Printing data in multibase format

Then I print 'data' as 'multibase' # not enough, wath base should be used?

maybe

Then I print 'data' as 'base64 multibase' # base64 can be changed with all bases

?

Printing keys in multikey format

Then I print 'ecdh' from 'keyring' as 'base64 multikey'
Then I print 'ecdh public key' as 'base64 multikey'

Printing hash in multihash format

same as above

Example

Given I have a 'multikey' named 'my key'  # -> ACK.my_key with base and alg in CODEC

When I create the ecdh key with secret 'my key'
When I create the ecdh public key

Then I print the 'my key'
Then I print the 'ecdh public key' as 'base64 multikey'
@matteo-cristino
Copy link
Collaborator Author

Using the Then phase to encode as multistuff does not seems the best option, maybe a When statement can do it better like

When I create the multibase of 'data' with base 'base64'
When I create the multikey of [ecdh|ecdsa] secret key 'key' with base 'base64'
When I create the multikey of eddsa secret key 'key' with base 'base64'
When I create the multikey of [ecdh|ecdsa] public key 'key' with base 'base64'
When I create the multikey of eddsa public key 'key' with base 'base64'
When I create the multihash of sha2-256 'hash' with base 'base64'
When I create the multihash of sha2-384 'hash' with base 'base64'
When I create the multihash of sha3-256 'hash' with base 'base64'
When I create the multihash of sha3-384 'hash' with base 'base64'

(hash can not be autodetected from length since multihash support different type of hash like keccak and shake that can have the same length)

@jaromil
Copy link
Member

jaromil commented Jan 28, 2025

One more round of evaluation about saving the type of hash and the multihash status in CODEC to simplify these statements:

When I create the multihash of ''

which will check if the argument is a hash, and of what kind and will tag it so into CODEC for correct rendering.

Then I print the 'multihash'
Then I print the 'multihash' as 'hex'

If the argument is tagged as multihash in CODEC, then render it as such using base64 as default encoding.

The drawback is that users need to remember what is encoded as multihash which is not evident if renamed. I think it is acceptable.

@matteo-cristino
Copy link
Collaborator Author

The encoding can be moved to the then phase, you are right!

In the hash I left the type of hash since multihash is expanding also to include other hashes, so I do not think you could distinguish between sha2-256 or sha3-256 or keccak-256 or shake-256.

A full list of of multicodec can be found here

@jaromil
Copy link
Member

jaromil commented Jan 28, 2025

We can distinguish saving in CODEC from the info given in the statement:
When("create hash of '' using ''",_name,_hash)
as well from a new Given statement:
Given("have a '' hash '',_encoding,_hashtype)
as well we can think of a When statement which arbitrarily classifies as hash any octet fitting size (size checks should be made everywhere)

@matteo-cristino
Copy link
Collaborator Author

Ok seems good 👌

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

No branches or pull requests

2 participants