* 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)
| 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 | * |
nothing calls this directly
no test coverage detected