Git Product home page Git Product logo

sol-falcon-verify's Introduction

Falcon512 Signature Verification in Solidity

This repo contains a port of the OQS/PQClean Falcon 512 Signature Verification code from C to Solidity in the form of an Ethereum Smart Contract for deployment to a Besu Blockchain. The Ethereum smart contract is currently implemented in a single rather large file: contracts/Falcon.sol.

This solution also contains some associated mocha/truffle tests written in JavaScript. There are 120 tests in all:

  • 20 tests against a single set of test data generated by IronBridge
    • Tests #1..#18: Validation of the inbound data.
    • Test #19 Unhappy Path - All format and type validation requirements are met, apart from the signature which is valid but incorrect.
    • Test #20 Happy Path - All data is valid.
  • Test the verification step of all 100 KAT tests parsed from the NIST Falcon-512 KAT test suite (falcon512-KAT.rsp).

References:

IMPORTANT NOTE ON SECURITY

This implementation of the Falcon Signature Verification algorithm is a Proof of Concept (PoC) only and, as it stands, is not in a state ready for production. It was done purely as a porting exercise in order to determine viability and to estimate gas requirements.

The Solidity/Smart Contract/EVM environment imposes strict rules and restrictions regarding memory and stack utilization, and also some quite serious limitations regarding arrays of constants.

  • In order to work around the former, many variables and function arguments which were originally intended to be stack based, and hence temporary, have been implemented in "storage", also known as the "Contract State". Apart from increasing gas cost, this also creates a serious vulnerability. In this PoC, no attempt has been made to secure, clear or destroy this data.
  • Regarding the latter: there are several large arrays of constants in the original code, and a few more added by myself in the interest of performance. At the time of writing, Solidity does not support arrays of constants, hence these 'constants' are not immutable as intended and could, in theory, be altered in order to break, manipulate or compromise one or more steps in the algorithm.

This list does not intend to be exhaustive - i.e. it is quite possible that there are more vulnerabilities than the two stated above.

Lastly, regarding signature types: Falcon 512 supports a few signature formats. Although every effort has been made to retain all the necessary code for each of the formats, these have not yet been tested or verified.

sol-falcon-verify's People

Contributors

diega avatar eum602 avatar jg-cqc avatar yerayrodriguez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sol-falcon-verify's Issues

contract code size exceeds 24576

hi , i am facing issues in deployment of this contract, i have tried on remix and truffle but even after enabling optimisation code is too ling to be deployed.

kindly can you guide me, how to resolve this issue

Implement Falcon signer without using SHAKE-256

Given the prohibitive cost of SHAKE-256 in the EVM, a replacement must be chosen in #11, then, we must modify some implementation of the signer for using its output in the on-chain verification process. Given that this will run into client environments, it can be implemented in any multiplatform language .

We may need to keep track of this development in a different repository

Mock SHAKE-256 smart contract calls

Falcon reference implementation uses SHAKE-256 as default XOF function. Running this hashing function within the EVM is prohibitively expensive, so, to ensure Falcon correctness against reference test vectors, we must hardcode the return values of this invocations. Later on, this mock XOF smart contract will be replaced with some cost effective dynamic implementation.

Port verify_raw function from reference implementation

This function is the core of the Falcon signature verification. It doesn't need XOF contexts or anything not already present in the execution environment of the EVM.
Moving on implementing this first has a few benefits:

  • the test vectors are intended to be run against this function, so some part of them can be reused for testing
  • measuring the cost associated to this function may give us a pretty good understanding of the cost of the overall public verify method

ref: vrfy.c#645

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.