<div dir="ltr"><div>Dear folks<br></div><div><br></div><div>I'm trying to understand the inner workings of ndn-cxx's signature format, in order to use it on one of my toys.<br></div><div>OS is Ubuntu 16.04. ndn-cxx repository is at commit 7f01247b5bc75d9416e22828b72976abd57f16a9.</div><div><br></div><div>I have the following code snippet:<br></div><span style="font-family:monospace,monospace">// g++ -std=c++11 -o x x.cpp $(pkg-config --cflags --libs libndn-cxx)</span><br><span style="font-family:monospace,monospace"></span><br><span style="font-family:monospace,monospace">#include <iostream></span><br><span style="font-family:monospace,monospace">#include <ndn-cxx/security/v2/key-chain.hpp></span><br><span style="font-family:monospace,monospace">#include <ndn-cxx/security/verification-helpers.hpp></span><br><span style="font-family:monospace,monospace"></span><br><span style="font-family:monospace,monospace">int main() {</span><br><span style="font-family:monospace,monospace">  uint8_t input[12];</span><br><span style="font-family:monospace,monospace">  memcpy(input, "hello world.", sizeof(input));</span><br><span style="font-family:monospace,monospace"></span><br><span style="font-family:monospace,monospace">  ndn::KeyChain keyChain;</span><br><span style="font-family:monospace,monospace">  auto sig = keyChain.sign(input, sizeof(input));</span><br><span style="font-family:monospace,monospace">  sig.encode();</span><br><span style="font-family:monospace,monospace"></span><br><span style="font-family:monospace,monospace">  auto pubkey = keyChain.getPib().getDefaultIdentity().getDefaultKey().getPublicKey();</span><br><span style="font-family:monospace,monospace">  bool res = ndn::security::verifySignature(input, sizeof(input), sig.wire(), sig.size(), pubkey.data(), pubkey.size());</span><br><span style="font-family:monospace,monospace">  std::cout << res;</span><br><span style="font-family:monospace,monospace">}</span><br><div><div></div><div>This code snippet uses the default key to sign a message "hello world.", and then verify the signature using the same key.</div><div><br></div><div>I started with a clean $HOME/.ndn directory, and I have a single EC key as the default.</div><div>$ ndnsec list -c<br><span style="font-family:monospace,monospace">* /ec<br>  +->* /ec/KEY/%8E%24y%D3CX9%D1<br>       +->* /ec/KEY/%8E%24y%D3CX9%D1/self/%FD%00%00%01%60d%EBV%BC</span><br></div><div><br></div><div>I expect the code snippet to print "1" indicating the signature is correct. However, it printed "0" indicating the signature is bad.</div><div>I traced into <span style="font-family:monospace,monospace">ndn::security::verifySignature</span> functions. The public key was successfully loaded from PKCS8 format, but the transforms concluded that the signature is wrong.</div><div>I also independently verified that the signature bits are correct, using a different ECDSA implementation (namely, micro-ecc).<br></div><div><br></div><div>Can anyone help with this?<br></div><div><br></div>Yours, Junxiao<br></div></div>