monnand / dhkx Goto Github PK
View Code? Open in Web Editor NEWDiffie-Hellman Key-exchange algorithm in Go
License: Apache License 2.0
Diffie-Hellman Key-exchange algorithm in Go
License: Apache License 2.0
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
Can you add a License to this project?
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.