o1-labs / o1js

TypeScript framework for zk-SNARKs and zkApps
https://docs.minaprotocol.com/en/zkapps/how-to-write-a-zkapp
Apache License 2.0
515 stars 117 forks source link

[SHA512 RFC] - Add SHA512 #1462

Open KimlikDAO-bot opened 8 months ago

KimlikDAO-bot commented 8 months ago

SHA512 in o1js

Overview

We propose adding SHA512 to o1js. SHA512 is used in many applications, including but not limited to passports issued by certain countries (Brazil, Mexico, Finland, Türkiye) and various government ID cards.

Implementation

The SHA512 algorithm employs 64-bit unsigned integers (u64) in its operations, which, it appears (https://github.com/o1-labs/o1js/issues/731#issuecomment-1810137079), can be implemented efficiently using the existing o1js functionality.

The basic interface, in line with the existing SHA256 interface, will be defined as:

interface SHA512 {
  hash(data: FlexibleBytes): Bytes;
}

Later on, more specialized and optimized methods may be added for short byte arrays of length a multiple of 8.

Testing

We will add the following tests:

mitschabaude commented 8 months ago

Yes please!!!