Skip to content

Verify DomainKeys Identified Mail (DKIM) signatures in solidity

Notifications You must be signed in to change notification settings

AmbireTech/solidity-dkim

 
 

Repository files navigation

Solidity DKIM

A Solidity library to efficiently verify DKIM signatures:

  • Supports rsa-sha1 and rsa-sha256 signature algorithms
  • Implements both canonicalization algorithms (simple, relaxed)
  • Gas costs less than 100 thousand
  • Includes email parser library & demo website
  • Tested on Gmail, iCloud, Outlook, Protonmail and Yahoo

How it works

The goal is to verify DKIM signatures using solidity in a secure, private and economical way.

We achieve that by parsing the raw email off-chain in the user's client, and then running the verification on-chain. This ensures that the email gets securely verified while keeping gas costs low.

The project consists of:

  1. DKIM.sol to verify signatures
  2. parse-email to parse emails (supports node & browser environments)
  3. Service.sol to demonstrate usage with Oracle
  4. solidity-dkim demo demo website

Try it out

  1. download a sample email
  2. (optional) download your own email download
  3. visit demo app
  4. make sure metamask is on the rinkeby network
  5. upload email
  6. verify 🎉

Getting Started

Setup

$ git clone https://github.com/nionis/solidity-dkim
$ cd solidity-dkim
$ npm install

Setup Demo

$ cd client
$ npm install

Run project

$ npm run dev
$ migrate

$ cd client
$ npm run dev

Next steps

  • The goal of this project is to provide the necessary primitives for DKIM verification in an unopinioned way. This is why we only verify what is required and we don't perform any parsing on-chain. The next step is to build a login method within Service.sol.

Contributions to open-sourced projects

3rd party smart contracts

Inspired by

Pitfalls

  • no header boundary found: this is usually due to a raw email format being incorrect. Make sure you "download" the raw email like shown here, since copy / pasting to a text file may replace CRLF characters with LF, learn more

About

Verify DomainKeys Identified Mail (DKIM) signatures in solidity

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Solidity 43.9%
  • JavaScript 29.6%
  • TypeScript 18.6%
  • HTML 7.9%