UNPKG

o1js-email-verify

Version:

Implemented using [o1js](https://github.com/o1-labs/o1js), this project is a reimplementation of [zk-email](https://github.com/zkemail/zk-email-verify), leveraging the Mina proving system [Kimchi](https://o1-labs.github.io/proof-systems/specs/kimchi.html#

23 lines (22 loc) 1.46 kB
import { Field, Bytes } from 'o1js'; import { Bigint2048 } from 'o1js-rsa'; export { emailVerify }; /** * Verifies a DKIM signature using the provided message, signature, and public key. * * This function hashes the headers, encodes the hash using PKCS#1 v1.5, and verifies the RSA signature. * If required, it also checks the body hash against the one provided in the email headers. * * @param paddedHeader - The padded header as Bytes to be verified. * @param headerHashIndex - The index of the header hash within the padded header as Field. * @param signature - The signature to be verified as Bigint2048. * @param publicKey - The public key used for verification as Bigint2048. * @param modulusLength - The length of the RSA modulus. * @param bodyHashCheck - Boolean indicating whether to check the body hash. * @param paddedBodyRemainingBytes - The remaining padded body bytes as Bytes. * @param precomputedHash - The precomputed hash as Bytes. * @param bodyHashIndex - The index of the body hash within the headers as Field. * @param headerBodyHashIndex - The index of the body hash within the header hash as Field. * @returns - The public key hash. */ declare function emailVerify(paddedHeader: Bytes, headerHashIndex: Field, signature: Bigint2048, publicKey: Bigint2048, modulusLength: number, bodyHashCheck: boolean, paddedBodyRemainingBytes: Bytes, precomputedHash: Bytes, bodyHashIndex: Field, headerBodyHashIndex: Field): Field;