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

Function sharedKey

vmm/src/x25519.js:1525–1534  ·  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

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

Callers

nothing calls this directly

Calls 2

checkArrayTypesFunction · 0.70
crypto_scalarmultFunction · 0.70

Tested by

no test coverage detected