Skip to content
This repository was archived by the owner on May 3, 2024. It is now read-only.

blake2f precompile #51

@Brechtpd

Description

@Brechtpd

Checklist:

  • Can do multiple blake2f hash calculations in a single circuit
  • For each of those blake2f hash calculations, can do any number of rounds
  • Easy to change the layout (number of columns) so different work loads can be handled
  • Possible to do 5M rounds in a circuit with height <= 2**25
  • Doc explaining how the circuit works on a high level
  • Challenge API integration
  • There's a blake2f table struct similar to this one for keccak: https://github.com/privacy-scaling-explorations/zkevm-circuits/blob/bfbedfd1f579fdcee75679773e526b18eefcf10a/zkevm-circuits/src/table.rs#L865. This it the API that will be used by external circuits to lookup blake2f hashes in e.g. for keccak other circuits simple lookup the hash of some input data like this: (1, input_rlc, num_bytes, hash). The format for blake2 will probably be a bit different because of how the blake2f precompile works, perhaps something like this
    • is_enabled column: Set to 1 only for rows that contain valid hash for the data in the column below, otherwise needs to be set to 0 (so no garbage data can be lookup up). In other words is_enabled is set to 1 once per blake2f once all data has been verified and the hash is calculated.
    • num_rounds column: the number of rounds that produced the blake2f hash
    • state_rlc column: the rlc of the state vector data
    • message_rlc column: the rlc of all the input bytes used in the hash
    • offset_counter_0', offset_counter_1' columns: the offset counters
    • f column: final block indicator
    • lo_hash column : the lowest 128 bits of the blake2 hash
    • hi_hash column : the highest 128 bits of the blake2 hash

Description:

Implementation probably similar to sha256, so a good idea to first look at that implementation and use it as a base: privacy-ethereum#756
Presentation: https://docs.google.com/presentation/d/1eHVzLPRIEziCJ_oDuJG0yZ-5klNj_daqioC0UaGDaiw/edit#slide=id.p

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions