@@ -93,7 +93,6 @@ func (l LinkID) Eq(i2 LinkID) bool {
9393type ChainLinkUnpacked struct {
9494 prev LinkID
9595 seqno keybase1.Seqno
96- highSkip * HighSkip
9796 seqType keybase1.SeqType
9897 ignoreIfUnsupported SigIgnoreIfUnsupported
9998 payloadLocal []byte // local track payloads
@@ -227,7 +226,6 @@ type ChainLink struct {
227226 unsigned bool
228227 dirty bool
229228 revocationsCache * []keybase1.SigID
230- computedHighSkip * HighSkip
231229
232230 unpacked * ChainLinkUnpacked
233231 cki * ComputedKeyInfos
@@ -284,10 +282,6 @@ func (c *ChainLink) GetIgnoreIfSupported() SigIgnoreIfUnsupported {
284282 return c .getIgnoreIfUnsupportedFromPayload ()
285283}
286284
287- func (c * ChainLink ) getHighSkipFromPayload () * HighSkip {
288- return c .unpacked .highSkip
289- }
290-
291285func (c * ChainLink ) IsStubbed () bool {
292286 return c .unpacked .stubbed
293287}
@@ -496,52 +490,6 @@ func (c *ChainLink) checkAgainstMerkleTree(t *MerkleTriple) (found bool, err err
496490 return
497491}
498492
499- func (tmp * ChainLinkUnpacked ) parseHighSkipFromPayload (payload []byte ) (* HighSkip , error ) {
500- hs , dataType , _ , err := jsonparser .Get (payload , "high_skip" )
501- // high_skip is optional, but must be an object if it exists
502- if err != nil {
503- if err == jsonparser .KeyPathNotFoundError {
504- return nil , nil
505- }
506- return nil , err
507- }
508-
509- if dataType != jsonparser .Object {
510- return nil , ChainLinkError {fmt .Sprintf ("When provided, expected high_skip to be a JSON object, was %v." , dataType )}
511- }
512-
513- highSkipSeqnoInt , err := jsonparser .GetInt (hs , "seqno" )
514- if err != nil {
515- return nil , err
516- }
517-
518- // highSkipHash can either be null (zero-value of a LinkID) or a hexstring.
519- // We call GetString first instead of Get so we only parse the value
520- // twice for the first link.
521- highSkipHashStr , err := jsonparser .GetString (hs , "hash" )
522- var highSkipHash LinkID
523- if err != nil {
524- // If there was an error parsing as a string, make sure the value is null.
525- _ , dataType , _ , getErr := jsonparser .Get (hs , "hash" )
526- if getErr != nil {
527- return nil , getErr
528- }
529- if dataType != jsonparser .Null {
530- return nil , ChainLinkError {
531- fmt .Sprintf ("high_skip.hash was neither a valid string (%v) nor null." , err .Error ()),
532- }
533- }
534- } else {
535- highSkipHash , err = LinkIDFromHex (highSkipHashStr )
536- if err != nil {
537- return nil , err
538- }
539- }
540-
541- highSkip := NewHighSkip (keybase1 .Seqno (highSkipSeqnoInt ), highSkipHash )
542- return & highSkip , nil
543- }
544-
545493func (tmp * ChainLinkUnpacked ) unpackPayloadJSON (g * GlobalContext , payload []byte ) error {
546494 if s , err := jsonparser .GetString (payload , "body" , "key" , "fingerprint" ); err == nil {
547495 if tmp .pgpFingerprint , err = PGPFingerprintFromHex (s ); err != nil {
@@ -576,12 +524,6 @@ func (tmp *ChainLinkUnpacked) unpackPayloadJSON(g *GlobalContext, payload []byte
576524 }
577525 }
578526
579- highSkip , err := tmp .parseHighSkipFromPayload (payload )
580- if err != nil {
581- return err
582- }
583- tmp .highSkip = highSkip
584-
585527 tmp .typ , err = jsonparser .GetString (payload , "body" , "type" )
586528 if err != nil {
587529 return err
@@ -696,22 +638,11 @@ func (c *ChainLink) unpackStubbed(raw string) error {
696638 }
697639
698640 c .id = ol .LinkID ()
699-
700- // Because the outer link does not have a highSkip parent object, we check
701- // for the nullity of highSkipSeqno to see if highSkip should be set, since
702- // a null highSkipHash is valid when specifying highSkip=0.
703- var highSkipPtr * HighSkip
704- if ol .HighSkipSeqno != nil {
705- highSkip := NewHighSkip (* ol .HighSkipSeqno , * ol .HighSkipHash )
706- highSkipPtr = & highSkip
707- }
708-
709641 c .unpacked = & ChainLinkUnpacked {
710642 prev : ol .Prev ,
711643 seqno : ol .Seqno ,
712644 seqType : ol .SeqType ,
713645 ignoreIfUnsupported : ol .IgnoreIfUnsupported ,
714- highSkip : highSkipPtr ,
715646 sigVersion : ol .Version ,
716647 outerLinkV2 : ol ,
717648 stubbed : true ,
@@ -1042,14 +973,13 @@ func (c *ChainLink) verifyPayloadV2() error {
1042973 prev := c .getPrevFromPayload ()
1043974 curr := c .getPayloadHash ()
1044975 ignoreIfUnsupported := c .getIgnoreIfUnsupportedFromPayload ()
1045- linkType , err := c .GetSigchainV2TypeFromInner (SigIgnoreIfUnsupported (ignoreIfUnsupported ))
976+ linkType , err := c .GetSigchainV2Type (SigIgnoreIfUnsupported (ignoreIfUnsupported ))
1046977 if err != nil {
1047978 return err
1048979 }
1049980 seqType := c .getSeqTypeFromPayload ()
1050- highSkip := c .getHighSkipFromPayload ()
1051981
1052- if err := ol .AssertFields (version , seqno , prev , curr , linkType , seqType , ignoreIfUnsupported , highSkip ); err != nil {
982+ if err := ol .AssertFields (version , seqno , prev , curr , linkType , seqType , ignoreIfUnsupported ); err != nil {
1053983 return err
1054984 }
1055985
@@ -1088,10 +1018,6 @@ func (c *ChainLink) GetSeqno() keybase1.Seqno {
10881018 return c .unpacked .seqno
10891019}
10901020
1091- func (c * ChainLink ) GetHighSkip () * HighSkip {
1092- return c .unpacked .highSkip
1093- }
1094-
10951021func (c * ChainLink ) GetSigID () keybase1.SigID {
10961022 return c .unpacked .sigID
10971023}
@@ -1238,7 +1164,7 @@ func (c *ChainLink) verifyLinkV2() error {
12381164 return c .verifyPayloadV2 ()
12391165}
12401166
1241- func (c * ChainLink ) GetSigchainV2TypeFromInner (ignoreIfUnsupported SigIgnoreIfUnsupported ) (SigchainV2Type , error ) {
1167+ func (c * ChainLink ) GetSigchainV2Type (ignoreIfUnsupported SigIgnoreIfUnsupported ) (SigchainV2Type , error ) {
12421168 if c .unpacked == nil || c .unpacked .typ == "" {
12431169 return SigchainV2TypeNone , errors .New ("chain link not unpacked" )
12441170 }
@@ -1255,22 +1181,6 @@ func (c *ChainLink) GetSigchainV2TypeFromV2Shell() (SigchainV2Type, error) {
12551181 return c .unpacked .outerLinkV2 .LinkType , nil
12561182}
12571183
1258- // GetSigchainV2Type is a helper function for getting a ChainLink's type. If it
1259- // is a v2 link (that may or may not be stubbed), return the type from the
1260- // outer link, otherwise from the inner link.
1261- func (c * ChainLink ) GetSigchainV2Type () (SigchainV2Type , error ) {
1262- if c .unpacked == nil {
1263- return SigchainV2TypeNone , errors .New ("chain link is not unpacked" )
1264- }
1265- if c .unpacked .outerLinkV2 == nil && c .unpacked .typ == "" {
1266- return SigchainV2TypeNone , errors .New ("chain inner link type is not unpacked, and has no v2 shell" )
1267- }
1268- if c .unpacked .outerLinkV2 != nil {
1269- return c .GetSigchainV2TypeFromV2Shell ()
1270- }
1271- return c .GetSigchainV2TypeFromInner (c .GetIgnoreIfSupported ())
1272- }
1273-
12741184func (c * ChainLink ) checkServerSignatureMetadata (ckf ComputedKeyFamily ) (ret keybase1.KID , err error ) {
12751185 var serverKID , linkKID , verifyKID keybase1.KID
12761186
@@ -1441,52 +1351,3 @@ func (c ChainLink) AllowStubbing() bool {
14411351 }
14421352 return c .unpacked .outerLinkV2 .LinkType .AllowStubbing ()
14431353}
1444-
1445- // IsHighUserLink determines whether a chainlink counts as "high" in a user's chain,
1446- // which is defined as an Eldest link, a link with seqno=1, a link that is Sibkey,
1447- // PGPUpdate, Revoke, or any link that is revoking.
1448- func (c ChainLink ) IsHighUserLink (mctx MetaContext , uid keybase1.UID ) (bool , error ) {
1449- v2Type , err := c .GetSigchainV2Type ()
1450- if err != nil {
1451- return false , err
1452- }
1453-
1454- hardcodedEldest := false
1455- if c .GetSeqno () > 1 {
1456- prevLink := c .parent .GetLinkFromSeqno (c .GetSeqno () - 1 )
1457- if prevLink == nil {
1458- return false , ChainLinkWrongSeqnoError {}
1459- }
1460- hardcodedEldest , err = isSubchainStart (mctx , & c , prevLink , uid )
1461- if err != nil {
1462- return false , err
1463- }
1464- }
1465-
1466- isFirstLink := v2Type == SigchainV2TypeEldest || c .GetSeqno () == 1 || hardcodedEldest
1467- isNewHighLink := isFirstLink ||
1468- v2Type == SigchainV2TypeRevoke ||
1469- v2Type == SigchainV2TypeWebServiceBindingWithRevoke ||
1470- v2Type == SigchainV2TypeCryptocurrencyWithRevoke ||
1471- v2Type == SigchainV2TypeSibkey ||
1472- v2Type == SigchainV2TypePGPUpdate
1473- return isNewHighLink , nil
1474- }
1475-
1476- // ExpectedNextHighSkip returns the expected highSkip of the immediately
1477- // subsequent link in the chain (which may not exist yet). This function can
1478- // only be called after VerifyChain has processed the chainLink, and set
1479- // c.computedHighSkip.
1480- func (c ChainLink ) ExpectedNextHighSkip (mctx MetaContext , uid keybase1.UID ) (HighSkip , error ) {
1481- isHigh , err := c .IsHighUserLink (mctx , uid )
1482- if err != nil {
1483- return HighSkip {}, err
1484- }
1485- if isHigh {
1486- return NewHighSkip (c .GetSeqno (), c .id ), nil
1487- }
1488- if c .computedHighSkip == nil {
1489- return HighSkip {}, NewUserReverifyNeededError ("Expected to have already computed this link's HighSkip, but it was not computed." )
1490- }
1491- return * c .computedHighSkip , nil
1492- }
0 commit comments