Giter Site home page Giter Site logo

armfazh / h2c-rust-ref Goto Github PK

View Code? Open in Web Editor NEW
24.0 4.0 5.0 290 KB

[RFC9380] Hash to curves - Rust reference implementation

Home Page: https://datatracker.ietf.org/doc/draft-irtf-cfrg-hash-to-curve

License: BSD 3-Clause "New" or "Revised" License

Rust 100.00%
hash elliptic-curves hash-to-curve draft-ietf-hash-to-curve rust cryptography rfc-9380

h2c-rust-ref's Introduction

Hashing to Elliptic Curves

Rustico


IETF Data Tracker: draft-irtf-cfrg-hash-to-curve

Internet-Draft: git repository

This document specifies a number of algorithms that may be used to encode or hash an arbitrary string to a point on an elliptic curve.

Reference Implementation

The purpose of this implementation is for generating test vectors and enabling cross compatibility with other implementations.

Warning

This implementation is not protected against any kind of attack, including side-channel attacks. It MUST NOT be used in production systems.

Limitations

  • No specific architecture optimizations.
  • No side-channel protection, see Warning section.

Development branch master

Draft versions implemented

Latest: v14

Previous: v12, v08, v07, v06, v05

Compatible Implementations

Internals

hash to curve

License

BSD 3-Clause License

Contact

Feel free to open a github issue for anything related to the implementation, otherwise e-mail authors of the draft.

h2c-rust-ref's People

Contributors

armfazh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

h2c-rust-ref's Issues

Remove alloc dependancy

A priori, hasher code like this should really run without an alloc or std dependency, so in particular Vec should not be used anywhere. It may be unavoidable if the standard is bad of course, but things like an XoF mode clearly never need Vec. There is also a lot of redundant hashing.

An expander trait could look like this for example:

pub trait Expander {
    fn construct_dst_prime(&self) -> ArrayVec::<[u8; { MAX_DST_LENGTH +1 }]>;
    fn expand<const LENGTH: usize>(&self, msg: &[u8]) -> [u8; LENGTH];
}

As this trait is internal, construct_dst_prime should really be some setup method, thus avoiding the AtomicRefCell, so maybe:

pub trait Expander {
    fn set_dst(&mut self, dst: &[u8]);
    fn expand<const LENGTH: usize>(&self, msg: &[u8]) -> [u8; LENGTH];
}

pub(super) struct ExpanderXof<T: Update + Clone + ExtendableOutput> {
    pub(super) xofer: T,
    pub(super) dst_prime: ArrayVec::<[u8; { MAX_DST_LENGTH +1 }]>,
    pub(super) k: usize,
}

pub(super) struct ExpanderXmd<T: DynDigest + Clone> {
    pub(super) hasher: T,
    pub(super) dst_prime: ArrayVec::<[u8; { MAX_DST_LENGTH +1 }]>,
    pub(super) block_size: usize,
}

Also, MAX_DST_LENGTH = 256 is enforced by the "I2OSP(len(DST), 1)" in the standard, but where does this DST shortening logic? I'm only seeing "ABORT .. if len(DST) > 256" in https://datatracker.ietf.org/doc/draft-irtf-cfrg-hash-to-curve/16/

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.