Code Monkey home page Code Monkey logo

dhkx's People

Contributors

maufl avatar monnand avatar nevo avatar nhelke 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  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

dhkx's Issues

New Group for MSE/PE

Hi

I would like to use your library to implement the key-exchange part of MSE/PE. The spec requires P:

 0xFFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A63A36210000000000090563

And G = 2.

I could easily add a groupId #3 for the purpose but I see that you seem to be aiming for increasing length primes with your different cases.

Could you please suggest to me a way to add this group to your library in clean way, that fits your thinking, and without breaking backwards compatibility. If you tell me how you think it should be done, I will happily do it and submit a pull request.

Best,

Nicholas

Simple implementation issue

Greetings!

I am having trouble understanding how I supply a private key that is not newly created, e.g. created in a previous command. In short, I need to create key pairs in one command and perform secret key derivation in another command.

As the example:

package main

import (
	"github.com/monnand/dhkx"
	"flag"
	"fmt"
	"math/big"
)

var (
	key       = flag.String("key", "", "Private key.")
	pub       = flag.String("pub", "", "Public key.")
	gen       = flag.Bool("gen", false, "Generate asymmetric keypair.")
	derive    = flag.Bool("derive", false, "Derive shared secret key.")
)

func main() {
	flag.Parse()

	g, _ := dhkx.GetGroup(14)

	if *gen {
		// Generate a private key from the group.
		// Use the default random number generator.
		priv, _ := g.GeneratePrivateKey(nil)

		fmt.Printf("Private= %v\n", priv)

		// Get the public key from the private key.
		pub := priv.Bytes()

		fmt.Printf("Public= %x\n", pub)
	}

	if *derive {
		PubKey := dhkx.NewPublicKey([]byte(*pub))

		fmt.Printf("PubKey: %v\n", PubKey)

		// Compute the key
		k, _ := g.ComputeKey(PubKey, *dhkx.DHKey(*key))

		// Get the key in the form of []byte
		key := k.Bytes()
		fmt.Printf("Key: %x\n", key)
	}
}

But I don't understood how to transform the parameter provieded by flag in to dhkx.DHKey:

.\main.go:42:43: cannot convert *key (type string) to type dhkx.DHKey

How to inform the private key?

Thanks 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.