Fix Claim transaction to prove authority.

This commit is contained in:
Arthur Britto
2012-05-15 20:28:29 -07:00
parent f030dc2ca1
commit 9bbbf24f43
5 changed files with 28 additions and 15 deletions

View File

@@ -668,7 +668,9 @@ Json::Value RPCServer::doWalletClaim(Json::Value& params)
else
{
// Trying to build:
// peer_wallet_claim <account_id> <generator_id> <encrypted_master_public_generator> <account_id_signature> [<source_tag>] [<annotation>]
// peer_wallet_claim <account_id> <encrypted_master_public_generator> <generator_pubkey> <generator_signature>
// <source_tag> [<annotation>]
//
//
// Which has no confidential information.
@@ -703,13 +705,18 @@ Json::Value RPCServer::doWalletClaim(Json::Value& params)
// hash of regular account #reserved public key.
uint160 uGeneratorID = naRegularReservedPublic.getAccountID();
std::vector<unsigned char> vucGeneratorCipher = naRegularReservedPrivate.accountPrivateEncrypt(naRegularReservedPublic, naMasterGenerator.getFamilyGenerator());
std::vector<unsigned char> vucGeneratorSig;
// XXX Check result.
naRegularReservedPrivate.accountPrivateSign(Serializer::getSHA512Half(vucGeneratorCipher), vucGeneratorSig);
Transaction::pointer trns = Transaction::sharedClaim(
naAccountPublic, naAccountPrivate,
naAccountPublic,
uSourceTag,
naRegularReservedPublic, // GeneratorID
vucGeneratorCipher);
vucGeneratorCipher,
naRegularReservedPublic.getAccountPublic(),
vucGeneratorSig);
(void) theApp->getOPs().processTransaction(trns);

View File

@@ -32,7 +32,7 @@ enum SOE_Field
sfBorrower, sfLender, sfLimit, sfOfferCurrency, sfLedgerHash,
sfLastReceive, sfLastTxn, sfNextRate, sfNextRateLgr, sfNextRateExp,
sfNickname, sfMinimumOffer,
sfAuthorizedKey, sfGenerator, sfGeneratorID, sfAccountID,
sfAuthorizedKey, sfGenerator, sfPubKey, sfSignature, sfGeneratorID, sfAccountID,
// test fields
sfTest1, sfTest2, sfTest3, sfTest4

View File

@@ -118,11 +118,13 @@ bool Transaction::sign(const NewcoinAddress& naAccountPrivate)
Transaction::pointer Transaction::setClaim(
const NewcoinAddress& naPrivateKey,
const NewcoinAddress& naGeneratorID,
const std::vector<unsigned char>& vucGenerator)
const std::vector<unsigned char>& vucGenerator,
const std::vector<unsigned char>& vucPubKey,
const std::vector<unsigned char>& vucSignature)
{
mTransaction->setITFieldH160(sfGeneratorID, naGeneratorID.getAccountID());
mTransaction->setITFieldVL(sfGenerator, vucGenerator);
mTransaction->setITFieldVL(sfPubKey, vucPubKey);
mTransaction->setITFieldVL(sfSignature, vucSignature);
sign(naPrivateKey);
@@ -133,8 +135,9 @@ Transaction::pointer Transaction::sharedClaim(
const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey,
const NewcoinAddress& naSourceAccount,
uint32 uSourceTag,
const NewcoinAddress& naGeneratorID,
const std::vector<unsigned char>& vucGenerator)
const std::vector<unsigned char>& vucGenerator,
const std::vector<unsigned char>& vucPubKey,
const std::vector<unsigned char>& vucSignature)
{
pointer tResult = boost::make_shared<Transaction>(ttCLAIM,
naPublicKey, naSourceAccount,
@@ -142,7 +145,7 @@ Transaction::pointer Transaction::sharedClaim(
0, // Free.
uSourceTag);
return tResult->setClaim(naPrivateKey, naGeneratorID, vucGenerator);
return tResult->setClaim(naPrivateKey, vucGenerator, vucPubKey, vucSignature);
}
//

View File

@@ -55,8 +55,9 @@ private:
Transaction::pointer setClaim(
const NewcoinAddress& naPrivateKey,
const NewcoinAddress& naGeneratorID,
const std::vector<unsigned char>& vucGenerator);
const std::vector<unsigned char>& vucGenerator,
const std::vector<unsigned char>& vucPubKey,
const std::vector<unsigned char>& vucSignature);
public:
Transaction(const SerializedTransaction::pointer st, bool bValidate);
@@ -85,8 +86,9 @@ public:
const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey,
const NewcoinAddress& naSourceAccount,
uint32 uSourceTag,
const NewcoinAddress& naGeneratorID,
const std::vector<unsigned char>& vucGenerator);
const std::vector<unsigned char>& vucGenerator,
const std::vector<unsigned char>& vucPubKey,
const std::vector<unsigned char>& vucSignature);
#if 0
Transaction(const NewcoinAddress& fromID, const NewcoinAddress& toID,
CKey::pointer pubKey, uint64 uAmount, uint64 fee, uint32 fromSeq, uint32 fromLedger,

View File

@@ -18,8 +18,9 @@ TransactionFormat InnerTxnFormats[]=
},
{ "Claim", ttCLAIM, {
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
{ S_FIELD(GeneratorID), STI_HASH160, SOE_REQUIRED, 0 },
{ S_FIELD(Generator), STI_VL, SOE_REQUIRED, 0 },
{ S_FIELD(PubKey), STI_VL, SOE_REQUIRED, 0 },
{ S_FIELD(Signature), STI_VL, SOE_REQUIRED, 0 },
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 },
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x02000000 },
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }