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

[Protocol Upgrade] Hash hashes as binary instead of hex representation #1

Open
FantasticoFox opened this issue May 30, 2024 · 3 comments

Comments

@FantasticoFox
Copy link

Currently the hasher is using strings which are concatenated and then hashed again.
We would like to change this behavior to use the binary representation of the hashes instead.

If a hash is not present (like signature or witness as optional input hashes) they are not added to the hasher-digest (input hashes for the verifiction_hash).

Example: using binary-representation of hashes and using a SHA3 hasher like this one to hash it.

In PHP this is done via:

<!DOCTYPE html>
<html>
<body>

<?php
$hash = "a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26";
$binhash = hex2bin($hash);
$hashed = hash('sha3-512', $binhash);
echo "$hashed";
?>

</body>
</html>

When calculating the different hashes we choose binary input or string input as follows.

binary

  • verification {
    content_hash (sha3 / 64 bytes)
    metadata_hash (sha3 / 64 bytes)
    prev_ref_hash? (sha3 / 64 bytes)
    merge_ref_hash? (sha3 / 64 bytes)
    }
  • signature {
    eth signature (libsecp256k1 signature + recoveryid / 65 bytes)
    eth pubkey (libsecp256k1 public_key / 65 bytes)
    }
  • merkle-tree/merkle-node {
    left_hash (sha3 / 64 bytes)
    right_hash (sha3 / 64 bytes)
    }
  • witness_hash {
    domain_snapshot_genesis_hash (sha3 / 64 bytes)
    merkle_root (sha3 / 64 bytes)
    witness_network (uint64 / little-endian / 8 bytes)
    witness_event_transaction_hash (eth tx hash / 32 bytes)
    }

text

  • metadata {
    "AQUA" (exactly this),
    version (exactly 4 characters / version number / string),
    time ("YYYYMMDDhhmmss" / numbers only / string),
    domain (variable length, maximum of 64 bytes / hex encoded / string),
    }
  • content {
    like currently
    }
@FantasticoFox
Copy link
Author

@FantasticoFox FantasticoFox transferred this issue from inblockio/mediawiki-extensions-Aqua Sep 10, 2024
@rht
Copy link

rht commented Oct 13, 2024

This will be made obsolete by merklelization of a single revision content and making it a flat key-value dictionary.

@rht
Copy link

rht commented Oct 13, 2024

See inblockio/aqua-verifier-js#28.

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