micro-ecc Integration
SkillDev toolsUse when integrating, porting, or debugging micro-ecc (uECC) ECDH, ECDSA, key generation, uECC_set_rng, signatures, curve selection, or key/signature byte formats on an MCU
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the micro-ecc Integration skill
What this skill tells your AI
The instructions your AI receives, as published by easyzoom/aix-skills in skills/micro-ecc-integration/SKILL.md and read by ahel’s review.
Overview
Use this skill to integrate micro-ecc (kmackay/micro-ecc, header uECC.h) by treating randomness, key storage, curve choice, and test vectors as security-critical. ECC that compiles but never called uECC_set_rng() or uses mismatched key byte formats is not working. The core key generation, signing, verification, and ECDH functions return 1 on success and 0 on failure (uECC_verify returns 1 only for a valid signature); the size-query helpers instead return a byte count, and uECC_compress/uECC_decompress return void.
When To Use
Use this skill when:
- The user wants ECDH (
uECC_shared_secret), ECDSA (uECC_sign/uECC_verify), or key generation (uECC_make_key) on an MCU using micro-ecc. - The issue involves
uECC_make_key/uECC_signreturning0, bad signatures, key mismatch, RNG, curve selection, endian/format mismatch, or slow scalar multiplication. - The project uses
uECC.h,uECC.c, auECC_Curve, oruECC_set_rng.
Do not use this skill for full TLS stacks. Use mbedtls-integration for TLS. For AES/SHA/HMAC primitives, use tinycrypt-integration.
First Questions
Ask for:
- Curve and operation:
uECC_secp160r1,uECC_secp192r1,uECC_secp224r1,uECC_secp256r1, oruECC_secp256k1; and ECDH vs ECDSA. - Target MCU, compiler, and whether a hardware TRNG/crypto peripheral exists.
- The RNG source wired into
uECC_set_rng()and the key storage policy. - Public/private key byte format and endian expectations of the peer (
uECC_VLI_NATIVE_LITTLE_ENDIANsetting, compressed vs uncompressed). - Test vector, signature, or verification failure details, and the return code seen.
Integration Checklist
-
Choose curve deliberately. Pick a
uECC_CurveviauECC_secp256r1()(or the peer's curve) and enable it with the matchinguECC_SUPPORTS_secp256r1macro. Disable unused curves to save flash. -
Provide a real RNG first. Register
uECC_set_rng(uECC_RNG_Function fn)wherefnhas signatureint fn(uint8_t *dest, unsigned size)and returns1whendestis filled with good entropy,0otherwise. Without a valid RNG, bothuECC_make_keyanduECC_signreturn0. OnlyuECC_sign_deterministic(RFC 6979-style deterministic nonce, needs auECC_HashContext) works without an RNG. -
Size every buffer from the curve. Always use
uECC_curve_private_key_size(curve)anduECC_curve_public_key_size(curve)instead of hard-coded lengths or arithmetic on each other. The public key isx||yand equalsuECC_curve_public_key_size(curve); the private key equalsuECC_curve_private_key_size(curve). These are equal to 2x the field size and 1x the field size respectively for every curve EXCEPTsecp160r1, where the private key is 21 bytes (the order needs an extra byte; the leading byte is often0x00) while the public key is 40 bytes. Never derive public-key or signature length from the private-key length. -
Match key/signature byte format. Default is big-endian; public keys are raw
x||ywith NO0x04uncompressed prefix, so prepend0x04for SEC1/OpenSSL peers. If interop breaks, checkuECC_VLI_NATIVE_LITTLE_ENDIANmatches both sides; keys/signatures across the two settings are incompatible. The signature isr||sand its length equals the public-key length (uECC_curve_public_key_size(curve)) -- forsecp160r1that is 40 bytes, not2 * private_key_size(peers such as python-ecdsa may instead expect 42). -
Sign the hash, not the message.
uECC_sign(private_key, hash, hash_size, signature, curve)anduECC_verifytake a message digest plushash_size; hash the message yourself (e.g. SHA-256) and pass the digest. A hash longer than the curve order is truncated internally. -
Handle compressed points if needed. With
uECC_SUPPORT_COMPRESSED_POINT, useuECC_compress/uECC_decompress; a compressed point is one coordinate plus a leading parity byte, i.e.(uECC_curve_public_key_size(curve) / 2) + 1bytes. Validate imported keys withuECC_valid_public_key. -
Protect secrets. Do not log private keys, the ECDSA nonce, or the shared secret from
uECC_shared_secret.
Common Failures
uECC_set_rng()never called, souECC_make_key/uECC_signsilently return0.- RNG callback returns
0(or returns success while producing weak/deterministic bytes) in production. - Public key sent with or expecting a
0x04prefix; micro-ecc uses rawx||ywithout it. secp160r1private key allocated as 20 bytes instead of 21, corrupting adjacent memory or the key.- Deriving signature or public-key length from the private-key length; on
secp160r1this over-allocates (42 vs 40) and breaks interop. uECC_VLI_NATIVE_LITTLE_ENDIANmismatch between device and peer, so byte order flips and verify fails.- Passing the raw message to
uECC_sign/uECC_verifyinstead of the digest, or hashing inconsistently between the two sides. - Curve mismatch: device built with
uECC_secp256r1but server usessecp256k1.
Verification
Before claiming micro-ecc works:
- State the
uECC_Curve, operation, key/signature byte layout, and the RNG registered viauECC_set_rng. - Confirm
uECC_make_keyreturns1and buffers were sized withuECC_curve_public_key_size/uECC_curve_private_key_size(not derived from each other). - Confirm known test vectors pass:
uECC_verifyreturns1for a valid signature and0for tampered data/hash. - For ECDH, confirm both peers derive the same
uECC_shared_secret. - Confirm secrets are not logged and storage policy is explicit.
Example
User:
micro-ecc 签名服务器验不过。
Agent:
- Asks for the curve, whether the public key carries a
0x04prefix, the hash input touECC_sign, the RNG behinduECC_set_rng, and theuECC_VLI_NATIVE_LITTLE_ENDIANsetting on both sides. - Checks endian and that a digest (not the raw message) is passed, and reconstructs the peer's SEC1 format by prepending
0x04to thex||ypublic key. - Verifies with a known vector via
uECC_verifybefore changing protocol code.
Signals
- GitHub stars
- 31
- Forks
- 3
- Last commit
- Jul 2026
Advanced
- Catalog kind
- skill
- Gateway key
micro-ecc-integration- Source
- github.com/easyzoom/aix-skills