Bitcoin Forum
November 05, 2024, 06:37:41 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Why is the maximum length of pubkey 120,not 100 or other?  (Read 494 times)
zzkjliu (OP)
Newbie
*
Offline Offline

Activity: 6
Merit: 0


View Profile
March 08, 2014, 07:01:13 AM
 #1

 IsStandard() function in script.cpp has the following code:

Code:
            // Template matching opcodes:
            if (opcode2 == OP_PUBKEYS)
            {
                while (vch1.size() >= 33 && vch1.size() <= 120)
                {

there,Why is the maximum size of pubkey 120,not 100 or other?

12648430
Full Member
***
Offline Offline

Activity: 144
Merit: 100


View Profile
March 08, 2014, 09:22:36 AM
 #2

That was changed in a Feb 21 git commit (595b6d8); in the next release the maximum pubkey size will be 65. (Pubkeys are exactly 33 or 65 bytes, depending on whether they're "compressed").
zzkjliu (OP)
Newbie
*
Offline Offline

Activity: 6
Merit: 0


View Profile
March 08, 2014, 10:11:01 AM
Last edit: March 08, 2014, 10:30:25 AM by zzkjliu
 #3

From v0.3.18 to v0.9.0rc2, this value has been 120.  The length of pubkey is 33 or 65, that is common sense, the developer is impossible not to know, but why take the 120? at that time must have their reasons, what is the reasons?

Code:
Solver() function in script.cpp in v0.3.18 has the following code: 
bool Solver(const CScript& scriptPubKey, vector<pair<opcodetype, valtype> >& vSolutionRet)
{
    ......
    // Scan templates
    const CScript& script1 = scriptPubKey;
    foreach(const CScript& script2, vTemplates)
    {
       ......
        loop
        {
            ......
            if (opcode2 == OP_PUBKEY)
            {
                if (vch1.size() < 33 || vch1.size() > 120
                    break;
                vSolutionRet.push_back(make_pair(opcode2, vch1));
            }
            else if (opcode2 == OP_PUBKEYHASH)
            {
                if (vch1.size() != sizeof(uint160))
                    break;
                vSolutionRet.push_back(make_pair(opcode2, vch1));
            }
            else if (opcode1 != opcode2 || vch1 != vch2)
            {
                break;
            }
        }
    }

    vSolutionRet.clear();
    return false;
}

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!