Skip to content

@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

Independent and unofficial. Not affiliated with, endorsed by, or sponsored by Anker Innovations, Anker eufy, or eufy. "Anker eufy", "eufy" and "Anker" are trademarks of their respective owners. Use responsibly — rapid or failed logins can trigger captcha or temporary cooldowns.