Skip to content

Commit ecf37f9

Browse files
authored
(Revert for codefreeze) "* Reading and writing high skips on userchains (feature-flagged)" (keybase#14004)
(For codefreeze) This reverts commit cdbe03f.
1 parent cca416f commit ecf37f9

23 files changed

+78
-686
lines changed

go/engine/cryptocurrency.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ func (e *CryptocurrencyEngine) Run(m libkb.MetaContext) (err error) {
109109
}
110110

111111
sig, _, _, err := libkb.MakeSig(
112-
m,
113112
sigKey,
114113
libkb.LinkTypeCryptocurrency,
115114
sigInner,

go/engine/prove.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ func (p *Prove) generateProof(m libkb.MetaContext) (err error) {
196196
}
197197

198198
p.sig, p.sigID, _, err = libkb.MakeSig(
199-
m,
200199
p.signingKey,
201200
libkb.LinkTypeWebServiceBinding,
202201
p.sigInner,

go/engine/revoke_test.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -141,24 +141,6 @@ func testRevokePaperDevice(t *testing.T, upgradePerUserKey bool) {
141141
} else {
142142
checkPerUserKeyring(t, tc.G, 0)
143143
}
144-
145-
arg := libkb.NewLoadUserByNameArg(tc.G, u.Username)
146-
user, err := libkb.LoadUser(arg)
147-
require.NoError(t, err)
148-
149-
var nextSeqno int
150-
var postedSeqno int
151-
if upgradePerUserKey {
152-
nextSeqno = 7
153-
postedSeqno = 4
154-
} else {
155-
nextSeqno = 5
156-
postedSeqno = 3
157-
}
158-
nextExpected, err := user.GetExpectedNextHighSkip(libkb.NewMetaContextForTest(tc))
159-
require.NoError(t, err)
160-
require.Equal(t, nextExpected.Seqno, keybase1.Seqno(nextSeqno))
161-
assertPostedHighSkipSeqno(t, tc, user.GetName(), postedSeqno)
162144
}
163145

164146
func TestRevokerPaperDeviceTwice(t *testing.T) {

go/engine/track_token.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ func (e *TrackToken) storeRemoteTrack(m libkb.MetaContext, pubKID keybase1.KID)
226226

227227
sigVersion := libkb.SigVersion(*e.arg.Options.SigVersion)
228228
sig, sigID, linkID, err := libkb.MakeSig(
229-
m,
230229
signingKey,
231230
libkb.LinkTypeTrack,
232231
e.trackStatementBytes,
@@ -265,7 +264,7 @@ func (e *TrackToken) storeRemoteTrack(m libkb.MetaContext, pubKID keybase1.KID)
265264
return err
266265
}
267266

268-
me.SigChainBump(linkID, sigID, false)
267+
me.SigChainBump(linkID, sigID)
269268

270269
return err
271270
}

go/engine/untrack.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ func (e *UntrackEngine) storeRemoteUntrack(m libkb.MetaContext, them *libkb.User
205205

206206
sigVersion := libkb.SigVersion(e.arg.SigVersion)
207207
sig, sigID, _, err := libkb.MakeSig(
208-
m,
209208
signingKey,
210209
libkb.LinkTypeUntrack,
211210
e.untrackStatementBytes,

go/engine/user_test.go

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -115,46 +115,3 @@ func TestMerkleHashMetaAndFirstAppearedInKeyFamily(t *testing.T) {
115115
checkSubkey(subkey.GetKID())
116116
}
117117
}
118-
119-
func assertPostedHighSkipSeqno(t *testing.T, tc libkb.TestContext, name string, seqno int) {
120-
u, err := libkb.LoadUser(libkb.NewLoadUserByNameArg(tc.G, name))
121-
if err != nil {
122-
t.Fatal(err)
123-
}
124-
125-
highSkip := u.GetLastLink().GetHighSkip()
126-
require.Equal(t, highSkip.Seqno, keybase1.Seqno(seqno))
127-
}
128-
129-
func TestBlankUserHighSkip(t *testing.T) {
130-
tc := SetupEngineTest(t, "user")
131-
defer tc.Cleanup()
132-
133-
i := CreateAndSignupFakeUser(tc, "login")
134-
135-
assertPostedHighSkipSeqno(t, tc, i.Username, 1)
136-
}
137-
138-
func TestPaperUserHighSkip(t *testing.T) {
139-
tc := SetupEngineTest(t, "user")
140-
defer tc.Cleanup()
141-
them, _ := createFakeUserWithNoKeys(tc)
142-
143-
i := CreateAndSignupFakeUserPaper(tc, "login")
144-
assertPostedHighSkipSeqno(t, tc, i.Username, 4)
145-
146-
trackUser(tc, i, libkb.NewNormalizedUsername(them), libkb.GetDefaultSigVersion(tc.G))
147-
assertPostedHighSkipSeqno(t, tc, i.Username, 4)
148-
149-
eng := NewPaperKey(tc.G)
150-
uis := libkb.UIs{
151-
LogUI: tc.G.UI.GetLogUI(),
152-
LoginUI: &libkb.TestLoginUI{},
153-
SecretUI: &libkb.TestSecretUI{},
154-
}
155-
m := NewMetaContextForTest(tc).WithUIs(uis)
156-
if err := RunEngine2(m, eng); err != nil {
157-
t.Fatal(err)
158-
}
159-
assertPostedHighSkipSeqno(t, tc, i.Username, 7)
160-
}

go/libkb/chain_link.go

Lines changed: 3 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ func (l LinkID) Eq(i2 LinkID) bool {
9393
type 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-
291285
func (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-
545493
func (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-
10951021
func (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-
12741184
func (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

Comments
 (0)