reply: reply: A new realization of ecc-sm2

2024-01-28 Thread zhongxuan (A)

> "zhongxuan (A)"  writes:

>> Where should I commit my patch? The access request to fork in Nettle / 
>> nettle * GitLab (liu.se)<https://git.lysator.liu.se/nettle/nettle> was 
>> denied.

> Hi, I think you asked for "developer access" in the Nettle repo, which would 
> allow you to push any changes you like to the repository. You can't have 
> that, but unfortunately, I couldn't add any explanatory message when pushing 
> the deny button in gitlab.

> The usual way to contribute code in gitlab (as well as on github), is that 
> you make your own "fork" of the repository, where you have full permissions. 
> You commit your changes to a branch in that fork, and then create a merge 
> request asking for changes to be merged into the original repo.

Yes, I've tried to make a fork in 
https://git.lysator.liu.se/nettle/nettle/-/forks/new but failed, it just 
reports ' An error occurred while forking the project. Please try again. '.
I replied a long email but tragically didn’t attach my patch.
Here I attach my new patch of ecc-sm2.
Besides, could you help me figure out what's wrong with my fork? I preferred to 
commit in fork mode, too.

> See
> https://docs.gitlab.com/ee/user/project/repository/forking_workflow.html
> on how to create a fork from the gitlab ui.

> When you work with git locally, you can have both your own "fork" repo and 
> the original repo as git "remotes".
  
> And if gitlab doesn't work out for you, you could also send the updated patch 
> to this list.

> Best regards,
> /Niels

> --
> Niels Möller. PGP key CB4962D070D77D7FCB8BA36271D8F1FF368C6677.
> Internet email is subject to wholesale government surveillance.
___
nettle-bugs mailing list -- nettle-bugs@lists.lysator.liu.se
To unsubscribe send an email to nettle-bugs-le...@lists.lysator.liu.se


reply: reply: a realization of SM2 and questions about my subscription request of mailinglist

2024-01-22 Thread zhongxuan (A)
Sorry for so long to reply, I tried to fork a branch in 
gitlab(https://git.lysator.liu.se/nettle/nettle) but failed, seemed that I 
don’t have enough permissions, or should I push my code in 
github(https://github.com/gnutls/nettle) ?
Here are the replies: 

>"zhongxuan (A)"  writes:
>
>> Anyway, I made a realization of SM2, Here is the first part of it, 
>> including the curve and sm2_add and sm2_mul in affine coordinate.
>
>Thanks, I'm having a first read, see comments below. It would be good to have 
>a link to the best english-language (and freely available) reference. I think 
>you have told me earlier, and I've found 
>https://datatracker.ietf.org/doc/html/draft-shen-sm2-ecdsa. It would be 
>helpful with a reference in a comment, e.g., at the top of ecc-sm2.c.

Insert a opensource link of this elliptic curve at the top of ecc-sm2.c

>
>> And if it's convenient to you, I can push the other parts including 
>> keygen, crypt and sign.
>
>I think it's a good first step to get basic scalar multiplication working, 
>i.e., ecc_point_mul and ecc_point_mul_g working and tested.

Thus this sm2 is also a 'a + 3 mod p = 0' elliptic curve, the mul_a and mul_g 
function of secp256r1 can also work.
We have tested the result with the geometric method like what in eccdata.c.

>
>For signatures, are they similar to ECDSA, or something different? For 
>encryption, how does that work?

Yes its similar to ECDSA, you can refer to this page:
https://datatracker.ietf.org/doc/html/draft-shen-sm2-ecdsa
Or there is an official public manual about this curve:
http://www.gmbz.org.cn/main/postDetail.html?id=20180724110812
I'm not sure whether could you access these pdfs.

>
>My initial comments on your patch inline below.
>
>Regards,
>/Niels
>
>> --- /dev/null
>> +++ b/ecc-sm2.c
>> @@ -0,0 +1,261 @@
>> +/* ecc-sm2.c
>> +
>> +   Compile time constant (but machine dependent) tables.
>
>Anything that is machine dependent should be in ecc-sm2.h, generated by 
>eccdata.

Removed.

>
>> +   Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights 
>> reserved.
>> +
>> +   This file is part of GNU Nettle.
>> +
>> +   GNU Nettle is free software: you can redistribute it and/or
>> +   modify it under the terms of either:
>> +
>> + * the GNU Lesser General Public License as published by the Free
>> +   Software Foundation; either version 3 of the License, or (at your
>> +   option) any later version.
>> +
>> +   or
>> +
>> + * the GNU General Public License as published by the Free
>> +   Software Foundation; either version 2 of the License, or (at your
>> +   option) any later version.
>> +
>> +   or both in parallel, as here.
>> +
>> +   GNU Nettle 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
>> +   General Public License for more details.
>> +
>> +   You should have received copies of the GNU General Public License and
>> +   the GNU Lesser General Public License along with this program.  If
>> +   not, see http://www.gnu.org/licenses/.
>> +*/
>> +
>> +/* Development of Nettle's ECC support was funded by the .SE 
>> +Internet Fund. */
>> +
>> +#if HAVE_CONFIG_H
>> +# include "config.h"
>> +#endif
>> +
>> +#include 
>> +#include 
>> +
>> +#include "sm2.h"
>> +#include "sm2-internal.h"
>> +#include "ecc-internal.h"
>> +#include "ecc-sm2.h"
>> +#include "ecc-curve.h"
>> +
>> +const char *nettle_sm2_a =
>> +"fffefffc";
>> +const char *nettle_sm2_xG =
>> +"32c4ae2c1f1981195f9904466a39c9948fe30bbff2660be1715a4589334c74c7";
>> +const char *nettle_sm2_yG =
>> +"bc3736a2f4f6779c59bdcee36b692153d0a9877cc62a474002df32e52139f0a0";
>
>These strings appear unused.

Yep, this base point is unused, removed.
The nettle_sm2_a used to check whether a point is in sm2 curve, by checking y^2 
= x^3 + ax + b.

>
>> +static void
>> +ecc_sm2_inv (const struct ecc_modulo *p,
>> +   mp_limb_t *rp, const mp_limb_t *ap,
>> +   mp_limb_t *scratch) { #define a5m1 scratch 
>> +#define
>> +t0 (scratch + ECC_LIMB_SIZE) #define a15m1 t0 #define a32m1 a5m1 
>> +#define a62m1 (scratch + 2*ECC_LIMB_SIZE) #define a96m1 t0 #define 
>> +a3 (scratch + 3*ECC_LIMB_SIZE) #define 

A new realization of ecc-sm2

2024-01-22 Thread zhongxuan (A)
Hi Niels,
I have sent a new version of ecc-sm2 realization patch cause that I'm not sure 
which git repository should I commit (gitlab or github?).
I have tried the ecc_mod_inv and it works well in FP.
Where should I commit my patch? The access request to fork in Nettle / nettle * 
GitLab (liu.se) was denied.
Best regards

___
nettle-bugs mailing list -- nettle-bugs@lists.lysator.liu.se
To unsubscribe send an email to nettle-bugs-le...@lists.lysator.liu.se