chromaLTS
chromaLTS
DDeno
Created by chromaLTS on 10/2/2024 in #help
Using std/crypto with x25519 crashes - How do i use node experimental modules instead?
if theres anything else i can help with just let me know 😉
14 replies
DDeno
Created by chromaLTS on 10/2/2024 in #help
Using std/crypto with x25519 crashes - How do i use node experimental modules instead?
@divy Thanks for the quick response in general! ❤️ I understand not spending time on helping to format issues, so i just went ahead and opened this the best i could - https://github.com/denoland/std/issues/6085
14 replies
DDeno
Created by chromaLTS on 10/2/2024 in #help
Using std/crypto with x25519 crashes - How do i use node experimental modules instead?
also can i sidestep the bug rn by importing nodes fixed version somehow – even tho its hidden behind the experimental-modules flag?
14 replies
DDeno
Created by chromaLTS on 10/2/2024 in #help
Using std/crypto with x25519 crashes - How do i use node experimental modules instead?
@divy Sorry to bother you but i dont want to be more intrusive then nessesary – so im opting to ask now instead of making mistakes later. Where do i open it?, std? - theres existing issues similar but seems outdated and stale. -https://github.com/denoland/std/issues/4224 and https://github.com/denoland/deno/issues/16145 but also super old. both still open.
14 replies
DDeno
Created by chromaLTS on 10/2/2024 in #help
Using std/crypto with x25519 crashes - How do i use node experimental modules instead?
sure
14 replies
DDeno
Created by chromaLTS on 10/2/2024 in #help
Using std/crypto with x25519 crashes - How do i use node experimental modules instead?
import { crypto } from "@std/crypto/crypto"; async function deriveSharedSecret(privateKey: any, publicKey: any) { return await crypto.subtle.deriveBits( { name: "X25519", public: publicKey, }, privateKey, 128, ); }

async function genKeys() { const alicesKeyPair = await crypto.subtle.generateKey( { name: "X25519", }, false, ["deriveBits"], ) const bobsKeyPair = await crypto.subtle.generateKey( { name: "X25519", }, false, ["deriveBits"], ) console.log("Keys changed"); return {alicesKeyPair, bobsKeyPair} } async function runExample(){ // Generate 2 X25519 key pairs: one for Alice and one for Bob // In more normal usage, they would generate their key pairs // separately and exchange public keys securely // Alice then generates a secret using her private key and Bob's public key. // Bob could generate the same secret using his private key and Alice's public key. const {alicesKeyPair, bobsKeyPair} = await genKeys() const sharedSecretAlice = await deriveSharedSecret( //@ts-ignore alicesKeyPair.privateKey, //@ts-ignore bobsKeyPair.publicKey, ); let buffer = new Uint8Array(sharedSecretAlice, 0, 10); console.log(${buffer}…[${sharedSecretAlice.byteLength} bytes total] (Alice secret)); const sharedSecretBob = await deriveSharedSecret( //@ts-ignore bobsKeyPair.privateKey, //@ts-ignore alicesKeyPair.publicKey, ); buffer = new Uint8Array(sharedSecretBob, 0, 10); console.log(${buffer}…[${sharedSecretAlice.byteLength} bytes total] (Bob secret)); }
14 replies
DDeno
Created by chromaLTS on 10/2/2024 in #help
Using std/crypto with x25519 crashes - How do i use node experimental modules instead?
this is the code im running
14 replies
DDeno
Created by chromaLTS on 10/2/2024 in #help
Using std/crypto with x25519 crashes - How do i use node experimental modules instead?
@divy error: Uncaught (in promise) OperationError: Invalid key return await crypto.subtle.deriveBits( ^ at deriveBits (ext:deno_crypto/00_crypto.js:4514:15) at SubtleCrypto.deriveBits (ext:deno_crypto/00_crypto.js:1151:26) at deriveSharedSecret (redacted) at Object.redacted (redacted) at async redacted
14 replies
DDeno
Created by chromaLTS on 10/2/2024 in #help
Using std/crypto with x25519 crashes - How do i use node experimental modules instead?
2 sec
14 replies