id
int32 0
167k
| repo
stringlengths 5
54
| path
stringlengths 4
155
| func_name
stringlengths 1
118
| original_string
stringlengths 52
85.5k
| language
stringclasses 1
value | code
stringlengths 52
85.5k
| code_tokens
sequencelengths 21
1.41k
| docstring
stringlengths 6
2.61k
| docstring_tokens
sequencelengths 3
215
| sha
stringlengths 40
40
| url
stringlengths 85
252
|
---|---|---|---|---|---|---|---|---|---|---|---|
161,500 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | CreateTeamTLF | func (k KeybaseServiceMeasured) CreateTeamTLF(
ctx context.Context, teamID keybase1.TeamID, tlfID tlf.ID) (err error) {
k.createTeamTLFTimer.Time(func() {
err = k.delegate.CreateTeamTLF(ctx, teamID, tlfID)
})
return err
} | go | func (k KeybaseServiceMeasured) CreateTeamTLF(
ctx context.Context, teamID keybase1.TeamID, tlfID tlf.ID) (err error) {
k.createTeamTLFTimer.Time(func() {
err = k.delegate.CreateTeamTLF(ctx, teamID, tlfID)
})
return err
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"CreateTeamTLF",
"(",
"ctx",
"context",
".",
"Context",
",",
"teamID",
"keybase1",
".",
"TeamID",
",",
"tlfID",
"tlf",
".",
"ID",
")",
"(",
"err",
"error",
")",
"{",
"k",
".",
"createTeamTLFTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"err",
"=",
"k",
".",
"delegate",
".",
"CreateTeamTLF",
"(",
"ctx",
",",
"teamID",
",",
"tlfID",
")",
"\n",
"}",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // CreateTeamTLF implements the KeybaseService interface for
// KeybaseServiceMeasured. | [
"CreateTeamTLF",
"implements",
"the",
"KeybaseService",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L184-L190 |
161,501 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | GetTeamSettings | func (k KeybaseServiceMeasured) GetTeamSettings(
ctx context.Context, teamID keybase1.TeamID,
offline keybase1.OfflineAvailability) (
settings keybase1.KBFSTeamSettings, err error) {
k.getTeamSettingsTimer.Time(func() {
settings, err = k.delegate.GetTeamSettings(ctx, teamID, offline)
})
return settings, err
} | go | func (k KeybaseServiceMeasured) GetTeamSettings(
ctx context.Context, teamID keybase1.TeamID,
offline keybase1.OfflineAvailability) (
settings keybase1.KBFSTeamSettings, err error) {
k.getTeamSettingsTimer.Time(func() {
settings, err = k.delegate.GetTeamSettings(ctx, teamID, offline)
})
return settings, err
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"GetTeamSettings",
"(",
"ctx",
"context",
".",
"Context",
",",
"teamID",
"keybase1",
".",
"TeamID",
",",
"offline",
"keybase1",
".",
"OfflineAvailability",
")",
"(",
"settings",
"keybase1",
".",
"KBFSTeamSettings",
",",
"err",
"error",
")",
"{",
"k",
".",
"getTeamSettingsTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"settings",
",",
"err",
"=",
"k",
".",
"delegate",
".",
"GetTeamSettings",
"(",
"ctx",
",",
"teamID",
",",
"offline",
")",
"\n",
"}",
")",
"\n",
"return",
"settings",
",",
"err",
"\n",
"}"
] | // GetTeamSettings implements the KeybaseService interface for
// KeybaseServiceMeasured. | [
"GetTeamSettings",
"implements",
"the",
"KeybaseService",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L194-L202 |
161,502 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | GetCurrentMerkleRoot | func (k KeybaseServiceMeasured) GetCurrentMerkleRoot(ctx context.Context) (
root keybase1.MerkleRootV2, updateTime time.Time, err error) {
k.getCurrentMerkleRootTimer.Time(func() {
root, updateTime, err = k.delegate.GetCurrentMerkleRoot(ctx)
})
return root, updateTime, err
} | go | func (k KeybaseServiceMeasured) GetCurrentMerkleRoot(ctx context.Context) (
root keybase1.MerkleRootV2, updateTime time.Time, err error) {
k.getCurrentMerkleRootTimer.Time(func() {
root, updateTime, err = k.delegate.GetCurrentMerkleRoot(ctx)
})
return root, updateTime, err
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"GetCurrentMerkleRoot",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"root",
"keybase1",
".",
"MerkleRootV2",
",",
"updateTime",
"time",
".",
"Time",
",",
"err",
"error",
")",
"{",
"k",
".",
"getCurrentMerkleRootTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"root",
",",
"updateTime",
",",
"err",
"=",
"k",
".",
"delegate",
".",
"GetCurrentMerkleRoot",
"(",
"ctx",
")",
"\n",
"}",
")",
"\n",
"return",
"root",
",",
"updateTime",
",",
"err",
"\n",
"}"
] | // GetCurrentMerkleRoot implements the KeybaseService interface for
// KeybaseServiceMeasured. | [
"GetCurrentMerkleRoot",
"implements",
"the",
"KeybaseService",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L206-L212 |
161,503 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | VerifyMerkleRoot | func (k KeybaseServiceMeasured) VerifyMerkleRoot(
ctx context.Context, root keybase1.MerkleRootV2,
kbfsRoot keybase1.KBFSRoot) (err error) {
k.verifyMerkleRootTimer.Time(func() {
err = k.delegate.VerifyMerkleRoot(ctx, root, kbfsRoot)
})
return err
} | go | func (k KeybaseServiceMeasured) VerifyMerkleRoot(
ctx context.Context, root keybase1.MerkleRootV2,
kbfsRoot keybase1.KBFSRoot) (err error) {
k.verifyMerkleRootTimer.Time(func() {
err = k.delegate.VerifyMerkleRoot(ctx, root, kbfsRoot)
})
return err
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"VerifyMerkleRoot",
"(",
"ctx",
"context",
".",
"Context",
",",
"root",
"keybase1",
".",
"MerkleRootV2",
",",
"kbfsRoot",
"keybase1",
".",
"KBFSRoot",
")",
"(",
"err",
"error",
")",
"{",
"k",
".",
"verifyMerkleRootTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"err",
"=",
"k",
".",
"delegate",
".",
"VerifyMerkleRoot",
"(",
"ctx",
",",
"root",
",",
"kbfsRoot",
")",
"\n",
"}",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // VerifyMerkleRoot implements the KBPKI interface for
// KeybaseServiceMeasured. | [
"VerifyMerkleRoot",
"implements",
"the",
"KBPKI",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L216-L223 |
161,504 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | CurrentSession | func (k KeybaseServiceMeasured) CurrentSession(ctx context.Context, sessionID int) (
sessionInfo idutil.SessionInfo, err error) {
k.currentSessionTimer.Time(func() {
sessionInfo, err = k.delegate.CurrentSession(ctx, sessionID)
})
return sessionInfo, err
} | go | func (k KeybaseServiceMeasured) CurrentSession(ctx context.Context, sessionID int) (
sessionInfo idutil.SessionInfo, err error) {
k.currentSessionTimer.Time(func() {
sessionInfo, err = k.delegate.CurrentSession(ctx, sessionID)
})
return sessionInfo, err
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"CurrentSession",
"(",
"ctx",
"context",
".",
"Context",
",",
"sessionID",
"int",
")",
"(",
"sessionInfo",
"idutil",
".",
"SessionInfo",
",",
"err",
"error",
")",
"{",
"k",
".",
"currentSessionTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"sessionInfo",
",",
"err",
"=",
"k",
".",
"delegate",
".",
"CurrentSession",
"(",
"ctx",
",",
"sessionID",
")",
"\n",
"}",
")",
"\n",
"return",
"sessionInfo",
",",
"err",
"\n",
"}"
] | // CurrentSession implements the KeybaseService interface for
// KeybaseServiceMeasured. | [
"CurrentSession",
"implements",
"the",
"KeybaseService",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L227-L233 |
161,505 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | FavoriteAdd | func (k KeybaseServiceMeasured) FavoriteAdd(ctx context.Context, folder keybase1.Folder) (err error) {
k.favoriteAddTimer.Time(func() {
err = k.delegate.FavoriteAdd(ctx, folder)
})
return err
} | go | func (k KeybaseServiceMeasured) FavoriteAdd(ctx context.Context, folder keybase1.Folder) (err error) {
k.favoriteAddTimer.Time(func() {
err = k.delegate.FavoriteAdd(ctx, folder)
})
return err
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"FavoriteAdd",
"(",
"ctx",
"context",
".",
"Context",
",",
"folder",
"keybase1",
".",
"Folder",
")",
"(",
"err",
"error",
")",
"{",
"k",
".",
"favoriteAddTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"err",
"=",
"k",
".",
"delegate",
".",
"FavoriteAdd",
"(",
"ctx",
",",
"folder",
")",
"\n",
"}",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // FavoriteAdd implements the KeybaseService interface for
// KeybaseServiceMeasured. | [
"FavoriteAdd",
"implements",
"the",
"KeybaseService",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L237-L242 |
161,506 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | FavoriteDelete | func (k KeybaseServiceMeasured) FavoriteDelete(ctx context.Context, folder keybase1.Folder) (err error) {
k.favoriteDeleteTimer.Time(func() {
err = k.delegate.FavoriteDelete(ctx, folder)
})
return err
} | go | func (k KeybaseServiceMeasured) FavoriteDelete(ctx context.Context, folder keybase1.Folder) (err error) {
k.favoriteDeleteTimer.Time(func() {
err = k.delegate.FavoriteDelete(ctx, folder)
})
return err
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"FavoriteDelete",
"(",
"ctx",
"context",
".",
"Context",
",",
"folder",
"keybase1",
".",
"Folder",
")",
"(",
"err",
"error",
")",
"{",
"k",
".",
"favoriteDeleteTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"err",
"=",
"k",
".",
"delegate",
".",
"FavoriteDelete",
"(",
"ctx",
",",
"folder",
")",
"\n",
"}",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // FavoriteDelete implements the KeybaseService interface for
// KeybaseServiceMeasured. | [
"FavoriteDelete",
"implements",
"the",
"KeybaseService",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L246-L251 |
161,507 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | FavoriteList | func (k KeybaseServiceMeasured) FavoriteList(ctx context.Context, sessionID int) (
favorites keybase1.FavoritesResult, err error) {
k.favoriteListTimer.Time(func() {
favorites, err = k.delegate.FavoriteList(ctx, sessionID)
})
return favorites, err
} | go | func (k KeybaseServiceMeasured) FavoriteList(ctx context.Context, sessionID int) (
favorites keybase1.FavoritesResult, err error) {
k.favoriteListTimer.Time(func() {
favorites, err = k.delegate.FavoriteList(ctx, sessionID)
})
return favorites, err
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"FavoriteList",
"(",
"ctx",
"context",
".",
"Context",
",",
"sessionID",
"int",
")",
"(",
"favorites",
"keybase1",
".",
"FavoritesResult",
",",
"err",
"error",
")",
"{",
"k",
".",
"favoriteListTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"favorites",
",",
"err",
"=",
"k",
".",
"delegate",
".",
"FavoriteList",
"(",
"ctx",
",",
"sessionID",
")",
"\n",
"}",
")",
"\n",
"return",
"favorites",
",",
"err",
"\n",
"}"
] | // FavoriteList implements the KeybaseService interface for
// KeybaseServiceMeasured. | [
"FavoriteList",
"implements",
"the",
"KeybaseService",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L255-L261 |
161,508 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | EncryptFavorites | func (k KeybaseServiceMeasured) EncryptFavorites(ctx context.Context,
dataIn []byte) (dataOut []byte, err error) {
k.favoriteListTimer.Time(func() {
dataOut, err = k.delegate.EncryptFavorites(ctx, dataIn)
})
return dataOut, err
} | go | func (k KeybaseServiceMeasured) EncryptFavorites(ctx context.Context,
dataIn []byte) (dataOut []byte, err error) {
k.favoriteListTimer.Time(func() {
dataOut, err = k.delegate.EncryptFavorites(ctx, dataIn)
})
return dataOut, err
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"EncryptFavorites",
"(",
"ctx",
"context",
".",
"Context",
",",
"dataIn",
"[",
"]",
"byte",
")",
"(",
"dataOut",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"k",
".",
"favoriteListTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"dataOut",
",",
"err",
"=",
"k",
".",
"delegate",
".",
"EncryptFavorites",
"(",
"ctx",
",",
"dataIn",
")",
"\n",
"}",
")",
"\n",
"return",
"dataOut",
",",
"err",
"\n",
"}"
] | // EncryptFavorites implements the KeybaseService interface for
// KeybaseServiceMeasured. | [
"EncryptFavorites",
"implements",
"the",
"KeybaseService",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L265-L271 |
161,509 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | NotifyOnlineStatusChanged | func (k KeybaseServiceMeasured) NotifyOnlineStatusChanged(
ctx context.Context, online bool) (err error) {
k.notifyTimer.Time(func() {
err = k.delegate.NotifyOnlineStatusChanged(ctx, online)
})
return err
} | go | func (k KeybaseServiceMeasured) NotifyOnlineStatusChanged(
ctx context.Context, online bool) (err error) {
k.notifyTimer.Time(func() {
err = k.delegate.NotifyOnlineStatusChanged(ctx, online)
})
return err
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"NotifyOnlineStatusChanged",
"(",
"ctx",
"context",
".",
"Context",
",",
"online",
"bool",
")",
"(",
"err",
"error",
")",
"{",
"k",
".",
"notifyTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"err",
"=",
"k",
".",
"delegate",
".",
"NotifyOnlineStatusChanged",
"(",
"ctx",
",",
"online",
")",
"\n",
"}",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // NotifyOnlineStatusChanged implements the KeybaseService interface for
// KeybaseServiceMeasured. | [
"NotifyOnlineStatusChanged",
"implements",
"the",
"KeybaseService",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L285-L291 |
161,510 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | Notify | func (k KeybaseServiceMeasured) Notify(ctx context.Context, notification *keybase1.FSNotification) (err error) {
k.notifyTimer.Time(func() {
err = k.delegate.Notify(ctx, notification)
})
return err
} | go | func (k KeybaseServiceMeasured) Notify(ctx context.Context, notification *keybase1.FSNotification) (err error) {
k.notifyTimer.Time(func() {
err = k.delegate.Notify(ctx, notification)
})
return err
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"Notify",
"(",
"ctx",
"context",
".",
"Context",
",",
"notification",
"*",
"keybase1",
".",
"FSNotification",
")",
"(",
"err",
"error",
")",
"{",
"k",
".",
"notifyTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"err",
"=",
"k",
".",
"delegate",
".",
"Notify",
"(",
"ctx",
",",
"notification",
")",
"\n",
"}",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Notify implements the KeybaseService interface for KeybaseServiceMeasured. | [
"Notify",
"implements",
"the",
"KeybaseService",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L294-L299 |
161,511 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | NotifyPathUpdated | func (k KeybaseServiceMeasured) NotifyPathUpdated(
ctx context.Context, path string) (err error) {
k.notifyPathUpdatedTimer.Time(func() {
err = k.delegate.NotifyPathUpdated(ctx, path)
})
return err
} | go | func (k KeybaseServiceMeasured) NotifyPathUpdated(
ctx context.Context, path string) (err error) {
k.notifyPathUpdatedTimer.Time(func() {
err = k.delegate.NotifyPathUpdated(ctx, path)
})
return err
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"NotifyPathUpdated",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
")",
"(",
"err",
"error",
")",
"{",
"k",
".",
"notifyPathUpdatedTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"err",
"=",
"k",
".",
"delegate",
".",
"NotifyPathUpdated",
"(",
"ctx",
",",
"path",
")",
"\n",
"}",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // NotifyPathUpdated implements the KeybaseService interface for
// KeybaseServiceMeasured. | [
"NotifyPathUpdated",
"implements",
"the",
"KeybaseService",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L303-L309 |
161,512 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | NotifySyncStatus | func (k KeybaseServiceMeasured) NotifySyncStatus(ctx context.Context,
status *keybase1.FSPathSyncStatus) (err error) {
k.notifyTimer.Time(func() {
err = k.delegate.NotifySyncStatus(ctx, status)
})
return err
} | go | func (k KeybaseServiceMeasured) NotifySyncStatus(ctx context.Context,
status *keybase1.FSPathSyncStatus) (err error) {
k.notifyTimer.Time(func() {
err = k.delegate.NotifySyncStatus(ctx, status)
})
return err
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"NotifySyncStatus",
"(",
"ctx",
"context",
".",
"Context",
",",
"status",
"*",
"keybase1",
".",
"FSPathSyncStatus",
")",
"(",
"err",
"error",
")",
"{",
"k",
".",
"notifyTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"err",
"=",
"k",
".",
"delegate",
".",
"NotifySyncStatus",
"(",
"ctx",
",",
"status",
")",
"\n",
"}",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // NotifySyncStatus implements the KeybaseService interface for
// KeybaseServiceMeasured. | [
"NotifySyncStatus",
"implements",
"the",
"KeybaseService",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L313-L319 |
161,513 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | NotifyOverallSyncStatus | func (k KeybaseServiceMeasured) NotifyOverallSyncStatus(
ctx context.Context, status keybase1.FolderSyncStatus) (err error) {
k.notifyTimer.Time(func() {
err = k.delegate.NotifyOverallSyncStatus(ctx, status)
})
return err
} | go | func (k KeybaseServiceMeasured) NotifyOverallSyncStatus(
ctx context.Context, status keybase1.FolderSyncStatus) (err error) {
k.notifyTimer.Time(func() {
err = k.delegate.NotifyOverallSyncStatus(ctx, status)
})
return err
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"NotifyOverallSyncStatus",
"(",
"ctx",
"context",
".",
"Context",
",",
"status",
"keybase1",
".",
"FolderSyncStatus",
")",
"(",
"err",
"error",
")",
"{",
"k",
".",
"notifyTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"err",
"=",
"k",
".",
"delegate",
".",
"NotifyOverallSyncStatus",
"(",
"ctx",
",",
"status",
")",
"\n",
"}",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // NotifyOverallSyncStatus implements the KeybaseService interface for
// KeybaseServiceMeasured. | [
"NotifyOverallSyncStatus",
"implements",
"the",
"KeybaseService",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L323-L329 |
161,514 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | FlushUserFromLocalCache | func (k KeybaseServiceMeasured) FlushUserFromLocalCache(
ctx context.Context, uid keybase1.UID) {
k.delegate.FlushUserFromLocalCache(ctx, uid)
} | go | func (k KeybaseServiceMeasured) FlushUserFromLocalCache(
ctx context.Context, uid keybase1.UID) {
k.delegate.FlushUserFromLocalCache(ctx, uid)
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"FlushUserFromLocalCache",
"(",
"ctx",
"context",
".",
"Context",
",",
"uid",
"keybase1",
".",
"UID",
")",
"{",
"k",
".",
"delegate",
".",
"FlushUserFromLocalCache",
"(",
"ctx",
",",
"uid",
")",
"\n",
"}"
] | // FlushUserFromLocalCache implements the KeybaseService interface for
// KeybaseServiceMeasured. | [
"FlushUserFromLocalCache",
"implements",
"the",
"KeybaseService",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L333-L336 |
161,515 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | ClearCaches | func (k KeybaseServiceMeasured) ClearCaches(ctx context.Context) {
k.delegate.ClearCaches(ctx)
} | go | func (k KeybaseServiceMeasured) ClearCaches(ctx context.Context) {
k.delegate.ClearCaches(ctx)
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"ClearCaches",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"k",
".",
"delegate",
".",
"ClearCaches",
"(",
"ctx",
")",
"\n",
"}"
] | // ClearCaches implements the KeybaseService interface for
// KeybaseServiceMeasured. | [
"ClearCaches",
"implements",
"the",
"KeybaseService",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L340-L342 |
161,516 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | EstablishMountDir | func (k KeybaseServiceMeasured) EstablishMountDir(ctx context.Context) (string, error) {
return k.delegate.EstablishMountDir(ctx)
} | go | func (k KeybaseServiceMeasured) EstablishMountDir(ctx context.Context) (string, error) {
return k.delegate.EstablishMountDir(ctx)
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"EstablishMountDir",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"k",
".",
"delegate",
".",
"EstablishMountDir",
"(",
"ctx",
")",
"\n",
"}"
] | // EstablishMountDir implements the KeybaseDaemon interface for KeybaseDaemonLocal. | [
"EstablishMountDir",
"implements",
"the",
"KeybaseDaemon",
"interface",
"for",
"KeybaseDaemonLocal",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L345-L347 |
161,517 | keybase/client | go/kbfs/libkbfs/keybase_service_measured.go | PutGitMetadata | func (k KeybaseServiceMeasured) PutGitMetadata(
ctx context.Context, folder keybase1.Folder, repoID keybase1.RepoID,
metadata keybase1.GitLocalMetadata) (err error) {
k.putGitMetadataTimer.Time(func() {
err = k.delegate.PutGitMetadata(ctx, folder, repoID, metadata)
})
return err
} | go | func (k KeybaseServiceMeasured) PutGitMetadata(
ctx context.Context, folder keybase1.Folder, repoID keybase1.RepoID,
metadata keybase1.GitLocalMetadata) (err error) {
k.putGitMetadataTimer.Time(func() {
err = k.delegate.PutGitMetadata(ctx, folder, repoID, metadata)
})
return err
} | [
"func",
"(",
"k",
"KeybaseServiceMeasured",
")",
"PutGitMetadata",
"(",
"ctx",
"context",
".",
"Context",
",",
"folder",
"keybase1",
".",
"Folder",
",",
"repoID",
"keybase1",
".",
"RepoID",
",",
"metadata",
"keybase1",
".",
"GitLocalMetadata",
")",
"(",
"err",
"error",
")",
"{",
"k",
".",
"putGitMetadataTimer",
".",
"Time",
"(",
"func",
"(",
")",
"{",
"err",
"=",
"k",
".",
"delegate",
".",
"PutGitMetadata",
"(",
"ctx",
",",
"folder",
",",
"repoID",
",",
"metadata",
")",
"\n",
"}",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // PutGitMetadata implements the KeybaseDaemon interface for
// KeybaseServiceMeasured. | [
"PutGitMetadata",
"implements",
"the",
"KeybaseDaemon",
"interface",
"for",
"KeybaseServiceMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_service_measured.go#L351-L358 |
161,518 | keybase/client | go/kbfs/libgit/rpc.go | NewRPCHandlerWithCtx | func NewRPCHandlerWithCtx(kbCtx libkbfs.Context, config libkbfs.Config,
kbfsInitParams *libkbfs.InitParams) (*RPCHandler, func()) {
shutdown := StartAutogit(config, 100)
return &RPCHandler{
kbCtx: kbCtx,
config: config,
kbfsInitParams: kbfsInitParams,
log: config.MakeLogger(""),
}, shutdown
} | go | func NewRPCHandlerWithCtx(kbCtx libkbfs.Context, config libkbfs.Config,
kbfsInitParams *libkbfs.InitParams) (*RPCHandler, func()) {
shutdown := StartAutogit(config, 100)
return &RPCHandler{
kbCtx: kbCtx,
config: config,
kbfsInitParams: kbfsInitParams,
log: config.MakeLogger(""),
}, shutdown
} | [
"func",
"NewRPCHandlerWithCtx",
"(",
"kbCtx",
"libkbfs",
".",
"Context",
",",
"config",
"libkbfs",
".",
"Config",
",",
"kbfsInitParams",
"*",
"libkbfs",
".",
"InitParams",
")",
"(",
"*",
"RPCHandler",
",",
"func",
"(",
")",
")",
"{",
"shutdown",
":=",
"StartAutogit",
"(",
"config",
",",
"100",
")",
"\n",
"return",
"&",
"RPCHandler",
"{",
"kbCtx",
":",
"kbCtx",
",",
"config",
":",
"config",
",",
"kbfsInitParams",
":",
"kbfsInitParams",
",",
"log",
":",
"config",
".",
"MakeLogger",
"(",
"\"",
"\"",
")",
",",
"}",
",",
"shutdown",
"\n",
"}"
] | // NewRPCHandlerWithCtx returns a new instance of a Git RPC handler. | [
"NewRPCHandlerWithCtx",
"returns",
"a",
"new",
"instance",
"of",
"a",
"Git",
"RPC",
"handler",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libgit/rpc.go#L31-L40 |
161,519 | keybase/client | go/kbfs/libgit/rpc.go | CreateRepo | func (rh *RPCHandler) CreateRepo(
ctx context.Context, arg keybase1.CreateRepoArg) (
id keybase1.RepoID, err error) {
rh.log.CDebugf(ctx, "Creating repo %s in folder %s/%s",
arg.Name, arg.Folder.FolderType, arg.Folder.Name)
defer func() {
rh.log.CDebugf(ctx, "Done creating repo: %+v", err)
}()
ctx, cancel := context.WithCancel(ctx)
defer cancel()
ctx, gitConfig, tlfHandle, tempDir, err := rh.getHandleAndConfig(
ctx, arg.Folder)
if err != nil {
return "", err
}
defer func() {
rmErr := os.RemoveAll(tempDir)
if rmErr != nil {
rh.log.CDebugf(
ctx, "Error cleaning storage dir %s: %+v\n", tempDir, rmErr)
}
}()
defer gitConfig.Shutdown(ctx)
ctx = context.WithValue(ctx, libkbfs.CtxAllowNameKey, kbfsRepoDir)
gitID, err := CreateRepoAndID(ctx, gitConfig, tlfHandle, string(arg.Name))
if err != nil {
return "", err
}
err = rh.waitForJournal(ctx, gitConfig, tlfHandle)
if err != nil {
return "", err
}
return keybase1.RepoID(gitID.String()), nil
} | go | func (rh *RPCHandler) CreateRepo(
ctx context.Context, arg keybase1.CreateRepoArg) (
id keybase1.RepoID, err error) {
rh.log.CDebugf(ctx, "Creating repo %s in folder %s/%s",
arg.Name, arg.Folder.FolderType, arg.Folder.Name)
defer func() {
rh.log.CDebugf(ctx, "Done creating repo: %+v", err)
}()
ctx, cancel := context.WithCancel(ctx)
defer cancel()
ctx, gitConfig, tlfHandle, tempDir, err := rh.getHandleAndConfig(
ctx, arg.Folder)
if err != nil {
return "", err
}
defer func() {
rmErr := os.RemoveAll(tempDir)
if rmErr != nil {
rh.log.CDebugf(
ctx, "Error cleaning storage dir %s: %+v\n", tempDir, rmErr)
}
}()
defer gitConfig.Shutdown(ctx)
ctx = context.WithValue(ctx, libkbfs.CtxAllowNameKey, kbfsRepoDir)
gitID, err := CreateRepoAndID(ctx, gitConfig, tlfHandle, string(arg.Name))
if err != nil {
return "", err
}
err = rh.waitForJournal(ctx, gitConfig, tlfHandle)
if err != nil {
return "", err
}
return keybase1.RepoID(gitID.String()), nil
} | [
"func",
"(",
"rh",
"*",
"RPCHandler",
")",
"CreateRepo",
"(",
"ctx",
"context",
".",
"Context",
",",
"arg",
"keybase1",
".",
"CreateRepoArg",
")",
"(",
"id",
"keybase1",
".",
"RepoID",
",",
"err",
"error",
")",
"{",
"rh",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"arg",
".",
"Name",
",",
"arg",
".",
"Folder",
".",
"FolderType",
",",
"arg",
".",
"Folder",
".",
"Name",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"rh",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"(",
")",
"\n\n",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"ctx",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"ctx",
",",
"gitConfig",
",",
"tlfHandle",
",",
"tempDir",
",",
"err",
":=",
"rh",
".",
"getHandleAndConfig",
"(",
"ctx",
",",
"arg",
".",
"Folder",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"defer",
"func",
"(",
")",
"{",
"rmErr",
":=",
"os",
".",
"RemoveAll",
"(",
"tempDir",
")",
"\n",
"if",
"rmErr",
"!=",
"nil",
"{",
"rh",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\\n",
"\"",
",",
"tempDir",
",",
"rmErr",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n",
"defer",
"gitConfig",
".",
"Shutdown",
"(",
"ctx",
")",
"\n\n",
"ctx",
"=",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"libkbfs",
".",
"CtxAllowNameKey",
",",
"kbfsRepoDir",
")",
"\n",
"gitID",
",",
"err",
":=",
"CreateRepoAndID",
"(",
"ctx",
",",
"gitConfig",
",",
"tlfHandle",
",",
"string",
"(",
"arg",
".",
"Name",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"rh",
".",
"waitForJournal",
"(",
"ctx",
",",
"gitConfig",
",",
"tlfHandle",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"keybase1",
".",
"RepoID",
"(",
"gitID",
".",
"String",
"(",
")",
")",
",",
"nil",
"\n",
"}"
] | // CreateRepo implements keybase1.KBFSGitInterface for KeybaseServiceBase. | [
"CreateRepo",
"implements",
"keybase1",
".",
"KBFSGitInterface",
"for",
"KeybaseServiceBase",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libgit/rpc.go#L132-L169 |
161,520 | keybase/client | go/kbfs/libgit/rpc.go | DeleteRepo | func (rh *RPCHandler) DeleteRepo(
ctx context.Context, arg keybase1.DeleteRepoArg) (err error) {
rh.log.CDebugf(ctx, "Deleting repo %s from folder %s/%s",
arg.Name, arg.Folder.FolderType, arg.Folder.Name)
defer func() {
rh.log.CDebugf(ctx, "Done deleting repo: %+v", err)
}()
ctx, cancel := context.WithCancel(ctx)
defer cancel()
ctx, gitConfig, tlfHandle, tempDir, err := rh.getHandleAndConfig(
ctx, arg.Folder)
if err != nil {
return err
}
defer func() {
rmErr := os.RemoveAll(tempDir)
if rmErr != nil {
rh.log.CDebugf(
ctx, "Error cleaning storage dir %s: %+v\n", tempDir, rmErr)
}
}()
defer gitConfig.Shutdown(ctx)
err = DeleteRepo(ctx, gitConfig, tlfHandle, string(arg.Name))
if err != nil {
return err
}
err = rh.waitForJournal(ctx, gitConfig, tlfHandle)
if err != nil {
return err
}
rh.scheduleCleaning(arg.Folder)
return nil
} | go | func (rh *RPCHandler) DeleteRepo(
ctx context.Context, arg keybase1.DeleteRepoArg) (err error) {
rh.log.CDebugf(ctx, "Deleting repo %s from folder %s/%s",
arg.Name, arg.Folder.FolderType, arg.Folder.Name)
defer func() {
rh.log.CDebugf(ctx, "Done deleting repo: %+v", err)
}()
ctx, cancel := context.WithCancel(ctx)
defer cancel()
ctx, gitConfig, tlfHandle, tempDir, err := rh.getHandleAndConfig(
ctx, arg.Folder)
if err != nil {
return err
}
defer func() {
rmErr := os.RemoveAll(tempDir)
if rmErr != nil {
rh.log.CDebugf(
ctx, "Error cleaning storage dir %s: %+v\n", tempDir, rmErr)
}
}()
defer gitConfig.Shutdown(ctx)
err = DeleteRepo(ctx, gitConfig, tlfHandle, string(arg.Name))
if err != nil {
return err
}
err = rh.waitForJournal(ctx, gitConfig, tlfHandle)
if err != nil {
return err
}
rh.scheduleCleaning(arg.Folder)
return nil
} | [
"func",
"(",
"rh",
"*",
"RPCHandler",
")",
"DeleteRepo",
"(",
"ctx",
"context",
".",
"Context",
",",
"arg",
"keybase1",
".",
"DeleteRepoArg",
")",
"(",
"err",
"error",
")",
"{",
"rh",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"arg",
".",
"Name",
",",
"arg",
".",
"Folder",
".",
"FolderType",
",",
"arg",
".",
"Folder",
".",
"Name",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"rh",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"(",
")",
"\n\n",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"ctx",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"ctx",
",",
"gitConfig",
",",
"tlfHandle",
",",
"tempDir",
",",
"err",
":=",
"rh",
".",
"getHandleAndConfig",
"(",
"ctx",
",",
"arg",
".",
"Folder",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"func",
"(",
")",
"{",
"rmErr",
":=",
"os",
".",
"RemoveAll",
"(",
"tempDir",
")",
"\n",
"if",
"rmErr",
"!=",
"nil",
"{",
"rh",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\\n",
"\"",
",",
"tempDir",
",",
"rmErr",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n",
"defer",
"gitConfig",
".",
"Shutdown",
"(",
"ctx",
")",
"\n\n",
"err",
"=",
"DeleteRepo",
"(",
"ctx",
",",
"gitConfig",
",",
"tlfHandle",
",",
"string",
"(",
"arg",
".",
"Name",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"rh",
".",
"waitForJournal",
"(",
"ctx",
",",
"gitConfig",
",",
"tlfHandle",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"rh",
".",
"scheduleCleaning",
"(",
"arg",
".",
"Folder",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // DeleteRepo implements keybase1.KBFSGitInterface for KeybaseServiceBase. | [
"DeleteRepo",
"implements",
"keybase1",
".",
"KBFSGitInterface",
"for",
"KeybaseServiceBase",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libgit/rpc.go#L214-L250 |
161,521 | keybase/client | go/kbfs/libgit/rpc.go | Gc | func (rh *RPCHandler) Gc(
ctx context.Context, arg keybase1.GcArg) (err error) {
rh.log.CDebugf(ctx, "Garbage-collecting repo %s from folder %s/%s",
arg.Name, arg.Folder.FolderType, arg.Folder.Name)
defer func() {
rh.log.CDebugf(ctx, "Done garbage-collecting repo: %+v", err)
}()
ctx, cancel := context.WithCancel(ctx)
defer cancel()
ctx, gitConfig, tlfHandle, tempDir, err := rh.getHandleAndConfig(
ctx, arg.Folder)
if err != nil {
return err
}
defer func() {
rmErr := os.RemoveAll(tempDir)
if rmErr != nil {
rh.log.CDebugf(
ctx, "Error cleaning storage dir %s: %+v\n", tempDir, rmErr)
}
}()
defer gitConfig.Shutdown(ctx)
gco := GCOptions{
MaxLooseRefs: arg.Options.MaxLooseRefs,
PruneMinLooseObjects: arg.Options.PruneMinLooseObjects,
PruneExpireTime: keybase1.FromTime(arg.Options.PruneExpireTime),
MaxObjectPacks: arg.Options.MaxObjectPacks,
}
err = GCRepo(ctx, gitConfig, tlfHandle, string(arg.Name), gco)
if err != nil {
return err
}
return rh.waitForJournal(ctx, gitConfig, tlfHandle)
} | go | func (rh *RPCHandler) Gc(
ctx context.Context, arg keybase1.GcArg) (err error) {
rh.log.CDebugf(ctx, "Garbage-collecting repo %s from folder %s/%s",
arg.Name, arg.Folder.FolderType, arg.Folder.Name)
defer func() {
rh.log.CDebugf(ctx, "Done garbage-collecting repo: %+v", err)
}()
ctx, cancel := context.WithCancel(ctx)
defer cancel()
ctx, gitConfig, tlfHandle, tempDir, err := rh.getHandleAndConfig(
ctx, arg.Folder)
if err != nil {
return err
}
defer func() {
rmErr := os.RemoveAll(tempDir)
if rmErr != nil {
rh.log.CDebugf(
ctx, "Error cleaning storage dir %s: %+v\n", tempDir, rmErr)
}
}()
defer gitConfig.Shutdown(ctx)
gco := GCOptions{
MaxLooseRefs: arg.Options.MaxLooseRefs,
PruneMinLooseObjects: arg.Options.PruneMinLooseObjects,
PruneExpireTime: keybase1.FromTime(arg.Options.PruneExpireTime),
MaxObjectPacks: arg.Options.MaxObjectPacks,
}
err = GCRepo(ctx, gitConfig, tlfHandle, string(arg.Name), gco)
if err != nil {
return err
}
return rh.waitForJournal(ctx, gitConfig, tlfHandle)
} | [
"func",
"(",
"rh",
"*",
"RPCHandler",
")",
"Gc",
"(",
"ctx",
"context",
".",
"Context",
",",
"arg",
"keybase1",
".",
"GcArg",
")",
"(",
"err",
"error",
")",
"{",
"rh",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"arg",
".",
"Name",
",",
"arg",
".",
"Folder",
".",
"FolderType",
",",
"arg",
".",
"Folder",
".",
"Name",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"rh",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"(",
")",
"\n\n",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"ctx",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"ctx",
",",
"gitConfig",
",",
"tlfHandle",
",",
"tempDir",
",",
"err",
":=",
"rh",
".",
"getHandleAndConfig",
"(",
"ctx",
",",
"arg",
".",
"Folder",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"func",
"(",
")",
"{",
"rmErr",
":=",
"os",
".",
"RemoveAll",
"(",
"tempDir",
")",
"\n",
"if",
"rmErr",
"!=",
"nil",
"{",
"rh",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\\n",
"\"",
",",
"tempDir",
",",
"rmErr",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n",
"defer",
"gitConfig",
".",
"Shutdown",
"(",
"ctx",
")",
"\n\n",
"gco",
":=",
"GCOptions",
"{",
"MaxLooseRefs",
":",
"arg",
".",
"Options",
".",
"MaxLooseRefs",
",",
"PruneMinLooseObjects",
":",
"arg",
".",
"Options",
".",
"PruneMinLooseObjects",
",",
"PruneExpireTime",
":",
"keybase1",
".",
"FromTime",
"(",
"arg",
".",
"Options",
".",
"PruneExpireTime",
")",
",",
"MaxObjectPacks",
":",
"arg",
".",
"Options",
".",
"MaxObjectPacks",
",",
"}",
"\n",
"err",
"=",
"GCRepo",
"(",
"ctx",
",",
"gitConfig",
",",
"tlfHandle",
",",
"string",
"(",
"arg",
".",
"Name",
")",
",",
"gco",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"rh",
".",
"waitForJournal",
"(",
"ctx",
",",
"gitConfig",
",",
"tlfHandle",
")",
"\n",
"}"
] | // Gc implements keybase1.KBFSGitInterface for KeybaseServiceBase. | [
"Gc",
"implements",
"keybase1",
".",
"KBFSGitInterface",
"for",
"KeybaseServiceBase",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libgit/rpc.go#L253-L289 |
161,522 | keybase/client | go/libkb/passphrase_stream_cache.go | PassphraseStream | func (s *PassphraseStreamCache) PassphraseStream() *PassphraseStream {
if s == nil {
return nil
}
s.Lock()
defer s.Unlock()
return s.passphraseStream.Clone()
} | go | func (s *PassphraseStreamCache) PassphraseStream() *PassphraseStream {
if s == nil {
return nil
}
s.Lock()
defer s.Unlock()
return s.passphraseStream.Clone()
} | [
"func",
"(",
"s",
"*",
"PassphraseStreamCache",
")",
"PassphraseStream",
"(",
")",
"*",
"PassphraseStream",
"{",
"if",
"s",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n",
"return",
"s",
".",
"passphraseStream",
".",
"Clone",
"(",
")",
"\n",
"}"
] | // PassphraseStream returns a copy of the currently cached passphrase stream,
// or nil if none exists. | [
"PassphraseStream",
"returns",
"a",
"copy",
"of",
"the",
"currently",
"cached",
"passphrase",
"stream",
"or",
"nil",
"if",
"none",
"exists",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/passphrase_stream_cache.go#L112-L119 |
161,523 | keybase/client | go/engine/saltpack_user_keyfinder.go | AddPUK | func (e *SaltpackUserKeyfinder) AddPUK(m libkb.MetaContext, upk *keybase1.UserPlusKeysV2) error {
if !e.Arg.UseEntityKeys {
// No need to add anything
return nil
}
if e.hasRecipientEntityKeys(upk.Uid.AsUserOrTeam()) {
// This user's keys were already added
return nil
}
hasPUK := len(upk.PerUserKeys) > 0
if !hasPUK {
hasPaperKey := false
hasDeviceKey := false
for KID, key := range upk.DeviceKeys {
if e.isPaperEncryptionKey(&key, &upk.DeviceKeys) {
hasPaperKey = true
}
if libkb.KIDIsDeviceEncrypt(KID) && !e.isPaperEncryptionKey(&key, &upk.DeviceKeys) {
hasDeviceKey = true
}
}
m.Debug("did not add any per user keys for %v", upk.Username)
return libkb.NoNaClEncryptionKeyError{
Username: upk.Username,
HasPGPKey: len(upk.PGPKeys) > 0,
HasPUK: hasPUK,
HasDeviceKey: hasDeviceKey,
HasPaperKey: hasPaperKey,
}
}
// We ensured above that the user has a PUK, so the loop below will be executed at least once
maxGen := -1
var lk keybase1.KID
for _, k := range upk.PerUserKeys {
if k.Gen > maxGen {
maxGen = k.Gen
lk = k.EncKID
}
}
if lk == "" {
panic("This should never happen, user has a PUK with a nil KID")
}
m.Debug("adding user %v's latest per user key", upk.Username)
e.RecipientEntityKeyMap[upk.Uid.AsUserOrTeam()] = []keybase1.KID{lk}
return nil
} | go | func (e *SaltpackUserKeyfinder) AddPUK(m libkb.MetaContext, upk *keybase1.UserPlusKeysV2) error {
if !e.Arg.UseEntityKeys {
// No need to add anything
return nil
}
if e.hasRecipientEntityKeys(upk.Uid.AsUserOrTeam()) {
// This user's keys were already added
return nil
}
hasPUK := len(upk.PerUserKeys) > 0
if !hasPUK {
hasPaperKey := false
hasDeviceKey := false
for KID, key := range upk.DeviceKeys {
if e.isPaperEncryptionKey(&key, &upk.DeviceKeys) {
hasPaperKey = true
}
if libkb.KIDIsDeviceEncrypt(KID) && !e.isPaperEncryptionKey(&key, &upk.DeviceKeys) {
hasDeviceKey = true
}
}
m.Debug("did not add any per user keys for %v", upk.Username)
return libkb.NoNaClEncryptionKeyError{
Username: upk.Username,
HasPGPKey: len(upk.PGPKeys) > 0,
HasPUK: hasPUK,
HasDeviceKey: hasDeviceKey,
HasPaperKey: hasPaperKey,
}
}
// We ensured above that the user has a PUK, so the loop below will be executed at least once
maxGen := -1
var lk keybase1.KID
for _, k := range upk.PerUserKeys {
if k.Gen > maxGen {
maxGen = k.Gen
lk = k.EncKID
}
}
if lk == "" {
panic("This should never happen, user has a PUK with a nil KID")
}
m.Debug("adding user %v's latest per user key", upk.Username)
e.RecipientEntityKeyMap[upk.Uid.AsUserOrTeam()] = []keybase1.KID{lk}
return nil
} | [
"func",
"(",
"e",
"*",
"SaltpackUserKeyfinder",
")",
"AddPUK",
"(",
"m",
"libkb",
".",
"MetaContext",
",",
"upk",
"*",
"keybase1",
".",
"UserPlusKeysV2",
")",
"error",
"{",
"if",
"!",
"e",
".",
"Arg",
".",
"UseEntityKeys",
"{",
"// No need to add anything",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"e",
".",
"hasRecipientEntityKeys",
"(",
"upk",
".",
"Uid",
".",
"AsUserOrTeam",
"(",
")",
")",
"{",
"// This user's keys were already added",
"return",
"nil",
"\n",
"}",
"\n\n",
"hasPUK",
":=",
"len",
"(",
"upk",
".",
"PerUserKeys",
")",
">",
"0",
"\n\n",
"if",
"!",
"hasPUK",
"{",
"hasPaperKey",
":=",
"false",
"\n",
"hasDeviceKey",
":=",
"false",
"\n",
"for",
"KID",
",",
"key",
":=",
"range",
"upk",
".",
"DeviceKeys",
"{",
"if",
"e",
".",
"isPaperEncryptionKey",
"(",
"&",
"key",
",",
"&",
"upk",
".",
"DeviceKeys",
")",
"{",
"hasPaperKey",
"=",
"true",
"\n",
"}",
"\n",
"if",
"libkb",
".",
"KIDIsDeviceEncrypt",
"(",
"KID",
")",
"&&",
"!",
"e",
".",
"isPaperEncryptionKey",
"(",
"&",
"key",
",",
"&",
"upk",
".",
"DeviceKeys",
")",
"{",
"hasDeviceKey",
"=",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"m",
".",
"Debug",
"(",
"\"",
"\"",
",",
"upk",
".",
"Username",
")",
"\n",
"return",
"libkb",
".",
"NoNaClEncryptionKeyError",
"{",
"Username",
":",
"upk",
".",
"Username",
",",
"HasPGPKey",
":",
"len",
"(",
"upk",
".",
"PGPKeys",
")",
">",
"0",
",",
"HasPUK",
":",
"hasPUK",
",",
"HasDeviceKey",
":",
"hasDeviceKey",
",",
"HasPaperKey",
":",
"hasPaperKey",
",",
"}",
"\n",
"}",
"\n\n",
"// We ensured above that the user has a PUK, so the loop below will be executed at least once",
"maxGen",
":=",
"-",
"1",
"\n",
"var",
"lk",
"keybase1",
".",
"KID",
"\n",
"for",
"_",
",",
"k",
":=",
"range",
"upk",
".",
"PerUserKeys",
"{",
"if",
"k",
".",
"Gen",
">",
"maxGen",
"{",
"maxGen",
"=",
"k",
".",
"Gen",
"\n",
"lk",
"=",
"k",
".",
"EncKID",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"lk",
"==",
"\"",
"\"",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"m",
".",
"Debug",
"(",
"\"",
"\"",
",",
"upk",
".",
"Username",
")",
"\n",
"e",
".",
"RecipientEntityKeyMap",
"[",
"upk",
".",
"Uid",
".",
"AsUserOrTeam",
"(",
")",
"]",
"=",
"[",
"]",
"keybase1",
".",
"KID",
"{",
"lk",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // AddPUK returns no error unless the user has no PUK, in which case it returns a libkb.NoNaClEncryptionKeyError | [
"AddPUK",
"returns",
"no",
"error",
"unless",
"the",
"user",
"has",
"no",
"PUK",
"in",
"which",
"case",
"it",
"returns",
"a",
"libkb",
".",
"NoNaClEncryptionKeyError"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/saltpack_user_keyfinder.go#L234-L286 |
161,524 | keybase/client | go/kbfs/libkbfs/flag_size.go | String | func (sf SizeFlag) String() string {
// This happens when izZeroValue() from flag.go makes a zero
// value from the type of a flag.
if sf.v == nil {
return "0"
}
v := *sf.v
var suffix string
const units = "kmgt"
var c byte
if v%1000 == 0 {
for i := 0; v%1000 == 0 && i < len(units); i++ {
c = units[i]
v /= 1000
}
suffix = string(c)
} else if v%1024 == 0 {
for i := 0; v%1024 == 0 && i < len(units); i++ {
c = units[i]
v /= 1024
}
suffix = string(c) + "i"
}
return fmt.Sprintf("%d%s", v, suffix)
} | go | func (sf SizeFlag) String() string {
// This happens when izZeroValue() from flag.go makes a zero
// value from the type of a flag.
if sf.v == nil {
return "0"
}
v := *sf.v
var suffix string
const units = "kmgt"
var c byte
if v%1000 == 0 {
for i := 0; v%1000 == 0 && i < len(units); i++ {
c = units[i]
v /= 1000
}
suffix = string(c)
} else if v%1024 == 0 {
for i := 0; v%1024 == 0 && i < len(units); i++ {
c = units[i]
v /= 1024
}
suffix = string(c) + "i"
}
return fmt.Sprintf("%d%s", v, suffix)
} | [
"func",
"(",
"sf",
"SizeFlag",
")",
"String",
"(",
")",
"string",
"{",
"// This happens when izZeroValue() from flag.go makes a zero",
"// value from the type of a flag.",
"if",
"sf",
".",
"v",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"v",
":=",
"*",
"sf",
".",
"v",
"\n",
"var",
"suffix",
"string",
"\n",
"const",
"units",
"=",
"\"",
"\"",
"\n",
"var",
"c",
"byte",
"\n",
"if",
"v",
"%",
"1000",
"==",
"0",
"{",
"for",
"i",
":=",
"0",
";",
"v",
"%",
"1000",
"==",
"0",
"&&",
"i",
"<",
"len",
"(",
"units",
")",
";",
"i",
"++",
"{",
"c",
"=",
"units",
"[",
"i",
"]",
"\n",
"v",
"/=",
"1000",
"\n",
"}",
"\n",
"suffix",
"=",
"string",
"(",
"c",
")",
"\n",
"}",
"else",
"if",
"v",
"%",
"1024",
"==",
"0",
"{",
"for",
"i",
":=",
"0",
";",
"v",
"%",
"1024",
"==",
"0",
"&&",
"i",
"<",
"len",
"(",
"units",
")",
";",
"i",
"++",
"{",
"c",
"=",
"units",
"[",
"i",
"]",
"\n",
"v",
"/=",
"1024",
"\n",
"}",
"\n",
"suffix",
"=",
"string",
"(",
"c",
")",
"+",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"v",
",",
"suffix",
")",
"\n",
"}"
] | // String for flag interface. | [
"String",
"for",
"flag",
"interface",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/flag_size.go#L22-L46 |
161,525 | keybase/client | go/kbfs/libkbfs/flag_size.go | Set | func (sf SizeFlag) Set(raw string) error {
i := 0
for ; i < len(raw) && raw[i] >= '0' && raw[i] <= '9'; i++ {
}
val, err := strconv.ParseInt(raw[:i], 10, 64)
if err != nil {
return err
}
// constant map so concurrent access is ok.
mult, found := sizeFlagMap[strings.ToLower(raw[i:])]
if !found {
return fmt.Errorf("Invalid syntax: %q, supported syntax is 0-9+(k|m|g|t)[i]", raw)
}
*sf.v = val * mult
return nil
} | go | func (sf SizeFlag) Set(raw string) error {
i := 0
for ; i < len(raw) && raw[i] >= '0' && raw[i] <= '9'; i++ {
}
val, err := strconv.ParseInt(raw[:i], 10, 64)
if err != nil {
return err
}
// constant map so concurrent access is ok.
mult, found := sizeFlagMap[strings.ToLower(raw[i:])]
if !found {
return fmt.Errorf("Invalid syntax: %q, supported syntax is 0-9+(k|m|g|t)[i]", raw)
}
*sf.v = val * mult
return nil
} | [
"func",
"(",
"sf",
"SizeFlag",
")",
"Set",
"(",
"raw",
"string",
")",
"error",
"{",
"i",
":=",
"0",
"\n",
"for",
";",
"i",
"<",
"len",
"(",
"raw",
")",
"&&",
"raw",
"[",
"i",
"]",
">=",
"'0'",
"&&",
"raw",
"[",
"i",
"]",
"<=",
"'9'",
";",
"i",
"++",
"{",
"}",
"\n",
"val",
",",
"err",
":=",
"strconv",
".",
"ParseInt",
"(",
"raw",
"[",
":",
"i",
"]",
",",
"10",
",",
"64",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"// constant map so concurrent access is ok.",
"mult",
",",
"found",
":=",
"sizeFlagMap",
"[",
"strings",
".",
"ToLower",
"(",
"raw",
"[",
"i",
":",
"]",
")",
"]",
"\n",
"if",
"!",
"found",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"raw",
")",
"\n",
"}",
"\n",
"*",
"sf",
".",
"v",
"=",
"val",
"*",
"mult",
"\n",
"return",
"nil",
"\n",
"}"
] | // Set for flag interface. | [
"Set",
"for",
"flag",
"interface",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/flag_size.go#L49-L64 |
161,526 | keybase/client | go/engine/pgp_keyfinder.go | NewPGPKeyfinder | func NewPGPKeyfinder(g *libkb.GlobalContext, arg *PGPKeyfinderArg) *PGPKeyfinder {
return &PGPKeyfinder{
arg: arg,
Contextified: libkb.NewContextified(g),
}
} | go | func NewPGPKeyfinder(g *libkb.GlobalContext, arg *PGPKeyfinderArg) *PGPKeyfinder {
return &PGPKeyfinder{
arg: arg,
Contextified: libkb.NewContextified(g),
}
} | [
"func",
"NewPGPKeyfinder",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"arg",
"*",
"PGPKeyfinderArg",
")",
"*",
"PGPKeyfinder",
"{",
"return",
"&",
"PGPKeyfinder",
"{",
"arg",
":",
"arg",
",",
"Contextified",
":",
"libkb",
".",
"NewContextified",
"(",
"g",
")",
",",
"}",
"\n",
"}"
] | // NewPGPKeyfinder creates a PGPKeyfinder engine. | [
"NewPGPKeyfinder",
"creates",
"a",
"PGPKeyfinder",
"engine",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/pgp_keyfinder.go#L24-L29 |
161,527 | keybase/client | go/engine/pgp_keyfinder.go | loadUsers | func (e *PGPKeyfinder) loadUsers(m libkb.MetaContext) {
if e.runerr != nil {
return
}
for _, u := range e.arg.Usernames {
arg := libkb.NewLoadUserByNameArg(e.G(), u)
user, err := libkb.LoadUser(arg)
if err != nil {
e.runerr = err
return
}
e.addUser(user, false)
}
} | go | func (e *PGPKeyfinder) loadUsers(m libkb.MetaContext) {
if e.runerr != nil {
return
}
for _, u := range e.arg.Usernames {
arg := libkb.NewLoadUserByNameArg(e.G(), u)
user, err := libkb.LoadUser(arg)
if err != nil {
e.runerr = err
return
}
e.addUser(user, false)
}
} | [
"func",
"(",
"e",
"*",
"PGPKeyfinder",
")",
"loadUsers",
"(",
"m",
"libkb",
".",
"MetaContext",
")",
"{",
"if",
"e",
".",
"runerr",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"u",
":=",
"range",
"e",
".",
"arg",
".",
"Usernames",
"{",
"arg",
":=",
"libkb",
".",
"NewLoadUserByNameArg",
"(",
"e",
".",
"G",
"(",
")",
",",
"u",
")",
"\n",
"user",
",",
"err",
":=",
"libkb",
".",
"LoadUser",
"(",
"arg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"e",
".",
"runerr",
"=",
"err",
"\n",
"return",
"\n",
"}",
"\n",
"e",
".",
"addUser",
"(",
"user",
",",
"false",
")",
"\n",
"}",
"\n\n",
"}"
] | // don't identify or track, just load the users | [
"don",
"t",
"identify",
"or",
"track",
"just",
"load",
"the",
"users"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/pgp_keyfinder.go#L65-L80 |
161,528 | keybase/client | go/engine/untrack.go | NewUntrackEngine | func NewUntrackEngine(g *libkb.GlobalContext, arg *UntrackEngineArg) *UntrackEngine {
if libkb.SigVersion(arg.SigVersion) == libkb.KeybaseNullSigVersion {
arg.SigVersion = libkb.GetDefaultSigVersion(g)
}
return &UntrackEngine{
arg: arg,
Contextified: libkb.NewContextified(g),
}
} | go | func NewUntrackEngine(g *libkb.GlobalContext, arg *UntrackEngineArg) *UntrackEngine {
if libkb.SigVersion(arg.SigVersion) == libkb.KeybaseNullSigVersion {
arg.SigVersion = libkb.GetDefaultSigVersion(g)
}
return &UntrackEngine{
arg: arg,
Contextified: libkb.NewContextified(g),
}
} | [
"func",
"NewUntrackEngine",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"arg",
"*",
"UntrackEngineArg",
")",
"*",
"UntrackEngine",
"{",
"if",
"libkb",
".",
"SigVersion",
"(",
"arg",
".",
"SigVersion",
")",
"==",
"libkb",
".",
"KeybaseNullSigVersion",
"{",
"arg",
".",
"SigVersion",
"=",
"libkb",
".",
"GetDefaultSigVersion",
"(",
"g",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"UntrackEngine",
"{",
"arg",
":",
"arg",
",",
"Contextified",
":",
"libkb",
".",
"NewContextified",
"(",
"g",
")",
",",
"}",
"\n",
"}"
] | // NewUntrackEngine creates a default UntrackEngine for tracking theirName. | [
"NewUntrackEngine",
"creates",
"a",
"default",
"UntrackEngine",
"for",
"tracking",
"theirName",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/untrack.go#L26-L35 |
161,529 | keybase/client | go/teams/audit.go | NewAuditor | func NewAuditor(g *libkb.GlobalContext) *Auditor {
ret := &Auditor{}
ret.newLRU(libkb.NewMetaContextBackground(g))
return ret
} | go | func NewAuditor(g *libkb.GlobalContext) *Auditor {
ret := &Auditor{}
ret.newLRU(libkb.NewMetaContextBackground(g))
return ret
} | [
"func",
"NewAuditor",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
")",
"*",
"Auditor",
"{",
"ret",
":=",
"&",
"Auditor",
"{",
"}",
"\n",
"ret",
".",
"newLRU",
"(",
"libkb",
".",
"NewMetaContextBackground",
"(",
"g",
")",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // NewAuditor makes a new auditor | [
"NewAuditor",
"makes",
"a",
"new",
"auditor"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/audit.go#L85-L89 |
161,530 | keybase/client | go/teams/audit.go | NewAuditorAndInstall | func NewAuditorAndInstall(g *libkb.GlobalContext) {
if g.GetEnv().GetDisableTeamAuditor() {
g.Log.CDebugf(context.TODO(), "Using dummy auditor, audit disabled")
g.SetTeamAuditor(dummyAuditor{})
} else {
a := NewAuditor(g)
g.SetTeamAuditor(a)
g.AddLogoutHook(a, "team auditor")
g.AddDbNukeHook(a, "team auditor")
}
} | go | func NewAuditorAndInstall(g *libkb.GlobalContext) {
if g.GetEnv().GetDisableTeamAuditor() {
g.Log.CDebugf(context.TODO(), "Using dummy auditor, audit disabled")
g.SetTeamAuditor(dummyAuditor{})
} else {
a := NewAuditor(g)
g.SetTeamAuditor(a)
g.AddLogoutHook(a, "team auditor")
g.AddDbNukeHook(a, "team auditor")
}
} | [
"func",
"NewAuditorAndInstall",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
")",
"{",
"if",
"g",
".",
"GetEnv",
"(",
")",
".",
"GetDisableTeamAuditor",
"(",
")",
"{",
"g",
".",
"Log",
".",
"CDebugf",
"(",
"context",
".",
"TODO",
"(",
")",
",",
"\"",
"\"",
")",
"\n",
"g",
".",
"SetTeamAuditor",
"(",
"dummyAuditor",
"{",
"}",
")",
"\n",
"}",
"else",
"{",
"a",
":=",
"NewAuditor",
"(",
"g",
")",
"\n",
"g",
".",
"SetTeamAuditor",
"(",
"a",
")",
"\n",
"g",
".",
"AddLogoutHook",
"(",
"a",
",",
"\"",
"\"",
")",
"\n",
"g",
".",
"AddDbNukeHook",
"(",
"a",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}"
] | // NewAuditorAndInstall makes a new Auditor and dangles it
// off of the given GlobalContext. | [
"NewAuditorAndInstall",
"makes",
"a",
"new",
"Auditor",
"and",
"dangles",
"it",
"off",
"of",
"the",
"given",
"GlobalContext",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/audit.go#L93-L103 |
161,531 | keybase/client | go/teams/audit.go | doPreProbes | func (a *Auditor) doPreProbes(m libkb.MetaContext, history *keybase1.AuditHistory, probeID int, headMerkleSeqno keybase1.Seqno) (numProbes int, err error) {
defer m.Trace("Auditor#doPreProbes", func() error { return err })()
first := m.G().MerkleClient.FirstSeqnoWithSkips(m)
if first == nil {
return 0, NewAuditError("cannot find a first modern merkle sequence")
}
probeTuples, err := a.computeProbes(m, history.ID, history.PreProbes, probeID, *first, headMerkleSeqno, len(history.PreProbes), getAuditParams(m).NumPreProbes)
if err != nil {
return 0, err
}
if len(probeTuples) == 0 {
m.Debug("No probe pairs, so bailing")
return 0, nil
}
for _, tuple := range probeTuples {
m.Debug("preProbe: checking probe at merkle %d", tuple.merkle)
if tuple.team != keybase1.Seqno(0) || !tuple.linkID.IsNil() {
return 0, NewAuditError("merkle root at %v should have been nil for %v; got %s/%d",
tuple.merkle, history.ID, tuple.linkID, tuple.team)
}
}
return len(probeTuples), nil
} | go | func (a *Auditor) doPreProbes(m libkb.MetaContext, history *keybase1.AuditHistory, probeID int, headMerkleSeqno keybase1.Seqno) (numProbes int, err error) {
defer m.Trace("Auditor#doPreProbes", func() error { return err })()
first := m.G().MerkleClient.FirstSeqnoWithSkips(m)
if first == nil {
return 0, NewAuditError("cannot find a first modern merkle sequence")
}
probeTuples, err := a.computeProbes(m, history.ID, history.PreProbes, probeID, *first, headMerkleSeqno, len(history.PreProbes), getAuditParams(m).NumPreProbes)
if err != nil {
return 0, err
}
if len(probeTuples) == 0 {
m.Debug("No probe pairs, so bailing")
return 0, nil
}
for _, tuple := range probeTuples {
m.Debug("preProbe: checking probe at merkle %d", tuple.merkle)
if tuple.team != keybase1.Seqno(0) || !tuple.linkID.IsNil() {
return 0, NewAuditError("merkle root at %v should have been nil for %v; got %s/%d",
tuple.merkle, history.ID, tuple.linkID, tuple.team)
}
}
return len(probeTuples), nil
} | [
"func",
"(",
"a",
"*",
"Auditor",
")",
"doPreProbes",
"(",
"m",
"libkb",
".",
"MetaContext",
",",
"history",
"*",
"keybase1",
".",
"AuditHistory",
",",
"probeID",
"int",
",",
"headMerkleSeqno",
"keybase1",
".",
"Seqno",
")",
"(",
"numProbes",
"int",
",",
"err",
"error",
")",
"{",
"defer",
"m",
".",
"Trace",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
")",
"(",
")",
"\n\n",
"first",
":=",
"m",
".",
"G",
"(",
")",
".",
"MerkleClient",
".",
"FirstSeqnoWithSkips",
"(",
"m",
")",
"\n",
"if",
"first",
"==",
"nil",
"{",
"return",
"0",
",",
"NewAuditError",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"probeTuples",
",",
"err",
":=",
"a",
".",
"computeProbes",
"(",
"m",
",",
"history",
".",
"ID",
",",
"history",
".",
"PreProbes",
",",
"probeID",
",",
"*",
"first",
",",
"headMerkleSeqno",
",",
"len",
"(",
"history",
".",
"PreProbes",
")",
",",
"getAuditParams",
"(",
"m",
")",
".",
"NumPreProbes",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n",
"if",
"len",
"(",
"probeTuples",
")",
"==",
"0",
"{",
"m",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"return",
"0",
",",
"nil",
"\n",
"}",
"\n",
"for",
"_",
",",
"tuple",
":=",
"range",
"probeTuples",
"{",
"m",
".",
"Debug",
"(",
"\"",
"\"",
",",
"tuple",
".",
"merkle",
")",
"\n",
"if",
"tuple",
".",
"team",
"!=",
"keybase1",
".",
"Seqno",
"(",
"0",
")",
"||",
"!",
"tuple",
".",
"linkID",
".",
"IsNil",
"(",
")",
"{",
"return",
"0",
",",
"NewAuditError",
"(",
"\"",
"\"",
",",
"tuple",
".",
"merkle",
",",
"history",
".",
"ID",
",",
"tuple",
".",
"linkID",
",",
"tuple",
".",
"team",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"len",
"(",
"probeTuples",
")",
",",
"nil",
"\n",
"}"
] | // doPreProbes probabilistically checks that no team occupied the slot before the team
// in question was created. It selects probes from before the team was created. Each
// probed leaf must not be occupied. | [
"doPreProbes",
"probabilistically",
"checks",
"that",
"no",
"team",
"occupied",
"the",
"slot",
"before",
"the",
"team",
"in",
"question",
"was",
"created",
".",
"It",
"selects",
"probes",
"from",
"before",
"the",
"team",
"was",
"created",
".",
"Each",
"probed",
"leaf",
"must",
"not",
"be",
"occupied",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/audit.go#L322-L346 |
161,532 | keybase/client | go/kbfs/idutil/session.go | GetCurrentSessionIfPossible | func GetCurrentSessionIfPossible(
ctx context.Context, kbpki CurrentSessionGetter, sessionNotRequired bool) (
SessionInfo, error) {
session, err := kbpki.GetCurrentSession(ctx)
if err == nil {
return session, nil
}
// Return all errors if a session is required.
if !sessionNotRequired {
return SessionInfo{}, err
}
// If not logged in, return empty session.
if _, notLoggedIn := err.(NoCurrentSessionError); notLoggedIn {
return SessionInfo{}, nil
}
// Otherwise, just return the error.
return SessionInfo{}, err
} | go | func GetCurrentSessionIfPossible(
ctx context.Context, kbpki CurrentSessionGetter, sessionNotRequired bool) (
SessionInfo, error) {
session, err := kbpki.GetCurrentSession(ctx)
if err == nil {
return session, nil
}
// Return all errors if a session is required.
if !sessionNotRequired {
return SessionInfo{}, err
}
// If not logged in, return empty session.
if _, notLoggedIn := err.(NoCurrentSessionError); notLoggedIn {
return SessionInfo{}, nil
}
// Otherwise, just return the error.
return SessionInfo{}, err
} | [
"func",
"GetCurrentSessionIfPossible",
"(",
"ctx",
"context",
".",
"Context",
",",
"kbpki",
"CurrentSessionGetter",
",",
"sessionNotRequired",
"bool",
")",
"(",
"SessionInfo",
",",
"error",
")",
"{",
"session",
",",
"err",
":=",
"kbpki",
".",
"GetCurrentSession",
"(",
"ctx",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"return",
"session",
",",
"nil",
"\n",
"}",
"\n",
"// Return all errors if a session is required.",
"if",
"!",
"sessionNotRequired",
"{",
"return",
"SessionInfo",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"// If not logged in, return empty session.",
"if",
"_",
",",
"notLoggedIn",
":=",
"err",
".",
"(",
"NoCurrentSessionError",
")",
";",
"notLoggedIn",
"{",
"return",
"SessionInfo",
"{",
"}",
",",
"nil",
"\n",
"}",
"\n\n",
"// Otherwise, just return the error.",
"return",
"SessionInfo",
"{",
"}",
",",
"err",
"\n",
"}"
] | // GetCurrentSessionIfPossible returns the current username and UID
// from kbpki.GetCurrentSession. If sessionNotRequired is true
// NoCurrentSessionError is ignored and empty username and uid will be
// returned. If it is false all errors are returned. | [
"GetCurrentSessionIfPossible",
"returns",
"the",
"current",
"username",
"and",
"UID",
"from",
"kbpki",
".",
"GetCurrentSession",
".",
"If",
"sessionNotRequired",
"is",
"true",
"NoCurrentSessionError",
"is",
"ignored",
"and",
"empty",
"username",
"and",
"uid",
"will",
"be",
"returned",
".",
"If",
"it",
"is",
"false",
"all",
"errors",
"are",
"returned",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/session.go#L20-L39 |
161,533 | keybase/client | go/kbfs/idutil/session.go | SessionInfoFromProtocol | func SessionInfoFromProtocol(session keybase1.Session) (SessionInfo, error) {
// Import the KIDs to validate them.
deviceSubkey, err := libkb.ImportKeypairFromKID(session.DeviceSubkeyKid)
if err != nil {
return SessionInfo{}, err
}
deviceSibkey, err := libkb.ImportKeypairFromKID(session.DeviceSibkeyKid)
if err != nil {
return SessionInfo{}, err
}
cryptPublicKey := kbfscrypto.MakeCryptPublicKey(deviceSubkey.GetKID())
verifyingKey := kbfscrypto.MakeVerifyingKey(deviceSibkey.GetKID())
return SessionInfo{
Name: kbname.NewNormalizedUsername(session.Username),
UID: keybase1.UID(session.Uid),
CryptPublicKey: cryptPublicKey,
VerifyingKey: verifyingKey,
}, nil
} | go | func SessionInfoFromProtocol(session keybase1.Session) (SessionInfo, error) {
// Import the KIDs to validate them.
deviceSubkey, err := libkb.ImportKeypairFromKID(session.DeviceSubkeyKid)
if err != nil {
return SessionInfo{}, err
}
deviceSibkey, err := libkb.ImportKeypairFromKID(session.DeviceSibkeyKid)
if err != nil {
return SessionInfo{}, err
}
cryptPublicKey := kbfscrypto.MakeCryptPublicKey(deviceSubkey.GetKID())
verifyingKey := kbfscrypto.MakeVerifyingKey(deviceSibkey.GetKID())
return SessionInfo{
Name: kbname.NewNormalizedUsername(session.Username),
UID: keybase1.UID(session.Uid),
CryptPublicKey: cryptPublicKey,
VerifyingKey: verifyingKey,
}, nil
} | [
"func",
"SessionInfoFromProtocol",
"(",
"session",
"keybase1",
".",
"Session",
")",
"(",
"SessionInfo",
",",
"error",
")",
"{",
"// Import the KIDs to validate them.",
"deviceSubkey",
",",
"err",
":=",
"libkb",
".",
"ImportKeypairFromKID",
"(",
"session",
".",
"DeviceSubkeyKid",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"SessionInfo",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"deviceSibkey",
",",
"err",
":=",
"libkb",
".",
"ImportKeypairFromKID",
"(",
"session",
".",
"DeviceSibkeyKid",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"SessionInfo",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"cryptPublicKey",
":=",
"kbfscrypto",
".",
"MakeCryptPublicKey",
"(",
"deviceSubkey",
".",
"GetKID",
"(",
")",
")",
"\n",
"verifyingKey",
":=",
"kbfscrypto",
".",
"MakeVerifyingKey",
"(",
"deviceSibkey",
".",
"GetKID",
"(",
")",
")",
"\n",
"return",
"SessionInfo",
"{",
"Name",
":",
"kbname",
".",
"NewNormalizedUsername",
"(",
"session",
".",
"Username",
")",
",",
"UID",
":",
"keybase1",
".",
"UID",
"(",
"session",
".",
"Uid",
")",
",",
"CryptPublicKey",
":",
"cryptPublicKey",
",",
"VerifyingKey",
":",
"verifyingKey",
",",
"}",
",",
"nil",
"\n",
"}"
] | // SessionInfoFromProtocol returns SessionInfo from Session | [
"SessionInfoFromProtocol",
"returns",
"SessionInfo",
"from",
"Session"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/session.go#L42-L60 |
161,534 | keybase/client | go/kbfs/cache/measurable.go | Size | func (m memoizedMeasurable) Size() int {
if m.size <= 0 {
m.size = m.m.Size()
}
return m.size
} | go | func (m memoizedMeasurable) Size() int {
if m.size <= 0 {
m.size = m.m.Size()
}
return m.size
} | [
"func",
"(",
"m",
"memoizedMeasurable",
")",
"Size",
"(",
")",
"int",
"{",
"if",
"m",
".",
"size",
"<=",
"0",
"{",
"m",
".",
"size",
"=",
"m",
".",
"m",
".",
"Size",
"(",
")",
"\n",
"}",
"\n",
"return",
"m",
".",
"size",
"\n",
"}"
] | // Size implements the Measurable interface. | [
"Size",
"implements",
"the",
"Measurable",
"interface",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/cache/measurable.go#L26-L31 |
161,535 | keybase/client | go/engine/login.go | NewLogin | func NewLogin(g *libkb.GlobalContext, deviceType string, username string, ct keybase1.ClientType) *Login {
return NewLoginWithUserSwitch(g, deviceType, username, ct, false)
} | go | func NewLogin(g *libkb.GlobalContext, deviceType string, username string, ct keybase1.ClientType) *Login {
return NewLoginWithUserSwitch(g, deviceType, username, ct, false)
} | [
"func",
"NewLogin",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"deviceType",
"string",
",",
"username",
"string",
",",
"ct",
"keybase1",
".",
"ClientType",
")",
"*",
"Login",
"{",
"return",
"NewLoginWithUserSwitch",
"(",
"g",
",",
"deviceType",
",",
"username",
",",
"ct",
",",
"false",
")",
"\n",
"}"
] | // NewLogin creates a Login engine. username is optional.
// deviceType should be libkb.DeviceTypeDesktop or
// libkb.DeviceTypeMobile. | [
"NewLogin",
"creates",
"a",
"Login",
"engine",
".",
"username",
"is",
"optional",
".",
"deviceType",
"should",
"be",
"libkb",
".",
"DeviceTypeDesktop",
"or",
"libkb",
".",
"DeviceTypeMobile",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/login.go#L37-L39 |
161,536 | keybase/client | go/engine/login.go | notProvisionedErr | func (e *Login) notProvisionedErr(m libkb.MetaContext, err error) bool {
if err == errNoDevice {
return true
}
if err == errNoConfig {
return true
}
m.Debug("notProvisioned, not handling error %s (err type: %T)", err, err)
return false
} | go | func (e *Login) notProvisionedErr(m libkb.MetaContext, err error) bool {
if err == errNoDevice {
return true
}
if err == errNoConfig {
return true
}
m.Debug("notProvisioned, not handling error %s (err type: %T)", err, err)
return false
} | [
"func",
"(",
"e",
"*",
"Login",
")",
"notProvisionedErr",
"(",
"m",
"libkb",
".",
"MetaContext",
",",
"err",
"error",
")",
"bool",
"{",
"if",
"err",
"==",
"errNoDevice",
"{",
"return",
"true",
"\n",
"}",
"\n",
"if",
"err",
"==",
"errNoConfig",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"m",
".",
"Debug",
"(",
"\"",
"\"",
",",
"err",
",",
"err",
")",
"\n",
"return",
"false",
"\n",
"}"
] | // notProvisionedErr will return true if err signifies that login
// failed because this device has not yet been provisioned. | [
"notProvisionedErr",
"will",
"return",
"true",
"if",
"err",
"signifies",
"that",
"login",
"failed",
"because",
"this",
"device",
"has",
"not",
"yet",
"been",
"provisioned",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/login.go#L203-L213 |
161,537 | keybase/client | go/kbfs/cache/cache.go | NewRandomEvictedCache | func NewRandomEvictedCache(maxBytes int) Cache {
return &randomEvictedCache{
maxBytes: maxBytes,
data: make(map[Measurable]memoizedMeasurable),
}
} | go | func NewRandomEvictedCache(maxBytes int) Cache {
return &randomEvictedCache{
maxBytes: maxBytes,
data: make(map[Measurable]memoizedMeasurable),
}
} | [
"func",
"NewRandomEvictedCache",
"(",
"maxBytes",
"int",
")",
"Cache",
"{",
"return",
"&",
"randomEvictedCache",
"{",
"maxBytes",
":",
"maxBytes",
",",
"data",
":",
"make",
"(",
"map",
"[",
"Measurable",
"]",
"memoizedMeasurable",
")",
",",
"}",
"\n",
"}"
] | // NewRandomEvictedCache returns a Cache that uses random eviction strategy.
// The cache will have a capacity of maxBytes bytes. A zero-byte capacity cache
// is valid.
//
// Internally we store a memoizing wrapper for the raw Measurable to avoid
// unnecessarily frequent size calculations.
//
// Note that memoizing size means once the entry is in the cache, we never
// bother recalculating their size. It's fine if the size changes, but the
// cache eviction will continue using the old size. | [
"NewRandomEvictedCache",
"returns",
"a",
"Cache",
"that",
"uses",
"random",
"eviction",
"strategy",
".",
"The",
"cache",
"will",
"have",
"a",
"capacity",
"of",
"maxBytes",
"bytes",
".",
"A",
"zero",
"-",
"byte",
"capacity",
"cache",
"is",
"valid",
".",
"Internally",
"we",
"store",
"a",
"memoizing",
"wrapper",
"for",
"the",
"raw",
"Measurable",
"to",
"avoid",
"unnecessarily",
"frequent",
"size",
"calculations",
".",
"Note",
"that",
"memoizing",
"size",
"means",
"once",
"the",
"entry",
"is",
"in",
"the",
"cache",
"we",
"never",
"bother",
"recalculating",
"their",
"size",
".",
"It",
"s",
"fine",
"if",
"the",
"size",
"changes",
"but",
"the",
"cache",
"eviction",
"will",
"continue",
"using",
"the",
"old",
"size",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/cache/cache.go#L44-L49 |
161,538 | keybase/client | go/kbfs/cache/cache.go | NewLRUEvictedCache | func NewLRUEvictedCache(maxBytes int) Cache {
c := &lruEvictedCache{
maxBytes: maxBytes,
}
c.data = &lru.Cache{
OnEvicted: func(key lru.Key, value interface{}) {
// No locking is needed in this function because we do them in
// public methods Get/Add, and RemoveOldest() is only called in the
// Add method.
if memoized, ok := value.(memoizedMeasurable); ok {
if k, ok := key.(Measurable); ok {
c.cachedBytes -= k.Size() + memoized.Size()
}
}
},
}
return c
} | go | func NewLRUEvictedCache(maxBytes int) Cache {
c := &lruEvictedCache{
maxBytes: maxBytes,
}
c.data = &lru.Cache{
OnEvicted: func(key lru.Key, value interface{}) {
// No locking is needed in this function because we do them in
// public methods Get/Add, and RemoveOldest() is only called in the
// Add method.
if memoized, ok := value.(memoizedMeasurable); ok {
if k, ok := key.(Measurable); ok {
c.cachedBytes -= k.Size() + memoized.Size()
}
}
},
}
return c
} | [
"func",
"NewLRUEvictedCache",
"(",
"maxBytes",
"int",
")",
"Cache",
"{",
"c",
":=",
"&",
"lruEvictedCache",
"{",
"maxBytes",
":",
"maxBytes",
",",
"}",
"\n",
"c",
".",
"data",
"=",
"&",
"lru",
".",
"Cache",
"{",
"OnEvicted",
":",
"func",
"(",
"key",
"lru",
".",
"Key",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"// No locking is needed in this function because we do them in",
"// public methods Get/Add, and RemoveOldest() is only called in the",
"// Add method.",
"if",
"memoized",
",",
"ok",
":=",
"value",
".",
"(",
"memoizedMeasurable",
")",
";",
"ok",
"{",
"if",
"k",
",",
"ok",
":=",
"key",
".",
"(",
"Measurable",
")",
";",
"ok",
"{",
"c",
".",
"cachedBytes",
"-=",
"k",
".",
"Size",
"(",
")",
"+",
"memoized",
".",
"Size",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
",",
"}",
"\n",
"return",
"c",
"\n",
"}"
] | // NewLRUEvictedCache returns a Cache that uses LRU eviction strategy.
// The cache will have a capacity of maxBytes bytes. A zero-byte capacity cache
// is valid.
//
// Internally we store a memoizing wrapper for the raw Measurable to avoid
// unnecessarily frequent size calculations.
//
// Note that this means once the entry is in the cache, we never bother
// recalculating their size. It's fine if the size changes, but the cache
// eviction will continue using the old size. | [
"NewLRUEvictedCache",
"returns",
"a",
"Cache",
"that",
"uses",
"LRU",
"eviction",
"strategy",
".",
"The",
"cache",
"will",
"have",
"a",
"capacity",
"of",
"maxBytes",
"bytes",
".",
"A",
"zero",
"-",
"byte",
"capacity",
"cache",
"is",
"valid",
".",
"Internally",
"we",
"store",
"a",
"memoizing",
"wrapper",
"for",
"the",
"raw",
"Measurable",
"to",
"avoid",
"unnecessarily",
"frequent",
"size",
"calculations",
".",
"Note",
"that",
"this",
"means",
"once",
"the",
"entry",
"is",
"in",
"the",
"cache",
"we",
"never",
"bother",
"recalculating",
"their",
"size",
".",
"It",
"s",
"fine",
"if",
"the",
"size",
"changes",
"but",
"the",
"cache",
"eviction",
"will",
"continue",
"using",
"the",
"old",
"size",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/cache/cache.go#L121-L138 |
161,539 | keybase/client | go/kbfs/libfuse/archive_reltime_file.go | NewArchiveRelTimeFile | func NewArchiveRelTimeFile(
fs *FS, handle *tlfhandle.Handle, filename string,
entryValid *time.Duration) *SpecialReadFile {
*entryValid = 0
return &SpecialReadFile{
read: func(ctx context.Context) ([]byte, time.Time, error) {
data, isRel, err := libfs.FileDataFromRelativeTimeString(
ctx, fs.config, handle, filename)
if err != nil {
return nil, time.Time{}, err
}
if !isRel {
panic("ArchiveRelTimeFile should only be used with " +
"reltime file names")
}
return data, time.Time{}, nil
},
}
} | go | func NewArchiveRelTimeFile(
fs *FS, handle *tlfhandle.Handle, filename string,
entryValid *time.Duration) *SpecialReadFile {
*entryValid = 0
return &SpecialReadFile{
read: func(ctx context.Context) ([]byte, time.Time, error) {
data, isRel, err := libfs.FileDataFromRelativeTimeString(
ctx, fs.config, handle, filename)
if err != nil {
return nil, time.Time{}, err
}
if !isRel {
panic("ArchiveRelTimeFile should only be used with " +
"reltime file names")
}
return data, time.Time{}, nil
},
}
} | [
"func",
"NewArchiveRelTimeFile",
"(",
"fs",
"*",
"FS",
",",
"handle",
"*",
"tlfhandle",
".",
"Handle",
",",
"filename",
"string",
",",
"entryValid",
"*",
"time",
".",
"Duration",
")",
"*",
"SpecialReadFile",
"{",
"*",
"entryValid",
"=",
"0",
"\n",
"return",
"&",
"SpecialReadFile",
"{",
"read",
":",
"func",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"byte",
",",
"time",
".",
"Time",
",",
"error",
")",
"{",
"data",
",",
"isRel",
",",
"err",
":=",
"libfs",
".",
"FileDataFromRelativeTimeString",
"(",
"ctx",
",",
"fs",
".",
"config",
",",
"handle",
",",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"time",
".",
"Time",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"if",
"!",
"isRel",
"{",
"panic",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"data",
",",
"time",
".",
"Time",
"{",
"}",
",",
"nil",
"\n",
"}",
",",
"}",
"\n",
"}"
] | // NewArchiveRelTimeFile returns a special read file that contains a
// by-revision directory name that corresponds to the given relative
// time string for the given folder. | [
"NewArchiveRelTimeFile",
"returns",
"a",
"special",
"read",
"file",
"that",
"contains",
"a",
"by",
"-",
"revision",
"directory",
"name",
"that",
"corresponds",
"to",
"the",
"given",
"relative",
"time",
"string",
"for",
"the",
"given",
"folder",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/archive_reltime_file.go#L20-L38 |
161,540 | keybase/client | go/service/log_queue.go | setDropFlag | func (q *logQueue) setDropFlag() {
select {
case q.drop <- true:
// do this outside the logging mechanism to make sure it gets through
fmt.Fprintf(os.Stderr, "WARNING: dropping log messages destined for %q due to full log buffer\n", q.name)
default:
}
} | go | func (q *logQueue) setDropFlag() {
select {
case q.drop <- true:
// do this outside the logging mechanism to make sure it gets through
fmt.Fprintf(os.Stderr, "WARNING: dropping log messages destined for %q due to full log buffer\n", q.name)
default:
}
} | [
"func",
"(",
"q",
"*",
"logQueue",
")",
"setDropFlag",
"(",
")",
"{",
"select",
"{",
"case",
"q",
".",
"drop",
"<-",
"true",
":",
"// do this outside the logging mechanism to make sure it gets through",
"fmt",
".",
"Fprintf",
"(",
"os",
".",
"Stderr",
",",
"\"",
"\\n",
"\"",
",",
"q",
".",
"name",
")",
"\n",
"default",
":",
"}",
"\n",
"}"
] | // setDropFlag puts a flag into the drop channel if the channel is
// empty. This is to signal that external log messages have been
// dropped. | [
"setDropFlag",
"puts",
"a",
"flag",
"into",
"the",
"drop",
"channel",
"if",
"the",
"channel",
"is",
"empty",
".",
"This",
"is",
"to",
"signal",
"that",
"external",
"log",
"messages",
"have",
"been",
"dropped",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/log_queue.go#L77-L84 |
161,541 | keybase/client | go/service/log_queue.go | checkDropFlag | func (q *logQueue) checkDropFlag() {
select {
case <-q.drop:
q.buffer <- &logEntry{
level: keybase1.LogLevel_WARN,
format: "Service log messages were dropped due to full buffer",
}
default:
}
} | go | func (q *logQueue) checkDropFlag() {
select {
case <-q.drop:
q.buffer <- &logEntry{
level: keybase1.LogLevel_WARN,
format: "Service log messages were dropped due to full buffer",
}
default:
}
} | [
"func",
"(",
"q",
"*",
"logQueue",
")",
"checkDropFlag",
"(",
")",
"{",
"select",
"{",
"case",
"<-",
"q",
".",
"drop",
":",
"q",
".",
"buffer",
"<-",
"&",
"logEntry",
"{",
"level",
":",
"keybase1",
".",
"LogLevel_WARN",
",",
"format",
":",
"\"",
"\"",
",",
"}",
"\n",
"default",
":",
"}",
"\n",
"}"
] | // checkDropFlag checks to see if anything is in the drop channel.
// If there is a flag in there, it will warn client that log
// messages were dropped. | [
"checkDropFlag",
"checks",
"to",
"see",
"if",
"anything",
"is",
"in",
"the",
"drop",
"channel",
".",
"If",
"there",
"is",
"a",
"flag",
"in",
"there",
"it",
"will",
"warn",
"client",
"that",
"log",
"messages",
"were",
"dropped",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/log_queue.go#L89-L98 |
161,542 | keybase/client | go/chat/inboxsource.go | getConvsLocal | func (s *HybridInboxSource) getConvsLocal(ctx context.Context, uid gregor1.UID,
convIDs []chat1.ConversationID) ([]chat1.ConversationLocal, error) {
// Read back affected conversation so we can send it to the frontend
ib, _, err := s.Read(ctx, uid, types.ConversationLocalizerBlocking, types.InboxSourceDataSourceAll, nil,
&chat1.GetInboxLocalQuery{
ConvIDs: convIDs,
}, nil)
return ib.Convs, err
} | go | func (s *HybridInboxSource) getConvsLocal(ctx context.Context, uid gregor1.UID,
convIDs []chat1.ConversationID) ([]chat1.ConversationLocal, error) {
// Read back affected conversation so we can send it to the frontend
ib, _, err := s.Read(ctx, uid, types.ConversationLocalizerBlocking, types.InboxSourceDataSourceAll, nil,
&chat1.GetInboxLocalQuery{
ConvIDs: convIDs,
}, nil)
return ib.Convs, err
} | [
"func",
"(",
"s",
"*",
"HybridInboxSource",
")",
"getConvsLocal",
"(",
"ctx",
"context",
".",
"Context",
",",
"uid",
"gregor1",
".",
"UID",
",",
"convIDs",
"[",
"]",
"chat1",
".",
"ConversationID",
")",
"(",
"[",
"]",
"chat1",
".",
"ConversationLocal",
",",
"error",
")",
"{",
"// Read back affected conversation so we can send it to the frontend",
"ib",
",",
"_",
",",
"err",
":=",
"s",
".",
"Read",
"(",
"ctx",
",",
"uid",
",",
"types",
".",
"ConversationLocalizerBlocking",
",",
"types",
".",
"InboxSourceDataSourceAll",
",",
"nil",
",",
"&",
"chat1",
".",
"GetInboxLocalQuery",
"{",
"ConvIDs",
":",
"convIDs",
",",
"}",
",",
"nil",
")",
"\n",
"return",
"ib",
".",
"Convs",
",",
"err",
"\n",
"}"
] | // Get convs. May return fewer or no conversations. | [
"Get",
"convs",
".",
"May",
"return",
"fewer",
"or",
"no",
"conversations",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/inboxsource.go#L905-L913 |
161,543 | keybase/client | go/protocol/keybase1/login.go | GetConfiguredAccounts | func (c LoginClient) GetConfiguredAccounts(ctx context.Context, sessionID int) (res []ConfiguredAccount, err error) {
__arg := GetConfiguredAccountsArg{SessionID: sessionID}
err = c.Cli.Call(ctx, "keybase.1.login.getConfiguredAccounts", []interface{}{__arg}, &res)
return
} | go | func (c LoginClient) GetConfiguredAccounts(ctx context.Context, sessionID int) (res []ConfiguredAccount, err error) {
__arg := GetConfiguredAccountsArg{SessionID: sessionID}
err = c.Cli.Call(ctx, "keybase.1.login.getConfiguredAccounts", []interface{}{__arg}, &res)
return
} | [
"func",
"(",
"c",
"LoginClient",
")",
"GetConfiguredAccounts",
"(",
"ctx",
"context",
".",
"Context",
",",
"sessionID",
"int",
")",
"(",
"res",
"[",
"]",
"ConfiguredAccount",
",",
"err",
"error",
")",
"{",
"__arg",
":=",
"GetConfiguredAccountsArg",
"{",
"SessionID",
":",
"sessionID",
"}",
"\n",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"&",
"res",
")",
"\n",
"return",
"\n",
"}"
] | // Returns an array of information about accounts configured on the local
// machine. Currently configured accounts are defined as those that have stored
// secrets, but this definition may be expanded in the future. | [
"Returns",
"an",
"array",
"of",
"information",
"about",
"accounts",
"configured",
"on",
"the",
"local",
"machine",
".",
"Currently",
"configured",
"accounts",
"are",
"defined",
"as",
"those",
"that",
"have",
"stored",
"secrets",
"but",
"this",
"definition",
"may",
"be",
"expanded",
"in",
"the",
"future",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/login.go#L359-L363 |
161,544 | keybase/client | go/protocol/keybase1/login.go | Login | func (c LoginClient) Login(ctx context.Context, __arg LoginArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.login.login", []interface{}{__arg}, nil)
return
} | go | func (c LoginClient) Login(ctx context.Context, __arg LoginArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.login.login", []interface{}{__arg}, nil)
return
} | [
"func",
"(",
"c",
"LoginClient",
")",
"Login",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"LoginArg",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"nil",
")",
"\n",
"return",
"\n",
"}"
] | // Performs login. deviceType should be libkb.DeviceTypeDesktop
// or libkb.DeviceTypeMobile. username is optional. If the current
// device isn't provisioned, this function will provision it. | [
"Performs",
"login",
".",
"deviceType",
"should",
"be",
"libkb",
".",
"DeviceTypeDesktop",
"or",
"libkb",
".",
"DeviceTypeMobile",
".",
"username",
"is",
"optional",
".",
"If",
"the",
"current",
"device",
"isn",
"t",
"provisioned",
"this",
"function",
"will",
"provision",
"it",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/login.go#L368-L371 |
161,545 | keybase/client | go/protocol/keybase1/login.go | LoginProvisionedDevice | func (c LoginClient) LoginProvisionedDevice(ctx context.Context, __arg LoginProvisionedDeviceArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.login.loginProvisionedDevice", []interface{}{__arg}, nil)
return
} | go | func (c LoginClient) LoginProvisionedDevice(ctx context.Context, __arg LoginProvisionedDeviceArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.login.loginProvisionedDevice", []interface{}{__arg}, nil)
return
} | [
"func",
"(",
"c",
"LoginClient",
")",
"LoginProvisionedDevice",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"LoginProvisionedDeviceArg",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"nil",
")",
"\n",
"return",
"\n",
"}"
] | // Login a user only if the user is on a provisioned device. Username is optional.
// If noPassphrasePrompt is set, then only a stored secret will be used to unlock
// the device keys. | [
"Login",
"a",
"user",
"only",
"if",
"the",
"user",
"is",
"on",
"a",
"provisioned",
"device",
".",
"Username",
"is",
"optional",
".",
"If",
"noPassphrasePrompt",
"is",
"set",
"then",
"only",
"a",
"stored",
"secret",
"will",
"be",
"used",
"to",
"unlock",
"the",
"device",
"keys",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/login.go#L376-L379 |
161,546 | keybase/client | go/protocol/keybase1/login.go | LoginWithPaperKey | func (c LoginClient) LoginWithPaperKey(ctx context.Context, sessionID int) (err error) {
__arg := LoginWithPaperKeyArg{SessionID: sessionID}
err = c.Cli.Call(ctx, "keybase.1.login.loginWithPaperKey", []interface{}{__arg}, nil)
return
} | go | func (c LoginClient) LoginWithPaperKey(ctx context.Context, sessionID int) (err error) {
__arg := LoginWithPaperKeyArg{SessionID: sessionID}
err = c.Cli.Call(ctx, "keybase.1.login.loginWithPaperKey", []interface{}{__arg}, nil)
return
} | [
"func",
"(",
"c",
"LoginClient",
")",
"LoginWithPaperKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"sessionID",
"int",
")",
"(",
"err",
"error",
")",
"{",
"__arg",
":=",
"LoginWithPaperKeyArg",
"{",
"SessionID",
":",
"sessionID",
"}",
"\n",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"nil",
")",
"\n",
"return",
"\n",
"}"
] | // Login and unlock by
// - trying unlocked device keys if available
// - prompting for a paper key and using that | [
"Login",
"and",
"unlock",
"by",
"-",
"trying",
"unlocked",
"device",
"keys",
"if",
"available",
"-",
"prompting",
"for",
"a",
"paper",
"key",
"and",
"using",
"that"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/login.go#L384-L388 |
161,547 | keybase/client | go/protocol/keybase1/login.go | PaperKey | func (c LoginClient) PaperKey(ctx context.Context, sessionID int) (err error) {
__arg := PaperKeyArg{SessionID: sessionID}
err = c.Cli.Call(ctx, "keybase.1.login.paperKey", []interface{}{__arg}, nil)
return
} | go | func (c LoginClient) PaperKey(ctx context.Context, sessionID int) (err error) {
__arg := PaperKeyArg{SessionID: sessionID}
err = c.Cli.Call(ctx, "keybase.1.login.paperKey", []interface{}{__arg}, nil)
return
} | [
"func",
"(",
"c",
"LoginClient",
")",
"PaperKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"sessionID",
"int",
")",
"(",
"err",
"error",
")",
"{",
"__arg",
":=",
"PaperKeyArg",
"{",
"SessionID",
":",
"sessionID",
"}",
"\n",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"nil",
")",
"\n",
"return",
"\n",
"}"
] | // PaperKey generates paper backup keys for restoring an account.
// It calls login_ui.displayPaperKeyPhrase with the phrase. | [
"PaperKey",
"generates",
"paper",
"backup",
"keys",
"for",
"restoring",
"an",
"account",
".",
"It",
"calls",
"login_ui",
".",
"displayPaperKeyPhrase",
"with",
"the",
"phrase",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/login.go#L416-L420 |
161,548 | keybase/client | go/protocol/keybase1/login.go | PaperKeySubmit | func (c LoginClient) PaperKeySubmit(ctx context.Context, __arg PaperKeySubmitArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.login.paperKeySubmit", []interface{}{__arg}, nil)
return
} | go | func (c LoginClient) PaperKeySubmit(ctx context.Context, __arg PaperKeySubmitArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.login.paperKeySubmit", []interface{}{__arg}, nil)
return
} | [
"func",
"(",
"c",
"LoginClient",
")",
"PaperKeySubmit",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"PaperKeySubmitArg",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"nil",
")",
"\n",
"return",
"\n",
"}"
] | // paperKeySubmit checks that paperPhrase is a valid paper key
// for the logged in user, caches the keys, and sends a notification. | [
"paperKeySubmit",
"checks",
"that",
"paperPhrase",
"is",
"a",
"valid",
"paper",
"key",
"for",
"the",
"logged",
"in",
"user",
"caches",
"the",
"keys",
"and",
"sends",
"a",
"notification",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/login.go#L424-L427 |
161,549 | keybase/client | go/protocol/keybase1/login.go | Unlock | func (c LoginClient) Unlock(ctx context.Context, sessionID int) (err error) {
__arg := UnlockArg{SessionID: sessionID}
err = c.Cli.Call(ctx, "keybase.1.login.unlock", []interface{}{__arg}, nil)
return
} | go | func (c LoginClient) Unlock(ctx context.Context, sessionID int) (err error) {
__arg := UnlockArg{SessionID: sessionID}
err = c.Cli.Call(ctx, "keybase.1.login.unlock", []interface{}{__arg}, nil)
return
} | [
"func",
"(",
"c",
"LoginClient",
")",
"Unlock",
"(",
"ctx",
"context",
".",
"Context",
",",
"sessionID",
"int",
")",
"(",
"err",
"error",
")",
"{",
"__arg",
":=",
"UnlockArg",
"{",
"SessionID",
":",
"sessionID",
"}",
"\n",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"nil",
")",
"\n",
"return",
"\n",
"}"
] | // Unlock restores access to local key store by priming passphrase stream cache. | [
"Unlock",
"restores",
"access",
"to",
"local",
"key",
"store",
"by",
"priming",
"passphrase",
"stream",
"cache",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/login.go#L430-L434 |
161,550 | keybase/client | go/protocol/keybase1/login.go | LoginOneshot | func (c LoginClient) LoginOneshot(ctx context.Context, __arg LoginOneshotArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.login.loginOneshot", []interface{}{__arg}, nil)
return
} | go | func (c LoginClient) LoginOneshot(ctx context.Context, __arg LoginOneshotArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.login.loginOneshot", []interface{}{__arg}, nil)
return
} | [
"func",
"(",
"c",
"LoginClient",
")",
"LoginOneshot",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"LoginOneshotArg",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"nil",
")",
"\n",
"return",
"\n",
"}"
] | // loginOneshot allows a service to have a "onetime login", without
// provisioning a device. It bootstraps credentials with the given
// paperkey | [
"loginOneshot",
"allows",
"a",
"service",
"to",
"have",
"a",
"onetime",
"login",
"without",
"provisioning",
"a",
"device",
".",
"It",
"bootstraps",
"credentials",
"with",
"the",
"given",
"paperkey"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/login.go#L451-L454 |
161,551 | keybase/client | go/stellar/options.go | NetworkOptions | func (o *Options) NetworkOptions(mctx libkb.MetaContext, r remote.Remoter) stellar1.NetworkOptions {
o.Lock()
defer o.Unlock()
if time.Since(o.mtime) < 1*time.Hour {
return o.network
}
options, err := r.NetworkOptions(mctx.Ctx())
if err != nil {
mctx.Debug("error calling NetworkOptions: %s", err)
} else {
mctx.Debug("updating NetworkOptions: %+v", options)
o.network = options
o.mtime = time.Now()
}
return o.network
} | go | func (o *Options) NetworkOptions(mctx libkb.MetaContext, r remote.Remoter) stellar1.NetworkOptions {
o.Lock()
defer o.Unlock()
if time.Since(o.mtime) < 1*time.Hour {
return o.network
}
options, err := r.NetworkOptions(mctx.Ctx())
if err != nil {
mctx.Debug("error calling NetworkOptions: %s", err)
} else {
mctx.Debug("updating NetworkOptions: %+v", options)
o.network = options
o.mtime = time.Now()
}
return o.network
} | [
"func",
"(",
"o",
"*",
"Options",
")",
"NetworkOptions",
"(",
"mctx",
"libkb",
".",
"MetaContext",
",",
"r",
"remote",
".",
"Remoter",
")",
"stellar1",
".",
"NetworkOptions",
"{",
"o",
".",
"Lock",
"(",
")",
"\n",
"defer",
"o",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"time",
".",
"Since",
"(",
"o",
".",
"mtime",
")",
"<",
"1",
"*",
"time",
".",
"Hour",
"{",
"return",
"o",
".",
"network",
"\n",
"}",
"\n\n",
"options",
",",
"err",
":=",
"r",
".",
"NetworkOptions",
"(",
"mctx",
".",
"Ctx",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"mctx",
".",
"Debug",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"else",
"{",
"mctx",
".",
"Debug",
"(",
"\"",
"\"",
",",
"options",
")",
"\n",
"o",
".",
"network",
"=",
"options",
"\n",
"o",
".",
"mtime",
"=",
"time",
".",
"Now",
"(",
")",
"\n",
"}",
"\n\n",
"return",
"o",
".",
"network",
"\n",
"}"
] | // NetworkOptions returns stellar1.NetworkOptions that is less than 1 hour old. | [
"NetworkOptions",
"returns",
"stellar1",
".",
"NetworkOptions",
"that",
"is",
"less",
"than",
"1",
"hour",
"old",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/options.go#L26-L44 |
161,552 | keybase/client | go/libkb/stellar.go | ParseStellarSecretKey | func ParseStellarSecretKey(secStr string) (stellar1.SecretKey, stellar1.AccountID, *keypair.Full, error) {
secStr = strings.ToUpper(secStr)
if len(secStr) != 56 {
return "", "", nil, fmt.Errorf("Stellar secret key must be 56 chars long: was %v", len(secStr))
}
_, err := base32.StdEncoding.DecodeString(secStr)
if err != nil {
return "", "", nil, fmt.Errorf("invalid characters in Stellar secret key")
}
kp, err := keypair.Parse(secStr)
if err != nil {
return "", "", nil, fmt.Errorf("invalid Stellar secret key: %v", err)
}
switch kp := kp.(type) {
case *keypair.FromAddress:
return "", "", nil, errors.New("unexpected Stellar account ID, expected secret key")
case *keypair.Full:
return stellar1.SecretKey(kp.Seed()), stellar1.AccountID(kp.Address()), kp, nil
default:
return "", "", nil, fmt.Errorf("invalid Stellar secret key")
}
} | go | func ParseStellarSecretKey(secStr string) (stellar1.SecretKey, stellar1.AccountID, *keypair.Full, error) {
secStr = strings.ToUpper(secStr)
if len(secStr) != 56 {
return "", "", nil, fmt.Errorf("Stellar secret key must be 56 chars long: was %v", len(secStr))
}
_, err := base32.StdEncoding.DecodeString(secStr)
if err != nil {
return "", "", nil, fmt.Errorf("invalid characters in Stellar secret key")
}
kp, err := keypair.Parse(secStr)
if err != nil {
return "", "", nil, fmt.Errorf("invalid Stellar secret key: %v", err)
}
switch kp := kp.(type) {
case *keypair.FromAddress:
return "", "", nil, errors.New("unexpected Stellar account ID, expected secret key")
case *keypair.Full:
return stellar1.SecretKey(kp.Seed()), stellar1.AccountID(kp.Address()), kp, nil
default:
return "", "", nil, fmt.Errorf("invalid Stellar secret key")
}
} | [
"func",
"ParseStellarSecretKey",
"(",
"secStr",
"string",
")",
"(",
"stellar1",
".",
"SecretKey",
",",
"stellar1",
".",
"AccountID",
",",
"*",
"keypair",
".",
"Full",
",",
"error",
")",
"{",
"secStr",
"=",
"strings",
".",
"ToUpper",
"(",
"secStr",
")",
"\n",
"if",
"len",
"(",
"secStr",
")",
"!=",
"56",
"{",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"len",
"(",
"secStr",
")",
")",
"\n",
"}",
"\n",
"_",
",",
"err",
":=",
"base32",
".",
"StdEncoding",
".",
"DecodeString",
"(",
"secStr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"kp",
",",
"err",
":=",
"keypair",
".",
"Parse",
"(",
"secStr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"switch",
"kp",
":=",
"kp",
".",
"(",
"type",
")",
"{",
"case",
"*",
"keypair",
".",
"FromAddress",
":",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"case",
"*",
"keypair",
".",
"Full",
":",
"return",
"stellar1",
".",
"SecretKey",
"(",
"kp",
".",
"Seed",
"(",
")",
")",
",",
"stellar1",
".",
"AccountID",
"(",
"kp",
".",
"Address",
"(",
")",
")",
",",
"kp",
",",
"nil",
"\n",
"default",
":",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}"
] | // ParseStellarSecretKey parses a secret key and returns it and the AccountID it is the master key of.
// Returns helpful error messages than can be shown to users. | [
"ParseStellarSecretKey",
"parses",
"a",
"secret",
"key",
"and",
"returns",
"it",
"and",
"the",
"AccountID",
"it",
"is",
"the",
"master",
"key",
"of",
".",
"Returns",
"helpful",
"error",
"messages",
"than",
"can",
"be",
"shown",
"to",
"users",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/stellar.go#L40-L61 |
161,553 | keybase/client | go/libkb/stellar.go | ParseStellarAccountID | func ParseStellarAccountID(idStr string) (stellar1.AccountID, error) {
idStr = strings.ToUpper(idStr)
if len(idStr) != 56 {
return "", NewInvalidStellarAccountIDError(fmt.Sprintf("Stellar account ID must be 56 chars long: was %v", len(idStr)))
}
_, err := base32.StdEncoding.DecodeString(idStr)
if err != nil {
return "", NewInvalidStellarAccountIDError("invalid characters in Stellar account ID")
}
kp, err := keypair.Parse(idStr)
if err != nil {
return "", NewInvalidStellarAccountIDError(fmt.Sprintf("invalid Stellar account ID key: %s", err))
}
switch kp := kp.(type) {
case *keypair.FromAddress:
return stellar1.AccountID(kp.Address()), nil
case *keypair.Full:
return "", NewInvalidStellarAccountIDError("unexpected Stellar secret key, expected account ID")
default:
return "", NewInvalidStellarAccountIDError("invalid keypair type")
}
} | go | func ParseStellarAccountID(idStr string) (stellar1.AccountID, error) {
idStr = strings.ToUpper(idStr)
if len(idStr) != 56 {
return "", NewInvalidStellarAccountIDError(fmt.Sprintf("Stellar account ID must be 56 chars long: was %v", len(idStr)))
}
_, err := base32.StdEncoding.DecodeString(idStr)
if err != nil {
return "", NewInvalidStellarAccountIDError("invalid characters in Stellar account ID")
}
kp, err := keypair.Parse(idStr)
if err != nil {
return "", NewInvalidStellarAccountIDError(fmt.Sprintf("invalid Stellar account ID key: %s", err))
}
switch kp := kp.(type) {
case *keypair.FromAddress:
return stellar1.AccountID(kp.Address()), nil
case *keypair.Full:
return "", NewInvalidStellarAccountIDError("unexpected Stellar secret key, expected account ID")
default:
return "", NewInvalidStellarAccountIDError("invalid keypair type")
}
} | [
"func",
"ParseStellarAccountID",
"(",
"idStr",
"string",
")",
"(",
"stellar1",
".",
"AccountID",
",",
"error",
")",
"{",
"idStr",
"=",
"strings",
".",
"ToUpper",
"(",
"idStr",
")",
"\n",
"if",
"len",
"(",
"idStr",
")",
"!=",
"56",
"{",
"return",
"\"",
"\"",
",",
"NewInvalidStellarAccountIDError",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"len",
"(",
"idStr",
")",
")",
")",
"\n",
"}",
"\n",
"_",
",",
"err",
":=",
"base32",
".",
"StdEncoding",
".",
"DecodeString",
"(",
"idStr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"NewInvalidStellarAccountIDError",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"kp",
",",
"err",
":=",
"keypair",
".",
"Parse",
"(",
"idStr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"NewInvalidStellarAccountIDError",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"err",
")",
")",
"\n",
"}",
"\n",
"switch",
"kp",
":=",
"kp",
".",
"(",
"type",
")",
"{",
"case",
"*",
"keypair",
".",
"FromAddress",
":",
"return",
"stellar1",
".",
"AccountID",
"(",
"kp",
".",
"Address",
"(",
")",
")",
",",
"nil",
"\n",
"case",
"*",
"keypair",
".",
"Full",
":",
"return",
"\"",
"\"",
",",
"NewInvalidStellarAccountIDError",
"(",
"\"",
"\"",
")",
"\n",
"default",
":",
"return",
"\"",
"\"",
",",
"NewInvalidStellarAccountIDError",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}"
] | // ParseStellarAccountID parses an account ID and returns it.
// Returns helpful error messages than can be shown to users. | [
"ParseStellarAccountID",
"parses",
"an",
"account",
"ID",
"and",
"returns",
"it",
".",
"Returns",
"helpful",
"error",
"messages",
"than",
"can",
"be",
"shown",
"to",
"users",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/stellar.go#L65-L86 |
161,554 | keybase/client | go/keybase/main.go | configureProcesses | func configureProcesses(g *libkb.GlobalContext, cl *libcmdline.CommandLine, cmd *libcmdline.Command) (err error) {
g.Log.Debug("+ configureProcesses")
defer func() {
g.Log.Debug("- configureProcesses -> %v", err)
}()
// On Linux, the service configures its own autostart file. Otherwise, no
// need to configure if we're a service.
if cl.IsService() {
g.Log.Debug("| in configureProcesses, is service")
if runtime.GOOS == "linux" {
g.Log.Debug("| calling AutoInstall for Linux")
_, err := install.AutoInstall(g, "", false, 10*time.Second, g.Log)
if err != nil {
return err
}
}
return nil
}
// Start the server on the other end, possibly.
// There are two cases in which we do this: (1) we want
// a local loopback server in standalone mode; (2) we
// need to "autofork" it. Do at most one of these
// operations.
if g.Env.GetStandalone() {
if cl.IsNoStandalone() {
err = client.CantRunInStandaloneError{}
return err
}
svc := service.NewService(g, false /* isDaemon */)
err = svc.SetupCriticalSubServices()
if err != nil {
return err
}
err = svc.StartLoopbackServer()
if err != nil {
return err
}
// StandaloneChatConnector is an interface with only one
// method: StartStandaloneChat. This way we can pass Service
// object while not exposing anything but that one function.
g.StandaloneChatConnector = svc
g.Standalone = true
if pflerr, ok := err.(libkb.PIDFileLockError); ok {
err = fmt.Errorf("Can't run in standalone mode with a service running (see %q)",
pflerr.Filename)
return err
}
return err
}
// After this point, we need to provide a remote logging story if necessary
// If this command specifically asks not to be forked, then we are done in this
// function. This sort of thing is true for the `ctl` commands and also the `version`
// command.
fc := cl.GetForkCmd()
if fc == libcmdline.NoFork {
return configureLogging(g, cl)
}
var newProc bool
if libkb.IsBrewBuild {
// If we're running in Brew mode, we might need to install ourselves as a persistent
// service for future invocations of the command.
newProc, err = install.AutoInstall(g, "", false, 10*time.Second, g.Log)
if err != nil {
return err
}
} else {
// If this command warrants an autofork, do it now.
if fc == libcmdline.ForceFork || g.Env.GetAutoFork() {
newProc, err = client.AutoForkServer(g, cl)
if err != nil {
return err
}
}
}
// Restart the service if we see that it's out of date. It's important to do this
// before we make any RPCs to the service --- for instance, before the logging
// calls below. See the v1.0.8 update fiasco for more details. Also, only need
// to do this if we didn't just start a new process.
if !newProc {
if err = client.FixVersionClash(g, cl); err != nil {
return err
}
}
// Ignore error
if err = client.WarnOutdatedKBFS(g, cl); err != nil {
g.Log.Debug("| Could not do kbfs versioncheck: %s", err)
}
g.Log.Debug("| After forks; newProc=%v", newProc)
if err = configureLogging(g, cl); err != nil {
return err
}
// This sends the client's PATH to the service so the service can update
// its PATH if necessary. This is called after FixVersionClash(), which
// happens above in configureProcesses().
if err = configurePath(g, cl); err != nil {
// Further note -- don't die here. It could be we're calling this method
// against an earlier version of the service that doesn't support it.
// It's not critical that it succeed, so continue on.
g.Log.Debug("Configure path failed: %v", err)
}
return nil
} | go | func configureProcesses(g *libkb.GlobalContext, cl *libcmdline.CommandLine, cmd *libcmdline.Command) (err error) {
g.Log.Debug("+ configureProcesses")
defer func() {
g.Log.Debug("- configureProcesses -> %v", err)
}()
// On Linux, the service configures its own autostart file. Otherwise, no
// need to configure if we're a service.
if cl.IsService() {
g.Log.Debug("| in configureProcesses, is service")
if runtime.GOOS == "linux" {
g.Log.Debug("| calling AutoInstall for Linux")
_, err := install.AutoInstall(g, "", false, 10*time.Second, g.Log)
if err != nil {
return err
}
}
return nil
}
// Start the server on the other end, possibly.
// There are two cases in which we do this: (1) we want
// a local loopback server in standalone mode; (2) we
// need to "autofork" it. Do at most one of these
// operations.
if g.Env.GetStandalone() {
if cl.IsNoStandalone() {
err = client.CantRunInStandaloneError{}
return err
}
svc := service.NewService(g, false /* isDaemon */)
err = svc.SetupCriticalSubServices()
if err != nil {
return err
}
err = svc.StartLoopbackServer()
if err != nil {
return err
}
// StandaloneChatConnector is an interface with only one
// method: StartStandaloneChat. This way we can pass Service
// object while not exposing anything but that one function.
g.StandaloneChatConnector = svc
g.Standalone = true
if pflerr, ok := err.(libkb.PIDFileLockError); ok {
err = fmt.Errorf("Can't run in standalone mode with a service running (see %q)",
pflerr.Filename)
return err
}
return err
}
// After this point, we need to provide a remote logging story if necessary
// If this command specifically asks not to be forked, then we are done in this
// function. This sort of thing is true for the `ctl` commands and also the `version`
// command.
fc := cl.GetForkCmd()
if fc == libcmdline.NoFork {
return configureLogging(g, cl)
}
var newProc bool
if libkb.IsBrewBuild {
// If we're running in Brew mode, we might need to install ourselves as a persistent
// service for future invocations of the command.
newProc, err = install.AutoInstall(g, "", false, 10*time.Second, g.Log)
if err != nil {
return err
}
} else {
// If this command warrants an autofork, do it now.
if fc == libcmdline.ForceFork || g.Env.GetAutoFork() {
newProc, err = client.AutoForkServer(g, cl)
if err != nil {
return err
}
}
}
// Restart the service if we see that it's out of date. It's important to do this
// before we make any RPCs to the service --- for instance, before the logging
// calls below. See the v1.0.8 update fiasco for more details. Also, only need
// to do this if we didn't just start a new process.
if !newProc {
if err = client.FixVersionClash(g, cl); err != nil {
return err
}
}
// Ignore error
if err = client.WarnOutdatedKBFS(g, cl); err != nil {
g.Log.Debug("| Could not do kbfs versioncheck: %s", err)
}
g.Log.Debug("| After forks; newProc=%v", newProc)
if err = configureLogging(g, cl); err != nil {
return err
}
// This sends the client's PATH to the service so the service can update
// its PATH if necessary. This is called after FixVersionClash(), which
// happens above in configureProcesses().
if err = configurePath(g, cl); err != nil {
// Further note -- don't die here. It could be we're calling this method
// against an earlier version of the service that doesn't support it.
// It's not critical that it succeed, so continue on.
g.Log.Debug("Configure path failed: %v", err)
}
return nil
} | [
"func",
"configureProcesses",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"cl",
"*",
"libcmdline",
".",
"CommandLine",
",",
"cmd",
"*",
"libcmdline",
".",
"Command",
")",
"(",
"err",
"error",
")",
"{",
"g",
".",
"Log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"g",
".",
"Log",
".",
"Debug",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"(",
")",
"\n\n",
"// On Linux, the service configures its own autostart file. Otherwise, no",
"// need to configure if we're a service.",
"if",
"cl",
".",
"IsService",
"(",
")",
"{",
"g",
".",
"Log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"if",
"runtime",
".",
"GOOS",
"==",
"\"",
"\"",
"{",
"g",
".",
"Log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"_",
",",
"err",
":=",
"install",
".",
"AutoInstall",
"(",
"g",
",",
"\"",
"\"",
",",
"false",
",",
"10",
"*",
"time",
".",
"Second",
",",
"g",
".",
"Log",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"// Start the server on the other end, possibly.",
"// There are two cases in which we do this: (1) we want",
"// a local loopback server in standalone mode; (2) we",
"// need to \"autofork\" it. Do at most one of these",
"// operations.",
"if",
"g",
".",
"Env",
".",
"GetStandalone",
"(",
")",
"{",
"if",
"cl",
".",
"IsNoStandalone",
"(",
")",
"{",
"err",
"=",
"client",
".",
"CantRunInStandaloneError",
"{",
"}",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"svc",
":=",
"service",
".",
"NewService",
"(",
"g",
",",
"false",
"/* isDaemon */",
")",
"\n",
"err",
"=",
"svc",
".",
"SetupCriticalSubServices",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"err",
"=",
"svc",
".",
"StartLoopbackServer",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// StandaloneChatConnector is an interface with only one",
"// method: StartStandaloneChat. This way we can pass Service",
"// object while not exposing anything but that one function.",
"g",
".",
"StandaloneChatConnector",
"=",
"svc",
"\n",
"g",
".",
"Standalone",
"=",
"true",
"\n\n",
"if",
"pflerr",
",",
"ok",
":=",
"err",
".",
"(",
"libkb",
".",
"PIDFileLockError",
")",
";",
"ok",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"pflerr",
".",
"Filename",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"// After this point, we need to provide a remote logging story if necessary",
"// If this command specifically asks not to be forked, then we are done in this",
"// function. This sort of thing is true for the `ctl` commands and also the `version`",
"// command.",
"fc",
":=",
"cl",
".",
"GetForkCmd",
"(",
")",
"\n",
"if",
"fc",
"==",
"libcmdline",
".",
"NoFork",
"{",
"return",
"configureLogging",
"(",
"g",
",",
"cl",
")",
"\n",
"}",
"\n\n",
"var",
"newProc",
"bool",
"\n",
"if",
"libkb",
".",
"IsBrewBuild",
"{",
"// If we're running in Brew mode, we might need to install ourselves as a persistent",
"// service for future invocations of the command.",
"newProc",
",",
"err",
"=",
"install",
".",
"AutoInstall",
"(",
"g",
",",
"\"",
"\"",
",",
"false",
",",
"10",
"*",
"time",
".",
"Second",
",",
"g",
".",
"Log",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"else",
"{",
"// If this command warrants an autofork, do it now.",
"if",
"fc",
"==",
"libcmdline",
".",
"ForceFork",
"||",
"g",
".",
"Env",
".",
"GetAutoFork",
"(",
")",
"{",
"newProc",
",",
"err",
"=",
"client",
".",
"AutoForkServer",
"(",
"g",
",",
"cl",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Restart the service if we see that it's out of date. It's important to do this",
"// before we make any RPCs to the service --- for instance, before the logging",
"// calls below. See the v1.0.8 update fiasco for more details. Also, only need",
"// to do this if we didn't just start a new process.",
"if",
"!",
"newProc",
"{",
"if",
"err",
"=",
"client",
".",
"FixVersionClash",
"(",
"g",
",",
"cl",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Ignore error",
"if",
"err",
"=",
"client",
".",
"WarnOutdatedKBFS",
"(",
"g",
",",
"cl",
")",
";",
"err",
"!=",
"nil",
"{",
"g",
".",
"Log",
".",
"Debug",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"g",
".",
"Log",
".",
"Debug",
"(",
"\"",
"\"",
",",
"newProc",
")",
"\n",
"if",
"err",
"=",
"configureLogging",
"(",
"g",
",",
"cl",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// This sends the client's PATH to the service so the service can update",
"// its PATH if necessary. This is called after FixVersionClash(), which",
"// happens above in configureProcesses().",
"if",
"err",
"=",
"configurePath",
"(",
"g",
",",
"cl",
")",
";",
"err",
"!=",
"nil",
"{",
"// Further note -- don't die here. It could be we're calling this method",
"// against an earlier version of the service that doesn't support it.",
"// It's not critical that it succeed, so continue on.",
"g",
".",
"Log",
".",
"Debug",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // AutoFork? Standalone? ClientServer? Brew service? This function deals with the
// various run configurations that we can run in. | [
"AutoFork?",
"Standalone?",
"ClientServer?",
"Brew",
"service?",
"This",
"function",
"deals",
"with",
"the",
"various",
"run",
"configurations",
"that",
"we",
"can",
"run",
"in",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/keybase/main.go#L269-L382 |
161,555 | keybase/client | go/keybase/main.go | configurePath | func configurePath(g *libkb.GlobalContext, cl *libcmdline.CommandLine) error {
if cl.IsService() {
// this only runs on the client
return nil
}
return client.SendPath(g)
} | go | func configurePath(g *libkb.GlobalContext, cl *libcmdline.CommandLine) error {
if cl.IsService() {
// this only runs on the client
return nil
}
return client.SendPath(g)
} | [
"func",
"configurePath",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"cl",
"*",
"libcmdline",
".",
"CommandLine",
")",
"error",
"{",
"if",
"cl",
".",
"IsService",
"(",
")",
"{",
"// this only runs on the client",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"client",
".",
"SendPath",
"(",
"g",
")",
"\n",
"}"
] | // configurePath sends the client's PATH to the service. | [
"configurePath",
"sends",
"the",
"client",
"s",
"PATH",
"to",
"the",
"service",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/keybase/main.go#L424-L431 |
161,556 | keybase/client | go/keybase/main.go | stripFieldsFromAppStatusError | func stripFieldsFromAppStatusError(e error) error {
if e == nil {
return e
}
if ase, ok := e.(libkb.AppStatusError); ok {
return fmt.Errorf("%s (code %d)", ase.Desc, ase.Code)
}
return e
} | go | func stripFieldsFromAppStatusError(e error) error {
if e == nil {
return e
}
if ase, ok := e.(libkb.AppStatusError); ok {
return fmt.Errorf("%s (code %d)", ase.Desc, ase.Code)
}
return e
} | [
"func",
"stripFieldsFromAppStatusError",
"(",
"e",
"error",
")",
"error",
"{",
"if",
"e",
"==",
"nil",
"{",
"return",
"e",
"\n",
"}",
"\n",
"if",
"ase",
",",
"ok",
":=",
"e",
".",
"(",
"libkb",
".",
"AppStatusError",
")",
";",
"ok",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ase",
".",
"Desc",
",",
"ase",
".",
"Code",
")",
"\n",
"}",
"\n",
"return",
"e",
"\n",
"}"
] | // stripFieldsFromAppStatusError is an error prettifier. By default, AppStatusErrors print optional
// fields that were problematic. But they make for pretty ugly error messages spit back to the user.
// So strip that out, but still leave in an error-code integer, since those are quite helpful. | [
"stripFieldsFromAppStatusError",
"is",
"an",
"error",
"prettifier",
".",
"By",
"default",
"AppStatusErrors",
"print",
"optional",
"fields",
"that",
"were",
"problematic",
".",
"But",
"they",
"make",
"for",
"pretty",
"ugly",
"error",
"messages",
"spit",
"back",
"to",
"the",
"user",
".",
"So",
"strip",
"that",
"out",
"but",
"still",
"leave",
"in",
"an",
"error",
"-",
"code",
"integer",
"since",
"those",
"are",
"quite",
"helpful",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/keybase/main.go#L469-L477 |
161,557 | keybase/client | go/kbfs/libkey/key_server_local.go | NewKeyServerMemory | func NewKeyServerMemory(config KeyServerConfig, log logger.Logger) (
*KeyServerLocal, error) {
return newKeyServerLocal(config, log, storage.NewMemStorage(), nil)
} | go | func NewKeyServerMemory(config KeyServerConfig, log logger.Logger) (
*KeyServerLocal, error) {
return newKeyServerLocal(config, log, storage.NewMemStorage(), nil)
} | [
"func",
"NewKeyServerMemory",
"(",
"config",
"KeyServerConfig",
",",
"log",
"logger",
".",
"Logger",
")",
"(",
"*",
"KeyServerLocal",
",",
"error",
")",
"{",
"return",
"newKeyServerLocal",
"(",
"config",
",",
"log",
",",
"storage",
".",
"NewMemStorage",
"(",
")",
",",
"nil",
")",
"\n",
"}"
] | // NewKeyServerMemory returns a KeyServerLocal with an in-memory leveldb
// instance. | [
"NewKeyServerMemory",
"returns",
"a",
"KeyServerLocal",
"with",
"an",
"in",
"-",
"memory",
"leveldb",
"instance",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkey/key_server_local.go#L69-L72 |
161,558 | keybase/client | go/kbfs/libkey/key_server_local.go | NewKeyServerDir | func NewKeyServerDir(
config KeyServerConfig, log logger.Logger, dirPath string) (
*KeyServerLocal, error) {
return newKeyServerDisk(config, log, dirPath, nil)
} | go | func NewKeyServerDir(
config KeyServerConfig, log logger.Logger, dirPath string) (
*KeyServerLocal, error) {
return newKeyServerDisk(config, log, dirPath, nil)
} | [
"func",
"NewKeyServerDir",
"(",
"config",
"KeyServerConfig",
",",
"log",
"logger",
".",
"Logger",
",",
"dirPath",
"string",
")",
"(",
"*",
"KeyServerLocal",
",",
"error",
")",
"{",
"return",
"newKeyServerDisk",
"(",
"config",
",",
"log",
",",
"dirPath",
",",
"nil",
")",
"\n",
"}"
] | // NewKeyServerDir constructs a new KeyServerLocal that stores its
// data in the given directory. | [
"NewKeyServerDir",
"constructs",
"a",
"new",
"KeyServerLocal",
"that",
"stores",
"its",
"data",
"in",
"the",
"given",
"directory",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkey/key_server_local.go#L87-L91 |
161,559 | keybase/client | go/kbfs/libkey/key_server_local.go | NewKeyServerTempDir | func NewKeyServerTempDir(
config KeyServerConfig, log logger.Logger) (*KeyServerLocal, error) {
tempdir, err := ioutil.TempDir(os.TempDir(), "kbfs_keyserver_tmp")
if err != nil {
return nil, err
}
return newKeyServerDisk(config, log, tempdir, func(log logger.Logger) {
err := ioutil.RemoveAll(tempdir)
if err != nil {
log.Warning("error removing %s: %s", tempdir, err)
}
})
} | go | func NewKeyServerTempDir(
config KeyServerConfig, log logger.Logger) (*KeyServerLocal, error) {
tempdir, err := ioutil.TempDir(os.TempDir(), "kbfs_keyserver_tmp")
if err != nil {
return nil, err
}
return newKeyServerDisk(config, log, tempdir, func(log logger.Logger) {
err := ioutil.RemoveAll(tempdir)
if err != nil {
log.Warning("error removing %s: %s", tempdir, err)
}
})
} | [
"func",
"NewKeyServerTempDir",
"(",
"config",
"KeyServerConfig",
",",
"log",
"logger",
".",
"Logger",
")",
"(",
"*",
"KeyServerLocal",
",",
"error",
")",
"{",
"tempdir",
",",
"err",
":=",
"ioutil",
".",
"TempDir",
"(",
"os",
".",
"TempDir",
"(",
")",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"newKeyServerDisk",
"(",
"config",
",",
"log",
",",
"tempdir",
",",
"func",
"(",
"log",
"logger",
".",
"Logger",
")",
"{",
"err",
":=",
"ioutil",
".",
"RemoveAll",
"(",
"tempdir",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Warning",
"(",
"\"",
"\"",
",",
"tempdir",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
")",
"\n",
"}"
] | // NewKeyServerTempDir constructs a new KeyServerLocal that stores its
// data in a temp directory which is cleaned up on shutdown. | [
"NewKeyServerTempDir",
"constructs",
"a",
"new",
"KeyServerLocal",
"that",
"stores",
"its",
"data",
"in",
"a",
"temp",
"directory",
"which",
"is",
"cleaned",
"up",
"on",
"shutdown",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkey/key_server_local.go#L95-L107 |
161,560 | keybase/client | go/kbfs/libkey/key_server_local.go | GetTLFCryptKeyServerHalf | func (ks *KeyServerLocal) GetTLFCryptKeyServerHalf(
ctx context.Context, serverHalfID kbfscrypto.TLFCryptKeyServerHalfID,
key kbfscrypto.CryptPublicKey) (
serverHalf kbfscrypto.TLFCryptKeyServerHalf, err error) {
if err := checkContext(ctx); err != nil {
return kbfscrypto.TLFCryptKeyServerHalf{}, err
}
ks.shutdownLock.RLock()
defer ks.shutdownLock.RUnlock()
if *ks.shutdown {
err = errors.New("Key server already shut down")
}
buf, err := ks.db.Get(serverHalfID.ID.Bytes(), nil)
if err != nil {
return
}
err = ks.config.Codec().Decode(buf, &serverHalf)
if err != nil {
return kbfscrypto.TLFCryptKeyServerHalf{}, err
}
session, err := ks.config.KBPKI().GetCurrentSession(ctx)
if err != nil {
return kbfscrypto.TLFCryptKeyServerHalf{}, err
}
err = kbfscrypto.VerifyTLFCryptKeyServerHalfID(
serverHalfID, session.UID, key, serverHalf)
if err != nil {
ks.log.CDebugf(ctx, "error verifying server half ID: %+v", err)
return kbfscrypto.TLFCryptKeyServerHalf{},
kbfsmd.ServerErrorUnauthorized{Err: err}
}
return serverHalf, nil
} | go | func (ks *KeyServerLocal) GetTLFCryptKeyServerHalf(
ctx context.Context, serverHalfID kbfscrypto.TLFCryptKeyServerHalfID,
key kbfscrypto.CryptPublicKey) (
serverHalf kbfscrypto.TLFCryptKeyServerHalf, err error) {
if err := checkContext(ctx); err != nil {
return kbfscrypto.TLFCryptKeyServerHalf{}, err
}
ks.shutdownLock.RLock()
defer ks.shutdownLock.RUnlock()
if *ks.shutdown {
err = errors.New("Key server already shut down")
}
buf, err := ks.db.Get(serverHalfID.ID.Bytes(), nil)
if err != nil {
return
}
err = ks.config.Codec().Decode(buf, &serverHalf)
if err != nil {
return kbfscrypto.TLFCryptKeyServerHalf{}, err
}
session, err := ks.config.KBPKI().GetCurrentSession(ctx)
if err != nil {
return kbfscrypto.TLFCryptKeyServerHalf{}, err
}
err = kbfscrypto.VerifyTLFCryptKeyServerHalfID(
serverHalfID, session.UID, key, serverHalf)
if err != nil {
ks.log.CDebugf(ctx, "error verifying server half ID: %+v", err)
return kbfscrypto.TLFCryptKeyServerHalf{},
kbfsmd.ServerErrorUnauthorized{Err: err}
}
return serverHalf, nil
} | [
"func",
"(",
"ks",
"*",
"KeyServerLocal",
")",
"GetTLFCryptKeyServerHalf",
"(",
"ctx",
"context",
".",
"Context",
",",
"serverHalfID",
"kbfscrypto",
".",
"TLFCryptKeyServerHalfID",
",",
"key",
"kbfscrypto",
".",
"CryptPublicKey",
")",
"(",
"serverHalf",
"kbfscrypto",
".",
"TLFCryptKeyServerHalf",
",",
"err",
"error",
")",
"{",
"if",
"err",
":=",
"checkContext",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"kbfscrypto",
".",
"TLFCryptKeyServerHalf",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"ks",
".",
"shutdownLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"ks",
".",
"shutdownLock",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"*",
"ks",
".",
"shutdown",
"{",
"err",
"=",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"buf",
",",
"err",
":=",
"ks",
".",
"db",
".",
"Get",
"(",
"serverHalfID",
".",
"ID",
".",
"Bytes",
"(",
")",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"err",
"=",
"ks",
".",
"config",
".",
"Codec",
"(",
")",
".",
"Decode",
"(",
"buf",
",",
"&",
"serverHalf",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"kbfscrypto",
".",
"TLFCryptKeyServerHalf",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"session",
",",
"err",
":=",
"ks",
".",
"config",
".",
"KBPKI",
"(",
")",
".",
"GetCurrentSession",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"kbfscrypto",
".",
"TLFCryptKeyServerHalf",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"kbfscrypto",
".",
"VerifyTLFCryptKeyServerHalfID",
"(",
"serverHalfID",
",",
"session",
".",
"UID",
",",
"key",
",",
"serverHalf",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"ks",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"kbfscrypto",
".",
"TLFCryptKeyServerHalf",
"{",
"}",
",",
"kbfsmd",
".",
"ServerErrorUnauthorized",
"{",
"Err",
":",
"err",
"}",
"\n",
"}",
"\n",
"return",
"serverHalf",
",",
"nil",
"\n",
"}"
] | // GetTLFCryptKeyServerHalf implements the KeyServer interface for
// KeyServerLocal. | [
"GetTLFCryptKeyServerHalf",
"implements",
"the",
"KeyServer",
"interface",
"for",
"KeyServerLocal",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkey/key_server_local.go#L111-L148 |
161,561 | keybase/client | go/kbfs/libkey/key_server_local.go | PutTLFCryptKeyServerHalves | func (ks *KeyServerLocal) PutTLFCryptKeyServerHalves(ctx context.Context,
keyServerHalves kbfsmd.UserDeviceKeyServerHalves) error {
if err := checkContext(ctx); err != nil {
return err
}
ks.shutdownLock.RLock()
defer ks.shutdownLock.RUnlock()
if *ks.shutdown {
return errors.New("Key server already shut down")
}
// batch up the writes such that they're atomic.
batch := &leveldb.Batch{}
for uid, deviceMap := range keyServerHalves {
for deviceKey, serverHalf := range deviceMap {
buf, err := ks.config.Codec().Encode(serverHalf)
if err != nil {
return err
}
id, err := kbfscrypto.MakeTLFCryptKeyServerHalfID(
uid, deviceKey, serverHalf)
if err != nil {
return err
}
batch.Put(id.ID.Bytes(), buf)
}
}
return ks.db.Write(batch, nil)
} | go | func (ks *KeyServerLocal) PutTLFCryptKeyServerHalves(ctx context.Context,
keyServerHalves kbfsmd.UserDeviceKeyServerHalves) error {
if err := checkContext(ctx); err != nil {
return err
}
ks.shutdownLock.RLock()
defer ks.shutdownLock.RUnlock()
if *ks.shutdown {
return errors.New("Key server already shut down")
}
// batch up the writes such that they're atomic.
batch := &leveldb.Batch{}
for uid, deviceMap := range keyServerHalves {
for deviceKey, serverHalf := range deviceMap {
buf, err := ks.config.Codec().Encode(serverHalf)
if err != nil {
return err
}
id, err := kbfscrypto.MakeTLFCryptKeyServerHalfID(
uid, deviceKey, serverHalf)
if err != nil {
return err
}
batch.Put(id.ID.Bytes(), buf)
}
}
return ks.db.Write(batch, nil)
} | [
"func",
"(",
"ks",
"*",
"KeyServerLocal",
")",
"PutTLFCryptKeyServerHalves",
"(",
"ctx",
"context",
".",
"Context",
",",
"keyServerHalves",
"kbfsmd",
".",
"UserDeviceKeyServerHalves",
")",
"error",
"{",
"if",
"err",
":=",
"checkContext",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"ks",
".",
"shutdownLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"ks",
".",
"shutdownLock",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"*",
"ks",
".",
"shutdown",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// batch up the writes such that they're atomic.",
"batch",
":=",
"&",
"leveldb",
".",
"Batch",
"{",
"}",
"\n",
"for",
"uid",
",",
"deviceMap",
":=",
"range",
"keyServerHalves",
"{",
"for",
"deviceKey",
",",
"serverHalf",
":=",
"range",
"deviceMap",
"{",
"buf",
",",
"err",
":=",
"ks",
".",
"config",
".",
"Codec",
"(",
")",
".",
"Encode",
"(",
"serverHalf",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"id",
",",
"err",
":=",
"kbfscrypto",
".",
"MakeTLFCryptKeyServerHalfID",
"(",
"uid",
",",
"deviceKey",
",",
"serverHalf",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"batch",
".",
"Put",
"(",
"id",
".",
"ID",
".",
"Bytes",
"(",
")",
",",
"buf",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"ks",
".",
"db",
".",
"Write",
"(",
"batch",
",",
"nil",
")",
"\n",
"}"
] | // PutTLFCryptKeyServerHalves implements the KeyServer interface for
// KeyServerLocal. | [
"PutTLFCryptKeyServerHalves",
"implements",
"the",
"KeyServer",
"interface",
"for",
"KeyServerLocal",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkey/key_server_local.go#L152-L181 |
161,562 | keybase/client | go/kbfs/libkey/key_server_local.go | DeleteTLFCryptKeyServerHalf | func (ks *KeyServerLocal) DeleteTLFCryptKeyServerHalf(ctx context.Context,
_ keybase1.UID, _ kbfscrypto.CryptPublicKey,
serverHalfID kbfscrypto.TLFCryptKeyServerHalfID) error {
if err := checkContext(ctx); err != nil {
return err
}
ks.shutdownLock.RLock()
defer ks.shutdownLock.RUnlock()
if *ks.shutdown {
return errors.New("Key server already shut down")
}
// TODO: verify that the kid is really valid for the given uid
return ks.db.Delete(serverHalfID.ID.Bytes(), nil)
} | go | func (ks *KeyServerLocal) DeleteTLFCryptKeyServerHalf(ctx context.Context,
_ keybase1.UID, _ kbfscrypto.CryptPublicKey,
serverHalfID kbfscrypto.TLFCryptKeyServerHalfID) error {
if err := checkContext(ctx); err != nil {
return err
}
ks.shutdownLock.RLock()
defer ks.shutdownLock.RUnlock()
if *ks.shutdown {
return errors.New("Key server already shut down")
}
// TODO: verify that the kid is really valid for the given uid
return ks.db.Delete(serverHalfID.ID.Bytes(), nil)
} | [
"func",
"(",
"ks",
"*",
"KeyServerLocal",
")",
"DeleteTLFCryptKeyServerHalf",
"(",
"ctx",
"context",
".",
"Context",
",",
"_",
"keybase1",
".",
"UID",
",",
"_",
"kbfscrypto",
".",
"CryptPublicKey",
",",
"serverHalfID",
"kbfscrypto",
".",
"TLFCryptKeyServerHalfID",
")",
"error",
"{",
"if",
"err",
":=",
"checkContext",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"ks",
".",
"shutdownLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"ks",
".",
"shutdownLock",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"*",
"ks",
".",
"shutdown",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// TODO: verify that the kid is really valid for the given uid",
"return",
"ks",
".",
"db",
".",
"Delete",
"(",
"serverHalfID",
".",
"ID",
".",
"Bytes",
"(",
")",
",",
"nil",
")",
"\n",
"}"
] | // DeleteTLFCryptKeyServerHalf implements the KeyServer interface for
// KeyServerLocal. | [
"DeleteTLFCryptKeyServerHalf",
"implements",
"the",
"KeyServer",
"interface",
"for",
"KeyServerLocal",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkey/key_server_local.go#L185-L201 |
161,563 | keybase/client | go/kbfs/libkey/key_server_local.go | CopyWithConfigAndLogger | func (ks *KeyServerLocal) CopyWithConfigAndLogger(
config KeyServerConfig, log logger.Logger) *KeyServerLocal {
return &KeyServerLocal{
config, ks.db, log, ks.shutdownLock, ks.shutdown, ks.shutdownFunc}
} | go | func (ks *KeyServerLocal) CopyWithConfigAndLogger(
config KeyServerConfig, log logger.Logger) *KeyServerLocal {
return &KeyServerLocal{
config, ks.db, log, ks.shutdownLock, ks.shutdown, ks.shutdownFunc}
} | [
"func",
"(",
"ks",
"*",
"KeyServerLocal",
")",
"CopyWithConfigAndLogger",
"(",
"config",
"KeyServerConfig",
",",
"log",
"logger",
".",
"Logger",
")",
"*",
"KeyServerLocal",
"{",
"return",
"&",
"KeyServerLocal",
"{",
"config",
",",
"ks",
".",
"db",
",",
"log",
",",
"ks",
".",
"shutdownLock",
",",
"ks",
".",
"shutdown",
",",
"ks",
".",
"shutdownFunc",
"}",
"\n",
"}"
] | // CopyWithConfigAndLogger copies a key server but swaps the config
// and the logger. | [
"CopyWithConfigAndLogger",
"copies",
"a",
"key",
"server",
"but",
"swaps",
"the",
"config",
"and",
"the",
"logger",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkey/key_server_local.go#L205-L209 |
161,564 | keybase/client | go/kbfs/libkey/key_server_local.go | Shutdown | func (ks *KeyServerLocal) Shutdown() {
ks.shutdownLock.Lock()
defer ks.shutdownLock.Unlock()
if *ks.shutdown {
return
}
*ks.shutdown = true
if ks.db != nil {
ks.db.Close()
}
if ks.shutdownFunc != nil {
ks.shutdownFunc(ks.log)
}
} | go | func (ks *KeyServerLocal) Shutdown() {
ks.shutdownLock.Lock()
defer ks.shutdownLock.Unlock()
if *ks.shutdown {
return
}
*ks.shutdown = true
if ks.db != nil {
ks.db.Close()
}
if ks.shutdownFunc != nil {
ks.shutdownFunc(ks.log)
}
} | [
"func",
"(",
"ks",
"*",
"KeyServerLocal",
")",
"Shutdown",
"(",
")",
"{",
"ks",
".",
"shutdownLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ks",
".",
"shutdownLock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"*",
"ks",
".",
"shutdown",
"{",
"return",
"\n",
"}",
"\n",
"*",
"ks",
".",
"shutdown",
"=",
"true",
"\n\n",
"if",
"ks",
".",
"db",
"!=",
"nil",
"{",
"ks",
".",
"db",
".",
"Close",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"ks",
".",
"shutdownFunc",
"!=",
"nil",
"{",
"ks",
".",
"shutdownFunc",
"(",
"ks",
".",
"log",
")",
"\n",
"}",
"\n",
"}"
] | // Shutdown implements the KeyServer interface for KeyServerLocal. | [
"Shutdown",
"implements",
"the",
"KeyServer",
"interface",
"for",
"KeyServerLocal",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkey/key_server_local.go#L212-L227 |
161,565 | keybase/client | go/kbfs/libpages/config/acl_checker_v1.go | getPermissions | func (c *aclCheckerV1) getPermissions(p string, username *string) (
permissions permissionsV1, max permissionsV1, effectivePath string) {
// This is only called on the root aclCheckerV1, and c.ac is always
// populated here. So even if no other path shows up in the ACLs, any path
// will get root's *accessControlV1 as the last resort.
ac := c.getAccessControl(nil, p)
permissions = ac.anonymous
if ac.whitelistAdditional == nil || username == nil {
return permissions, ac.maxPermission, ac.p
}
if perms, ok := ac.whitelistAdditional[*username]; ok {
permissions.read = perms.read || permissions.read
permissions.list = perms.list || permissions.list
}
return permissions, ac.maxPermission, ac.p
} | go | func (c *aclCheckerV1) getPermissions(p string, username *string) (
permissions permissionsV1, max permissionsV1, effectivePath string) {
// This is only called on the root aclCheckerV1, and c.ac is always
// populated here. So even if no other path shows up in the ACLs, any path
// will get root's *accessControlV1 as the last resort.
ac := c.getAccessControl(nil, p)
permissions = ac.anonymous
if ac.whitelistAdditional == nil || username == nil {
return permissions, ac.maxPermission, ac.p
}
if perms, ok := ac.whitelistAdditional[*username]; ok {
permissions.read = perms.read || permissions.read
permissions.list = perms.list || permissions.list
}
return permissions, ac.maxPermission, ac.p
} | [
"func",
"(",
"c",
"*",
"aclCheckerV1",
")",
"getPermissions",
"(",
"p",
"string",
",",
"username",
"*",
"string",
")",
"(",
"permissions",
"permissionsV1",
",",
"max",
"permissionsV1",
",",
"effectivePath",
"string",
")",
"{",
"// This is only called on the root aclCheckerV1, and c.ac is always",
"// populated here. So even if no other path shows up in the ACLs, any path",
"// will get root's *accessControlV1 as the last resort.",
"ac",
":=",
"c",
".",
"getAccessControl",
"(",
"nil",
",",
"p",
")",
"\n",
"permissions",
"=",
"ac",
".",
"anonymous",
"\n",
"if",
"ac",
".",
"whitelistAdditional",
"==",
"nil",
"||",
"username",
"==",
"nil",
"{",
"return",
"permissions",
",",
"ac",
".",
"maxPermission",
",",
"ac",
".",
"p",
"\n",
"}",
"\n",
"if",
"perms",
",",
"ok",
":=",
"ac",
".",
"whitelistAdditional",
"[",
"*",
"username",
"]",
";",
"ok",
"{",
"permissions",
".",
"read",
"=",
"perms",
".",
"read",
"||",
"permissions",
".",
"read",
"\n",
"permissions",
".",
"list",
"=",
"perms",
".",
"list",
"||",
"permissions",
".",
"list",
"\n",
"}",
"\n",
"return",
"permissions",
",",
"ac",
".",
"maxPermission",
",",
"ac",
".",
"p",
"\n",
"}"
] | // getPermissions returns the permissions that username has on p. This method
// should only be called on the root aclCheckerV1. | [
"getPermissions",
"returns",
"the",
"permissions",
"that",
"username",
"has",
"on",
"p",
".",
"This",
"method",
"should",
"only",
"be",
"called",
"on",
"the",
"root",
"aclCheckerV1",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libpages/config/acl_checker_v1.go#L207-L222 |
161,566 | keybase/client | go/kbfs/libfuse/platform_flags_osx.go | AddPlatformFlags | func AddPlatformFlags(flags *flag.FlagSet) *PlatformParams {
var params PlatformParams
flags.BoolVar(¶ms.UseSystemFuse, "use-system-fuse", false,
"Use the system OSXFUSE instead of keybase's OSXFUSE")
flags.BoolVar(¶ms.UseLocal, "local-experimental", false,
"Use 'local' mount option and enable other hacky stuff for testing macOS "+
"apps. The \"hacky stuff\" includes a Trash implementation that only "+
"works for the user's own private TLF, so if you enable this please "+
"only work under your own private TLF.")
return ¶ms
} | go | func AddPlatformFlags(flags *flag.FlagSet) *PlatformParams {
var params PlatformParams
flags.BoolVar(¶ms.UseSystemFuse, "use-system-fuse", false,
"Use the system OSXFUSE instead of keybase's OSXFUSE")
flags.BoolVar(¶ms.UseLocal, "local-experimental", false,
"Use 'local' mount option and enable other hacky stuff for testing macOS "+
"apps. The \"hacky stuff\" includes a Trash implementation that only "+
"works for the user's own private TLF, so if you enable this please "+
"only work under your own private TLF.")
return ¶ms
} | [
"func",
"AddPlatformFlags",
"(",
"flags",
"*",
"flag",
".",
"FlagSet",
")",
"*",
"PlatformParams",
"{",
"var",
"params",
"PlatformParams",
"\n",
"flags",
".",
"BoolVar",
"(",
"&",
"params",
".",
"UseSystemFuse",
",",
"\"",
"\"",
",",
"false",
",",
"\"",
"\"",
")",
"\n",
"flags",
".",
"BoolVar",
"(",
"&",
"params",
".",
"UseLocal",
",",
"\"",
"\"",
",",
"false",
",",
"\"",
"\"",
"+",
"\"",
"\\\"",
"\\\"",
"\"",
"+",
"\"",
"\"",
"+",
"\"",
"\"",
")",
"\n",
"return",
"&",
"params",
"\n",
"}"
] | // AddPlatformFlags adds platform-specific flags to the given FlagSet
// and returns a PlatformParams object that will be filled in when the
// given FlagSet is parsed. | [
"AddPlatformFlags",
"adds",
"platform",
"-",
"specific",
"flags",
"to",
"the",
"given",
"FlagSet",
"and",
"returns",
"a",
"PlatformParams",
"object",
"that",
"will",
"be",
"filled",
"in",
"when",
"the",
"given",
"FlagSet",
"is",
"parsed",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/platform_flags_osx.go#L31-L41 |
161,567 | keybase/client | go/protocol/keybase1/provision_ui.go | SwitchToGPGSignOK | func (c ProvisionUiClient) SwitchToGPGSignOK(ctx context.Context, __arg SwitchToGPGSignOKArg) (res bool, err error) {
err = c.Cli.Call(ctx, "keybase.1.provisionUi.switchToGPGSignOK", []interface{}{__arg}, &res)
return
} | go | func (c ProvisionUiClient) SwitchToGPGSignOK(ctx context.Context, __arg SwitchToGPGSignOKArg) (res bool, err error) {
err = c.Cli.Call(ctx, "keybase.1.provisionUi.switchToGPGSignOK", []interface{}{__arg}, &res)
return
} | [
"func",
"(",
"c",
"ProvisionUiClient",
")",
"SwitchToGPGSignOK",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"SwitchToGPGSignOKArg",
")",
"(",
"res",
"bool",
",",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"&",
"res",
")",
"\n",
"return",
"\n",
"}"
] | // If there was an error importing a gpg key into the local
// keyring, tell the user and offer to switch to GPG signing
// with this key. Return true to switch to GPG signing,
// false to abort provisioning. | [
"If",
"there",
"was",
"an",
"error",
"importing",
"a",
"gpg",
"key",
"into",
"the",
"local",
"keyring",
"tell",
"the",
"user",
"and",
"offer",
"to",
"switch",
"to",
"GPG",
"signing",
"with",
"this",
"key",
".",
"Return",
"true",
"to",
"switch",
"to",
"GPG",
"signing",
"false",
"to",
"abort",
"provisioning",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/provision_ui.go#L414-L417 |
161,568 | keybase/client | go/protocol/keybase1/provision_ui.go | DisplaySecretExchanged | func (c ProvisionUiClient) DisplaySecretExchanged(ctx context.Context, sessionID int) (err error) {
__arg := DisplaySecretExchangedArg{SessionID: sessionID}
err = c.Cli.Call(ctx, "keybase.1.provisionUi.DisplaySecretExchanged", []interface{}{__arg}, nil)
return
} | go | func (c ProvisionUiClient) DisplaySecretExchanged(ctx context.Context, sessionID int) (err error) {
__arg := DisplaySecretExchangedArg{SessionID: sessionID}
err = c.Cli.Call(ctx, "keybase.1.provisionUi.DisplaySecretExchanged", []interface{}{__arg}, nil)
return
} | [
"func",
"(",
"c",
"ProvisionUiClient",
")",
"DisplaySecretExchanged",
"(",
"ctx",
"context",
".",
"Context",
",",
"sessionID",
"int",
")",
"(",
"err",
"error",
")",
"{",
"__arg",
":=",
"DisplaySecretExchangedArg",
"{",
"SessionID",
":",
"sessionID",
"}",
"\n",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"nil",
")",
"\n",
"return",
"\n",
"}"
] | // DisplaySecretExchanged is called when the kex2 secret has successfully been exchanged by the two
// devices. | [
"DisplaySecretExchanged",
"is",
"called",
"when",
"the",
"kex2",
"secret",
"has",
"successfully",
"been",
"exchanged",
"by",
"the",
"two",
"devices",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/provision_ui.go#L443-L447 |
161,569 | keybase/client | go/protocol/keybase1/provision_ui.go | PromptNewDeviceName | func (c ProvisionUiClient) PromptNewDeviceName(ctx context.Context, __arg PromptNewDeviceNameArg) (res string, err error) {
err = c.Cli.Call(ctx, "keybase.1.provisionUi.PromptNewDeviceName", []interface{}{__arg}, &res)
return
} | go | func (c ProvisionUiClient) PromptNewDeviceName(ctx context.Context, __arg PromptNewDeviceNameArg) (res string, err error) {
err = c.Cli.Call(ctx, "keybase.1.provisionUi.PromptNewDeviceName", []interface{}{__arg}, &res)
return
} | [
"func",
"(",
"c",
"ProvisionUiClient",
")",
"PromptNewDeviceName",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"PromptNewDeviceNameArg",
")",
"(",
"res",
"string",
",",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"&",
"res",
")",
"\n",
"return",
"\n",
"}"
] | // PromptNewDeviceName is called when the device provisioning process needs a name for the new device.
// To help the clients not send a duplicate name, existingDevices is populated with the current device
// names for the user. If the device name returned to the service is invalid or already
// taken, it will call this again with an error message in errorMessage. | [
"PromptNewDeviceName",
"is",
"called",
"when",
"the",
"device",
"provisioning",
"process",
"needs",
"a",
"name",
"for",
"the",
"new",
"device",
".",
"To",
"help",
"the",
"clients",
"not",
"send",
"a",
"duplicate",
"name",
"existingDevices",
"is",
"populated",
"with",
"the",
"current",
"device",
"names",
"for",
"the",
"user",
".",
"If",
"the",
"device",
"name",
"returned",
"to",
"the",
"service",
"is",
"invalid",
"or",
"already",
"taken",
"it",
"will",
"call",
"this",
"again",
"with",
"an",
"error",
"message",
"in",
"errorMessage",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/provision_ui.go#L453-L456 |
161,570 | keybase/client | go/protocol/keybase1/provision_ui.go | ProvisioneeSuccess | func (c ProvisionUiClient) ProvisioneeSuccess(ctx context.Context, __arg ProvisioneeSuccessArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.provisionUi.ProvisioneeSuccess", []interface{}{__arg}, nil)
return
} | go | func (c ProvisionUiClient) ProvisioneeSuccess(ctx context.Context, __arg ProvisioneeSuccessArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.provisionUi.ProvisioneeSuccess", []interface{}{__arg}, nil)
return
} | [
"func",
"(",
"c",
"ProvisionUiClient",
")",
"ProvisioneeSuccess",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"ProvisioneeSuccessArg",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"nil",
")",
"\n",
"return",
"\n",
"}"
] | // ProvisioneeSuccess is called on provisionee when it is successfully provisioned. | [
"ProvisioneeSuccess",
"is",
"called",
"on",
"provisionee",
"when",
"it",
"is",
"successfully",
"provisioned",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/provision_ui.go#L459-L462 |
161,571 | keybase/client | go/protocol/keybase1/provision_ui.go | ProvisionerSuccess | func (c ProvisionUiClient) ProvisionerSuccess(ctx context.Context, __arg ProvisionerSuccessArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.provisionUi.ProvisionerSuccess", []interface{}{__arg}, nil)
return
} | go | func (c ProvisionUiClient) ProvisionerSuccess(ctx context.Context, __arg ProvisionerSuccessArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.provisionUi.ProvisionerSuccess", []interface{}{__arg}, nil)
return
} | [
"func",
"(",
"c",
"ProvisionUiClient",
")",
"ProvisionerSuccess",
"(",
"ctx",
"context",
".",
"Context",
",",
"__arg",
"ProvisionerSuccessArg",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Cli",
".",
"Call",
"(",
"ctx",
",",
"\"",
"\"",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"__arg",
"}",
",",
"nil",
")",
"\n",
"return",
"\n",
"}"
] | // ProvisionerSuccess is called on provisioner when it successfully provisions another device. | [
"ProvisionerSuccess",
"is",
"called",
"on",
"provisioner",
"when",
"it",
"successfully",
"provisions",
"another",
"device",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/provision_ui.go#L465-L468 |
161,572 | keybase/client | go/libkb/msgpack.go | MsgpackDecodeAll | func MsgpackDecodeAll(data []byte, handle *codec.MsgpackHandle, out interface{}) error {
decoder := codec.NewDecoderBytes(data, handle)
err := decoder.Decode(out)
if err != nil {
return err
}
if decoder.NumBytesRead() != len(data) {
return fmt.Errorf("Did not consume entire buffer: %d byte(s) left", len(data)-decoder.NumBytesRead())
}
return nil
} | go | func MsgpackDecodeAll(data []byte, handle *codec.MsgpackHandle, out interface{}) error {
decoder := codec.NewDecoderBytes(data, handle)
err := decoder.Decode(out)
if err != nil {
return err
}
if decoder.NumBytesRead() != len(data) {
return fmt.Errorf("Did not consume entire buffer: %d byte(s) left", len(data)-decoder.NumBytesRead())
}
return nil
} | [
"func",
"MsgpackDecodeAll",
"(",
"data",
"[",
"]",
"byte",
",",
"handle",
"*",
"codec",
".",
"MsgpackHandle",
",",
"out",
"interface",
"{",
"}",
")",
"error",
"{",
"decoder",
":=",
"codec",
".",
"NewDecoderBytes",
"(",
"data",
",",
"handle",
")",
"\n",
"err",
":=",
"decoder",
".",
"Decode",
"(",
"out",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"decoder",
".",
"NumBytesRead",
"(",
")",
"!=",
"len",
"(",
"data",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"len",
"(",
"data",
")",
"-",
"decoder",
".",
"NumBytesRead",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Decode data into out, but make sure that all bytes in data are
// used. | [
"Decode",
"data",
"into",
"out",
"but",
"make",
"sure",
"that",
"all",
"bytes",
"in",
"data",
"are",
"used",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/msgpack.go#L26-L37 |
161,573 | keybase/client | go/libkb/pseudonym.go | MakePseudonym | func MakePseudonym(info TlfPseudonymInfo) (TlfPseudonym, error) {
input := tlfPseudonymContents{
Version: tlfPseudonymVersion,
Name: info.Name,
ID: info.ID,
KeyGen: info.KeyGen,
}
mh := codec.MsgpackHandle{WriteExt: true}
var buf []byte
enc := codec.NewEncoderBytes(&buf, &mh)
err := enc.Encode(input)
if err != nil {
return [32]byte{}, err
}
mac := hmac.New(sha256.New, info.HmacKey[:])
mac.Write(buf)
hmac := MakeByte32(mac.Sum(nil))
return hmac, nil
} | go | func MakePseudonym(info TlfPseudonymInfo) (TlfPseudonym, error) {
input := tlfPseudonymContents{
Version: tlfPseudonymVersion,
Name: info.Name,
ID: info.ID,
KeyGen: info.KeyGen,
}
mh := codec.MsgpackHandle{WriteExt: true}
var buf []byte
enc := codec.NewEncoderBytes(&buf, &mh)
err := enc.Encode(input)
if err != nil {
return [32]byte{}, err
}
mac := hmac.New(sha256.New, info.HmacKey[:])
mac.Write(buf)
hmac := MakeByte32(mac.Sum(nil))
return hmac, nil
} | [
"func",
"MakePseudonym",
"(",
"info",
"TlfPseudonymInfo",
")",
"(",
"TlfPseudonym",
",",
"error",
")",
"{",
"input",
":=",
"tlfPseudonymContents",
"{",
"Version",
":",
"tlfPseudonymVersion",
",",
"Name",
":",
"info",
".",
"Name",
",",
"ID",
":",
"info",
".",
"ID",
",",
"KeyGen",
":",
"info",
".",
"KeyGen",
",",
"}",
"\n",
"mh",
":=",
"codec",
".",
"MsgpackHandle",
"{",
"WriteExt",
":",
"true",
"}",
"\n",
"var",
"buf",
"[",
"]",
"byte",
"\n",
"enc",
":=",
"codec",
".",
"NewEncoderBytes",
"(",
"&",
"buf",
",",
"&",
"mh",
")",
"\n",
"err",
":=",
"enc",
".",
"Encode",
"(",
"input",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"[",
"32",
"]",
"byte",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"mac",
":=",
"hmac",
".",
"New",
"(",
"sha256",
".",
"New",
",",
"info",
".",
"HmacKey",
"[",
":",
"]",
")",
"\n",
"mac",
".",
"Write",
"(",
"buf",
")",
"\n",
"hmac",
":=",
"MakeByte32",
"(",
"mac",
".",
"Sum",
"(",
"nil",
")",
")",
"\n",
"return",
"hmac",
",",
"nil",
"\n",
"}"
] | // MakePseudonym makes a TLF pseudonym from the given input. | [
"MakePseudonym",
"makes",
"a",
"TLF",
"pseudonym",
"from",
"the",
"given",
"input",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/pseudonym.go#L99-L117 |
161,574 | keybase/client | go/libkb/pseudonym.go | GetTlfPseudonyms | func GetTlfPseudonyms(ctx context.Context, g *GlobalContext, pnyms []TlfPseudonym) ([]GetTlfPseudonymEither, error) {
var pnymStrings []string
for _, x := range pnyms {
pnymStrings = append(pnymStrings, x.String())
}
payload := make(JSONPayload)
payload["tlf_pseudonyms"] = pnymStrings
var res getTlfPseudonymsRes
mctx := NewMetaContext(ctx, g)
err := g.API.PostDecode(mctx,
APIArg{
Endpoint: "kbfs/pseudonym/get",
SessionType: APISessionTypeREQUIRED,
JSONPayload: payload,
},
&res)
if err != nil {
return nil, err
}
// Validate the response
if len(res.TlfPseudonyms) != len(pnyms) {
return nil, &PseudonymGetError{fmt.Sprintf("invalid server response for pseudonym get: len %v != %v",
len(res.TlfPseudonyms), len(pnyms))}
}
var resList []GetTlfPseudonymEither
for i, received := range res.TlfPseudonyms {
resList = append(resList, checkAndConvertTlfPseudonymFromServer(ctx, g, pnyms[i], received))
}
return resList, nil
} | go | func GetTlfPseudonyms(ctx context.Context, g *GlobalContext, pnyms []TlfPseudonym) ([]GetTlfPseudonymEither, error) {
var pnymStrings []string
for _, x := range pnyms {
pnymStrings = append(pnymStrings, x.String())
}
payload := make(JSONPayload)
payload["tlf_pseudonyms"] = pnymStrings
var res getTlfPseudonymsRes
mctx := NewMetaContext(ctx, g)
err := g.API.PostDecode(mctx,
APIArg{
Endpoint: "kbfs/pseudonym/get",
SessionType: APISessionTypeREQUIRED,
JSONPayload: payload,
},
&res)
if err != nil {
return nil, err
}
// Validate the response
if len(res.TlfPseudonyms) != len(pnyms) {
return nil, &PseudonymGetError{fmt.Sprintf("invalid server response for pseudonym get: len %v != %v",
len(res.TlfPseudonyms), len(pnyms))}
}
var resList []GetTlfPseudonymEither
for i, received := range res.TlfPseudonyms {
resList = append(resList, checkAndConvertTlfPseudonymFromServer(ctx, g, pnyms[i], received))
}
return resList, nil
} | [
"func",
"GetTlfPseudonyms",
"(",
"ctx",
"context",
".",
"Context",
",",
"g",
"*",
"GlobalContext",
",",
"pnyms",
"[",
"]",
"TlfPseudonym",
")",
"(",
"[",
"]",
"GetTlfPseudonymEither",
",",
"error",
")",
"{",
"var",
"pnymStrings",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"x",
":=",
"range",
"pnyms",
"{",
"pnymStrings",
"=",
"append",
"(",
"pnymStrings",
",",
"x",
".",
"String",
"(",
")",
")",
"\n",
"}",
"\n\n",
"payload",
":=",
"make",
"(",
"JSONPayload",
")",
"\n",
"payload",
"[",
"\"",
"\"",
"]",
"=",
"pnymStrings",
"\n\n",
"var",
"res",
"getTlfPseudonymsRes",
"\n",
"mctx",
":=",
"NewMetaContext",
"(",
"ctx",
",",
"g",
")",
"\n",
"err",
":=",
"g",
".",
"API",
".",
"PostDecode",
"(",
"mctx",
",",
"APIArg",
"{",
"Endpoint",
":",
"\"",
"\"",
",",
"SessionType",
":",
"APISessionTypeREQUIRED",
",",
"JSONPayload",
":",
"payload",
",",
"}",
",",
"&",
"res",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Validate the response",
"if",
"len",
"(",
"res",
".",
"TlfPseudonyms",
")",
"!=",
"len",
"(",
"pnyms",
")",
"{",
"return",
"nil",
",",
"&",
"PseudonymGetError",
"{",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"len",
"(",
"res",
".",
"TlfPseudonyms",
")",
",",
"len",
"(",
"pnyms",
")",
")",
"}",
"\n",
"}",
"\n",
"var",
"resList",
"[",
"]",
"GetTlfPseudonymEither",
"\n",
"for",
"i",
",",
"received",
":=",
"range",
"res",
".",
"TlfPseudonyms",
"{",
"resList",
"=",
"append",
"(",
"resList",
",",
"checkAndConvertTlfPseudonymFromServer",
"(",
"ctx",
",",
"g",
",",
"pnyms",
"[",
"i",
"]",
",",
"received",
")",
")",
"\n",
"}",
"\n\n",
"return",
"resList",
",",
"nil",
"\n",
"}"
] | // GetTlfPseudonyms fetches info for a list of pseudonyms.
// The output structs are returned in the order corresponding to the inputs.
// The top-level error is filled if the entire request fails.
// The each-struct errors may be filled for per-pseudonym errors. | [
"GetTlfPseudonyms",
"fetches",
"info",
"for",
"a",
"list",
"of",
"pseudonyms",
".",
"The",
"output",
"structs",
"are",
"returned",
"in",
"the",
"order",
"corresponding",
"to",
"the",
"inputs",
".",
"The",
"top",
"-",
"level",
"error",
"is",
"filled",
"if",
"the",
"entire",
"request",
"fails",
".",
"The",
"each",
"-",
"struct",
"errors",
"may",
"be",
"filled",
"for",
"per",
"-",
"pseudonym",
"errors",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/pseudonym.go#L157-L190 |
161,575 | keybase/client | go/libkb/key_pseudonym.go | MakeKeyPseudonym | func MakeKeyPseudonym(info KeyPseudonymInfo) (KeyPseudonym, error) {
var idBytes [16]byte
id := info.ID.ToBytes()
copy(idBytes[:], id)
input := keyPseudonymContents{
Version: KeyPseudonymVersion,
ID: idBytes,
Application: info.Application,
KeyGen: info.KeyGen,
}
mh := codec.MsgpackHandle{WriteExt: true}
var buf []byte
enc := codec.NewEncoderBytes(&buf, &mh)
if err := enc.Encode(input); err != nil {
return [32]byte{}, err
}
mac := hmac.New(sha256.New, info.Nonce[:])
mac.Write(buf)
hmac := MakeByte32(mac.Sum(nil))
return hmac, nil
} | go | func MakeKeyPseudonym(info KeyPseudonymInfo) (KeyPseudonym, error) {
var idBytes [16]byte
id := info.ID.ToBytes()
copy(idBytes[:], id)
input := keyPseudonymContents{
Version: KeyPseudonymVersion,
ID: idBytes,
Application: info.Application,
KeyGen: info.KeyGen,
}
mh := codec.MsgpackHandle{WriteExt: true}
var buf []byte
enc := codec.NewEncoderBytes(&buf, &mh)
if err := enc.Encode(input); err != nil {
return [32]byte{}, err
}
mac := hmac.New(sha256.New, info.Nonce[:])
mac.Write(buf)
hmac := MakeByte32(mac.Sum(nil))
return hmac, nil
} | [
"func",
"MakeKeyPseudonym",
"(",
"info",
"KeyPseudonymInfo",
")",
"(",
"KeyPseudonym",
",",
"error",
")",
"{",
"var",
"idBytes",
"[",
"16",
"]",
"byte",
"\n",
"id",
":=",
"info",
".",
"ID",
".",
"ToBytes",
"(",
")",
"\n\n",
"copy",
"(",
"idBytes",
"[",
":",
"]",
",",
"id",
")",
"\n\n",
"input",
":=",
"keyPseudonymContents",
"{",
"Version",
":",
"KeyPseudonymVersion",
",",
"ID",
":",
"idBytes",
",",
"Application",
":",
"info",
".",
"Application",
",",
"KeyGen",
":",
"info",
".",
"KeyGen",
",",
"}",
"\n",
"mh",
":=",
"codec",
".",
"MsgpackHandle",
"{",
"WriteExt",
":",
"true",
"}",
"\n",
"var",
"buf",
"[",
"]",
"byte",
"\n",
"enc",
":=",
"codec",
".",
"NewEncoderBytes",
"(",
"&",
"buf",
",",
"&",
"mh",
")",
"\n",
"if",
"err",
":=",
"enc",
".",
"Encode",
"(",
"input",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"[",
"32",
"]",
"byte",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"mac",
":=",
"hmac",
".",
"New",
"(",
"sha256",
".",
"New",
",",
"info",
".",
"Nonce",
"[",
":",
"]",
")",
"\n",
"mac",
".",
"Write",
"(",
"buf",
")",
"\n",
"hmac",
":=",
"MakeByte32",
"(",
"mac",
".",
"Sum",
"(",
"nil",
")",
")",
"\n",
"return",
"hmac",
",",
"nil",
"\n",
"}"
] | // MakePseudonym makes a key pseudonym from the given input. | [
"MakePseudonym",
"makes",
"a",
"key",
"pseudonym",
"from",
"the",
"given",
"input",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/key_pseudonym.go#L133-L156 |
161,576 | keybase/client | go/libkb/key_pseudonym.go | MakeAndPostKeyPseudonyms | func MakeAndPostKeyPseudonyms(m MetaContext, pnymInfos *[]KeyPseudonymInfo) (err error) {
var pnymReqs []keyPseudonymReq
if len(*pnymInfos) == 0 {
return
}
for i, info := range *pnymInfos {
// Compute the pseudonym
var pnym KeyPseudonym
pnym, err = MakeKeyPseudonym(info)
if err != nil {
return
}
(*pnymInfos)[i].KeyPseudonym = pnym
pnymReqs = append(pnymReqs, keyPseudonymReq{
Pseudonym: pnym,
ID: info.ID,
Application: int(info.Application),
KeyGen: int(info.KeyGen),
Nonce: info.Nonce,
})
}
payload := make(JSONPayload)
payload["key_pseudonyms"] = pnymReqs
_, err = m.G().API.PostJSON(m, APIArg{
Endpoint: "team/key_pseudonym",
JSONPayload: payload,
SessionType: APISessionTypeREQUIRED,
})
if err != nil {
return
}
return nil
} | go | func MakeAndPostKeyPseudonyms(m MetaContext, pnymInfos *[]KeyPseudonymInfo) (err error) {
var pnymReqs []keyPseudonymReq
if len(*pnymInfos) == 0 {
return
}
for i, info := range *pnymInfos {
// Compute the pseudonym
var pnym KeyPseudonym
pnym, err = MakeKeyPseudonym(info)
if err != nil {
return
}
(*pnymInfos)[i].KeyPseudonym = pnym
pnymReqs = append(pnymReqs, keyPseudonymReq{
Pseudonym: pnym,
ID: info.ID,
Application: int(info.Application),
KeyGen: int(info.KeyGen),
Nonce: info.Nonce,
})
}
payload := make(JSONPayload)
payload["key_pseudonyms"] = pnymReqs
_, err = m.G().API.PostJSON(m, APIArg{
Endpoint: "team/key_pseudonym",
JSONPayload: payload,
SessionType: APISessionTypeREQUIRED,
})
if err != nil {
return
}
return nil
} | [
"func",
"MakeAndPostKeyPseudonyms",
"(",
"m",
"MetaContext",
",",
"pnymInfos",
"*",
"[",
"]",
"KeyPseudonymInfo",
")",
"(",
"err",
"error",
")",
"{",
"var",
"pnymReqs",
"[",
"]",
"keyPseudonymReq",
"\n\n",
"if",
"len",
"(",
"*",
"pnymInfos",
")",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n\n",
"for",
"i",
",",
"info",
":=",
"range",
"*",
"pnymInfos",
"{",
"// Compute the pseudonym",
"var",
"pnym",
"KeyPseudonym",
"\n",
"pnym",
",",
"err",
"=",
"MakeKeyPseudonym",
"(",
"info",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"(",
"*",
"pnymInfos",
")",
"[",
"i",
"]",
".",
"KeyPseudonym",
"=",
"pnym",
"\n",
"pnymReqs",
"=",
"append",
"(",
"pnymReqs",
",",
"keyPseudonymReq",
"{",
"Pseudonym",
":",
"pnym",
",",
"ID",
":",
"info",
".",
"ID",
",",
"Application",
":",
"int",
"(",
"info",
".",
"Application",
")",
",",
"KeyGen",
":",
"int",
"(",
"info",
".",
"KeyGen",
")",
",",
"Nonce",
":",
"info",
".",
"Nonce",
",",
"}",
")",
"\n",
"}",
"\n\n",
"payload",
":=",
"make",
"(",
"JSONPayload",
")",
"\n",
"payload",
"[",
"\"",
"\"",
"]",
"=",
"pnymReqs",
"\n\n",
"_",
",",
"err",
"=",
"m",
".",
"G",
"(",
")",
".",
"API",
".",
"PostJSON",
"(",
"m",
",",
"APIArg",
"{",
"Endpoint",
":",
"\"",
"\"",
",",
"JSONPayload",
":",
"payload",
",",
"SessionType",
":",
"APISessionTypeREQUIRED",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // MakeAndPostKeyPseudonyms fills the KeyPseudonym field of each of the pnymInfos with the appropriate KeyPseudonym. | [
"MakeAndPostKeyPseudonyms",
"fills",
"the",
"KeyPseudonym",
"field",
"of",
"each",
"of",
"the",
"pnymInfos",
"with",
"the",
"appropriate",
"KeyPseudonym",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/key_pseudonym.go#L159-L195 |
161,577 | keybase/client | go/libkb/key_pseudonym.go | GetKeyPseudonyms | func GetKeyPseudonyms(m MetaContext, pnyms []KeyPseudonym) ([]KeyPseudonymOrError, error) {
var pnymStrings []string
for _, x := range pnyms {
pnymStrings = append(pnymStrings, x.String())
}
var res getKeyPseudonymsRes
err := m.G().API.GetDecode(m,
APIArg{
Endpoint: "team/key_pseudonym",
SessionType: APISessionTypeREQUIRED,
Args: HTTPArgs{
"key_pseudonyms": S{Val: strings.Join(pnymStrings, ",")},
},
},
&res)
if err != nil {
return nil, err
}
// Validate the response
if len(res.KeyPseudonyms) != len(pnyms) {
return nil, &KeyPseudonymGetError{fmt.Sprintf("invalid server response for pseudonym get: len %v != %v",
len(res.KeyPseudonyms), len(pnyms))}
}
var resList []KeyPseudonymOrError
for i, received := range res.KeyPseudonyms {
resList = append(resList, checkAndConvertKeyPseudonymFromServer(pnyms[i], received))
}
return resList, nil
} | go | func GetKeyPseudonyms(m MetaContext, pnyms []KeyPseudonym) ([]KeyPseudonymOrError, error) {
var pnymStrings []string
for _, x := range pnyms {
pnymStrings = append(pnymStrings, x.String())
}
var res getKeyPseudonymsRes
err := m.G().API.GetDecode(m,
APIArg{
Endpoint: "team/key_pseudonym",
SessionType: APISessionTypeREQUIRED,
Args: HTTPArgs{
"key_pseudonyms": S{Val: strings.Join(pnymStrings, ",")},
},
},
&res)
if err != nil {
return nil, err
}
// Validate the response
if len(res.KeyPseudonyms) != len(pnyms) {
return nil, &KeyPseudonymGetError{fmt.Sprintf("invalid server response for pseudonym get: len %v != %v",
len(res.KeyPseudonyms), len(pnyms))}
}
var resList []KeyPseudonymOrError
for i, received := range res.KeyPseudonyms {
resList = append(resList, checkAndConvertKeyPseudonymFromServer(pnyms[i], received))
}
return resList, nil
} | [
"func",
"GetKeyPseudonyms",
"(",
"m",
"MetaContext",
",",
"pnyms",
"[",
"]",
"KeyPseudonym",
")",
"(",
"[",
"]",
"KeyPseudonymOrError",
",",
"error",
")",
"{",
"var",
"pnymStrings",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"x",
":=",
"range",
"pnyms",
"{",
"pnymStrings",
"=",
"append",
"(",
"pnymStrings",
",",
"x",
".",
"String",
"(",
")",
")",
"\n",
"}",
"\n\n",
"var",
"res",
"getKeyPseudonymsRes",
"\n",
"err",
":=",
"m",
".",
"G",
"(",
")",
".",
"API",
".",
"GetDecode",
"(",
"m",
",",
"APIArg",
"{",
"Endpoint",
":",
"\"",
"\"",
",",
"SessionType",
":",
"APISessionTypeREQUIRED",
",",
"Args",
":",
"HTTPArgs",
"{",
"\"",
"\"",
":",
"S",
"{",
"Val",
":",
"strings",
".",
"Join",
"(",
"pnymStrings",
",",
"\"",
"\"",
")",
"}",
",",
"}",
",",
"}",
",",
"&",
"res",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Validate the response",
"if",
"len",
"(",
"res",
".",
"KeyPseudonyms",
")",
"!=",
"len",
"(",
"pnyms",
")",
"{",
"return",
"nil",
",",
"&",
"KeyPseudonymGetError",
"{",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"len",
"(",
"res",
".",
"KeyPseudonyms",
")",
",",
"len",
"(",
"pnyms",
")",
")",
"}",
"\n",
"}",
"\n",
"var",
"resList",
"[",
"]",
"KeyPseudonymOrError",
"\n",
"for",
"i",
",",
"received",
":=",
"range",
"res",
".",
"KeyPseudonyms",
"{",
"resList",
"=",
"append",
"(",
"resList",
",",
"checkAndConvertKeyPseudonymFromServer",
"(",
"pnyms",
"[",
"i",
"]",
",",
"received",
")",
")",
"\n",
"}",
"\n\n",
"return",
"resList",
",",
"nil",
"\n",
"}"
] | // GetKeyPseudonyms fetches info for a list of pseudonyms.
// The output structs are returned in the order corresponding to the inputs.
// The top-level error is filled if the entire request fails.
// The error in each of the returned structs may be filled for per-pseudonym errors. | [
"GetKeyPseudonyms",
"fetches",
"info",
"for",
"a",
"list",
"of",
"pseudonyms",
".",
"The",
"output",
"structs",
"are",
"returned",
"in",
"the",
"order",
"corresponding",
"to",
"the",
"inputs",
".",
"The",
"top",
"-",
"level",
"error",
"is",
"filled",
"if",
"the",
"entire",
"request",
"fails",
".",
"The",
"error",
"in",
"each",
"of",
"the",
"returned",
"structs",
"may",
"be",
"filled",
"for",
"per",
"-",
"pseudonym",
"errors",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/key_pseudonym.go#L201-L232 |
161,578 | keybase/client | go/libkb/key_pseudonym.go | RandomPseudonymNonce | func RandomPseudonymNonce() KeyPseudonymNonce {
slice, err := RandBytes(32)
if err != nil {
panic(err)
}
return KeyPseudonymNonce(MakeByte32(slice))
} | go | func RandomPseudonymNonce() KeyPseudonymNonce {
slice, err := RandBytes(32)
if err != nil {
panic(err)
}
return KeyPseudonymNonce(MakeByte32(slice))
} | [
"func",
"RandomPseudonymNonce",
"(",
")",
"KeyPseudonymNonce",
"{",
"slice",
",",
"err",
":=",
"RandBytes",
"(",
"32",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"KeyPseudonymNonce",
"(",
"MakeByte32",
"(",
"slice",
")",
")",
"\n",
"}"
] | // RandomPseudonymNonce returns a random nonce, which is used as an HMAC key. | [
"RandomPseudonymNonce",
"returns",
"a",
"random",
"nonce",
"which",
"is",
"used",
"as",
"an",
"HMAC",
"key",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/key_pseudonym.go#L297-L303 |
161,579 | keybase/client | go/engine/crypto.go | GetMySecretKey | func GetMySecretKey(ctx context.Context, g *libkb.GlobalContext, getSecretUI func() libkb.SecretUI, secretKeyType libkb.SecretKeyType, reason string) (libkb.GenericKey, error) {
key, err := g.ActiveDevice.KeyByType(secretKeyType)
if err != nil {
if _, ok := err.(libkb.NotFoundError); ok {
g.Log.CDebugf(ctx, "GetMySecretKey: no device key of type %s in ActiveDevice, returning LoginRequiredError", secretKeyType)
return nil, libkb.LoginRequiredError{Context: "GetMySecretKey"}
}
g.Log.CDebugf(ctx, "GetMySecretKey(%s), unexpected error: %s", secretKeyType, err)
return nil, err
}
return key, nil
} | go | func GetMySecretKey(ctx context.Context, g *libkb.GlobalContext, getSecretUI func() libkb.SecretUI, secretKeyType libkb.SecretKeyType, reason string) (libkb.GenericKey, error) {
key, err := g.ActiveDevice.KeyByType(secretKeyType)
if err != nil {
if _, ok := err.(libkb.NotFoundError); ok {
g.Log.CDebugf(ctx, "GetMySecretKey: no device key of type %s in ActiveDevice, returning LoginRequiredError", secretKeyType)
return nil, libkb.LoginRequiredError{Context: "GetMySecretKey"}
}
g.Log.CDebugf(ctx, "GetMySecretKey(%s), unexpected error: %s", secretKeyType, err)
return nil, err
}
return key, nil
} | [
"func",
"GetMySecretKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"getSecretUI",
"func",
"(",
")",
"libkb",
".",
"SecretUI",
",",
"secretKeyType",
"libkb",
".",
"SecretKeyType",
",",
"reason",
"string",
")",
"(",
"libkb",
".",
"GenericKey",
",",
"error",
")",
"{",
"key",
",",
"err",
":=",
"g",
".",
"ActiveDevice",
".",
"KeyByType",
"(",
"secretKeyType",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"_",
",",
"ok",
":=",
"err",
".",
"(",
"libkb",
".",
"NotFoundError",
")",
";",
"ok",
"{",
"g",
".",
"Log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"secretKeyType",
")",
"\n",
"return",
"nil",
",",
"libkb",
".",
"LoginRequiredError",
"{",
"Context",
":",
"\"",
"\"",
"}",
"\n",
"}",
"\n",
"g",
".",
"Log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",
"\"",
",",
"secretKeyType",
",",
"err",
")",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"key",
",",
"nil",
"\n",
"}"
] | // GetMySecretKey uses ActiveDevice to get a secret key for the current user.
//
// It used to have functionality to load the user and prompt for a passphrase to
// unlock the keys, but that is outdated now. Either you are logged in and
// have your device keys cached, or you aren't.
//
// If the key isn't found in the ActiveDevice cache, this will return LoginRequiredError. | [
"GetMySecretKey",
"uses",
"ActiveDevice",
"to",
"get",
"a",
"secret",
"key",
"for",
"the",
"current",
"user",
".",
"It",
"used",
"to",
"have",
"functionality",
"to",
"load",
"the",
"user",
"and",
"prompt",
"for",
"a",
"passphrase",
"to",
"unlock",
"the",
"keys",
"but",
"that",
"is",
"outdated",
"now",
".",
"Either",
"you",
"are",
"logged",
"in",
"and",
"have",
"your",
"device",
"keys",
"cached",
"or",
"you",
"aren",
"t",
".",
"If",
"the",
"key",
"isn",
"t",
"found",
"in",
"the",
"ActiveDevice",
"cache",
"this",
"will",
"return",
"LoginRequiredError",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/crypto.go#L27-L38 |
161,580 | keybase/client | go/engine/crypto.go | SignED25519 | func SignED25519(ctx context.Context, g *libkb.GlobalContext, getSecretUI func() libkb.SecretUI, arg keybase1.SignED25519Arg) (ret keybase1.ED25519SignatureInfo, err error) {
signingKey, err := GetMySecretKey(ctx, g, getSecretUI, libkb.DeviceSigningKeyType, arg.Reason)
if err != nil {
return
}
kp, ok := signingKey.(libkb.NaclSigningKeyPair)
if !ok || kp.Private == nil {
err = libkb.KeyCannotSignError{}
return
}
sig := kp.Private.Sign(arg.Msg)
publicKey := kp.Public
ret = keybase1.ED25519SignatureInfo{
Sig: keybase1.ED25519Signature(sig),
PublicKey: keybase1.ED25519PublicKey(publicKey),
}
return
} | go | func SignED25519(ctx context.Context, g *libkb.GlobalContext, getSecretUI func() libkb.SecretUI, arg keybase1.SignED25519Arg) (ret keybase1.ED25519SignatureInfo, err error) {
signingKey, err := GetMySecretKey(ctx, g, getSecretUI, libkb.DeviceSigningKeyType, arg.Reason)
if err != nil {
return
}
kp, ok := signingKey.(libkb.NaclSigningKeyPair)
if !ok || kp.Private == nil {
err = libkb.KeyCannotSignError{}
return
}
sig := kp.Private.Sign(arg.Msg)
publicKey := kp.Public
ret = keybase1.ED25519SignatureInfo{
Sig: keybase1.ED25519Signature(sig),
PublicKey: keybase1.ED25519PublicKey(publicKey),
}
return
} | [
"func",
"SignED25519",
"(",
"ctx",
"context",
".",
"Context",
",",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"getSecretUI",
"func",
"(",
")",
"libkb",
".",
"SecretUI",
",",
"arg",
"keybase1",
".",
"SignED25519Arg",
")",
"(",
"ret",
"keybase1",
".",
"ED25519SignatureInfo",
",",
"err",
"error",
")",
"{",
"signingKey",
",",
"err",
":=",
"GetMySecretKey",
"(",
"ctx",
",",
"g",
",",
"getSecretUI",
",",
"libkb",
".",
"DeviceSigningKeyType",
",",
"arg",
".",
"Reason",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"kp",
",",
"ok",
":=",
"signingKey",
".",
"(",
"libkb",
".",
"NaclSigningKeyPair",
")",
"\n",
"if",
"!",
"ok",
"||",
"kp",
".",
"Private",
"==",
"nil",
"{",
"err",
"=",
"libkb",
".",
"KeyCannotSignError",
"{",
"}",
"\n",
"return",
"\n",
"}",
"\n\n",
"sig",
":=",
"kp",
".",
"Private",
".",
"Sign",
"(",
"arg",
".",
"Msg",
")",
"\n",
"publicKey",
":=",
"kp",
".",
"Public",
"\n",
"ret",
"=",
"keybase1",
".",
"ED25519SignatureInfo",
"{",
"Sig",
":",
"keybase1",
".",
"ED25519Signature",
"(",
"sig",
")",
",",
"PublicKey",
":",
"keybase1",
".",
"ED25519PublicKey",
"(",
"publicKey",
")",
",",
"}",
"\n",
"return",
"\n",
"}"
] | // SignED25519 signs the given message with the current user's private
// signing key. | [
"SignED25519",
"signs",
"the",
"given",
"message",
"with",
"the",
"current",
"user",
"s",
"private",
"signing",
"key",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/crypto.go#L42-L61 |
161,581 | keybase/client | go/engine/crypto.go | SignED25519ForKBFS | func SignED25519ForKBFS(ctx context.Context, g *libkb.GlobalContext, getSecretUI func() libkb.SecretUI, arg keybase1.SignED25519ForKBFSArg) (
ret keybase1.ED25519SignatureInfo, err error) {
signingKey, err := GetMySecretKey(ctx, g, getSecretUI, libkb.DeviceSigningKeyType, arg.Reason)
if err != nil {
return
}
kp, ok := signingKey.(libkb.NaclSigningKeyPair)
if !ok || kp.Private == nil {
err = libkb.KeyCannotSignError{}
return
}
var sigInfo kbcrypto.NaclSigInfo
sigInfo, err = kp.SignV2(arg.Msg, kbcrypto.SignaturePrefixKBFS)
if err != nil {
return
}
publicKey := kp.Public
ret = keybase1.ED25519SignatureInfo{
Sig: keybase1.ED25519Signature(sigInfo.Sig),
PublicKey: keybase1.ED25519PublicKey(publicKey),
}
return
} | go | func SignED25519ForKBFS(ctx context.Context, g *libkb.GlobalContext, getSecretUI func() libkb.SecretUI, arg keybase1.SignED25519ForKBFSArg) (
ret keybase1.ED25519SignatureInfo, err error) {
signingKey, err := GetMySecretKey(ctx, g, getSecretUI, libkb.DeviceSigningKeyType, arg.Reason)
if err != nil {
return
}
kp, ok := signingKey.(libkb.NaclSigningKeyPair)
if !ok || kp.Private == nil {
err = libkb.KeyCannotSignError{}
return
}
var sigInfo kbcrypto.NaclSigInfo
sigInfo, err = kp.SignV2(arg.Msg, kbcrypto.SignaturePrefixKBFS)
if err != nil {
return
}
publicKey := kp.Public
ret = keybase1.ED25519SignatureInfo{
Sig: keybase1.ED25519Signature(sigInfo.Sig),
PublicKey: keybase1.ED25519PublicKey(publicKey),
}
return
} | [
"func",
"SignED25519ForKBFS",
"(",
"ctx",
"context",
".",
"Context",
",",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"getSecretUI",
"func",
"(",
")",
"libkb",
".",
"SecretUI",
",",
"arg",
"keybase1",
".",
"SignED25519ForKBFSArg",
")",
"(",
"ret",
"keybase1",
".",
"ED25519SignatureInfo",
",",
"err",
"error",
")",
"{",
"signingKey",
",",
"err",
":=",
"GetMySecretKey",
"(",
"ctx",
",",
"g",
",",
"getSecretUI",
",",
"libkb",
".",
"DeviceSigningKeyType",
",",
"arg",
".",
"Reason",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"kp",
",",
"ok",
":=",
"signingKey",
".",
"(",
"libkb",
".",
"NaclSigningKeyPair",
")",
"\n",
"if",
"!",
"ok",
"||",
"kp",
".",
"Private",
"==",
"nil",
"{",
"err",
"=",
"libkb",
".",
"KeyCannotSignError",
"{",
"}",
"\n",
"return",
"\n",
"}",
"\n\n",
"var",
"sigInfo",
"kbcrypto",
".",
"NaclSigInfo",
"\n",
"sigInfo",
",",
"err",
"=",
"kp",
".",
"SignV2",
"(",
"arg",
".",
"Msg",
",",
"kbcrypto",
".",
"SignaturePrefixKBFS",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"publicKey",
":=",
"kp",
".",
"Public",
"\n",
"ret",
"=",
"keybase1",
".",
"ED25519SignatureInfo",
"{",
"Sig",
":",
"keybase1",
".",
"ED25519Signature",
"(",
"sigInfo",
".",
"Sig",
")",
",",
"PublicKey",
":",
"keybase1",
".",
"ED25519PublicKey",
"(",
"publicKey",
")",
",",
"}",
"\n",
"return",
"\n",
"}"
] | // SignED25519ForKBFS signs the given message with the current user's private
// signing key on behalf of KBFS. | [
"SignED25519ForKBFS",
"signs",
"the",
"given",
"message",
"with",
"the",
"current",
"user",
"s",
"private",
"signing",
"key",
"on",
"behalf",
"of",
"KBFS",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/crypto.go#L65-L89 |
161,582 | keybase/client | go/engine/crypto.go | SignToString | func SignToString(ctx context.Context, g *libkb.GlobalContext, getSecretUI func() libkb.SecretUI, arg keybase1.SignToStringArg) (sig string, err error) {
signingKey, err := GetMySecretKey(ctx, g, getSecretUI, libkb.DeviceSigningKeyType, arg.Reason)
if err != nil {
return
}
kp, ok := signingKey.(libkb.NaclSigningKeyPair)
if !ok || kp.Private == nil {
err = libkb.KeyCannotSignError{}
return
}
sig, _, err = kp.SignToString(arg.Msg)
return
} | go | func SignToString(ctx context.Context, g *libkb.GlobalContext, getSecretUI func() libkb.SecretUI, arg keybase1.SignToStringArg) (sig string, err error) {
signingKey, err := GetMySecretKey(ctx, g, getSecretUI, libkb.DeviceSigningKeyType, arg.Reason)
if err != nil {
return
}
kp, ok := signingKey.(libkb.NaclSigningKeyPair)
if !ok || kp.Private == nil {
err = libkb.KeyCannotSignError{}
return
}
sig, _, err = kp.SignToString(arg.Msg)
return
} | [
"func",
"SignToString",
"(",
"ctx",
"context",
".",
"Context",
",",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"getSecretUI",
"func",
"(",
")",
"libkb",
".",
"SecretUI",
",",
"arg",
"keybase1",
".",
"SignToStringArg",
")",
"(",
"sig",
"string",
",",
"err",
"error",
")",
"{",
"signingKey",
",",
"err",
":=",
"GetMySecretKey",
"(",
"ctx",
",",
"g",
",",
"getSecretUI",
",",
"libkb",
".",
"DeviceSigningKeyType",
",",
"arg",
".",
"Reason",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"kp",
",",
"ok",
":=",
"signingKey",
".",
"(",
"libkb",
".",
"NaclSigningKeyPair",
")",
"\n",
"if",
"!",
"ok",
"||",
"kp",
".",
"Private",
"==",
"nil",
"{",
"err",
"=",
"libkb",
".",
"KeyCannotSignError",
"{",
"}",
"\n",
"return",
"\n",
"}",
"\n\n",
"sig",
",",
"_",
",",
"err",
"=",
"kp",
".",
"SignToString",
"(",
"arg",
".",
"Msg",
")",
"\n",
"return",
"\n",
"}"
] | // SignToString signs the given message with the current user's private
// signing key and outputs the serialized NaclSigInfo string. | [
"SignToString",
"signs",
"the",
"given",
"message",
"with",
"the",
"current",
"user",
"s",
"private",
"signing",
"key",
"and",
"outputs",
"the",
"serialized",
"NaclSigInfo",
"string",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/crypto.go#L93-L107 |
161,583 | keybase/client | go/engine/crypto.go | UnboxBytes32 | func UnboxBytes32(ctx context.Context, g *libkb.GlobalContext, getSecretUI func() libkb.SecretUI, arg keybase1.UnboxBytes32Arg) (bytes32 keybase1.Bytes32, err error) {
encryptionKey, err := GetMySecretKey(ctx, g, getSecretUI, libkb.DeviceEncryptionKeyType, arg.Reason)
if err != nil {
return
}
return unboxBytes32(encryptionKey, arg.EncryptedBytes32, arg.Nonce, arg.PeersPublicKey)
} | go | func UnboxBytes32(ctx context.Context, g *libkb.GlobalContext, getSecretUI func() libkb.SecretUI, arg keybase1.UnboxBytes32Arg) (bytes32 keybase1.Bytes32, err error) {
encryptionKey, err := GetMySecretKey(ctx, g, getSecretUI, libkb.DeviceEncryptionKeyType, arg.Reason)
if err != nil {
return
}
return unboxBytes32(encryptionKey, arg.EncryptedBytes32, arg.Nonce, arg.PeersPublicKey)
} | [
"func",
"UnboxBytes32",
"(",
"ctx",
"context",
".",
"Context",
",",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"getSecretUI",
"func",
"(",
")",
"libkb",
".",
"SecretUI",
",",
"arg",
"keybase1",
".",
"UnboxBytes32Arg",
")",
"(",
"bytes32",
"keybase1",
".",
"Bytes32",
",",
"err",
"error",
")",
"{",
"encryptionKey",
",",
"err",
":=",
"GetMySecretKey",
"(",
"ctx",
",",
"g",
",",
"getSecretUI",
",",
"libkb",
".",
"DeviceEncryptionKeyType",
",",
"arg",
".",
"Reason",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"return",
"unboxBytes32",
"(",
"encryptionKey",
",",
"arg",
".",
"EncryptedBytes32",
",",
"arg",
".",
"Nonce",
",",
"arg",
".",
"PeersPublicKey",
")",
"\n",
"}"
] | // UnboxBytes32 decrypts the given message with the current user's
// private encryption key and the given nonce and peer public key. | [
"UnboxBytes32",
"decrypts",
"the",
"given",
"message",
"with",
"the",
"current",
"user",
"s",
"private",
"encryption",
"key",
"and",
"the",
"given",
"nonce",
"and",
"peer",
"public",
"key",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/crypto.go#L111-L118 |
161,584 | keybase/client | go/engine/crypto.go | matchingCachedKey | func matchingCachedKey(m libkb.MetaContext, arg keybase1.UnboxBytes32AnyArg) (key libkb.GenericKey, index int, err error) {
// check device key first
dkey, err := m.ActiveDevice().EncryptionKey()
if err == nil && dkey != nil {
if n, ok := kidMatch(dkey, arg.Bundles); ok {
return dkey, n, nil
}
}
device := m.ActiveDevice().ProvisioningKey(m)
if device != nil {
pkey := device.EncryptionKey()
if n, ok := kidMatch(pkey, arg.Bundles); ok {
return pkey, n, nil
}
}
return nil, 0, nil
} | go | func matchingCachedKey(m libkb.MetaContext, arg keybase1.UnboxBytes32AnyArg) (key libkb.GenericKey, index int, err error) {
// check device key first
dkey, err := m.ActiveDevice().EncryptionKey()
if err == nil && dkey != nil {
if n, ok := kidMatch(dkey, arg.Bundles); ok {
return dkey, n, nil
}
}
device := m.ActiveDevice().ProvisioningKey(m)
if device != nil {
pkey := device.EncryptionKey()
if n, ok := kidMatch(pkey, arg.Bundles); ok {
return pkey, n, nil
}
}
return nil, 0, nil
} | [
"func",
"matchingCachedKey",
"(",
"m",
"libkb",
".",
"MetaContext",
",",
"arg",
"keybase1",
".",
"UnboxBytes32AnyArg",
")",
"(",
"key",
"libkb",
".",
"GenericKey",
",",
"index",
"int",
",",
"err",
"error",
")",
"{",
"// check device key first",
"dkey",
",",
"err",
":=",
"m",
".",
"ActiveDevice",
"(",
")",
".",
"EncryptionKey",
"(",
")",
"\n",
"if",
"err",
"==",
"nil",
"&&",
"dkey",
"!=",
"nil",
"{",
"if",
"n",
",",
"ok",
":=",
"kidMatch",
"(",
"dkey",
",",
"arg",
".",
"Bundles",
")",
";",
"ok",
"{",
"return",
"dkey",
",",
"n",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n\n",
"device",
":=",
"m",
".",
"ActiveDevice",
"(",
")",
".",
"ProvisioningKey",
"(",
"m",
")",
"\n",
"if",
"device",
"!=",
"nil",
"{",
"pkey",
":=",
"device",
".",
"EncryptionKey",
"(",
")",
"\n",
"if",
"n",
",",
"ok",
":=",
"kidMatch",
"(",
"pkey",
",",
"arg",
".",
"Bundles",
")",
";",
"ok",
"{",
"return",
"pkey",
",",
"n",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
",",
"0",
",",
"nil",
"\n",
"}"
] | // check cached keys for arg.Bundles match. | [
"check",
"cached",
"keys",
"for",
"arg",
".",
"Bundles",
"match",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/crypto.go#L239-L256 |
161,585 | keybase/client | go/engine/crypto.go | matchingDeviceKey | func matchingDeviceKey(m libkb.MetaContext, secretUI libkb.SecretUI, arg keybase1.UnboxBytes32AnyArg, me *libkb.User) (key libkb.GenericKey, index int, err error) {
ekey, err := me.GetDeviceSubkey()
if err == nil {
if n, ok := kidMatch(ekey, arg.Bundles); ok {
// unlock this key
parg := libkb.SecretKeyPromptArg{
Ska: libkb.SecretKeyArg{
Me: me,
KeyType: libkb.DeviceEncryptionKeyType,
},
SecretUI: secretUI,
Reason: arg.Reason,
UseCancelCache: true,
}
key, err := m.G().Keyrings.GetSecretKeyWithPrompt(m, parg)
if err != nil {
return nil, 0, err
}
return key, n, nil
}
m.Debug("matchingDeviceKey: no match found for ekey in arg.Bundles")
logNoMatch(m, ekey, arg.Bundles)
} else {
m.Debug("matchingDeviceKey: ignoring error getting device subkey: %s", err)
}
return nil, 0, nil
} | go | func matchingDeviceKey(m libkb.MetaContext, secretUI libkb.SecretUI, arg keybase1.UnboxBytes32AnyArg, me *libkb.User) (key libkb.GenericKey, index int, err error) {
ekey, err := me.GetDeviceSubkey()
if err == nil {
if n, ok := kidMatch(ekey, arg.Bundles); ok {
// unlock this key
parg := libkb.SecretKeyPromptArg{
Ska: libkb.SecretKeyArg{
Me: me,
KeyType: libkb.DeviceEncryptionKeyType,
},
SecretUI: secretUI,
Reason: arg.Reason,
UseCancelCache: true,
}
key, err := m.G().Keyrings.GetSecretKeyWithPrompt(m, parg)
if err != nil {
return nil, 0, err
}
return key, n, nil
}
m.Debug("matchingDeviceKey: no match found for ekey in arg.Bundles")
logNoMatch(m, ekey, arg.Bundles)
} else {
m.Debug("matchingDeviceKey: ignoring error getting device subkey: %s", err)
}
return nil, 0, nil
} | [
"func",
"matchingDeviceKey",
"(",
"m",
"libkb",
".",
"MetaContext",
",",
"secretUI",
"libkb",
".",
"SecretUI",
",",
"arg",
"keybase1",
".",
"UnboxBytes32AnyArg",
",",
"me",
"*",
"libkb",
".",
"User",
")",
"(",
"key",
"libkb",
".",
"GenericKey",
",",
"index",
"int",
",",
"err",
"error",
")",
"{",
"ekey",
",",
"err",
":=",
"me",
".",
"GetDeviceSubkey",
"(",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"if",
"n",
",",
"ok",
":=",
"kidMatch",
"(",
"ekey",
",",
"arg",
".",
"Bundles",
")",
";",
"ok",
"{",
"// unlock this key",
"parg",
":=",
"libkb",
".",
"SecretKeyPromptArg",
"{",
"Ska",
":",
"libkb",
".",
"SecretKeyArg",
"{",
"Me",
":",
"me",
",",
"KeyType",
":",
"libkb",
".",
"DeviceEncryptionKeyType",
",",
"}",
",",
"SecretUI",
":",
"secretUI",
",",
"Reason",
":",
"arg",
".",
"Reason",
",",
"UseCancelCache",
":",
"true",
",",
"}",
"\n",
"key",
",",
"err",
":=",
"m",
".",
"G",
"(",
")",
".",
"Keyrings",
".",
"GetSecretKeyWithPrompt",
"(",
"m",
",",
"parg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"0",
",",
"err",
"\n",
"}",
"\n",
"return",
"key",
",",
"n",
",",
"nil",
"\n",
"}",
"\n\n",
"m",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"logNoMatch",
"(",
"m",
",",
"ekey",
",",
"arg",
".",
"Bundles",
")",
"\n",
"}",
"else",
"{",
"m",
".",
"Debug",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
",",
"0",
",",
"nil",
"\n",
"}"
] | // check device key for arg.Bundles match. | [
"check",
"device",
"key",
"for",
"arg",
".",
"Bundles",
"match",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/crypto.go#L259-L287 |
161,586 | keybase/client | go/engine/crypto.go | matchingPaperKey | func matchingPaperKey(m libkb.MetaContext, secretUI libkb.SecretUI, arg keybase1.UnboxBytes32AnyArg, me *libkb.User) (key libkb.GenericKey, index int, err error) {
cki := me.GetComputedKeyInfos()
if cki == nil {
return nil, 0, nil
}
var matchingPaper []*libkb.Device
for _, pdev := range cki.PaperDevices() {
enckey, err := me.GetComputedKeyFamily().GetEncryptionSubkeyForDevice(pdev.ID)
if err != nil {
return nil, 0, err
}
if _, ok := kidMatch(enckey, arg.Bundles); ok {
m.Debug("matching paper key: %s", *pdev.Description)
matchingPaper = append(matchingPaper, pdev)
}
}
if len(matchingPaper) == 0 {
m.Debug("no matching paper keys found")
return nil, 0, nil
}
phrase, err := libkb.GetPaperKeyForCryptoPassphrase(m, secretUI, arg.Reason, matchingPaper)
if err != nil {
return nil, 0, err
}
paperPhrase, err := libkb.NewPaperKeyPhraseCheckVersion(m, phrase)
if err != nil {
return nil, 0, err
}
bkarg := &PaperKeyGenArg{
Passphrase: paperPhrase,
SkipPush: true,
}
bkeng := NewPaperKeyGen(m.G(), bkarg)
if err := RunEngine2(m, bkeng); err != nil {
return nil, 0, err
}
// find the index for the key they entered (and make sure the key they entered matches)
if n, ok := kidMatch(bkeng.EncKey(), arg.Bundles); ok {
m.ActiveDevice().CacheProvisioningKey(m, bkeng.DeviceWithKeys())
return bkeng.EncKey(), n, nil
}
return nil, 0, nil
} | go | func matchingPaperKey(m libkb.MetaContext, secretUI libkb.SecretUI, arg keybase1.UnboxBytes32AnyArg, me *libkb.User) (key libkb.GenericKey, index int, err error) {
cki := me.GetComputedKeyInfos()
if cki == nil {
return nil, 0, nil
}
var matchingPaper []*libkb.Device
for _, pdev := range cki.PaperDevices() {
enckey, err := me.GetComputedKeyFamily().GetEncryptionSubkeyForDevice(pdev.ID)
if err != nil {
return nil, 0, err
}
if _, ok := kidMatch(enckey, arg.Bundles); ok {
m.Debug("matching paper key: %s", *pdev.Description)
matchingPaper = append(matchingPaper, pdev)
}
}
if len(matchingPaper) == 0 {
m.Debug("no matching paper keys found")
return nil, 0, nil
}
phrase, err := libkb.GetPaperKeyForCryptoPassphrase(m, secretUI, arg.Reason, matchingPaper)
if err != nil {
return nil, 0, err
}
paperPhrase, err := libkb.NewPaperKeyPhraseCheckVersion(m, phrase)
if err != nil {
return nil, 0, err
}
bkarg := &PaperKeyGenArg{
Passphrase: paperPhrase,
SkipPush: true,
}
bkeng := NewPaperKeyGen(m.G(), bkarg)
if err := RunEngine2(m, bkeng); err != nil {
return nil, 0, err
}
// find the index for the key they entered (and make sure the key they entered matches)
if n, ok := kidMatch(bkeng.EncKey(), arg.Bundles); ok {
m.ActiveDevice().CacheProvisioningKey(m, bkeng.DeviceWithKeys())
return bkeng.EncKey(), n, nil
}
return nil, 0, nil
} | [
"func",
"matchingPaperKey",
"(",
"m",
"libkb",
".",
"MetaContext",
",",
"secretUI",
"libkb",
".",
"SecretUI",
",",
"arg",
"keybase1",
".",
"UnboxBytes32AnyArg",
",",
"me",
"*",
"libkb",
".",
"User",
")",
"(",
"key",
"libkb",
".",
"GenericKey",
",",
"index",
"int",
",",
"err",
"error",
")",
"{",
"cki",
":=",
"me",
".",
"GetComputedKeyInfos",
"(",
")",
"\n",
"if",
"cki",
"==",
"nil",
"{",
"return",
"nil",
",",
"0",
",",
"nil",
"\n",
"}",
"\n",
"var",
"matchingPaper",
"[",
"]",
"*",
"libkb",
".",
"Device",
"\n",
"for",
"_",
",",
"pdev",
":=",
"range",
"cki",
".",
"PaperDevices",
"(",
")",
"{",
"enckey",
",",
"err",
":=",
"me",
".",
"GetComputedKeyFamily",
"(",
")",
".",
"GetEncryptionSubkeyForDevice",
"(",
"pdev",
".",
"ID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"0",
",",
"err",
"\n",
"}",
"\n",
"if",
"_",
",",
"ok",
":=",
"kidMatch",
"(",
"enckey",
",",
"arg",
".",
"Bundles",
")",
";",
"ok",
"{",
"m",
".",
"Debug",
"(",
"\"",
"\"",
",",
"*",
"pdev",
".",
"Description",
")",
"\n",
"matchingPaper",
"=",
"append",
"(",
"matchingPaper",
",",
"pdev",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"len",
"(",
"matchingPaper",
")",
"==",
"0",
"{",
"m",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
",",
"0",
",",
"nil",
"\n",
"}",
"\n\n",
"phrase",
",",
"err",
":=",
"libkb",
".",
"GetPaperKeyForCryptoPassphrase",
"(",
"m",
",",
"secretUI",
",",
"arg",
".",
"Reason",
",",
"matchingPaper",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"0",
",",
"err",
"\n",
"}",
"\n",
"paperPhrase",
",",
"err",
":=",
"libkb",
".",
"NewPaperKeyPhraseCheckVersion",
"(",
"m",
",",
"phrase",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"0",
",",
"err",
"\n",
"}",
"\n\n",
"bkarg",
":=",
"&",
"PaperKeyGenArg",
"{",
"Passphrase",
":",
"paperPhrase",
",",
"SkipPush",
":",
"true",
",",
"}",
"\n",
"bkeng",
":=",
"NewPaperKeyGen",
"(",
"m",
".",
"G",
"(",
")",
",",
"bkarg",
")",
"\n",
"if",
"err",
":=",
"RunEngine2",
"(",
"m",
",",
"bkeng",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"0",
",",
"err",
"\n",
"}",
"\n\n",
"// find the index for the key they entered (and make sure the key they entered matches)",
"if",
"n",
",",
"ok",
":=",
"kidMatch",
"(",
"bkeng",
".",
"EncKey",
"(",
")",
",",
"arg",
".",
"Bundles",
")",
";",
"ok",
"{",
"m",
".",
"ActiveDevice",
"(",
")",
".",
"CacheProvisioningKey",
"(",
"m",
",",
"bkeng",
".",
"DeviceWithKeys",
"(",
")",
")",
"\n",
"return",
"bkeng",
".",
"EncKey",
"(",
")",
",",
"n",
",",
"nil",
"\n",
"}",
"\n\n",
"return",
"nil",
",",
"0",
",",
"nil",
"\n",
"}"
] | // check all the user's paper keys for arg.Bundles match | [
"check",
"all",
"the",
"user",
"s",
"paper",
"keys",
"for",
"arg",
".",
"Bundles",
"match"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/crypto.go#L290-L336 |
161,587 | keybase/client | go/git/crypto.go | NewCrypto | func NewCrypto(g *libkb.GlobalContext) *Crypto {
return &Crypto{
Contextified: libkb.NewContextified(g),
}
} | go | func NewCrypto(g *libkb.GlobalContext) *Crypto {
return &Crypto{
Contextified: libkb.NewContextified(g),
}
} | [
"func",
"NewCrypto",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
")",
"*",
"Crypto",
"{",
"return",
"&",
"Crypto",
"{",
"Contextified",
":",
"libkb",
".",
"NewContextified",
"(",
"g",
")",
",",
"}",
"\n",
"}"
] | // NewCrypto returns a Crypto object. | [
"NewCrypto",
"returns",
"a",
"Crypto",
"object",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/git/crypto.go#L34-L38 |
161,588 | keybase/client | go/git/crypto.go | Box | func (c *Crypto) Box(ctx context.Context, plaintext []byte, teamSpec keybase1.TeamIDWithVisibility) (*keybase1.EncryptedGitMetadata, error) {
team, err := c.loadTeam(ctx, teamSpec, 0)
if err != nil {
return nil, err
}
public := teamSpec.Visibility == keybase1.TLFVisibility_PUBLIC
key := publicCryptKey
if !public {
key, err = team.GitMetadataKey(ctx)
if err != nil {
return nil, err
}
}
nonce, err := libkb.RandomNaclDHNonce()
if err != nil {
return nil, err
}
var encKey [libkb.NaclSecretBoxKeySize]byte = key.Key
sealed := secretbox.Seal(nil, plaintext, &nonce, &encKey)
return &keybase1.EncryptedGitMetadata{
V: libkb.CurrentGitMetadataEncryptionVersion,
E: sealed,
N: nonce,
Gen: key.KeyGeneration,
}, nil
} | go | func (c *Crypto) Box(ctx context.Context, plaintext []byte, teamSpec keybase1.TeamIDWithVisibility) (*keybase1.EncryptedGitMetadata, error) {
team, err := c.loadTeam(ctx, teamSpec, 0)
if err != nil {
return nil, err
}
public := teamSpec.Visibility == keybase1.TLFVisibility_PUBLIC
key := publicCryptKey
if !public {
key, err = team.GitMetadataKey(ctx)
if err != nil {
return nil, err
}
}
nonce, err := libkb.RandomNaclDHNonce()
if err != nil {
return nil, err
}
var encKey [libkb.NaclSecretBoxKeySize]byte = key.Key
sealed := secretbox.Seal(nil, plaintext, &nonce, &encKey)
return &keybase1.EncryptedGitMetadata{
V: libkb.CurrentGitMetadataEncryptionVersion,
E: sealed,
N: nonce,
Gen: key.KeyGeneration,
}, nil
} | [
"func",
"(",
"c",
"*",
"Crypto",
")",
"Box",
"(",
"ctx",
"context",
".",
"Context",
",",
"plaintext",
"[",
"]",
"byte",
",",
"teamSpec",
"keybase1",
".",
"TeamIDWithVisibility",
")",
"(",
"*",
"keybase1",
".",
"EncryptedGitMetadata",
",",
"error",
")",
"{",
"team",
",",
"err",
":=",
"c",
".",
"loadTeam",
"(",
"ctx",
",",
"teamSpec",
",",
"0",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"public",
":=",
"teamSpec",
".",
"Visibility",
"==",
"keybase1",
".",
"TLFVisibility_PUBLIC",
"\n\n",
"key",
":=",
"publicCryptKey",
"\n",
"if",
"!",
"public",
"{",
"key",
",",
"err",
"=",
"team",
".",
"GitMetadataKey",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"nonce",
",",
"err",
":=",
"libkb",
".",
"RandomNaclDHNonce",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"encKey",
"[",
"libkb",
".",
"NaclSecretBoxKeySize",
"]",
"byte",
"=",
"key",
".",
"Key",
"\n",
"sealed",
":=",
"secretbox",
".",
"Seal",
"(",
"nil",
",",
"plaintext",
",",
"&",
"nonce",
",",
"&",
"encKey",
")",
"\n\n",
"return",
"&",
"keybase1",
".",
"EncryptedGitMetadata",
"{",
"V",
":",
"libkb",
".",
"CurrentGitMetadataEncryptionVersion",
",",
"E",
":",
"sealed",
",",
"N",
":",
"nonce",
",",
"Gen",
":",
"key",
".",
"KeyGeneration",
",",
"}",
",",
"nil",
"\n",
"}"
] | // Box encrypts the plaintext with the most current key for the given team. It yields a NaCl
// ciphertext and nonce, and also says which generation of the key it used. | [
"Box",
"encrypts",
"the",
"plaintext",
"with",
"the",
"most",
"current",
"key",
"for",
"the",
"given",
"team",
".",
"It",
"yields",
"a",
"NaCl",
"ciphertext",
"and",
"nonce",
"and",
"also",
"says",
"which",
"generation",
"of",
"the",
"key",
"it",
"used",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/git/crypto.go#L42-L72 |
161,589 | keybase/client | go/git/crypto.go | Unbox | func (c *Crypto) Unbox(ctx context.Context, teamSpec keybase1.TeamIDWithVisibility, metadata *keybase1.EncryptedGitMetadata) (plaintext []byte, err error) {
defer c.G().CTrace(ctx, fmt.Sprintf("git.Crypto#Unbox(%s, vis:%v)", teamSpec.TeamID, teamSpec.Visibility), func() error { return err })()
if metadata.V != 1 {
return nil, fmt.Errorf("invalid EncryptedGitMetadata version: %d", metadata.V)
}
public := teamSpec.Visibility == keybase1.TLFVisibility_PUBLIC
var needKeyGeneration keybase1.PerTeamKeyGeneration
if !public {
needKeyGeneration = metadata.Gen
}
team, err := c.loadTeam(ctx, teamSpec, needKeyGeneration)
if err != nil {
return nil, err
}
key := publicCryptKey
if !public {
key, err = team.ApplicationKeyAtGeneration(ctx, keybase1.TeamApplication_GIT_METADATA, metadata.Gen)
if err != nil {
return nil, err
}
}
var encKey [libkb.NaclSecretBoxKeySize]byte = key.Key
var naclNonce [libkb.NaclDHNonceSize]byte = metadata.N
plaintext, ok := secretbox.Open(nil, metadata.E, &naclNonce, &encKey)
if !ok {
return nil, libkb.DecryptOpenError{}
}
return plaintext, nil
} | go | func (c *Crypto) Unbox(ctx context.Context, teamSpec keybase1.TeamIDWithVisibility, metadata *keybase1.EncryptedGitMetadata) (plaintext []byte, err error) {
defer c.G().CTrace(ctx, fmt.Sprintf("git.Crypto#Unbox(%s, vis:%v)", teamSpec.TeamID, teamSpec.Visibility), func() error { return err })()
if metadata.V != 1 {
return nil, fmt.Errorf("invalid EncryptedGitMetadata version: %d", metadata.V)
}
public := teamSpec.Visibility == keybase1.TLFVisibility_PUBLIC
var needKeyGeneration keybase1.PerTeamKeyGeneration
if !public {
needKeyGeneration = metadata.Gen
}
team, err := c.loadTeam(ctx, teamSpec, needKeyGeneration)
if err != nil {
return nil, err
}
key := publicCryptKey
if !public {
key, err = team.ApplicationKeyAtGeneration(ctx, keybase1.TeamApplication_GIT_METADATA, metadata.Gen)
if err != nil {
return nil, err
}
}
var encKey [libkb.NaclSecretBoxKeySize]byte = key.Key
var naclNonce [libkb.NaclDHNonceSize]byte = metadata.N
plaintext, ok := secretbox.Open(nil, metadata.E, &naclNonce, &encKey)
if !ok {
return nil, libkb.DecryptOpenError{}
}
return plaintext, nil
} | [
"func",
"(",
"c",
"*",
"Crypto",
")",
"Unbox",
"(",
"ctx",
"context",
".",
"Context",
",",
"teamSpec",
"keybase1",
".",
"TeamIDWithVisibility",
",",
"metadata",
"*",
"keybase1",
".",
"EncryptedGitMetadata",
")",
"(",
"plaintext",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"defer",
"c",
".",
"G",
"(",
")",
".",
"CTrace",
"(",
"ctx",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"teamSpec",
".",
"TeamID",
",",
"teamSpec",
".",
"Visibility",
")",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
")",
"(",
")",
"\n\n",
"if",
"metadata",
".",
"V",
"!=",
"1",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"metadata",
".",
"V",
")",
"\n",
"}",
"\n\n",
"public",
":=",
"teamSpec",
".",
"Visibility",
"==",
"keybase1",
".",
"TLFVisibility_PUBLIC",
"\n\n",
"var",
"needKeyGeneration",
"keybase1",
".",
"PerTeamKeyGeneration",
"\n",
"if",
"!",
"public",
"{",
"needKeyGeneration",
"=",
"metadata",
".",
"Gen",
"\n",
"}",
"\n",
"team",
",",
"err",
":=",
"c",
".",
"loadTeam",
"(",
"ctx",
",",
"teamSpec",
",",
"needKeyGeneration",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"key",
":=",
"publicCryptKey",
"\n",
"if",
"!",
"public",
"{",
"key",
",",
"err",
"=",
"team",
".",
"ApplicationKeyAtGeneration",
"(",
"ctx",
",",
"keybase1",
".",
"TeamApplication_GIT_METADATA",
",",
"metadata",
".",
"Gen",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"var",
"encKey",
"[",
"libkb",
".",
"NaclSecretBoxKeySize",
"]",
"byte",
"=",
"key",
".",
"Key",
"\n",
"var",
"naclNonce",
"[",
"libkb",
".",
"NaclDHNonceSize",
"]",
"byte",
"=",
"metadata",
".",
"N",
"\n\n",
"plaintext",
",",
"ok",
":=",
"secretbox",
".",
"Open",
"(",
"nil",
",",
"metadata",
".",
"E",
",",
"&",
"naclNonce",
",",
"&",
"encKey",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"libkb",
".",
"DecryptOpenError",
"{",
"}",
"\n",
"}",
"\n",
"return",
"plaintext",
",",
"nil",
"\n",
"}"
] | // Unbox decrypts the given ciphertext with the given nonce, for the given generation of the
// given team. Can return an error. Will return a non-nil plaintext on success. | [
"Unbox",
"decrypts",
"the",
"given",
"ciphertext",
"with",
"the",
"given",
"nonce",
"for",
"the",
"given",
"generation",
"of",
"the",
"given",
"team",
".",
"Can",
"return",
"an",
"error",
".",
"Will",
"return",
"a",
"non",
"-",
"nil",
"plaintext",
"on",
"success",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/git/crypto.go#L76-L110 |
161,590 | keybase/client | go/engine/background_task.go | NewBackgroundTask | func NewBackgroundTask(g *libkb.GlobalContext, args *BackgroundTaskArgs) *BackgroundTask {
return &BackgroundTask{
Contextified: libkb.NewContextified(g),
args: args,
shutdownFunc: nil,
}
} | go | func NewBackgroundTask(g *libkb.GlobalContext, args *BackgroundTaskArgs) *BackgroundTask {
return &BackgroundTask{
Contextified: libkb.NewContextified(g),
args: args,
shutdownFunc: nil,
}
} | [
"func",
"NewBackgroundTask",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"args",
"*",
"BackgroundTaskArgs",
")",
"*",
"BackgroundTask",
"{",
"return",
"&",
"BackgroundTask",
"{",
"Contextified",
":",
"libkb",
".",
"NewContextified",
"(",
"g",
")",
",",
"args",
":",
"args",
",",
"shutdownFunc",
":",
"nil",
",",
"}",
"\n",
"}"
] | // NewBackgroundTask creates a BackgroundTask engine. | [
"NewBackgroundTask",
"creates",
"a",
"BackgroundTask",
"engine",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/background_task.go#L60-L66 |
161,591 | keybase/client | go/engine/background_task.go | Name | func (e *BackgroundTask) Name() string {
if e.args != nil {
return fmt.Sprintf("BackgroundTask(%v)", e.args.Name)
}
return "BackgroundTask"
} | go | func (e *BackgroundTask) Name() string {
if e.args != nil {
return fmt.Sprintf("BackgroundTask(%v)", e.args.Name)
}
return "BackgroundTask"
} | [
"func",
"(",
"e",
"*",
"BackgroundTask",
")",
"Name",
"(",
")",
"string",
"{",
"if",
"e",
".",
"args",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"args",
".",
"Name",
")",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] | // Name is the unique engine name. | [
"Name",
"is",
"the",
"unique",
"engine",
"name",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/background_task.go#L69-L74 |
161,592 | keybase/client | go/kbfs/kbfsmd/branch_id.go | MarshalBinary | func (id BranchID) MarshalBinary() (data []byte, err error) {
return id.id[:], nil
} | go | func (id BranchID) MarshalBinary() (data []byte, err error) {
return id.id[:], nil
} | [
"func",
"(",
"id",
"BranchID",
")",
"MarshalBinary",
"(",
")",
"(",
"data",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"return",
"id",
".",
"id",
"[",
":",
"]",
",",
"nil",
"\n",
"}"
] | // MarshalBinary implements the encoding.BinaryMarshaler interface for BranchID. | [
"MarshalBinary",
"implements",
"the",
"encoding",
".",
"BinaryMarshaler",
"interface",
"for",
"BranchID",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/branch_id.go#L50-L52 |
161,593 | keybase/client | go/kbfs/kbfsmd/branch_id.go | UnmarshalBinary | func (id *BranchID) UnmarshalBinary(data []byte) error {
if len(data) != BranchIDByteLen {
return errors.New("invalid BranchID")
}
copy(id.id[:], data)
return nil
} | go | func (id *BranchID) UnmarshalBinary(data []byte) error {
if len(data) != BranchIDByteLen {
return errors.New("invalid BranchID")
}
copy(id.id[:], data)
return nil
} | [
"func",
"(",
"id",
"*",
"BranchID",
")",
"UnmarshalBinary",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"len",
"(",
"data",
")",
"!=",
"BranchIDByteLen",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"copy",
"(",
"id",
".",
"id",
"[",
":",
"]",
",",
"data",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
// for BranchID. | [
"UnmarshalBinary",
"implements",
"the",
"encoding",
".",
"BinaryUnmarshaler",
"interface",
"for",
"BranchID",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/branch_id.go#L56-L62 |
161,594 | keybase/client | go/kbfs/kbfsmd/branch_id.go | ParseBranchID | func ParseBranchID(s string) (BranchID, error) {
if len(s) != BranchIDStringLen {
return NullBranchID, InvalidBranchID{s}
}
bytes, err := hex.DecodeString(s)
if err != nil {
return NullBranchID, InvalidBranchID{s}
}
var id BranchID
err = id.UnmarshalBinary(bytes)
if err != nil {
return NullBranchID, InvalidBranchID{s}
}
return id, nil
} | go | func ParseBranchID(s string) (BranchID, error) {
if len(s) != BranchIDStringLen {
return NullBranchID, InvalidBranchID{s}
}
bytes, err := hex.DecodeString(s)
if err != nil {
return NullBranchID, InvalidBranchID{s}
}
var id BranchID
err = id.UnmarshalBinary(bytes)
if err != nil {
return NullBranchID, InvalidBranchID{s}
}
return id, nil
} | [
"func",
"ParseBranchID",
"(",
"s",
"string",
")",
"(",
"BranchID",
",",
"error",
")",
"{",
"if",
"len",
"(",
"s",
")",
"!=",
"BranchIDStringLen",
"{",
"return",
"NullBranchID",
",",
"InvalidBranchID",
"{",
"s",
"}",
"\n",
"}",
"\n",
"bytes",
",",
"err",
":=",
"hex",
".",
"DecodeString",
"(",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"NullBranchID",
",",
"InvalidBranchID",
"{",
"s",
"}",
"\n",
"}",
"\n",
"var",
"id",
"BranchID",
"\n",
"err",
"=",
"id",
".",
"UnmarshalBinary",
"(",
"bytes",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"NullBranchID",
",",
"InvalidBranchID",
"{",
"s",
"}",
"\n",
"}",
"\n",
"return",
"id",
",",
"nil",
"\n",
"}"
] | // ParseBranchID parses a hex encoded BranchID. Returns NullBranchID
// and an InvalidBranchID on falire. | [
"ParseBranchID",
"parses",
"a",
"hex",
"encoded",
"BranchID",
".",
"Returns",
"NullBranchID",
"and",
"an",
"InvalidBranchID",
"on",
"falire",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/branch_id.go#L66-L80 |
161,595 | keybase/client | go/kbfs/kbfsmd/branch_id.go | MakeRandomBranchID | func MakeRandomBranchID() (BranchID, error) {
var id BranchID
// Loop just in case we randomly pick the null or local squash
// branch IDs.
for id == NullBranchID || id == PendingLocalSquashBranchID {
err := kbfscrypto.RandRead(id.id[:])
if err != nil {
return BranchID{}, err
}
}
return id, nil
} | go | func MakeRandomBranchID() (BranchID, error) {
var id BranchID
// Loop just in case we randomly pick the null or local squash
// branch IDs.
for id == NullBranchID || id == PendingLocalSquashBranchID {
err := kbfscrypto.RandRead(id.id[:])
if err != nil {
return BranchID{}, err
}
}
return id, nil
} | [
"func",
"MakeRandomBranchID",
"(",
")",
"(",
"BranchID",
",",
"error",
")",
"{",
"var",
"id",
"BranchID",
"\n",
"// Loop just in case we randomly pick the null or local squash",
"// branch IDs.",
"for",
"id",
"==",
"NullBranchID",
"||",
"id",
"==",
"PendingLocalSquashBranchID",
"{",
"err",
":=",
"kbfscrypto",
".",
"RandRead",
"(",
"id",
".",
"id",
"[",
":",
"]",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"BranchID",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"id",
",",
"nil",
"\n",
"}"
] | // MakeRandomBranchID generates a per-device branch ID using a CSPRNG.
// It will not return LocalSquashBranchID or NullBranchID. | [
"MakeRandomBranchID",
"generates",
"a",
"per",
"-",
"device",
"branch",
"ID",
"using",
"a",
"CSPRNG",
".",
"It",
"will",
"not",
"return",
"LocalSquashBranchID",
"or",
"NullBranchID",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/branch_id.go#L84-L95 |
161,596 | keybase/client | go/kbfs/kbfsmd/branch_id.go | FakeBranchID | func FakeBranchID(b byte) BranchID {
bytes := [BranchIDByteLen]byte{b}
return BranchID{bytes}
} | go | func FakeBranchID(b byte) BranchID {
bytes := [BranchIDByteLen]byte{b}
return BranchID{bytes}
} | [
"func",
"FakeBranchID",
"(",
"b",
"byte",
")",
"BranchID",
"{",
"bytes",
":=",
"[",
"BranchIDByteLen",
"]",
"byte",
"{",
"b",
"}",
"\n",
"return",
"BranchID",
"{",
"bytes",
"}",
"\n",
"}"
] | // FakeBranchID creates a fake branch ID from the given byte. | [
"FakeBranchID",
"creates",
"a",
"fake",
"branch",
"ID",
"from",
"the",
"given",
"byte",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/branch_id.go#L98-L101 |
161,597 | keybase/client | go/libkb/apiarg.go | NewRetryAPIArg | func NewRetryAPIArg(endpoint string) APIArg {
return APIArg{
Endpoint: endpoint,
InitialTimeout: HTTPRetryInitialTimeout,
RetryMultiplier: HTTPRetryMutliplier,
RetryCount: HTTPRetryCount,
}
} | go | func NewRetryAPIArg(endpoint string) APIArg {
return APIArg{
Endpoint: endpoint,
InitialTimeout: HTTPRetryInitialTimeout,
RetryMultiplier: HTTPRetryMutliplier,
RetryCount: HTTPRetryCount,
}
} | [
"func",
"NewRetryAPIArg",
"(",
"endpoint",
"string",
")",
"APIArg",
"{",
"return",
"APIArg",
"{",
"Endpoint",
":",
"endpoint",
",",
"InitialTimeout",
":",
"HTTPRetryInitialTimeout",
",",
"RetryMultiplier",
":",
"HTTPRetryMutliplier",
",",
"RetryCount",
":",
"HTTPRetryCount",
",",
"}",
"\n",
"}"
] | // NewRetryAPIArg creates an APIArg that will cause the http client
// to use a much smaller request timeout, but retry the request
// several times, backing off on the timeout each time. | [
"NewRetryAPIArg",
"creates",
"an",
"APIArg",
"that",
"will",
"cause",
"the",
"http",
"client",
"to",
"use",
"a",
"much",
"smaller",
"request",
"timeout",
"but",
"retry",
"the",
"request",
"several",
"times",
"backing",
"off",
"on",
"the",
"timeout",
"each",
"time",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/apiarg.go#L40-L47 |
161,598 | keybase/client | go/stellar/remote/remote.go | ShouldCreate | func ShouldCreate(ctx context.Context, g *libkb.GlobalContext) (res ShouldCreateResult, err error) {
mctx := libkb.NewMetaContext(ctx, g)
defer mctx.TraceTimed("Stellar.ShouldCreate", func() error { return err })()
defer func() {
mctx.Debug("Stellar.ShouldCreate: (res:%+v, err:%v)", res, err != nil)
}()
arg := libkb.NewAPIArg("stellar/shouldcreate")
arg.RetryCount = 3
arg.SessionType = libkb.APISessionTypeREQUIRED
var apiRes shouldCreateRes
err = mctx.G().API.GetDecode(mctx, arg, &apiRes)
return apiRes.ShouldCreateResult, err
} | go | func ShouldCreate(ctx context.Context, g *libkb.GlobalContext) (res ShouldCreateResult, err error) {
mctx := libkb.NewMetaContext(ctx, g)
defer mctx.TraceTimed("Stellar.ShouldCreate", func() error { return err })()
defer func() {
mctx.Debug("Stellar.ShouldCreate: (res:%+v, err:%v)", res, err != nil)
}()
arg := libkb.NewAPIArg("stellar/shouldcreate")
arg.RetryCount = 3
arg.SessionType = libkb.APISessionTypeREQUIRED
var apiRes shouldCreateRes
err = mctx.G().API.GetDecode(mctx, arg, &apiRes)
return apiRes.ShouldCreateResult, err
} | [
"func",
"ShouldCreate",
"(",
"ctx",
"context",
".",
"Context",
",",
"g",
"*",
"libkb",
".",
"GlobalContext",
")",
"(",
"res",
"ShouldCreateResult",
",",
"err",
"error",
")",
"{",
"mctx",
":=",
"libkb",
".",
"NewMetaContext",
"(",
"ctx",
",",
"g",
")",
"\n",
"defer",
"mctx",
".",
"TraceTimed",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
")",
"(",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"mctx",
".",
"Debug",
"(",
"\"",
"\"",
",",
"res",
",",
"err",
"!=",
"nil",
")",
"\n",
"}",
"(",
")",
"\n",
"arg",
":=",
"libkb",
".",
"NewAPIArg",
"(",
"\"",
"\"",
")",
"\n",
"arg",
".",
"RetryCount",
"=",
"3",
"\n",
"arg",
".",
"SessionType",
"=",
"libkb",
".",
"APISessionTypeREQUIRED",
"\n",
"var",
"apiRes",
"shouldCreateRes",
"\n",
"err",
"=",
"mctx",
".",
"G",
"(",
")",
".",
"API",
".",
"GetDecode",
"(",
"mctx",
",",
"arg",
",",
"&",
"apiRes",
")",
"\n",
"return",
"apiRes",
".",
"ShouldCreateResult",
",",
"err",
"\n",
"}"
] | // ShouldCreate asks the server whether to create this user's initial wallet. | [
"ShouldCreate",
"asks",
"the",
"server",
"whether",
"to",
"create",
"this",
"user",
"s",
"initial",
"wallet",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/remote/remote.go#L32-L44 |
161,599 | keybase/client | go/stellar/remote/remote.go | PostWithChainlink | func PostWithChainlink(mctx libkb.MetaContext, clearBundle stellar1.Bundle) (err error) {
defer mctx.TraceTimed("Stellar.PostWithChainlink", func() error { return err })()
uid := mctx.G().ActiveDevice.UID()
if uid.IsNil() {
return libkb.NoUIDError{}
}
mctx.Debug("Stellar.PostWithChainLink: load self")
loadMeArg := libkb.NewLoadUserArg(mctx.G()).
WithNetContext(mctx.Ctx()).
WithUID(uid).
WithSelf(true).
WithPublicKeyOptional()
me, err := libkb.LoadUser(loadMeArg)
if err != nil {
return err
}
deviceSigKey, err := mctx.G().ActiveDevice.SigningKey()
if err != nil {
return fmt.Errorf("signing key not found: (%v)", err)
}
pukGen, pukSeed, err := getLatestPuk(mctx.Ctx(), mctx.G())
if err != nil {
return err
}
payload, seqno, linkID, err := buildChainLinkPayload(mctx, clearBundle, me, pukGen, pukSeed, deviceSigKey)
if err != nil {
return err
}
mctx.Debug("Stellar.PostWithChainLink: post")
_, err = mctx.G().API.PostJSON(mctx, libkb.APIArg{
Endpoint: "key/multi",
SessionType: libkb.APISessionTypeREQUIRED,
JSONPayload: *payload,
})
if err != nil {
return err
}
if err = libkb.MerkleCheckPostedUserSig(mctx, uid, seqno, linkID); err != nil {
return err
}
mctx.G().UserChanged(mctx.Ctx(), uid)
return nil
} | go | func PostWithChainlink(mctx libkb.MetaContext, clearBundle stellar1.Bundle) (err error) {
defer mctx.TraceTimed("Stellar.PostWithChainlink", func() error { return err })()
uid := mctx.G().ActiveDevice.UID()
if uid.IsNil() {
return libkb.NoUIDError{}
}
mctx.Debug("Stellar.PostWithChainLink: load self")
loadMeArg := libkb.NewLoadUserArg(mctx.G()).
WithNetContext(mctx.Ctx()).
WithUID(uid).
WithSelf(true).
WithPublicKeyOptional()
me, err := libkb.LoadUser(loadMeArg)
if err != nil {
return err
}
deviceSigKey, err := mctx.G().ActiveDevice.SigningKey()
if err != nil {
return fmt.Errorf("signing key not found: (%v)", err)
}
pukGen, pukSeed, err := getLatestPuk(mctx.Ctx(), mctx.G())
if err != nil {
return err
}
payload, seqno, linkID, err := buildChainLinkPayload(mctx, clearBundle, me, pukGen, pukSeed, deviceSigKey)
if err != nil {
return err
}
mctx.Debug("Stellar.PostWithChainLink: post")
_, err = mctx.G().API.PostJSON(mctx, libkb.APIArg{
Endpoint: "key/multi",
SessionType: libkb.APISessionTypeREQUIRED,
JSONPayload: *payload,
})
if err != nil {
return err
}
if err = libkb.MerkleCheckPostedUserSig(mctx, uid, seqno, linkID); err != nil {
return err
}
mctx.G().UserChanged(mctx.Ctx(), uid)
return nil
} | [
"func",
"PostWithChainlink",
"(",
"mctx",
"libkb",
".",
"MetaContext",
",",
"clearBundle",
"stellar1",
".",
"Bundle",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"mctx",
".",
"TraceTimed",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"error",
"{",
"return",
"err",
"}",
")",
"(",
")",
"\n\n",
"uid",
":=",
"mctx",
".",
"G",
"(",
")",
".",
"ActiveDevice",
".",
"UID",
"(",
")",
"\n",
"if",
"uid",
".",
"IsNil",
"(",
")",
"{",
"return",
"libkb",
".",
"NoUIDError",
"{",
"}",
"\n",
"}",
"\n",
"mctx",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"loadMeArg",
":=",
"libkb",
".",
"NewLoadUserArg",
"(",
"mctx",
".",
"G",
"(",
")",
")",
".",
"WithNetContext",
"(",
"mctx",
".",
"Ctx",
"(",
")",
")",
".",
"WithUID",
"(",
"uid",
")",
".",
"WithSelf",
"(",
"true",
")",
".",
"WithPublicKeyOptional",
"(",
")",
"\n",
"me",
",",
"err",
":=",
"libkb",
".",
"LoadUser",
"(",
"loadMeArg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"deviceSigKey",
",",
"err",
":=",
"mctx",
".",
"G",
"(",
")",
".",
"ActiveDevice",
".",
"SigningKey",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"pukGen",
",",
"pukSeed",
",",
"err",
":=",
"getLatestPuk",
"(",
"mctx",
".",
"Ctx",
"(",
")",
",",
"mctx",
".",
"G",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"payload",
",",
"seqno",
",",
"linkID",
",",
"err",
":=",
"buildChainLinkPayload",
"(",
"mctx",
",",
"clearBundle",
",",
"me",
",",
"pukGen",
",",
"pukSeed",
",",
"deviceSigKey",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"mctx",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"_",
",",
"err",
"=",
"mctx",
".",
"G",
"(",
")",
".",
"API",
".",
"PostJSON",
"(",
"mctx",
",",
"libkb",
".",
"APIArg",
"{",
"Endpoint",
":",
"\"",
"\"",
",",
"SessionType",
":",
"libkb",
".",
"APISessionTypeREQUIRED",
",",
"JSONPayload",
":",
"*",
"payload",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"err",
"=",
"libkb",
".",
"MerkleCheckPostedUserSig",
"(",
"mctx",
",",
"uid",
",",
"seqno",
",",
"linkID",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"mctx",
".",
"G",
"(",
")",
".",
"UserChanged",
"(",
"mctx",
".",
"Ctx",
"(",
")",
",",
"uid",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // Post a bundle to the server with a chainlink. | [
"Post",
"a",
"bundle",
"to",
"the",
"server",
"with",
"a",
"chainlink",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/remote/remote.go#L96-L143 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.