MIRACL Cryptographic SDK: Multiprecision Integer and Rational Arithmetic Cryptographic Library is a C software library that is widely regarded by developers as the gold standard open source SDK for elliptic curve cryptography (ECC).

Related tags

Math MIRACL
Overview

MIRACL

What is MIRACL? Multiprecision Integer and Rational Arithmetic Cryptographic Library – the MIRACL Crypto SDK – is a C software library that is widely regarded by developers as the gold standard open source SDK for elliptic curve cryptography (ECC).

Why is it different? While many other cryptographic SDKs are focused on PC use, MIRACL also enables developers to build security into highly constrained environments, including embedded, mobile apps and SCADA.

Full documentation can be accessed here:

MIRACL enables

  • Reduced program code
  • Greatly simplified program development
  • Developer-designed APIs
  • Rapid implementation, using inline code wrappers, example programs and other innovations

These unique qualities are the reason MIRACL, and the solutions and services built using it, are in use in hundreds of organizations across the world, including BAE Systems, Hitachi, Intel, Panasonic, Toyota and many others.

Features and Benefits: why MIRACL is the right choice

MIRACL delivers a wide and unique range of benefits, enabling developers to secure even the most constrained environments quickly, easily and effectively. It features, amongst others:
  • An inline C++ wrapper – greatly simplifying program development
  • Over 25 example programs in C and C++, covering a wide range of applications, to give development a head start
  • Optimization of both embedded processors and RAM, to help developers overcome device and memory constraints
  • Compatibility with industry security technologies including AES encryption, RSA public key cryptography, Diffie-Hellman key exchange, DSA digital signature, and others
  • A set of tools that enable any new number-theoretic technique to be implemented quickly

The MIRACL library consists of well over 100 routines that cover all aspects of multi-precision arithmetic. Two new data-types are defined - big for large integers and flash (short for floating-slash) for large rational numbers. The large integer routines are based on Knuth’s algorithms, described in Chapter 4 of his classic work ‘The Art of Computer Programming’. Floating-slash arithmetic, which works with rounded fractions, was originally proposed by D. Matula and P. Kornerup. All routines have been thoroughly optimised for speed and efficiency, while at the same time remaining standard, portable C. However optional fast assembly language alternatives for certain time-critical routines are also included, particularly for the popular Intel 80x86 range of processors. A C++ interface is also provided. Full source code is included.

Bug Tracker

MIRACL Ltd. uses JIRA for bug and feature tracking which is integrated with our development system.   If you find a bug, you should report bugs into the MIRACL bug tracker .  You can check that the bug hasn't already been reported by searching for it. If you find the bug already reported, you can add a comment of your own about it, or change its status to "Confirmed". If the bug hasn't been reported, you can file a new bug report.

Community

MIRACL Ltd. is most of all a community of like-minded information security professionals who believe that cryptography is a necessary tool to advance individual freedom and safeguard privacy. MIRACL Ltd. acts on that belief by providing tools that can be used to secure information, guard privacy and advance individual freedom.
Anyone who uses MIRACL Ltd. code or services is part of this global community, and we invite you to help shape MIRACL to better meet your needs. To make it yours!
Keep track of development and community news.

Contributing:

MIRACL Ltd. provides an Open Source suite of solutions for data security.  The MIRACL Ltd. team firmly believes that our solutions and the organizations and users who benefit by them all derive value from active contributions from the community.
You can contribute to help shape and improve our MIRACL Ltd. products.  If you have ideas and suggestions on new features and improvements that you would like to see and help bring to MIRACL Ltd., please fork the public available code on GitHub.

Authors:

MIRACL Ltd.

Copyright and License:

© 2018 MIRACL UK Ltd., All Rights Reserved.

MIRACL SDK provides developers with an extensive and efficient set of cryptographic functions. For further information about its features and functionalities please refer to https://miracl.com.

MIRACL SDK is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

MIRACL SDK is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You can be released from the requirements of the license by purchasing a commercial license. Buying such a license is mandatory as soon as you develop commercial activities involving MIRACL without disclosing the source code of your own applications, or shipping MIRACL with a closed source product.

For full details regarding our MIRACL Ltd. terms of service please refer to the following links:

Comments
  • bls/BN pairing example segfaults

    bls/BN pairing example segfaults

    Hello, When I use the provided example of bls.cpp. There is a segfault that I have traced to the destructor of PFC. Am I missing something? What is being destructed that doesn't exist? Thanks, taybart

    opened by taybart 10
  • Errors in Miracl installation in MAC OS X - Updated with Steps [SOLVED]

    Errors in Miracl installation in MAC OS X - Updated with Steps [SOLVED]

    hello, I am trying to install miracl in OSX from this link https://github.com/jkhoury/MIRACL/blob/enhancement-1/README-makefile.txt

    When I try to generate KSS curve (Line number 39) in link, I am getting error of
    error: use of undeclared identifier 'to_binary' to_binary(y,bytes_per_big,&bytes[j],TRUE);

    Help please, how to solve it. Because I am trying to install java version of miracl from this link https://dsl-external.bbn.com/tracsvr/openP3S/wiki/jmiracl

    But as of now, I am not able to generate library for kss curve, I am stuck.

    Please help.

    Thanks. screen shot 2017-03-31 at 8 15 40 pm

    opened by npj008 10
  • How to serialize the cipher(G1,GT) and reload it ?

    How to serialize the cipher(G1,GT) and reload it ?

    Is there a way to do serialization in Miracl? Some Encryption Systems like ABE and broadcast encryption the cipher is the elements in G1 or GT. I want to separate the encryption process and decryption process in the example program https://github.com/miracl/MIRACL/blob/master/source/curve/pairing/cpabe.cpp to two program . So I think I should dump the Big object and G1 , GT object to a file in encryption program and reload it in Decryption program . Is there a method in Miracl can do this kind of work.

    opened by bo-hub 7
  • Point Multiplication Error

    Point Multiplication Error

    调用miracl库计算点乘时,得出的计算结果不正确,不知错误在哪里?哪位大神能帮忙指点下吗?非常感谢。实现源码如下: p1 = epoint_init(); pa = epoint_init();

    mip->IOBASE=16;
    cinstr(Para_a, "00");
    cinstr(Para_b, "05");
    cinstr(Prime_p, "B640000002A3A6F1D603AB4FF58EC74521F2934B1A7AEEDBE56F9B27E351457D");
    cinstr(Order_n, "B640000002A3A6F1D603AB4FF58EC74449F2934B18EA8BEEE56EE19CD69ECF25");
    cinstr(P1_x, "93DE051D62BF718FF5ED0704487D01D6E1E4086909DC3280E8C4E4817C66DDDD");
    cinstr(P1_y, "21FE8DDA4F21E607631065125C395BBC1C1C00CBFA6024350C464CD70A3EA616");
    cinstr(k1, "01EDEE3778F441F8DEA3D9FA0ACC4E07EE36C93F9A08618AF4AD85CEDE1C22");
    
    ecurve_init(Para_a, Para_b, Prime_p, MR_AFFINE);
    p1->marker = MR_EPOINT_NORMALIZED; 
    epoint_set(P1_x, P1_y, 0, p1);
    
    ecurve_mult(k1, p1, pa);
    cotnum(k1, stdout); 
    cotnum(p1->X, stdout);  
    cotnum(p1->Y, stdout);
    cotnum(pa->X, stdout);  
    cotnum(pa->Y, stdout);
    
    opened by newdible 7
  • Question about bilinearity of pairing

    Question about bilinearity of pairing

    Hi,

    We have completed the implementation of R-ate and now we are verifying its correctness. But we find that once we modify the parameters in the file , it can not meet the properties of bilinearity. Can you give me some advices?

    Parameters in our implementation

    Our parameters are set in advance. They just like this:

    • BN curve: y^2= x^3+b,b=5
    • Tower extension :1-2-4-12 default
    • The characteristic p of the prime field, the group order r, and the trace of Frobenius t_r of the curve are parametrized as follows: default We can easily find that our parameters are quiet similar except t and b.

    problem

    we set the point P and Q to a constant value and modify parameter t and b in in ake12bnx.cpp.Then our result are the same. But we find that it can not meet the properties of bilinearity of the R-ate Pairing. In fact ,we find default in this case.

    However, it meets the properties of bilinearity perfectly if we just use the original parameters in your file. That is to say, we will go wrong if we modify the parameters in your file.

    I wonder if there exists some combination between t and b ?Or any other reasons ?Can you give me some advices?

    Thank you!

    opened by SysFlat 7
  • Montgomery Modulus preparation breaks elliptic curve computation

    Montgomery Modulus preparation breaks elliptic curve computation

    If an elliptic curve is initialiazed and then the function prepare_monty is called then the following elliptic curve computations will be wrong. Here an example of this bug:

    int main(void) {
    
        big x,y,a,p,b, d, order, n0;
        epoint *g,*w;
    
        mip=mirsys(8/4,16);
        mip->IOBASE=10;
    
        // Dummy curve
        a = mirvar(1);
        b = mirvar(44);
        p = mirvar(229);
        x = mirvar(5);
        y = mirvar(116);
        order = mirvar(239);
        d=mirvar(4);
        n0 = mirvar(23);
    
        ecurve_init(a, b, p, MR_PROJECTIVE);  /* initialise curve */
        g = epoint_init();
        w = epoint_init();
    
        if (!epoint_set(x,y,0,g)) /* initialise point */
        {
            printf("1. Problem - point (x,y) is not on the curve\n");
            return 0;
        }
    
        // Multiplication
        ecurve_mult(d,g,w);
        epoint_get(w, x, y);
        cotnum(x, stdout);
    
        // Montgomery Modulus
        prepare_monty(n0);
    
        // Multiplication again
        ecurve_mult(d,g,w);
        epoint_get(w, x, y);
        cotnum(x, stdout);
        return 0;
    }
    

    This programm will output

    156
    12
    

    if you comment the line containing prepare_monty function it will output:

    156
    156
    
    opened by sylvainpelissier 7
  • generating primes with nxprime

    generating primes with nxprime

    I'm trying to test the compiled miracl.a with the following cpp code:

    extern "C" {
      #include "miracl.h"
      #include <stdio.h>
    }
    extern BOOL  nxprime(_MIPT_ big,big);
    extern flash mirvar(_MIPD_ int iv);
    extern miracl *mirsys(int,mr_small);
    
    #include <iostream>
    
    
    int main() {
      big a;
      miracl *mip = mirsys(5000,10);
      a = mirvar(5);
      std::cout << a->len << std::endl;
    }
    
    

    I get the following compiler output

    g++ -m64 -O2 __test__.cpp miracl.a -o test
    Undefined symbols for architecture x86_64:
      "_mirsys", referenced from:
          _main in __test__-1328d4.o
      "_mirvar", referenced from:
          _main in __test__-1328d4.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    

    Please help can't figure out how to use nxprime Here's the question on StackOverflow https://stackoverflow.com/questions/31218430/generating-primes-with-nxprime

    opened by sumproxy 7
  • Compile to ARM

    Compile to ARM

    I'm trying to compile this library for this architecture: uname -a: Linux localhost.localdomain 4.4.0-1030-raspi2 #37-Ubuntu SMP Thu Oct 20 15:06:25 UTC 2016 armv7l armv7l armv7l GNU/Linux

    However, I saw the arm.txt but I don't understand which modifications are necessary . In the case of different archs 64 or 32 bits , you have two libs : linux and linux64, but for ARM what is the solution?

    opened by prvsousa 6
  • OS X Compiling Issues

    OS X Compiling Issues

    Using OS X Yosemite 10.10.1 there are some problems when trying to compile.

    First using the Makefile:

    $ make
    gcc -c -O2 -I. -I/usr/lib   -c -o mrflsh4.o mrflsh4.c
    …
    gcc -c -O2 -I. -I/usr/lib   -c -o mrcore.o mrcore.c
    as   -o mrmuldv.o mrmuldv.s
    ar crv miracl.a mrflsh4.o mrflsh3.o mrflsh2.o mrpi.o mrflsh1.o mrio2.o mrio1.o mrdouble.o mrflash.o mrrand.o mrprime.o mrcrt.o mrscrt.o mrfast.o mrjack.o mrfrnd.o mrxgcd.o mrgcd.o mrstrong.o mrbrick.o mrebrick.o mrcurve.o mrshs256.o mrshs512.o mrfpe.o mrsha3.o mrshs.o mraes.o mrgcm.o mrround.o mrbuild.o mrarth3.o mrbits.o mrarth2.o mrpower.o mrsroot.o mrec2m.o mrgf2m.o mrlucas.o mrzzn2.o mrzzn2b.o mrzzn3.o mrecn2.o mrmonty.o mralloc.o mrarth1.o mrarth0.o mrsmall.o mrcore.o mrmuldv.o 
    r - mrflsh4.o
    …
    r - mrmuldv.o
    gcc -c -O2 -I. -I/usr/lib   -c -o hail.o hail.c
    make: *** No rule to make target `/usr/lib/libm.a', needed by `hail'.  Stop.
    

    It seems to want to reference libm.a which is not an OS X library to my knowledge.

    Next I tried to compile using the tips from the documentation:

    $ gcc -c -O2 -I. -I/miracl.a hail.c -o hail
    $ chmod +x hail
    $ ./hail
    -bash: ./hail: Malformed Mach-o file 
    

    Not sure why things are getting malformed.

    Lastly I tried omitting the -c -O2 flags:

    $ gcc -arch i386 -arch x86_64 -I. -I/miracl.a hail.c -o hail
    Undefined symbols for architecture i386:
      "_copy", referenced from:
          _main in hail-8a8ae1.o
      "_incr", referenced from:
          _main in hail-8a8ae1.o
      "_innum", referenced from:
          _main in hail-8a8ae1.o
      "_mirsys", referenced from:
          _main in hail-8a8ae1.o
      "_mirvar", referenced from:
          _main in hail-8a8ae1.o
      "_mr_compare", referenced from:
          _main in hail-8a8ae1.o
      "_otnum", referenced from:
          _main in hail-8a8ae1.o
      "_premult", referenced from:
          _main in hail-8a8ae1.o
      "_size", referenced from:
          _main in hail-8a8ae1.o
      "_subdiv", referenced from:
          _main in hail-8a8ae1.o
    ld: symbol(s) not found for architecture i386
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    

    Regardless of whether it's i386 or x86_64 compiling without the flags always fails with undefined symbols.

    Are there additional libraries that are required for MIRACL on OS X that I'm not aware of? I would really like to get this running, although I've come up empty.

    opened by wankbank 6
  • Base must be binary

    Base must be binary

    After following all the instruction for installing miracl , I tried running the first sample program for testing and have gotten the following error. MIRACL error from routine mirsys called from your program Base must be binary (MR_ALWAYS_BINARY defined in mirdef.h ?)

    Any idea where I went wrong?

    The sample program I'm talking about

    #include <stdio.h>
    #include "miracl.h"
    /* include MIRACL system */
    
    void main()
    { /* calculate factorial of number */
        big nf;
        /* declare "big" variable nf */
        int n;
        miracl *mip=mirsys(5000,10);
    
        // nf=mirvar(1);
    
        printf("factorial program\n");
        printf("input number n= \n");
        scanf("%d",&n);
        getchar();
        
        while (n>1)
            premult(nf,n--,nf);
    
        printf("n!= \n");
        otnum(nf,stdout); /* output result */
    
    }
    
    opened by CaptainLazarus 5
  • raspbian install MIRACL

    raspbian install MIRACL

    I read 'first.txt' and ran the program.

    1. unzip -j -aa -L MIRACL-master.zip

    2. bash linux However, there was a problem here. gcc: error: unrecognized command line option ‘-m32’; did you mean ‘-mbe32’?

    I'd appreciate it if you could tell me how to solve it.


    raspberry pi4 Model B 8gb

    processor : 0 model name : ARMv7 Processor rev 3 (v7l) BogoMIPS : 108.00 Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xd08 CPU revision : 3

    processor : 1 model name : ARMv7 Processor rev 3 (v7l) BogoMIPS : 108.00 Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xd08 CPU revision : 3

    processor : 2 model name : ARMv7 Processor rev 3 (v7l) BogoMIPS : 108.00 Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xd08 CPU revision : 3

    processor : 3 model name : ARMv7 Processor rev 3 (v7l) BogoMIPS : 108.00 Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xd08 CPU revision : 3

    Hardware : BCM2711 Revision : d03114 Serial : 100000002327a1d1 Model : Raspberry Pi 4 Model B Rev 1.4

    opened by kimud6003 4
LibTomMath is a free open source portable number theoretic multiple-precision integer library written entirely in C.

libtommath This is the git repository for LibTomMath, a free open source portable number theoretic multiple-precision integer (MPI) library written en

libtom 543 Dec 27, 2022
CMath is an open-source project for developers.

Project CMath An open-source project for developers by developers Member of GitHub Developer Program About CMath CMath is an open-source project for C

Jayed Rafi 2 Jun 11, 2022
C++ Matrix -- High performance and accurate (e.g. edge cases) matrix math library with expression template arithmetic operators

Matrix This is a math and arithmetic matrix library. It has stood many years of performing in mission critical production for financial systems. It ha

Hossein Moein 71 Oct 29, 2022
Simple long integer math library for C++

SLIMCPP Simple long integer math library for C++ SLIMCPP is C++ header-only library that implements long integers that exceed maximum size of native t

null 23 Dec 1, 2022
Universal Number Arithmetic

Universal: a header-only C++ template library for universal number arithmetic The goal of the Universal Numbers Library is to offer applications alter

Stillwater Supercomputing, Inc. 296 Dec 23, 2022
nml is a simple matrix and linear algebra library written in standard C.

nml is a simple matrix and linear algebra library written in standard C.

Andrei Ciobanu 45 Dec 9, 2022
Kraken is an open-source modern math library that comes with a fast-fixed matrix class and math-related functions.

Kraken ?? Table of Contents Introduction Requirement Contents Installation Introduction Kraken is a modern math library written in a way that gives ac

yahya mohammed 24 Nov 30, 2022
Jing-Kalk is a beautifully designed calculator that conforms to the JingOS style and Integrating the interactive experience of pad and PC.

Jing-Kalk Jing-Kalk is based on Kalk gitlab. Jing-Kalk is a beautifully designed calculator that conforms to the JingOS style and Integrating the inte

JingOS 42 Nov 26, 2022
A C library for statistical and scientific computing

Apophenia is an open statistical library for working with data sets and statistical or simulation models. It provides functions on the same level as t

null 186 Sep 11, 2022
a lean linear math library, aimed at graphics programming. Supports vec3, vec4, mat4x4 and quaternions

linmath.h -- A small library for linear math as required for computer graphics linmath.h provides the most used types required for programming compute

datenwolf 729 Jan 9, 2023
C++ Mathematical Expression Parsing And Evaluation Library

C++ Mathematical Expression Toolkit Library Documentation Section 00 - Introduction Section 01 - Capabilities Section 02 - Example Expressions

Arash Partow 445 Jan 4, 2023
libmpc++ is a C++ header-only library to solve linear and non-linear MPC

libmpc++ libmpc++ is a C++ library to solve linear and non-linear MPC. The library is written in modern C++17 and it is tested to work on Linux, macOS

Nicola Piccinelli 46 Dec 20, 2022
A lightweight, minimal and customisable maths library for C99

Small Maths Library A lightweight, minimal and customisable maths library for C99, generated by Lua. Generating Requires Lua 5.3. lua sml.lua Generat

null 5 May 6, 2022
Header only, single file, simple and efficient C++ library to compute the signed distance function to a triangle mesh

TriangleMeshDistance Header only, single file, simple and efficient C++11 library to compute the signed distance function to a triangle mesh. The dist

Interactive Computer Graphics 100 Dec 28, 2022
Library for nonconvex constrained optimization using the augmented Lagrangian method and the matrix-free PANOC algorithm.

alpaqa Alpaqa is an efficient implementation of the Augmented Lagrangian method for general nonlinear programming problems, which uses the first-order

OPTEC 21 Dec 9, 2022
A simple C++ complex & real matrix library, with matrix inversion, left division and determinant calculation

NaiveMatrixLib 帆帆的简易矩阵计算库 A simple C++ stdlib-based complex & real matrix library, with matrix inversion, left division (A\b) and determinant calculat

FerryYoungFan 50 Dec 28, 2022
A work-in-progress C++20/23 header-only maths library for game development, embedded, kernel and general-purpose that works in constant context.

kMath /kmæθ/ A work-in-progress general-purpose C++20/23 header-only maths library that works in constant context Abstract The kMath Project aims to p

The λ Project 13 Sep 5, 2022
Easy-to-use Scientific Computing library in/for C++ available for Linux and Windows.

Matrix Table of Contents Installation Development 2.1. Linux 2.2. Windows Benchmarking Testing Quick Start Guide 5.1. Initializers 5.2. Slicing 5.3. P

mlcpp 24 Nov 22, 2022
A toolkit for making real world machine learning and data analysis applications in C++

dlib C++ library Dlib is a modern C++ toolkit containing machine learning algorithms and tools for creating complex software in C++ to solve real worl

Davis E. King 11.6k Dec 31, 2022