Guys I would appreciate some help. I have wasted days trying everything to implement the .wasm thing for the vetkd to create transport key to pass to rust canister for encrypted generation. I am in creactjs with craco.
I have ended up opting for another library
import * as bls from ‘@noble/bls12-381’;
// 1. Generate ephemeral transport key pair (BLS12-381 G2)
let transportSeed = window.crypto.getRandomValues(new Uint8Array(32));
// Expand to 40 bytes as required by hashToPrivateKey
let transportSeed40 = new Uint8Array(40);
transportSeed40.set(transportSeed);
transportSeed40.set(window.crypto.getRandomValues(new Uint8Array(8)), 32);
const transportPrivKey = bls.utils.hashToPrivateKey(transportSeed40);
// Use compressed (96 bytes) format as required by DFINITY VetKD
const transportPubKeyBytes = bls.PointG2.fromPrivateKey(transportPrivKey).toRawBytes(true); // compressed (96 bytes)
// 2. Call backend get_encrypted_key_for_session
setStatusMessage('Requesting encrypted key from backend (authenticated)...');
const getEncryptedKeyResult = await actorInstance.get_encrypted_key_for_session(
BigInt(sessionId),
Array.from(transportPubKeyBytes),
);
I keep getting Canister called ic0.trap
with message: invalid encryption public key.\nConsider gracefully handling failures from this canister or altering the canister to handle exceptions.
Can someone confirm the exact specification of the expected encryption_public_key in
let args = VetkdDeriveEncryptedKeyArgs {
key_id: VetkdDeriveEncryptedKeyArgsKeyId {
name: “test_key_1”.to_string(),
curve: VetkdCurve::Bls12381G2,
},
derivation_path: vec!,
derivation_id: ByteBuf::from(session.hashed_login.as_bytes().to_vec()),
encryption_public_key: ByteBuf::from(transport_public_key),
};
PLEASE, it would be of great help to solve it.
When I try the WASM solution i get ERROR in ./node_modules/ic-vetkd-utils/ic_vetkd_utils.js 5:0-21
Can’t import the named export ‘__wbindgen_start’ (imported as ‘wasm’) from default-exporting module (only default export is available)
I follow exactly the guide in ic/packages/ic-vetkd-utils to build the webpack and add in package and npm install --save
then i try to import in a .js file and nothing. comes with that error. i have tried replace the code in. the utils to avoid __wbindgen_start, i have also tried the await vetkd( .wasm path). Nothing has worked.
or Error during authentication: wasm.__wbindgen_add_to_stack_pointer is not a function when i download the ready and used in examples/rust/vetkd/ic-vetkd-utils-0.1.0.tgz at master · dfinity/examples · GitHub