Code Monkey home page Code Monkey logo

nano-ecc's People

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nano-ecc's Issues

8051 Optimizations

README says that there was intentions to optimize this code for 8051 asm. Is this still on the roadmap, or has this repo been abandoned?

Difference with micro-ecc and easy-ecc

I noticed a small difference with the repos micro-ecc and easy-ecc. I had to modify myself this line of code (line 1338) in order to make the verify function work fine:

/* Calculate u1 and u2. */
vli_modInv(z, s, curve_n); /* Z = s^-1 */
ecc_bytes2native(u1, p_hash); //modification taken from easy-ecc
vli_modMult(u1, u1, z, curve_n); /* u1 = e/s */
vli_modMult(u2, r, z, curve_n); /* u2 = r/s */

I am not sure if the modification was left out on purpose but I leave it here in case anyone faces the same problem.

minor bugs in vli_add and vli_sub

This patch addresses some corner cases in vli_add and vli_sub. I have not tested it for correctness.

From ba453211161ed86b945ad7df44160959ee40a28f Mon Sep 17 00:00:00 2001
From: Ildar Muslukhov <ildar@redacted>
Date: Sat, 12 Apr 2014 11:37:23 -0700
Subject: [PATCH] Fixed a bug in the vli_add/vli_sub functions (handleding of a
 corner case, when p_right[i] == 0xff)

---
 ecc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ecc.c b/ecc.c
index bc2ee39..00976f2 100644
--- a/ecc.c
+++ b/ecc.c
@@ -220,7 +220,7 @@ static uint8_t vli_add(uint8_t *p_result, uint8_t *p_left, uint8_t *p_right)
         uint8_t l_sum = p_left[i] + p_right[i] + l_carry;
         if(l_sum != p_left[i])
         {
-            l_carry = (l_sum < p_left[i]);
+            l_carry = (l_sum < p_left[i]) | ((l_sum == p_left[i]) && (l_carry));
         }
         p_result[i] = l_sum;
     }
@@ -237,7 +237,7 @@ static uint8_t vli_sub(uint8_t *p_result, uint8_t *p_left, uint8_t *p_right)
         uint8_t l_diff = p_left[i] - p_right[i] - l_borrow;
         if(l_diff != p_left[i])
         {
-            l_borrow = (l_diff > p_left[i]);
+            l_borrow = (l_diff > p_left[i]) | ((l_diff == p_left[i]) && (l_borrow));
         }
         p_result[i] = l_diff;
     }
-- 
1.8.5.2 (Apple Git-48)

secp256k1

Hi, i'm looking at the source and wondering the opinion of the authors on adding the secp256k1 algorithm. I've not implemented an ecc algorithm, but would be interested to know what it will take to implement it and if there are any pointers to what I would need to change. For example, does it require changing scalar values from one of the existing algos, or is it more involved? Also, I was looking for a reference such as http://www.nsa.gov/ia/_files/nist-routines.pdf, but wasn't able to access it, do you know of any references for the secp256k1 algorithm?

Update: I was able to find other implementations, e.g. https://github.com/kmackay/micro-ecc

side-channel vulnerability in the ECDSA sign function

nano-ecc/ecc.c

Lines 1287 to 1291 in a91209d

vli_set(k, p_random);
if(vli_cmp(curve_n, k) != 1)
{
vli_sub(k, k, curve_n);
}

in these lines the random is been subtracted, in order to be smaller than the modulus.
But this conditional step could lead to some side channel attacks, because of the timing differences and because the chosen random and the used curve could affect the statistical distribution of the real k used...

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.