Giter Site home page Giter Site logo

matt783 / bls12-381_hash Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kwantam/bls12-381_hash

0.0 1.0 0.0 332 KB

Fast and simple constant-time hashing to the BLS12-381 elliptic curve

Home Page: https://bls-hash.crypto.fyi

License: Apache License 2.0

CMake 5.72% C 72.74% C++ 0.17% Python 16.49% Shell 1.43% Makefile 0.12% Objective-C 3.32%

bls12-381_hash's Introduction

hashing to BLS12-381

We describe and implement maps to BLS12-381 based on SvdW06 and and the "simplified SWU" map of BCIMRT10.

The SvdW map is similar to the one described in FT12, except that our construction is defined at every point in the base field. This may simplify constant-time implementations.

The SWU map uses two new tricks to speed up evaluation. It also uses only field operations, and in particular does not require fast Legendre symbol or extended Euclidean algorithms, which the SvdW map requires for efficiency. This simplifies implementation---especially constant-time implementation---since both of those algorithms would require implementing arbitrary modular reductions rather than reductions modulo a fixed prime.

The paper derives the maps and describes our optimizations. Our evaluation (see the paper) shows that the constant-time SWU map is never more than ~9% slower than the fastest (non--constant-time) implementations of the SW map. Moreover, comparing SW vs SWU when both are implemented in constant time using field ops only shows that the SWU map is faster by 1.3--2x.

We implement hashes to the G1 and G2 subgroups of the BLS12-381 curve.

  • "hash-and-check", as described in BLS03

  • one evaluation of the SvdW map followed by a point multiplication to clear the cofactor

  • sum of two evaluations of the SvdW map followed by a point multiplication to clear the cofactor

  • sum of one evaluation of the SvdW map with cofactor cleared plus one random element of the G1 subgroup (only for G1; performance would be too bad in G2)

  • one evaluation of the SWU map followed by a point multiplication to clear the cofactor

  • sum of two evaluations of the SWU map followed by a point multiplication to clear the cofactor

  • sum of one evaluation of the SWU map with cofactor cleared plus one random element of the G1 subgroup (only for G1; performance would be too bad in G2)

For each hash, we implement up to three versions:

  1. non--constant time, using GMP for field ops, and fast inversions and Legendre symbols,

  2. non--constant time, using GMP but restricted to using only field operations, and

  3. constant time, using only field ops for which we provide constant-time implementations.

The code uses several addition chains, which we found using addchain. Future work is to consider addition-subtraction chains, too.

BCIMRT10: Brier, Coron, Icart, Madore, Randriam, Tibouchi. "Efficient Indifferentiable Hashing into Ordinary Elliptic Curves." Proc. CRYPTO, 2010.

BLS01: Boneh, Lynn, and Shacham. "Short signatures from the Weil pairing." Proc. ASIACRYPT, 2001.

FT12: Fouque and Tibouchi, "Indifferentiable hashing to Barreto-Naehrig curves." Proc. LATINCRYPT, 2012.

SvdW06: Shallue and van de Woestijne, "Construction of rational points on elliptic curves over finite fields." Proc. ANTS 2006.

License

This software is (C) 2019 Riad S. Wahby

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

bls12-381_hash's People

Contributors

kwantam avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.