ecdh test
This commit is contained in:
@ -0,0 +1,15 @@
|
||||
// X25519 aka ECDH on Curve25519 from [RFC7748](https://www.rfc-editor.org/rfc/rfc7748)
|
||||
import { x25519 } from '@noble/curves/ed25519';
|
||||
|
||||
export function genKeys() {
|
||||
const priv = x25519.utils.randomPrivateKey();
|
||||
const pub = x25519.getPublicKey(priv);
|
||||
return {
|
||||
privkey: priv,
|
||||
pubkey: pub
|
||||
};
|
||||
}
|
||||
|
||||
export function sharedKey(priv, pub) {
|
||||
return x25519.getSharedSecret(priv, pub);
|
||||
}
|
||||
|
Reference in New Issue
Block a user