Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hirbodbehnam/easyx25519
A small library to make working with X25519 key agreement algorithm easier
https://github.com/hirbodbehnam/easyx25519
curve25519 golang golang-library key-agreement x25519
Last synced: 14 days ago
JSON representation
A small library to make working with X25519 key agreement algorithm easier
- Host: GitHub
- URL: https://github.com/hirbodbehnam/easyx25519
- Owner: HirbodBehnam
- License: mit
- Created: 2020-02-26T11:52:35.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-07-27T12:56:15.000Z (over 4 years ago)
- Last Synced: 2024-06-21T04:32:50.794Z (5 months ago)
- Topics: curve25519, golang, golang-library, key-agreement, x25519
- Language: Go
- Size: 7.81 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
# Easy X25519
![Go](https://github.com/HirbodBehnam/EasyX25519/workflows/Go/badge.svg)A simple way to do x25519 key agreements.
## Why this?
* Easy to use
* Use [curve25519.X25519](https://godoc.org/golang.org/x/crypto/curve25519#X25519) for multiplication and not other deprecated methods.
* Small code base
* Use slices of byte instead of [32]byte
## Installing
```
go get github.com/HirbodBehnam/EasyX25519
```
## Usage
This library has three functions.
1. `NewX25519`: Creates a fresh key pair for x25519 key exchange algorithm.
2. `NewX25519FromPrivateKey`: Creates a key pair from private key
3. `(*KeyPair) GenerateSharedSecret`: Pass the other recipient's public key to this command to generate a shared secret
### Documentation
https://pkg.go.dev/github.com/HirbodBehnam/EasyX25519
### Example
Here is a small example from test file:
```go
package mainimport (
"github.com/HirbodBehnam/EasyX25519"
"log"
)func main() {
// generate keys
alice, err := x25519.NewX25519()
if err != nil{
log.Fatalf("could not genearte key for alice: %s",err.Error())
}
log.Printf("Alice public key %x",alice.PublicKey)
bob, err := x25519.NewX25519()
if err != nil{
log.Fatalf("could not genearte key for bob: %s",err.Error())
}
log.Printf("Bob public key %x",bob.PublicKey)
// calculate secret
s1, err := alice.GenerateSharedSecret(bob.PublicKey)
if err != nil{
log.Fatalf("could not get secret for alice: %s",err.Error())
}
s2, err := bob.GenerateSharedSecret(alice.PublicKey)
if err != nil{
log.Fatalf("could not get secret for bob: %s",err.Error())
}
// check if they match
log.Printf("Alice secret %x",s1)
log.Printf("Bob secret %x",s2)
}
```