MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / sharedKey

Function sharedKey

vmm/ui/src/lib/x25519.js:1524–1533  ·  view source on GitHub ↗

* Returns a raw shared key between own private key and peer's public key (in other words, this is an ECC Diffie-Hellman function X25519, performing scalar multiplication). * * The result should not be used directly as a key, but should be processed with a one-way function (e.g. HSalsa20 as

(secretKey, publicKey)

Source from the content-addressed store, hash-verified

1522 * @returns Uint8Array
1523 */
1524 function sharedKey(secretKey, publicKey) {
1525 checkArrayTypes(publicKey, secretKey);
1526 if (publicKey.length !== 32)
1527 throw new Error('wrong public key length');
1528 if (secretKey.length !== 32)
1529 throw new Error('wrong secret key length');
1530 var sharedKey = new Uint8Array(32);
1531 crypto_scalarmult(sharedKey, secretKey, publicKey);
1532 return sharedKey;
1533 }
1534 /**
1535 * Signs the given message using the private key and returns a signed message (signature concatenated with the message copy).
1536 *

Callers

nothing calls this directly

Calls 2

checkArrayTypesFunction · 0.70
crypto_scalarmultFunction · 0.70

Tested by

no test coverage detected