Code Monkey home page Code Monkey logo

sibc's Introduction

Hi there ๐Ÿ‘‹

sibc's People

Contributors

calesanz avatar ioerror avatar jchavezsaab avatar jjchidguez avatar leif avatar thomwiggers 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  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

sibc's Issues

Release Tag Signing for Packaging

Would it be possible to sign the tags of the releases?

I am currently packaging sibc for the arch user repository (python-sibc-git), because it is used in an other project.

Having signed tags/releases would allow users to have more confidence in the autenticity of the package.

Also it would be very helpful if you could create a new release with the MANIFEST.in from #9 .

Thanks

Compatibility with cloudflare/circl

Hi,

First of all thank you very much for this awesome library!

Im currently working on a Go project which has to work with SCIDH keys generated by this library.
I'd like to use cloudflare/circl for the Go part, but I couldn't get them to work yet.

Do you know if these libraries are even compatible at all? Or maybe you can point me in the right direction.

I've tried the following:

package main

import (
	"crypto/rand"
	"encoding/base64"
	"fmt"

	"github.com/cloudflare/circl/dh/csidh"
)

var rng = rand.Reader

func main() {
	var privateKey csidh.PrivateKey
	var publicKey csidh.PublicKey

	if err := csidh.GeneratePrivateKey(&privateKey, rng); err != nil {
		panic(err)
	}

	csidh.GeneratePublicKey(&publicKey, &privateKey, rng)

	var privateOut [37]byte

	if ok := privateKey.Export(privateOut[:]); !ok {
		panic("failed to export")
	}

	fmt.Printf("privateKeyA: %s\n", base64.StdEncoding.EncodeToString(privateOut[:]))

	var publicOut [64]byte

	if ok := publicKey.Export(publicOut[:]); !ok {
		panic("failed to export")
	}

	fmt.Printf("publicKeyA: %s\n", base64.StdEncoding.EncodeToString(publicOut[:]))
}

and then tried to generate a public key from the printed private key. But that failed:

echo "LiTrMfNR3E4iHSTFEiu8I+ETtBVV7z79Ub+0vk/QsERcvu0kuw=="|sibc csidh-pubkey -
Traceback (most recent call last):
  File "/usr/local/bin/sibc", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/sibc/__main__.py", line 153, in csidh_pubkey
    click.echo(b64encode(algo.public_key(b64decode(secret_key.read()))))
  File "/usr/local/lib/python3.9/site-packages/sibc/csidh/__init__.py", line 133, in public_key
    xy = self.gae.GAE_at_0(sk)
  File "/usr/local/lib/python3.9/site-packages/sibc/csidh/gae_df.py", line 58, in GAE_at_0
    return self.GAE(
  File "/usr/local/lib/python3.9/site-packages/sibc/csidh/gae_df.py", line 626, in GAE
    E_k, m, e = self.evaluate_strategy(
  File "/usr/local/lib/python3.9/site-packages/sibc/csidh/gae_df.py", line 277, in evaluate_strategy
    s_i = sign(e[pos])  # Sign of e[pos]
IndexError: tuple index out of range

Thanks a lot in advance. :)

EDIT: I've also tried other test cases but they all seem to fail. Maybe I have to adjust some parameters for this to work?

Maybe wrong output of CSIDH's group action with style df and wd1

Hi,

First of all, thank you for your library. I'm trying to implement my CTIDH and reuse a lot of code from your library.

I ran the CSIDH-1024 protocol three times with a fixed Alice's private key and styles of df, wd1, wd2 respectively. The output public keys were different. I think this is weird.

Here are my steps. First I modified the file sibc/csidh/main.py . I commented the line 40 and added Alice's private key. So after my modification, line 39 ~ 45 became

    # omit line 1~39
    init_runtime()
    # a_private = random_exponents(m)

    a_private = [-2, 0, 0, 0, -4, -1, -1, 1, 0, 1, -2, 1, 0, 2, 1, 2, 0, 0, 0, 2, 1, 0, 1, 0, 0, 4, 0, 3, 0, 0, 0, -1, 0, 2, -1, 1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    assert len(a_private) == n

    a_public = GAE_at_0(a_private)
    # omit line 46~

I know that's not a good way to do it, sorry about that.

Then I ran the following command to see the public key of Alice

sibc -p p1024 -f hvelu -a csidh -s df -e 10 csidh-main
sibc -p p1024 -f hvelu -a csidh -s wd1 -e 10 csidh-main
sibc -p p1024 -f hvelu -a csidh -s wd2 -e 10 csidh-main

The outputs are

  1. df
// The running time is assuming S = 1.00 x M and a = 0.00 x M, and giving in millions of field operations.

// Exponent bounds := ( 4 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 5 5 5 5 5 5 5 5 5 5 5 5 5 4 5 4 3 3 4 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 );

// ===================== Public Key Generation
// --- Alice
// Running time (GAE):                  1.145M + 0.065S + 1.698a = 1.210M;
sk_a := ( -2 0 0 0 -4 -1 -1 1 0 1 -2 1 0 2 1 2 0 0 0 2 1 0 1 0 0 4 0 3 0 0 0 -1 0 2 -1 1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 );
pk_a := 0x60250dbf4f3acfa164280cfd7f911e04c078ac7626bc3b34bba9ebc0f89a5e675d6de1d1f48ab17b2ece19728b5eb594e64d721f58b9d29ef437b8475d1e84b9ebc9da119655314a2af27695d45c304ac877657cd05e590b46e3eb26e7173462391c1295daa7ca4d6e359645d3543acf592fe04e13052ac0ad50c0ae210a8ac;
  1. wd1
// The running time is assuming S = 1.00 x M and a = 0.00 x M, and giving in millions of field operations.

// Exponent bounds := ( 4 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 5 5 6 5 5 5 5 5 5 5 5 5 5 5 5 5 5 4 5 3 3 3 4 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 );

// ===================== Public Key Generation
// --- Alice
// Running time (GAE):                  0.774M + 0.051S + 1.177a = 0.826M;
sk_a := ( -2 0 0 0 -4 -1 -1 1 0 1 -2 1 0 2 1 2 0 0 0 2 1 0 1 0 0 4 0 3 0 0 0 -1 0 2 -1 1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 );
pk_a := 0xea4eb2f8d643e6c1c48bf1658444463b4d225c27a9287356188d0ecc8059333482a03ff6d3e1101a1c0846516c95515ffd4c0902df735a3872e161ca87d1f88faeeeea09d9b46b05176d5e0df43228a0554a2ff020cd7b3e750473fad07864eb52db5d252560a58273393691536111d965d54d381d25aaa7e93385873ceb1c;
  1. wd2
// The running time is assuming S = 1.00 x M and a = 0.00 x M, and giving in millions of field operations.

// Exponent bounds := ( 3 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 3 5 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 );

// ===================== Public Key Generation
// --- Alice
// Running time (GAE):                  0.640M + 0.037S + 0.872a = 0.677M;
sk_a := ( -2 0 0 0 -4 -1 -1 1 0 1 -2 1 0 2 1 2 0 0 0 2 1 0 1 0 0 4 0 3 0 0 0 -1 0 2 -1 1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 );
pk_a := 0x4d7263e488ccc3c1515436dc2262ce86323c40af01b8e795c44fc1b39cc9359f0b2b9492f97df14ee69f40579d6299ecf94aef274e2cff6f9988017d8a2eb3a8b6e1d8b0f59e9331202059dc060a375bb4db5d29787ddeabe8f6668948265ebca56b979df5102c6817f6373644cc79f071f8fe1eacddeedb672abf8523f37f;

These three pk_a are different, and wd2's result coincide with my implementations.

I implemented three versions of CSIDH. One of them is highly simplified, using isogeny of sagemath 10.1+. That one only computes the codomain, but doesn't push any point through the isogeny.

I'm sorry if I'm mistaken. Thank you in advance!

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.