Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

X25519.js

日本語のREADMEはこちらです: README.ja.md

JavaScript ES module implementation of Elliptic curve Diffie-Hellman key exchange over Curve25519.

Description

In cryptography, Curve25519 is an elliptic curve offering 128 bits of security and designed for use with the elliptic curve Diffie–Hellman (ECDH) key agreement scheme. It is one of the fastest ECC curves; it is not covered by any known patents, and it is less susceptible to weak random-number generators. The reference implementation is public domain software.

The original Curve25519 paper defined it as a Diffie–Hellman (DH) function. Daniel J. Bernstein has since proposed that the name Curve25519 be used for the underlying curve, and the name X25519 for the DH function.

Usage

import { X25519 } from "https://code4fukui.github.io/X25519/X25519.js";
import { Ed25519 } from "https://code4fukui.github.io/Ed25519/Ed25519.js";
import { subbin } from "https://js.sabae.cc/binutil.js";

const user1 = Ed25519.generateKeyPair();
const pub1 = X25519.getPublic(subbin(user1.privateKey, 0, 32));
// send pub1 to user2

const user2 = Ed25519.generateKeyPair();
const pub2 = X25519.getPublic(subbin(user2.privateKey, 0, 32));
// send pub2 to user1

// user1
const shared1 = X25519.getSharedKey(subbin(user1.privateKey, 0, 32), pub2);
// user2
const shared2 = X25519.getSharedKey(subbin(user2.privateKey, 0, 32), pub1);
console.log(shared1, shared2);

Authors

Projects

Links

License

MIT License — see LICENSE.

About

Elliptic curve Diffie-Hellman key exchange over Curve25519

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages