Browser-compatible implementation of Node.js crypto module providing cryptographic operations in web environments.
Overall
score
100%
Implement a secure key exchange system that allows two parties to establish a shared secret over an insecure channel. The system should support key generation, public key exchange, and shared secret computation using elliptic curve cryptography.
Create a module that implements the following functionality:
The implementation should:
Create your implementation in src/keyExchange.js with the following exports:
createKeyPair() - Creates and returns a new key exchange instancegetPublicKey(format) - Returns public key (format: 'compressed' or 'uncompressed')getPrivateKey() - Returns private key as hex stringcomputeSharedSecret(otherPublicKey) - Computes shared secret from other party's public key, returns hex stringimportPrivateKey(privateKeyHex) - Imports a previously exported private keyProvides cryptographic operations including elliptic curve key exchange.
Create a test in src/keyExchange.test.js that:
Expected outcome: Both parties derive the same shared secret value.
Create a test that:
Expected outcome: Compressed public keys work correctly for secret computation.
Create a test that:
Expected outcome: Imported keys produce the same cryptographic behavior as the original keys.
Install with Tessl CLI
npx tessl i tessl/npm-crypto-browserifydocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10