@mega-yfue/eufy-sdk / p2pCodec / eciesUnwrap
Function: eciesUnwrap()
ts
function eciesUnwrap(
envelope,
eccPrivateKeyHex,
options?
): Buffer<ArrayBufferLike> | undefined;The shared ECIES unwrap primitive used by both the gateway and the video paths.
envelope = ephemeralPub(33, compressed P-256) ‖ iv(16) ‖ ct(48) [‖ HMAC(32)]. Derivation: S = ECDH_X(eccPriv, ephPub) → kdf = eufyKDF(S) → aesKey = kdf[0:16]; (optionally verify HMAC(kdf[16:48], iv‖ct) == tag) → AES-128-CBC(aesKey, iv, ct) → plaintext. Returns the decrypted bytes, or undefined on any parse / HMAC / cipher failure (fails closed, never throws).
Parameters
envelope
Buffer
eccPrivateKeyHex
string
options?
EciesUnwrapOptions = {}
Returns
Buffer<ArrayBufferLike> | undefined