I've managed to add registration of ids to a version of clams I'm running on testnet. I've switched to having ids that are N prefix bytes of the underlying 20 byte address instead of using the checksum. In hex this is a 2N char id. An example is in tx 8690cfc9b0e40b7fb328da478e2523071ac759eea7cac729038b47b8f180948d with the clamspeech:
register pubkey 73 039df70c1c46425ae4d3be53892949e17bebcbe30f419132441faab92677b220f5
Here the given pubkey is from the address mr1yhbGu64c83LtN5GBxPVPBb7XheNi8rH, which in hex is
Version Byte: 6f
20 byte address: 732e7e8744a30f55ff7c43b77e473ff462777b43
Checksum: 8b8070fe
In principle, possible ids to register would be 73 (as above), 732e, 732e7e, etc.
I don't yet have code that correctly actually checks that the given id corresponds to a prefix of the address, so I wanted to ask (technically) how to do this.
Here's what I've found:
I can use CPubKey(ParseHex(strPubkey)) to convert "039d...f5" into a CPubKey. IsFullyValid will make sure it's a valid pubkey. GetID can be used to obtain the 20 byte address as a CKeyID (which seems to be the same as uint160).
On the other hand, I can use ParseHex on the given hex ID in the clamspeech to obtain a vector of unsigned chars. I crossed my fingers and tried to use memcmp as a way checking for a prefix, but it doesn't seem to work. Here's the current code snippet I have in main.cpp:
...
CPubKey vchPubKey = CPubKey(ParseHex(strPubkey));
...
CKeyID keyid = vchPubKey.GetID();
std::vector vchID = ParseHex(strID);
if (memcmp(&vchID,&keyid,vchID.size()) != 0) {
LogPrintf("invalid pubkey registration attempt %s; id %s is not a prefix of the address: %s\n", strPubkey, strID, tx.strCLAMSpeech.substr(0, MAX_TX_COMMENT_LEN));
} else {
pindex->vRpubkey.push_back(*(mapRpubkey[pid] = new CRpubkey(pindex->nHeight, tx.GetHash(), strID, strPubkey)));
}
I'm going to try to get on the #clams channel on IRC. If successful, I'll start asking questions there. I don't want to "spam" this thread with posts that aren't of general interest. I could also start a separate thread if people think I should.
Edit: I'm now registered at irc.freenode.net with nick TrentRussell and have joined the #clams channel. I've never used irc before, but will try to use it now and try to log the channel when I'm not online.