code wiki / (root) / nx_ecdsa_p256_sign_test.nx

nx_ecdsa_p256_sign_test.nx

buildroot/runtime/nx_ecdsa_p256_sign_test.nx

3926 B86 linesdepth 11pulls 20 transitivereach 0 importersview sourcekind gate/prooftopic ecdsa
docsdependenciesstructsconstsfunctions

about

nx_ecdsa_p256_sign_smoke.nx -- MONITOR for ECDSA P-256 SIGN. Sign-then-verify round-trip: pure-NishiLang produces (r, s) for a known (priv_key, msg_hash) pair, then feeds (priv_key * G, hash, r, s) to the already-shipped nx_ecdsa_p256_verify. Verify MUST return OK -- closes the loop that the sign side is producing substrate-valid signatures. Test vector: RFC 6979 §A.2.5 NIST P-256 + SHA-256 with the well-known sample privkey + message hash. priv = 0xC9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721 hash = SHA-256("sample") = 0xAF2BDBE1AA9B6EC1E2ADE1D694F41FC71A831D0268E9891562113D8A62ADD1BF Expected r = 0xEFD48B2AACB6A8FD1140DD9CD45E81D69D2C877B56AAF991C34D0EA84EAF3716 Expected s = 0xF7CB1C942D657C41D436C7A1B6E29F65F3E900DBB9AFF4064DC4AB2F843ACDA8 We don't compare against the RFC vector directly (the byte-order of internal limb representation makes the comparison fiddly); we instead assert that our sign output VERIFIES against the matching public key. That's the load-bearing property: sign produces a signature that the substrate's own verify accepts.

dependencies 7 imports · 0 importers

nx_syscalls.nx nx_u256.nx nx_p256_modn.nx nx_p256_point.nx nx_p256_scalar_mul.nx nx_ecdsa_p256.nx nx_ecdsa_p256_sign.nx nx_ecdsa_p256_sign_test.nx

imports: nx_syscalls.nxnx_u256.nxnx_p256_modn.nxnx_p256_point.nxnx_p256_scalar_mul.nxnx_ecdsa_p256.nxnx_ecdsa_p256_sign.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap u256_alloc nx_scratch nx_scratch_init sys_mmap ↻ nx_scratch_oom sys_write sys_exit sys_mmap ↻ u256_load_be nx_ecdsa_p256_sign nx_scratch_save nx_scratch_init ↻ _nx_ecdsa_p256_sign_impl u256_is_zero u256_alloc ↻ p256_modn_load_n u256_copy p256_modn_reduce nx_scratch_save ↻ u256_alloc ↻ p256_modn_load_n ↻ u256_copy ↻ u256_cmp u256_sub_with_borrow nx_scratch_restore u256_eq nx_scratch ↻ u256_store_be _ecdsa_sign_derive_k nx_scratch_save ↻ nx_scratch ↻ drbg_hmac_init _drbg_k _drbg_v _drbg_fill drbg_hmac_update _drbg_k ↻ _drbg_v ↻

structs

none

consts

none

functions

31func main() -> i64