Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 | 2x 2x 2x 2x | import {getCurve} from './curves'
/**
* Derive shared secret for key pair.
* @internal
*/
export function sharedSecret(privkey: Uint8Array, pubkey: Uint8Array, type: string) {
const curve = getCurve(type)
const priv = curve.keyFromPrivate(privkey)
const pub = curve.keyFromPublic(pubkey).getPublic()
return priv.derive(pub).toArrayLike(Uint8Array as any, 'be') as Uint8Array
}
|