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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
158,800 | keybase/client | go/mounter/mounter_nix.go | ForceUnmount | func ForceUnmount(dir string, log Log) error {
switch runtime.GOOS {
case "darwin":
log.Info("Force unmounting with diskutil")
out, err := exec.Command("/usr/sbin/diskutil", "unmountDisk", "force", dir).CombinedOutput()
log.Debug("Output: %s", string(out))
return err
case "linux":
log.Info("Force unmounting with umount -l")
out, err := exec.Command("umount", "-l", dir).CombinedOutput()
log.Debug("Output: %s", string(out))
return err
default:
return errors.New("Forced unmount is not supported on this platform yet")
}
} | go | func ForceUnmount(dir string, log Log) error {
switch runtime.GOOS {
case "darwin":
log.Info("Force unmounting with diskutil")
out, err := exec.Command("/usr/sbin/diskutil", "unmountDisk", "force", dir).CombinedOutput()
log.Debug("Output: %s", string(out))
return err
case "linux":
log.Info("Force unmounting with umount -l")
out, err := exec.Command("umount", "-l", dir).CombinedOutput()
log.Debug("Output: %s", string(out))
return err
default:
return errors.New("Forced unmount is not supported on this platform yet")
}
} | [
"func",
"ForceUnmount",
"(",
"dir",
"string",
",",
"log",
"Log",
")",
"error",
"{",
"switch",
"runtime",
".",
"GOOS",
"{",
"case",
"\"",
"\"",
":",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"out",
",",
"err",
":=",
"exec",
".",
"Command",
"... | // ForceUnmount tries to forcibly unmount a directory | [
"ForceUnmount",
"tries",
"to",
"forcibly",
"unmount",
"a",
"directory"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/mounter/mounter_nix.go#L43-L58 |
158,801 | keybase/client | go/kbfs/libfs/file.go | Write | func (f *File) Write(p []byte) (n int, err error) {
if f.readOnly {
return 0, errors.New("Trying to write a read-only file")
}
origOffset := atomic.LoadInt64(&f.offset)
err = f.fs.config.KBFSOps().Write(f.fs.ctx, f.node, p, origOffset)
if err != nil {
return 0, err
}
f.updateOffset(origOffset, int64(len(p)))
return len(p), nil
} | go | func (f *File) Write(p []byte) (n int, err error) {
if f.readOnly {
return 0, errors.New("Trying to write a read-only file")
}
origOffset := atomic.LoadInt64(&f.offset)
err = f.fs.config.KBFSOps().Write(f.fs.ctx, f.node, p, origOffset)
if err != nil {
return 0, err
}
f.updateOffset(origOffset, int64(len(p)))
return len(p), nil
} | [
"func",
"(",
"f",
"*",
"File",
")",
"Write",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"if",
"f",
".",
"readOnly",
"{",
"return",
"0",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n"... | // Write implements the billy.File interface for File. | [
"Write",
"implements",
"the",
"billy",
".",
"File",
"interface",
"for",
"File",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/file.go#L51-L64 |
158,802 | keybase/client | go/kbfs/libfs/file.go | Read | func (f *File) Read(p []byte) (n int, err error) {
origOffset := atomic.LoadInt64(&f.offset)
readBytes, err := f.fs.config.KBFSOps().Read(
f.fs.ctx, f.node, p, origOffset)
if err != nil {
return 0, err
}
if readBytes == 0 {
return 0, io.EOF
}
f.updateOffset(origOffset, readBytes)
return int(readBytes), nil
} | go | func (f *File) Read(p []byte) (n int, err error) {
origOffset := atomic.LoadInt64(&f.offset)
readBytes, err := f.fs.config.KBFSOps().Read(
f.fs.ctx, f.node, p, origOffset)
if err != nil {
return 0, err
}
if readBytes == 0 {
return 0, io.EOF
}
f.updateOffset(origOffset, readBytes)
return int(readBytes), nil
} | [
"func",
"(",
"f",
"*",
"File",
")",
"Read",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"origOffset",
":=",
"atomic",
".",
"LoadInt64",
"(",
"&",
"f",
".",
"offset",
")",
"\n",
"readBytes",
",",
"err",
":=",... | // Read implements the billy.File interface for File. | [
"Read",
"implements",
"the",
"billy",
".",
"File",
"interface",
"for",
"File",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/file.go#L67-L81 |
158,803 | keybase/client | go/kbfs/libfs/file.go | ReadAt | func (f *File) ReadAt(p []byte, off int64) (n int, err error) {
// ReadAt doesn't affect the underlying offset.
readBytes, err := f.fs.config.KBFSOps().Read(f.fs.ctx, f.node, p, off)
if err != nil {
return 0, err
}
if int(readBytes) < len(p) {
// ReadAt is more strict than Read.
return 0, errors.Errorf("Could only read %d bytes", readBytes)
}
return int(readBytes), nil
} | go | func (f *File) ReadAt(p []byte, off int64) (n int, err error) {
// ReadAt doesn't affect the underlying offset.
readBytes, err := f.fs.config.KBFSOps().Read(f.fs.ctx, f.node, p, off)
if err != nil {
return 0, err
}
if int(readBytes) < len(p) {
// ReadAt is more strict than Read.
return 0, errors.Errorf("Could only read %d bytes", readBytes)
}
return int(readBytes), nil
} | [
"func",
"(",
"f",
"*",
"File",
")",
"ReadAt",
"(",
"p",
"[",
"]",
"byte",
",",
"off",
"int64",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"// ReadAt doesn't affect the underlying offset.",
"readBytes",
",",
"err",
":=",
"f",
".",
"fs",
".",
... | // ReadAt implements the billy.File interface for File. | [
"ReadAt",
"implements",
"the",
"billy",
".",
"File",
"interface",
"for",
"File",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/file.go#L84-L96 |
158,804 | keybase/client | go/kbfs/libfs/file.go | Seek | func (f *File) Seek(offset int64, whence int) (n int64, err error) {
newOffset := offset
switch whence {
case io.SeekStart:
case io.SeekCurrent:
origOffset := atomic.LoadInt64(&f.offset)
newOffset = origOffset + offset
case io.SeekEnd:
ei, err := f.fs.config.KBFSOps().Stat(f.fs.ctx, f.node)
if err != nil {
return 0, err
}
newOffset = int64(ei.Size) + offset
}
if newOffset < 0 {
return 0, errors.Errorf("Cannot seek to offset %d", newOffset)
}
_ = atomic.SwapInt64(&f.offset, newOffset)
return newOffset, nil
} | go | func (f *File) Seek(offset int64, whence int) (n int64, err error) {
newOffset := offset
switch whence {
case io.SeekStart:
case io.SeekCurrent:
origOffset := atomic.LoadInt64(&f.offset)
newOffset = origOffset + offset
case io.SeekEnd:
ei, err := f.fs.config.KBFSOps().Stat(f.fs.ctx, f.node)
if err != nil {
return 0, err
}
newOffset = int64(ei.Size) + offset
}
if newOffset < 0 {
return 0, errors.Errorf("Cannot seek to offset %d", newOffset)
}
_ = atomic.SwapInt64(&f.offset, newOffset)
return newOffset, nil
} | [
"func",
"(",
"f",
"*",
"File",
")",
"Seek",
"(",
"offset",
"int64",
",",
"whence",
"int",
")",
"(",
"n",
"int64",
",",
"err",
"error",
")",
"{",
"newOffset",
":=",
"offset",
"\n",
"switch",
"whence",
"{",
"case",
"io",
".",
"SeekStart",
":",
"case"... | // Seek implements the billy.File interface for File. | [
"Seek",
"implements",
"the",
"billy",
".",
"File",
"interface",
"for",
"File",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/file.go#L99-L119 |
158,805 | keybase/client | go/kbfs/libfs/file.go | Close | func (f *File) Close() error {
err := f.Unlock()
if err != nil {
return err
}
f.node = nil
return nil
} | go | func (f *File) Close() error {
err := f.Unlock()
if err != nil {
return err
}
f.node = nil
return nil
} | [
"func",
"(",
"f",
"*",
"File",
")",
"Close",
"(",
")",
"error",
"{",
"err",
":=",
"f",
".",
"Unlock",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"f",
".",
"node",
"=",
"nil",
"\n",
"return",
"nil",
"\n",
... | // Close implements the billy.File interface for File. | [
"Close",
"implements",
"the",
"billy",
".",
"File",
"interface",
"for",
"File",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/file.go#L122-L129 |
158,806 | keybase/client | go/kbfs/libfs/file.go | Lock | func (f *File) Lock() (err error) {
done := make(chan struct{})
f.fs.sendEvents(FSEvent{
EventType: FSEventLock,
File: f,
Done: done,
})
defer close(done)
f.lockedLock.Lock()
defer f.lockedLock.Unlock()
if f.locked {
return nil
}
defer func() {
if err == nil {
f.locked = true
}
}()
// First, sync all and ask journal to flush all existing writes.
err = f.fs.SyncAll()
if err != nil {
return err
}
jManager, err := libkbfs.GetJournalManager(f.fs.config)
if err != nil {
return err
}
if err = jManager.FinishSingleOp(f.fs.ctx,
f.fs.root.GetFolderBranch().Tlf, nil, f.fs.priority); err != nil {
return err
}
// Now, sync up with the server, while making sure a lock is held by us. If
// lock taking fails, RPC layer retries automatically.
lockID := f.getLockID()
return f.fs.config.KBFSOps().SyncFromServer(f.fs.ctx,
f.fs.root.GetFolderBranch(), &lockID)
} | go | func (f *File) Lock() (err error) {
done := make(chan struct{})
f.fs.sendEvents(FSEvent{
EventType: FSEventLock,
File: f,
Done: done,
})
defer close(done)
f.lockedLock.Lock()
defer f.lockedLock.Unlock()
if f.locked {
return nil
}
defer func() {
if err == nil {
f.locked = true
}
}()
// First, sync all and ask journal to flush all existing writes.
err = f.fs.SyncAll()
if err != nil {
return err
}
jManager, err := libkbfs.GetJournalManager(f.fs.config)
if err != nil {
return err
}
if err = jManager.FinishSingleOp(f.fs.ctx,
f.fs.root.GetFolderBranch().Tlf, nil, f.fs.priority); err != nil {
return err
}
// Now, sync up with the server, while making sure a lock is held by us. If
// lock taking fails, RPC layer retries automatically.
lockID := f.getLockID()
return f.fs.config.KBFSOps().SyncFromServer(f.fs.ctx,
f.fs.root.GetFolderBranch(), &lockID)
} | [
"func",
"(",
"f",
"*",
"File",
")",
"Lock",
"(",
")",
"(",
"err",
"error",
")",
"{",
"done",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"f",
".",
"fs",
".",
"sendEvents",
"(",
"FSEvent",
"{",
"EventType",
":",
"FSEventLock",
",",
... | // Lock implements the billy.File interface for File. | [
"Lock",
"implements",
"the",
"billy",
".",
"File",
"interface",
"for",
"File",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/file.go#L142-L180 |
158,807 | keybase/client | go/kbfs/libfs/file.go | Unlock | func (f *File) Unlock() (err error) {
f.lockedLock.Lock()
defer f.lockedLock.Unlock()
if !f.locked {
return nil
}
// Send the event only if f.locked == true.
done := make(chan struct{})
f.fs.sendEvents(FSEvent{
EventType: FSEventUnlock,
File: f,
Done: done,
})
defer close(done)
defer func() {
if err == nil {
f.locked = false
}
}()
err = f.fs.SyncAll()
if err != nil {
return err
}
jManager, err := libkbfs.GetJournalManager(f.fs.config)
if err != nil {
return err
}
jStatus, _ := jManager.JournalStatus(f.fs.root.GetFolderBranch().Tlf)
if jStatus.RevisionStart == kbfsmd.RevisionUninitialized {
// Journal MDs are all flushed and we haven't made any more writes.
// Calling FinishSingleOp won't make it to the server, so we make a
// naked request to server just to release the lock.
return f.fs.config.MDServer().ReleaseLock(f.fs.ctx,
f.fs.root.GetFolderBranch().Tlf, f.getLockID())
}
if f.fs.config.Mode().Type() == libkbfs.InitSingleOp {
err = jManager.FinishSingleOp(f.fs.ctx,
f.fs.root.GetFolderBranch().Tlf, &keybase1.LockContext{
RequireLockID: f.getLockID(),
ReleaseAfterSuccess: true,
}, f.fs.priority)
if err != nil {
return err
}
} else {
err = jManager.WaitForCompleteFlush(
f.fs.ctx, f.fs.root.GetFolderBranch().Tlf)
if err != nil {
return err
}
f.fs.log.CDebugf(f.fs.ctx, "Releasing the lock")
// Need to explicitly release the lock from the server. If
// single-op mode isn't enabled, then the journal will be
// flushing on its own without waiting for the call to
// `FinishSingleOp`. That means the journal can already be
// completely flushed by the time `FinishSingleOp` is called,
// and it will be a no-op. It won't have made any call to the
// server to release the lock, so we have to do it explicitly
// here.
err = f.fs.config.MDServer().ReleaseLock(
f.fs.ctx, f.fs.root.GetFolderBranch().Tlf, f.getLockID())
if err != nil {
return err
}
}
return nil
} | go | func (f *File) Unlock() (err error) {
f.lockedLock.Lock()
defer f.lockedLock.Unlock()
if !f.locked {
return nil
}
// Send the event only if f.locked == true.
done := make(chan struct{})
f.fs.sendEvents(FSEvent{
EventType: FSEventUnlock,
File: f,
Done: done,
})
defer close(done)
defer func() {
if err == nil {
f.locked = false
}
}()
err = f.fs.SyncAll()
if err != nil {
return err
}
jManager, err := libkbfs.GetJournalManager(f.fs.config)
if err != nil {
return err
}
jStatus, _ := jManager.JournalStatus(f.fs.root.GetFolderBranch().Tlf)
if jStatus.RevisionStart == kbfsmd.RevisionUninitialized {
// Journal MDs are all flushed and we haven't made any more writes.
// Calling FinishSingleOp won't make it to the server, so we make a
// naked request to server just to release the lock.
return f.fs.config.MDServer().ReleaseLock(f.fs.ctx,
f.fs.root.GetFolderBranch().Tlf, f.getLockID())
}
if f.fs.config.Mode().Type() == libkbfs.InitSingleOp {
err = jManager.FinishSingleOp(f.fs.ctx,
f.fs.root.GetFolderBranch().Tlf, &keybase1.LockContext{
RequireLockID: f.getLockID(),
ReleaseAfterSuccess: true,
}, f.fs.priority)
if err != nil {
return err
}
} else {
err = jManager.WaitForCompleteFlush(
f.fs.ctx, f.fs.root.GetFolderBranch().Tlf)
if err != nil {
return err
}
f.fs.log.CDebugf(f.fs.ctx, "Releasing the lock")
// Need to explicitly release the lock from the server. If
// single-op mode isn't enabled, then the journal will be
// flushing on its own without waiting for the call to
// `FinishSingleOp`. That means the journal can already be
// completely flushed by the time `FinishSingleOp` is called,
// and it will be a no-op. It won't have made any call to the
// server to release the lock, so we have to do it explicitly
// here.
err = f.fs.config.MDServer().ReleaseLock(
f.fs.ctx, f.fs.root.GetFolderBranch().Tlf, f.getLockID())
if err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"f",
"*",
"File",
")",
"Unlock",
"(",
")",
"(",
"err",
"error",
")",
"{",
"f",
".",
"lockedLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"f",
".",
"lockedLock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"!",
"f",
".",
"locked",
"{",
"r... | // Unlock implements the billy.File interface for File. | [
"Unlock",
"implements",
"the",
"billy",
".",
"File",
"interface",
"for",
"File",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/file.go#L183-L255 |
158,808 | keybase/client | go/kbfs/libfs/file.go | Truncate | func (f *File) Truncate(size int64) error {
return f.fs.config.KBFSOps().Truncate(f.fs.ctx, f.node, uint64(size))
} | go | func (f *File) Truncate(size int64) error {
return f.fs.config.KBFSOps().Truncate(f.fs.ctx, f.node, uint64(size))
} | [
"func",
"(",
"f",
"*",
"File",
")",
"Truncate",
"(",
"size",
"int64",
")",
"error",
"{",
"return",
"f",
".",
"fs",
".",
"config",
".",
"KBFSOps",
"(",
")",
".",
"Truncate",
"(",
"f",
".",
"fs",
".",
"ctx",
",",
"f",
".",
"node",
",",
"uint64",
... | // Truncate implements the billy.File interface for File. | [
"Truncate",
"implements",
"the",
"billy",
".",
"File",
"interface",
"for",
"File",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/file.go#L258-L260 |
158,809 | keybase/client | go/libkb/id_table.go | ParseWebServiceBinding | func ParseWebServiceBinding(base GenericChainLink) (ret RemoteProofChainLink, err error) {
jw := base.UnmarshalPayloadJSON().AtKey("body").AtKey("service")
sptf := base.unpacked.proofText
if jw.IsNil() {
ret, err = ParseSelfSigChainLink(base)
if err != nil {
return nil, err
}
} else if sb, err := ParseServiceBlock(jw, keybase1.ProofType_NONE); err != nil {
err = fmt.Errorf("%s @%s", err, base.ToDebugString())
return nil, err
} else if sb.social {
ret = NewSocialProofChainLink(base, sb.typ, sb.id, sptf)
} else {
ret = NewWebProofChainLink(base, sb.typ, sb.id, sptf)
}
return ret, nil
} | go | func ParseWebServiceBinding(base GenericChainLink) (ret RemoteProofChainLink, err error) {
jw := base.UnmarshalPayloadJSON().AtKey("body").AtKey("service")
sptf := base.unpacked.proofText
if jw.IsNil() {
ret, err = ParseSelfSigChainLink(base)
if err != nil {
return nil, err
}
} else if sb, err := ParseServiceBlock(jw, keybase1.ProofType_NONE); err != nil {
err = fmt.Errorf("%s @%s", err, base.ToDebugString())
return nil, err
} else if sb.social {
ret = NewSocialProofChainLink(base, sb.typ, sb.id, sptf)
} else {
ret = NewWebProofChainLink(base, sb.typ, sb.id, sptf)
}
return ret, nil
} | [
"func",
"ParseWebServiceBinding",
"(",
"base",
"GenericChainLink",
")",
"(",
"ret",
"RemoteProofChainLink",
",",
"err",
"error",
")",
"{",
"jw",
":=",
"base",
".",
"UnmarshalPayloadJSON",
"(",
")",
".",
"AtKey",
"(",
"\"",
"\"",
")",
".",
"AtKey",
"(",
"\"... | // To be used for signatures in a user's signature chain. | [
"To",
"be",
"used",
"for",
"signatures",
"in",
"a",
"user",
"s",
"signature",
"chain",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/id_table.go#L389-L408 |
158,810 | keybase/client | go/libkb/id_table.go | ParsePGPUpdateChainLink | func ParsePGPUpdateChainLink(b GenericChainLink) (ret *PGPUpdateChainLink, err error) {
var kid keybase1.KID
pgpUpdate := b.UnmarshalPayloadJSON().AtPath("body.pgp_update")
if pgpUpdate.IsNil() {
err = ChainLinkError{fmt.Sprintf("missing pgp_update section @%s", b.ToDebugString())}
return
}
if kid, err = GetKID(pgpUpdate.AtKey("kid")); err != nil {
err = ChainLinkError{fmt.Sprintf("Missing kid @%s: %s", b.ToDebugString(), err)}
return
}
ret = &PGPUpdateChainLink{b, kid}
if fh := ret.GetPGPFullHash(); fh == "" {
err = ChainLinkError{fmt.Sprintf("Missing full_hash @%s", b.ToDebugString())}
ret = nil
return
}
return
} | go | func ParsePGPUpdateChainLink(b GenericChainLink) (ret *PGPUpdateChainLink, err error) {
var kid keybase1.KID
pgpUpdate := b.UnmarshalPayloadJSON().AtPath("body.pgp_update")
if pgpUpdate.IsNil() {
err = ChainLinkError{fmt.Sprintf("missing pgp_update section @%s", b.ToDebugString())}
return
}
if kid, err = GetKID(pgpUpdate.AtKey("kid")); err != nil {
err = ChainLinkError{fmt.Sprintf("Missing kid @%s: %s", b.ToDebugString(), err)}
return
}
ret = &PGPUpdateChainLink{b, kid}
if fh := ret.GetPGPFullHash(); fh == "" {
err = ChainLinkError{fmt.Sprintf("Missing full_hash @%s", b.ToDebugString())}
ret = nil
return
}
return
} | [
"func",
"ParsePGPUpdateChainLink",
"(",
"b",
"GenericChainLink",
")",
"(",
"ret",
"*",
"PGPUpdateChainLink",
",",
"err",
"error",
")",
"{",
"var",
"kid",
"keybase1",
".",
"KID",
"\n\n",
"pgpUpdate",
":=",
"b",
".",
"UnmarshalPayloadJSON",
"(",
")",
".",
"AtP... | // ParsePGPUpdateChainLink creates a PGPUpdateChainLink from a GenericChainLink
// and verifies that its pgp_update section contains a KID and full_hash | [
"ParsePGPUpdateChainLink",
"creates",
"a",
"PGPUpdateChainLink",
"from",
"a",
"GenericChainLink",
"and",
"verifies",
"that",
"its",
"pgp_update",
"section",
"contains",
"a",
"KID",
"and",
"full_hash"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/id_table.go#L845-L869 |
158,811 | keybase/client | go/libkb/id_table.go | VerifyReverseSig | func (s *WalletStellarChainLink) VerifyReverseSig(_ ComputedKeyFamily) (err error) {
key, err := ImportNaclSigningKeyPairFromHex(s.addressKID.String())
if err != nil {
return fmt.Errorf("Invalid wallet reverse signing KID: %s", s.addressKID)
}
return VerifyReverseSig(s.G(), key, "body.wallet_key.reverse_sig", s.UnmarshalPayloadJSON(), s.reverseSig)
} | go | func (s *WalletStellarChainLink) VerifyReverseSig(_ ComputedKeyFamily) (err error) {
key, err := ImportNaclSigningKeyPairFromHex(s.addressKID.String())
if err != nil {
return fmt.Errorf("Invalid wallet reverse signing KID: %s", s.addressKID)
}
return VerifyReverseSig(s.G(), key, "body.wallet_key.reverse_sig", s.UnmarshalPayloadJSON(), s.reverseSig)
} | [
"func",
"(",
"s",
"*",
"WalletStellarChainLink",
")",
"VerifyReverseSig",
"(",
"_",
"ComputedKeyFamily",
")",
"(",
"err",
"error",
")",
"{",
"key",
",",
"err",
":=",
"ImportNaclSigningKeyPairFromHex",
"(",
"s",
".",
"addressKID",
".",
"String",
"(",
")",
")"... | // VerifyReverseSig checks a SibkeyChainLink's reverse signature using the ComputedKeyFamily provided. | [
"VerifyReverseSig",
"checks",
"a",
"SibkeyChainLink",
"s",
"reverse",
"signature",
"using",
"the",
"ComputedKeyFamily",
"provided",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/id_table.go#L971-L978 |
158,812 | keybase/client | go/libkb/id_table.go | VerifyReverseSig | func VerifyReverseSig(g *GlobalContext, key GenericKey, path string, payload *jsonw.Wrapper, reverseSig string) (err error) {
var p1, p2 []byte
if p1, _, err = key.VerifyStringAndExtract(g.Log, reverseSig); err != nil {
err = ReverseSigError{fmt.Sprintf("Failed to verify/extract sig: %s", err)}
return err
}
if p1, err = jsonw.Canonicalize(p1); err != nil {
err = ReverseSigError{fmt.Sprintf("Failed to canonicalize json: %s", err)}
return err
}
// Make a deep copy. It's dangerous to try to mutate this thing
// since other goroutines might be accessing it at the same time.
var jsonCopy *jsonw.Wrapper
if jsonCopy, err = makeDeepCopy(payload); err != nil {
err = ReverseSigError{fmt.Sprintf("Failed to copy payload json: %s", err)}
return err
}
jsonCopy.SetValueAtPath(path, jsonw.NewNil())
if p2, err = jsonCopy.Marshal(); err != nil {
err = ReverseSigError{fmt.Sprintf("Can't remarshal JSON statement: %s", err)}
return err
}
eq := FastByteArrayEq(p1, p2)
if !eq {
err = ReverseSigError{fmt.Sprintf("JSON mismatch: %s != %s",
string(p1), string(p2))}
return err
}
return nil
} | go | func VerifyReverseSig(g *GlobalContext, key GenericKey, path string, payload *jsonw.Wrapper, reverseSig string) (err error) {
var p1, p2 []byte
if p1, _, err = key.VerifyStringAndExtract(g.Log, reverseSig); err != nil {
err = ReverseSigError{fmt.Sprintf("Failed to verify/extract sig: %s", err)}
return err
}
if p1, err = jsonw.Canonicalize(p1); err != nil {
err = ReverseSigError{fmt.Sprintf("Failed to canonicalize json: %s", err)}
return err
}
// Make a deep copy. It's dangerous to try to mutate this thing
// since other goroutines might be accessing it at the same time.
var jsonCopy *jsonw.Wrapper
if jsonCopy, err = makeDeepCopy(payload); err != nil {
err = ReverseSigError{fmt.Sprintf("Failed to copy payload json: %s", err)}
return err
}
jsonCopy.SetValueAtPath(path, jsonw.NewNil())
if p2, err = jsonCopy.Marshal(); err != nil {
err = ReverseSigError{fmt.Sprintf("Can't remarshal JSON statement: %s", err)}
return err
}
eq := FastByteArrayEq(p1, p2)
if !eq {
err = ReverseSigError{fmt.Sprintf("JSON mismatch: %s != %s",
string(p1), string(p2))}
return err
}
return nil
} | [
"func",
"VerifyReverseSig",
"(",
"g",
"*",
"GlobalContext",
",",
"key",
"GenericKey",
",",
"path",
"string",
",",
"payload",
"*",
"jsonw",
".",
"Wrapper",
",",
"reverseSig",
"string",
")",
"(",
"err",
"error",
")",
"{",
"var",
"p1",
",",
"p2",
"[",
"]"... | // VerifyReverseSig checks reverse signature using the key provided.
// does not modify `payload`.
// `path` is the path to the reverse sig spot to null before checking. | [
"VerifyReverseSig",
"checks",
"reverse",
"signature",
"using",
"the",
"key",
"provided",
".",
"does",
"not",
"modify",
"payload",
".",
"path",
"is",
"the",
"path",
"to",
"the",
"reverse",
"sig",
"spot",
"to",
"null",
"before",
"checking",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/id_table.go#L1729-L1763 |
158,813 | keybase/client | go/engine/identify2_with_uid.go | Run | func (e *Identify2WithUID) Run(m libkb.MetaContext) (err error) {
m = m.WithLogTag("ID2")
n := fmt.Sprintf("Identify2WithUID#Run(UID=%v, Assertion=%s)", e.arg.Uid, e.arg.UserAssertion)
defer m.TraceTimed(n, func() error { return err })()
m.Debug("| Full Arg: %+v", e.arg)
if e.arg.Uid.IsNil() {
return libkb.NoUIDError{}
}
// Only the first send matters, but we don't want to block the subsequent no-op
// sends. This code will break when we have more than 100 unblocking opportunities.
ch := make(chan error, 100)
e.resultCh = ch
go e.run(m)
err = <-ch
// Potentially reset the error based on the error and the calling context.
err = e.resetError(m, err)
return err
} | go | func (e *Identify2WithUID) Run(m libkb.MetaContext) (err error) {
m = m.WithLogTag("ID2")
n := fmt.Sprintf("Identify2WithUID#Run(UID=%v, Assertion=%s)", e.arg.Uid, e.arg.UserAssertion)
defer m.TraceTimed(n, func() error { return err })()
m.Debug("| Full Arg: %+v", e.arg)
if e.arg.Uid.IsNil() {
return libkb.NoUIDError{}
}
// Only the first send matters, but we don't want to block the subsequent no-op
// sends. This code will break when we have more than 100 unblocking opportunities.
ch := make(chan error, 100)
e.resultCh = ch
go e.run(m)
err = <-ch
// Potentially reset the error based on the error and the calling context.
err = e.resetError(m, err)
return err
} | [
"func",
"(",
"e",
"*",
"Identify2WithUID",
")",
"Run",
"(",
"m",
"libkb",
".",
"MetaContext",
")",
"(",
"err",
"error",
")",
"{",
"m",
"=",
"m",
".",
"WithLogTag",
"(",
"\"",
"\"",
")",
"\n\n",
"n",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
... | // Run then engine | [
"Run",
"then",
"engine"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/identify2_with_uid.go#L321-L344 |
158,814 | keybase/client | go/engine/identify2_with_uid.go | CCLCheckCompleted | func (e *Identify2WithUID) CCLCheckCompleted(lcr *libkb.LinkCheckResult) {
e.remotesMutex.Lock()
defer e.remotesMutex.Unlock()
m := e.metaContext
m.Debug("+ CheckCompleted for %s", lcr.GetLink().ToIDString())
defer m.Debug("- CheckCompleted")
// Always add to remotesReceived list, so that we have a full ProofSet.
pf := libkb.RemoteProofChainLinkToProof(lcr.GetLink())
e.remotesReceived.Add(pf)
if !e.useRemoteAssertions() || e.useTracking {
m.Debug("| Not using remote assertions or is tracking")
return
}
if !e.remoteAssertion.HasFactor(pf) {
m.Debug("| Proof isn't needed in our remote-assertion early-out check: %v", pf)
return
}
if err := lcr.GetError(); err != nil {
m.Debug("| got error -> %v", err)
e.remotesError = err
}
// note(maxtaco): this is a little ugly in that it's O(n^2) where n is the number
// of identities in the assertion. But I can't imagine n > 3, so this is fine
// for now.
matched := e.remoteAssertion.MatchSet(*e.remotesReceived)
m.Debug("| matched -> %v", matched)
if matched {
e.remotesCompleted = true
}
if e.remotesError != nil || e.remotesCompleted {
m.Debug("| unblocking, with err = %v", e.remotesError)
e.unblock(m, false, e.remotesError)
}
} | go | func (e *Identify2WithUID) CCLCheckCompleted(lcr *libkb.LinkCheckResult) {
e.remotesMutex.Lock()
defer e.remotesMutex.Unlock()
m := e.metaContext
m.Debug("+ CheckCompleted for %s", lcr.GetLink().ToIDString())
defer m.Debug("- CheckCompleted")
// Always add to remotesReceived list, so that we have a full ProofSet.
pf := libkb.RemoteProofChainLinkToProof(lcr.GetLink())
e.remotesReceived.Add(pf)
if !e.useRemoteAssertions() || e.useTracking {
m.Debug("| Not using remote assertions or is tracking")
return
}
if !e.remoteAssertion.HasFactor(pf) {
m.Debug("| Proof isn't needed in our remote-assertion early-out check: %v", pf)
return
}
if err := lcr.GetError(); err != nil {
m.Debug("| got error -> %v", err)
e.remotesError = err
}
// note(maxtaco): this is a little ugly in that it's O(n^2) where n is the number
// of identities in the assertion. But I can't imagine n > 3, so this is fine
// for now.
matched := e.remoteAssertion.MatchSet(*e.remotesReceived)
m.Debug("| matched -> %v", matched)
if matched {
e.remotesCompleted = true
}
if e.remotesError != nil || e.remotesCompleted {
m.Debug("| unblocking, with err = %v", e.remotesError)
e.unblock(m, false, e.remotesError)
}
} | [
"func",
"(",
"e",
"*",
"Identify2WithUID",
")",
"CCLCheckCompleted",
"(",
"lcr",
"*",
"libkb",
".",
"LinkCheckResult",
")",
"{",
"e",
".",
"remotesMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"e",
".",
"remotesMutex",
".",
"Unlock",
"(",
")",
"\n",
"m... | // CCLCheckCompleted is triggered whenever a remote proof check completes.
// We get these calls as a result of being a "CheckCompletedListener".
// When each result comes in, we check against our pool of needed remote
// assertions. If the set is complete, or if one that we need errors,
// we can unblock the caller. | [
"CCLCheckCompleted",
"is",
"triggered",
"whenever",
"a",
"remote",
"proof",
"check",
"completes",
".",
"We",
"get",
"these",
"calls",
"as",
"a",
"result",
"of",
"being",
"a",
"CheckCompletedListener",
".",
"When",
"each",
"result",
"comes",
"in",
"we",
"check"... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/identify2_with_uid.go#L648-L688 |
158,815 | keybase/client | go/kbhttp/srv.go | NewSrv | func NewSrv(log logger.Logger, listenerSource ListenerSource) *Srv {
return &Srv{
log: log,
listenerSource: listenerSource,
}
} | go | func NewSrv(log logger.Logger, listenerSource ListenerSource) *Srv {
return &Srv{
log: log,
listenerSource: listenerSource,
}
} | [
"func",
"NewSrv",
"(",
"log",
"logger",
".",
"Logger",
",",
"listenerSource",
"ListenerSource",
")",
"*",
"Srv",
"{",
"return",
"&",
"Srv",
"{",
"log",
":",
"log",
",",
"listenerSource",
":",
"listenerSource",
",",
"}",
"\n",
"}"
] | // NewSrv creates a new HTTP server with the given listener
// source. | [
"NewSrv",
"creates",
"a",
"new",
"HTTP",
"server",
"with",
"the",
"given",
"listener",
"source",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbhttp/srv.go#L103-L108 |
158,816 | keybase/client | go/kbhttp/srv.go | Start | func (h *Srv) Start() (err error) {
h.Lock()
defer h.Unlock()
if h.server != nil {
h.log.Debug("kbhttp.Srv: already running, not starting again")
// Just bail out of this if we are already running
return errAlreadyRunning
}
h.ServeMux = http.NewServeMux()
listener, address, err := h.listenerSource.GetListener()
if err != nil {
h.log.Debug("kbhttp.Srv: failed to get a listener: %s", err)
return err
}
h.server = &http.Server{
Addr: address,
Handler: h.ServeMux,
}
h.doneCh = make(chan struct{})
go func(server *http.Server, doneCh chan struct{}) {
h.log.Debug("kbhttp.Srv: server starting on: %s", address)
if err := server.Serve(listener); err != nil {
h.log.Debug("kbhttp.Srv: server died: %s", err)
}
close(doneCh)
}(h.server, h.doneCh)
return nil
} | go | func (h *Srv) Start() (err error) {
h.Lock()
defer h.Unlock()
if h.server != nil {
h.log.Debug("kbhttp.Srv: already running, not starting again")
// Just bail out of this if we are already running
return errAlreadyRunning
}
h.ServeMux = http.NewServeMux()
listener, address, err := h.listenerSource.GetListener()
if err != nil {
h.log.Debug("kbhttp.Srv: failed to get a listener: %s", err)
return err
}
h.server = &http.Server{
Addr: address,
Handler: h.ServeMux,
}
h.doneCh = make(chan struct{})
go func(server *http.Server, doneCh chan struct{}) {
h.log.Debug("kbhttp.Srv: server starting on: %s", address)
if err := server.Serve(listener); err != nil {
h.log.Debug("kbhttp.Srv: server died: %s", err)
}
close(doneCh)
}(h.server, h.doneCh)
return nil
} | [
"func",
"(",
"h",
"*",
"Srv",
")",
"Start",
"(",
")",
"(",
"err",
"error",
")",
"{",
"h",
".",
"Lock",
"(",
")",
"\n",
"defer",
"h",
".",
"Unlock",
"(",
")",
"\n",
"if",
"h",
".",
"server",
"!=",
"nil",
"{",
"h",
".",
"log",
".",
"Debug",
... | // Start starts listening on the server's listener source. | [
"Start",
"starts",
"listening",
"on",
"the",
"server",
"s",
"listener",
"source",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbhttp/srv.go#L111-L138 |
158,817 | keybase/client | go/kbhttp/srv.go | Active | func (h *Srv) Active() bool {
h.Lock()
defer h.Unlock()
return h.server != nil
} | go | func (h *Srv) Active() bool {
h.Lock()
defer h.Unlock()
return h.server != nil
} | [
"func",
"(",
"h",
"*",
"Srv",
")",
"Active",
"(",
")",
"bool",
"{",
"h",
".",
"Lock",
"(",
")",
"\n",
"defer",
"h",
".",
"Unlock",
"(",
")",
"\n",
"return",
"h",
".",
"server",
"!=",
"nil",
"\n",
"}"
] | // Active returns true if the server is active. | [
"Active",
"returns",
"true",
"if",
"the",
"server",
"is",
"active",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbhttp/srv.go#L141-L145 |
158,818 | keybase/client | go/kbhttp/srv.go | Addr | func (h *Srv) Addr() (string, error) {
h.Lock()
defer h.Unlock()
if h.server != nil {
return h.server.Addr, nil
}
return "", errors.New("server not running")
} | go | func (h *Srv) Addr() (string, error) {
h.Lock()
defer h.Unlock()
if h.server != nil {
return h.server.Addr, nil
}
return "", errors.New("server not running")
} | [
"func",
"(",
"h",
"*",
"Srv",
")",
"Addr",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"h",
".",
"Lock",
"(",
")",
"\n",
"defer",
"h",
".",
"Unlock",
"(",
")",
"\n",
"if",
"h",
".",
"server",
"!=",
"nil",
"{",
"return",
"h",
".",
"serv... | // Addr returns the server's address, if it's running. | [
"Addr",
"returns",
"the",
"server",
"s",
"address",
"if",
"it",
"s",
"running",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbhttp/srv.go#L148-L155 |
158,819 | keybase/client | go/kbhttp/srv.go | Stop | func (h *Srv) Stop() <-chan struct{} {
h.Lock()
defer h.Unlock()
if h.server != nil {
h.server.Close()
h.server = nil
return h.doneCh
}
doneCh := make(chan struct{})
close(doneCh)
return doneCh
} | go | func (h *Srv) Stop() <-chan struct{} {
h.Lock()
defer h.Unlock()
if h.server != nil {
h.server.Close()
h.server = nil
return h.doneCh
}
doneCh := make(chan struct{})
close(doneCh)
return doneCh
} | [
"func",
"(",
"h",
"*",
"Srv",
")",
"Stop",
"(",
")",
"<-",
"chan",
"struct",
"{",
"}",
"{",
"h",
".",
"Lock",
"(",
")",
"\n",
"defer",
"h",
".",
"Unlock",
"(",
")",
"\n",
"if",
"h",
".",
"server",
"!=",
"nil",
"{",
"h",
".",
"server",
".",
... | // Stop stops listening on the server's listener source. | [
"Stop",
"stops",
"listening",
"on",
"the",
"server",
"s",
"listener",
"source",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbhttp/srv.go#L158-L169 |
158,820 | keybase/client | go/kbfs/libhttpserver/server.go | NewToken | func (s *Server) NewToken() (token string, err error) {
buf := make([]byte, tokenByteSize)
if _, err = rand.Read(buf); err != nil {
return "", err
}
token = hex.EncodeToString(buf)
s.tokens.Add(token, nil)
return token, nil
} | go | func (s *Server) NewToken() (token string, err error) {
buf := make([]byte, tokenByteSize)
if _, err = rand.Read(buf); err != nil {
return "", err
}
token = hex.EncodeToString(buf)
s.tokens.Add(token, nil)
return token, nil
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"NewToken",
"(",
")",
"(",
"token",
"string",
",",
"err",
"error",
")",
"{",
"buf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"tokenByteSize",
")",
"\n",
"if",
"_",
",",
"err",
"=",
"rand",
".",
"Read",
"("... | // NewToken returns a new random token that a HTTP client can use to load
// content from the server. | [
"NewToken",
"returns",
"a",
"new",
"random",
"token",
"that",
"a",
"HTTP",
"client",
"can",
"use",
"to",
"load",
"content",
"from",
"the",
"server",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libhttpserver/server.go#L51-L59 |
158,821 | keybase/client | go/kbfs/libhttpserver/server.go | New | func New(appStateUpdater env.AppStateUpdater, config libkbfs.Config) (
s *Server, err error) {
logger := config.MakeLogger("HTTP")
s = &Server{
appStateUpdater: appStateUpdater,
config: config,
logger: logger,
}
if s.tokens, err = lru.New(tokenCacheSize); err != nil {
return nil, err
}
if s.fs, err = lru.New(fsCacheSize); err != nil {
return nil, err
}
if err = s.restart(); err != nil {
return nil, err
}
ctx, cancel := context.WithCancel(context.Background())
go s.monitorAppState(ctx)
s.cancel = cancel
libmime.Patch(additionalMimeTypes)
return s, nil
} | go | func New(appStateUpdater env.AppStateUpdater, config libkbfs.Config) (
s *Server, err error) {
logger := config.MakeLogger("HTTP")
s = &Server{
appStateUpdater: appStateUpdater,
config: config,
logger: logger,
}
if s.tokens, err = lru.New(tokenCacheSize); err != nil {
return nil, err
}
if s.fs, err = lru.New(fsCacheSize); err != nil {
return nil, err
}
if err = s.restart(); err != nil {
return nil, err
}
ctx, cancel := context.WithCancel(context.Background())
go s.monitorAppState(ctx)
s.cancel = cancel
libmime.Patch(additionalMimeTypes)
return s, nil
} | [
"func",
"New",
"(",
"appStateUpdater",
"env",
".",
"AppStateUpdater",
",",
"config",
"libkbfs",
".",
"Config",
")",
"(",
"s",
"*",
"Server",
",",
"err",
"error",
")",
"{",
"logger",
":=",
"config",
".",
"MakeLogger",
"(",
"\"",
"\"",
")",
"\n",
"s",
... | // New creates and starts a new server. | [
"New",
"creates",
"and",
"starts",
"a",
"new",
"server",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libhttpserver/server.go#L214-L236 |
158,822 | keybase/client | go/kbfs/libhttpserver/server.go | Address | func (s *Server) Address() (string, error) {
s.serverLock.RLock()
defer s.serverLock.RUnlock()
return s.server.Addr()
} | go | func (s *Server) Address() (string, error) {
s.serverLock.RLock()
defer s.serverLock.RUnlock()
return s.server.Addr()
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"Address",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"s",
".",
"serverLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"serverLock",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"s",
".",
"server",... | // Address returns the address that the server is listening on. | [
"Address",
"returns",
"the",
"address",
"that",
"the",
"server",
"is",
"listening",
"on",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libhttpserver/server.go#L239-L243 |
158,823 | keybase/client | go/kbfs/libhttpserver/server.go | Shutdown | func (s *Server) Shutdown() {
s.serverLock.Lock()
defer s.serverLock.Unlock()
s.server.Stop()
s.cancel()
} | go | func (s *Server) Shutdown() {
s.serverLock.Lock()
defer s.serverLock.Unlock()
s.server.Stop()
s.cancel()
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"Shutdown",
"(",
")",
"{",
"s",
".",
"serverLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"serverLock",
".",
"Unlock",
"(",
")",
"\n",
"s",
".",
"server",
".",
"Stop",
"(",
")",
"\n",
"s",
".",
"... | // Shutdown shuts down the server. | [
"Shutdown",
"shuts",
"down",
"the",
"server",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libhttpserver/server.go#L246-L251 |
158,824 | keybase/client | go/engine/track.go | NewTrackEngine | func NewTrackEngine(g *libkb.GlobalContext, arg *TrackEngineArg) *TrackEngine {
return &TrackEngine{
arg: arg,
Contextified: libkb.NewContextified(g),
}
} | go | func NewTrackEngine(g *libkb.GlobalContext, arg *TrackEngineArg) *TrackEngine {
return &TrackEngine{
arg: arg,
Contextified: libkb.NewContextified(g),
}
} | [
"func",
"NewTrackEngine",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"arg",
"*",
"TrackEngineArg",
")",
"*",
"TrackEngine",
"{",
"return",
"&",
"TrackEngine",
"{",
"arg",
":",
"arg",
",",
"Contextified",
":",
"libkb",
".",
"NewContextified",
"(",
"... | // NewTrackEngine creates a default TrackEngine for tracking theirName. | [
"NewTrackEngine",
"creates",
"a",
"default",
"TrackEngine",
"for",
"tracking",
"theirName",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/track.go#L29-L34 |
158,825 | keybase/client | go/kbfs/ioutil/os_wrap.go | OpenFile | func OpenFile(name string, flag int, perm os.FileMode) (*os.File, error) {
f, err := os.OpenFile(name, flag, perm)
if err != nil {
return nil, errors.Wrapf(err, "failed to open %q", name)
}
return f, nil
} | go | func OpenFile(name string, flag int, perm os.FileMode) (*os.File, error) {
f, err := os.OpenFile(name, flag, perm)
if err != nil {
return nil, errors.Wrapf(err, "failed to open %q", name)
}
return f, nil
} | [
"func",
"OpenFile",
"(",
"name",
"string",
",",
"flag",
"int",
",",
"perm",
"os",
".",
"FileMode",
")",
"(",
"*",
"os",
".",
"File",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"OpenFile",
"(",
"name",
",",
"flag",
",",
"perm",
")... | // OpenFile wraps OpenFile from "os". | [
"OpenFile",
"wraps",
"OpenFile",
"from",
"os",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/ioutil/os_wrap.go#L14-L21 |
158,826 | keybase/client | go/kbfs/ioutil/os_wrap.go | Mkdir | func Mkdir(path string, perm os.FileMode) error {
err := os.MkdirAll(path, perm)
if err != nil {
return errors.Wrapf(err, "failed to mkdir %q", path)
}
return nil
} | go | func Mkdir(path string, perm os.FileMode) error {
err := os.MkdirAll(path, perm)
if err != nil {
return errors.Wrapf(err, "failed to mkdir %q", path)
}
return nil
} | [
"func",
"Mkdir",
"(",
"path",
"string",
",",
"perm",
"os",
".",
"FileMode",
")",
"error",
"{",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"path",
",",
"perm",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
"... | // Mkdir wraps MkdirAll from "os". | [
"Mkdir",
"wraps",
"MkdirAll",
"from",
"os",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/ioutil/os_wrap.go#L34-L41 |
158,827 | keybase/client | go/kbfs/ioutil/os_wrap.go | MkdirAll | func MkdirAll(path string, perm os.FileMode) error {
twoAttempts := false
err := os.MkdirAll(path, perm)
// KBFS-3245: Simple workaround for test flake where a directory
// seems to disappear out from under us.
if os.IsNotExist(err) {
twoAttempts = true
err = os.MkdirAll(path, perm)
}
if err != nil {
return errors.Wrapf(err,
"failed to mkdir (all) %q, twoAttempts=%t", path, twoAttempts)
}
return nil
} | go | func MkdirAll(path string, perm os.FileMode) error {
twoAttempts := false
err := os.MkdirAll(path, perm)
// KBFS-3245: Simple workaround for test flake where a directory
// seems to disappear out from under us.
if os.IsNotExist(err) {
twoAttempts = true
err = os.MkdirAll(path, perm)
}
if err != nil {
return errors.Wrapf(err,
"failed to mkdir (all) %q, twoAttempts=%t", path, twoAttempts)
}
return nil
} | [
"func",
"MkdirAll",
"(",
"path",
"string",
",",
"perm",
"os",
".",
"FileMode",
")",
"error",
"{",
"twoAttempts",
":=",
"false",
"\n",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"path",
",",
"perm",
")",
"\n",
"// KBFS-3245: Simple workaround for test flake where... | // MkdirAll wraps MkdirAll from "os". | [
"MkdirAll",
"wraps",
"MkdirAll",
"from",
"os",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/ioutil/os_wrap.go#L44-L59 |
158,828 | keybase/client | go/kbfs/ioutil/os_wrap.go | Stat | func Stat(name string) (os.FileInfo, error) {
info, err := os.Stat(name)
if err != nil {
return nil, errors.Wrapf(err, "failed to stat %q", name)
}
return info, nil
} | go | func Stat(name string) (os.FileInfo, error) {
info, err := os.Stat(name)
if err != nil {
return nil, errors.Wrapf(err, "failed to stat %q", name)
}
return info, nil
} | [
"func",
"Stat",
"(",
"name",
"string",
")",
"(",
"os",
".",
"FileInfo",
",",
"error",
")",
"{",
"info",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrapf",
"(... | // Stat wraps Stat from "os". | [
"Stat",
"wraps",
"Stat",
"from",
"os",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/ioutil/os_wrap.go#L62-L69 |
158,829 | keybase/client | go/kbfs/ioutil/os_wrap.go | Remove | func Remove(name string) error {
err := os.Remove(name)
if err != nil {
return errors.Wrapf(err, "failed to remove %q", name)
}
return nil
} | go | func Remove(name string) error {
err := os.Remove(name)
if err != nil {
return errors.Wrapf(err, "failed to remove %q", name)
}
return nil
} | [
"func",
"Remove",
"(",
"name",
"string",
")",
"error",
"{",
"err",
":=",
"os",
".",
"Remove",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"name",
")",
"\n",
"}",
"\n... | // Remove wraps Remove from "os". | [
"Remove",
"wraps",
"Remove",
"from",
"os",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/ioutil/os_wrap.go#L72-L79 |
158,830 | keybase/client | go/kbfs/ioutil/os_wrap.go | Rename | func Rename(oldpath, newpath string) error {
err := os.Rename(oldpath, newpath)
if err != nil {
return errors.Wrapf(
err, "failed to rename %q to %q", oldpath, newpath)
}
return nil
} | go | func Rename(oldpath, newpath string) error {
err := os.Rename(oldpath, newpath)
if err != nil {
return errors.Wrapf(
err, "failed to rename %q to %q", oldpath, newpath)
}
return nil
} | [
"func",
"Rename",
"(",
"oldpath",
",",
"newpath",
"string",
")",
"error",
"{",
"err",
":=",
"os",
".",
"Rename",
"(",
"oldpath",
",",
"newpath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\""... | // Rename wraps Rename from "os". | [
"Rename",
"wraps",
"Rename",
"from",
"os",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/ioutil/os_wrap.go#L92-L100 |
158,831 | keybase/client | go/libkb/keyfamily.go | Insert | func (cki *ComputedKeyInfos) Insert(i *ComputedKeyInfo) {
cki.Infos[i.KID] = i
cki.dirty = true
} | go | func (cki *ComputedKeyInfos) Insert(i *ComputedKeyInfo) {
cki.Infos[i.KID] = i
cki.dirty = true
} | [
"func",
"(",
"cki",
"*",
"ComputedKeyInfos",
")",
"Insert",
"(",
"i",
"*",
"ComputedKeyInfo",
")",
"{",
"cki",
".",
"Infos",
"[",
"i",
".",
"KID",
"]",
"=",
"i",
"\n",
"cki",
".",
"dirty",
"=",
"true",
"\n",
"}"
] | // Insert inserts the given ComputedKeyInfo object 1 or 2 times,
// depending on if a KID or PGPFingerprint or both are available. | [
"Insert",
"inserts",
"the",
"given",
"ComputedKeyInfo",
"object",
"1",
"or",
"2",
"times",
"depending",
"on",
"if",
"a",
"KID",
"or",
"PGPFingerprint",
"or",
"both",
"are",
"available",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L216-L219 |
158,832 | keybase/client | go/libkb/keyfamily.go | PaperDevices | func (cki *ComputedKeyInfos) PaperDevices() []*Device {
var d []*Device
for _, v := range cki.Devices {
if v.Status == nil {
continue
}
if *v.Status != DeviceStatusActive {
continue
}
if v.Type != DeviceTypePaper {
continue
}
d = append(d, v)
}
return d
} | go | func (cki *ComputedKeyInfos) PaperDevices() []*Device {
var d []*Device
for _, v := range cki.Devices {
if v.Status == nil {
continue
}
if *v.Status != DeviceStatusActive {
continue
}
if v.Type != DeviceTypePaper {
continue
}
d = append(d, v)
}
return d
} | [
"func",
"(",
"cki",
"*",
"ComputedKeyInfos",
")",
"PaperDevices",
"(",
")",
"[",
"]",
"*",
"Device",
"{",
"var",
"d",
"[",
"]",
"*",
"Device",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"cki",
".",
"Devices",
"{",
"if",
"v",
".",
"Status",
"==",
... | // PaperDevices returns a list of all the paperkey devices. | [
"PaperDevices",
"returns",
"a",
"list",
"of",
"all",
"the",
"paperkey",
"devices",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L222-L237 |
158,833 | keybase/client | go/libkb/keyfamily.go | InsertServerEldestKey | func (cki ComputedKeyInfos) InsertServerEldestKey(eldestKey GenericKey, un NormalizedUsername) error {
kbid := KeybaseIdentity(cki.G(), un)
if pgp, ok := eldestKey.(*PGPKeyBundle); ok {
// In the future, we might choose to ignore this etime, as we do in
// InsertEldestLink below. When we do make that change, be certain
// to update the comment in PGPKeyBundle#CheckIdentity to reflect it.
// For now, we continue to honor the foo_user@keybase.io etime in the case
// there's no sigchain link over the key to specify a different etime.
match, ctime, etime := pgp.CheckIdentity(kbid)
etime = cki.G().HonorPGPExpireTime(etime)
if match {
kid := eldestKey.GetKID()
eldestCki := NewComputedKeyInfo(kid, true, true, KeyUncancelled, ctime, etime, "" /* activePGPHash */)
cki.Insert(&eldestCki)
return nil
}
return KeyFamilyError{"InsertServerEldestKey found a non-matching eldest key."}
}
return KeyFamilyError{"InsertServerEldestKey found a non-PGP key."}
} | go | func (cki ComputedKeyInfos) InsertServerEldestKey(eldestKey GenericKey, un NormalizedUsername) error {
kbid := KeybaseIdentity(cki.G(), un)
if pgp, ok := eldestKey.(*PGPKeyBundle); ok {
// In the future, we might choose to ignore this etime, as we do in
// InsertEldestLink below. When we do make that change, be certain
// to update the comment in PGPKeyBundle#CheckIdentity to reflect it.
// For now, we continue to honor the foo_user@keybase.io etime in the case
// there's no sigchain link over the key to specify a different etime.
match, ctime, etime := pgp.CheckIdentity(kbid)
etime = cki.G().HonorPGPExpireTime(etime)
if match {
kid := eldestKey.GetKID()
eldestCki := NewComputedKeyInfo(kid, true, true, KeyUncancelled, ctime, etime, "" /* activePGPHash */)
cki.Insert(&eldestCki)
return nil
}
return KeyFamilyError{"InsertServerEldestKey found a non-matching eldest key."}
}
return KeyFamilyError{"InsertServerEldestKey found a non-PGP key."}
} | [
"func",
"(",
"cki",
"ComputedKeyInfos",
")",
"InsertServerEldestKey",
"(",
"eldestKey",
"GenericKey",
",",
"un",
"NormalizedUsername",
")",
"error",
"{",
"kbid",
":=",
"KeybaseIdentity",
"(",
"cki",
".",
"G",
"(",
")",
",",
"un",
")",
"\n",
"if",
"pgp",
",... | // For use when there are no chain links at all, so all we can do is trust the
// eldest key that the server reported. | [
"For",
"use",
"when",
"there",
"are",
"no",
"chain",
"links",
"at",
"all",
"so",
"all",
"we",
"can",
"do",
"is",
"trust",
"the",
"eldest",
"key",
"that",
"the",
"server",
"reported",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L355-L375 |
158,834 | keybase/client | go/libkb/keyfamily.go | ParseKeyFamily | func ParseKeyFamily(g *GlobalContext, jw *jsonw.Wrapper) (ret *KeyFamily, err error) {
defer g.Trace("ParseKeyFamily", func() error { return err })()
if jw == nil || jw.IsNil() {
err = KeyFamilyError{"nil record from server"}
return
}
kf := KeyFamily{
Contextified: NewContextified(g),
pgp2kid: make(map[PGPFingerprint]keybase1.KID),
kid2pgp: make(map[keybase1.KID]PGPFingerprint),
}
// Fill in AllKeys. Somewhat wasteful but probably faster than
// using Jsonw wrappers, and less error-prone.
var rkf RawKeyFamily
if err = jw.UnmarshalAgain(&rkf); err != nil {
return
}
kf.BundlesForTesting = rkf.AllBundles
// Parse the keys, and collect the PGP keys to map their fingerprints.
kf.AllKIDs = make(map[keybase1.KID]bool)
kf.PGPKeySets = make(map[keybase1.KID]*PGPKeySet)
kf.SingleKeys = make(map[keybase1.KID]GenericKey)
for i, bundle := range rkf.AllBundles {
newKey, w, err := ParseGenericKey(bundle)
// Some users have some historical bad keys, so no reason to crap
// out if we can't parse them, especially if there are others than
// can do just as well.
if err != nil {
g.Log.Notice("Failed to parse public key at position %d", i)
g.Log.Debug("Key parsing error: %s", err)
g.Log.Debug("Full key dump follows")
g.Log.Debug(bundle)
continue
}
w.Warn(g)
kid := newKey.GetKID()
if pgp, isPGP := newKey.(*PGPKeyBundle); isPGP {
ks, ok := kf.PGPKeySets[kid]
if !ok {
ks = &PGPKeySet{NewContextified(g), nil, make(map[string]*PGPKeyBundle)}
kf.PGPKeySets[kid] = ks
fp := pgp.GetFingerprint()
kf.pgp2kid[fp] = kid
kf.kid2pgp[kid] = fp
}
ks.addKey(pgp)
} else {
kf.SingleKeys[kid] = newKey
}
kf.AllKIDs[kid] = true
}
ret = &kf
return
} | go | func ParseKeyFamily(g *GlobalContext, jw *jsonw.Wrapper) (ret *KeyFamily, err error) {
defer g.Trace("ParseKeyFamily", func() error { return err })()
if jw == nil || jw.IsNil() {
err = KeyFamilyError{"nil record from server"}
return
}
kf := KeyFamily{
Contextified: NewContextified(g),
pgp2kid: make(map[PGPFingerprint]keybase1.KID),
kid2pgp: make(map[keybase1.KID]PGPFingerprint),
}
// Fill in AllKeys. Somewhat wasteful but probably faster than
// using Jsonw wrappers, and less error-prone.
var rkf RawKeyFamily
if err = jw.UnmarshalAgain(&rkf); err != nil {
return
}
kf.BundlesForTesting = rkf.AllBundles
// Parse the keys, and collect the PGP keys to map their fingerprints.
kf.AllKIDs = make(map[keybase1.KID]bool)
kf.PGPKeySets = make(map[keybase1.KID]*PGPKeySet)
kf.SingleKeys = make(map[keybase1.KID]GenericKey)
for i, bundle := range rkf.AllBundles {
newKey, w, err := ParseGenericKey(bundle)
// Some users have some historical bad keys, so no reason to crap
// out if we can't parse them, especially if there are others than
// can do just as well.
if err != nil {
g.Log.Notice("Failed to parse public key at position %d", i)
g.Log.Debug("Key parsing error: %s", err)
g.Log.Debug("Full key dump follows")
g.Log.Debug(bundle)
continue
}
w.Warn(g)
kid := newKey.GetKID()
if pgp, isPGP := newKey.(*PGPKeyBundle); isPGP {
ks, ok := kf.PGPKeySets[kid]
if !ok {
ks = &PGPKeySet{NewContextified(g), nil, make(map[string]*PGPKeyBundle)}
kf.PGPKeySets[kid] = ks
fp := pgp.GetFingerprint()
kf.pgp2kid[fp] = kid
kf.kid2pgp[kid] = fp
}
ks.addKey(pgp)
} else {
kf.SingleKeys[kid] = newKey
}
kf.AllKIDs[kid] = true
}
ret = &kf
return
} | [
"func",
"ParseKeyFamily",
"(",
"g",
"*",
"GlobalContext",
",",
"jw",
"*",
"jsonw",
".",
"Wrapper",
")",
"(",
"ret",
"*",
"KeyFamily",
",",
"err",
"error",
")",
"{",
"defer",
"g",
".",
"Trace",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"error",
"{",
... | // ParseKeyFamily takes as input a dictionary from a JSON file and returns
// a parsed version for manipulation in the program. | [
"ParseKeyFamily",
"takes",
"as",
"input",
"a",
"dictionary",
"from",
"a",
"JSON",
"file",
"and",
"returns",
"a",
"parsed",
"version",
"for",
"manipulation",
"in",
"the",
"program",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L419-L481 |
158,835 | keybase/client | go/libkb/keyfamily.go | FindActiveSibkeyAtTime | func (ckf ComputedKeyFamily) FindActiveSibkeyAtTime(kid keybase1.KID, t time.Time) (key GenericKey, cki ComputedKeyInfo, err error) {
liveCki, err := ckf.getCkiIfActiveAtTime(kid, t)
if liveCki == nil || err != nil {
// err gets returned.
} else if !liveCki.Sibkey {
err = kbcrypto.BadKeyError{Msg: fmt.Sprintf("The key '%s' wasn't delegated as a sibkey", kid)}
} else {
key, err = ckf.FindKeyWithKIDUnsafe(kid)
cki = *liveCki
}
return
} | go | func (ckf ComputedKeyFamily) FindActiveSibkeyAtTime(kid keybase1.KID, t time.Time) (key GenericKey, cki ComputedKeyInfo, err error) {
liveCki, err := ckf.getCkiIfActiveAtTime(kid, t)
if liveCki == nil || err != nil {
// err gets returned.
} else if !liveCki.Sibkey {
err = kbcrypto.BadKeyError{Msg: fmt.Sprintf("The key '%s' wasn't delegated as a sibkey", kid)}
} else {
key, err = ckf.FindKeyWithKIDUnsafe(kid)
cki = *liveCki
}
return
} | [
"func",
"(",
"ckf",
"ComputedKeyFamily",
")",
"FindActiveSibkeyAtTime",
"(",
"kid",
"keybase1",
".",
"KID",
",",
"t",
"time",
".",
"Time",
")",
"(",
"key",
"GenericKey",
",",
"cki",
"ComputedKeyInfo",
",",
"err",
"error",
")",
"{",
"liveCki",
",",
"err",
... | // As FindActiveSibkey, but for a specific time. Note that going back in time
// only affects expiration, not revocation. Thus this function is mainly useful
// for validating the sigchain, when each delegation and revocation is getting
// replayed in order. | [
"As",
"FindActiveSibkey",
"but",
"for",
"a",
"specific",
"time",
".",
"Note",
"that",
"going",
"back",
"in",
"time",
"only",
"affects",
"expiration",
"not",
"revocation",
".",
"Thus",
"this",
"function",
"is",
"mainly",
"useful",
"for",
"validating",
"the",
... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L541-L552 |
158,836 | keybase/client | go/libkb/keyfamily.go | FindActiveEncryptionSubkey | func (ckf ComputedKeyFamily) FindActiveEncryptionSubkey(kid keybase1.KID) (ret GenericKey, cki ComputedKeyInfo, err error) {
ckip, err := ckf.getCkiIfActiveNow(kid)
if err != nil {
return nil, cki, err
}
if ckip.Sibkey {
return nil, cki, kbcrypto.BadKeyError{Msg: fmt.Sprintf("The key '%s' was delegated as a sibkey", kid.String())}
}
key, err := ckf.FindKeyWithKIDUnsafe(kid)
if err != nil {
return nil, cki, err
}
if !CanEncrypt(key) {
return nil, cki, kbcrypto.BadKeyError{Msg: fmt.Sprintf("The key '%s' cannot encrypt", kid.String())}
}
return key, *ckip, nil
} | go | func (ckf ComputedKeyFamily) FindActiveEncryptionSubkey(kid keybase1.KID) (ret GenericKey, cki ComputedKeyInfo, err error) {
ckip, err := ckf.getCkiIfActiveNow(kid)
if err != nil {
return nil, cki, err
}
if ckip.Sibkey {
return nil, cki, kbcrypto.BadKeyError{Msg: fmt.Sprintf("The key '%s' was delegated as a sibkey", kid.String())}
}
key, err := ckf.FindKeyWithKIDUnsafe(kid)
if err != nil {
return nil, cki, err
}
if !CanEncrypt(key) {
return nil, cki, kbcrypto.BadKeyError{Msg: fmt.Sprintf("The key '%s' cannot encrypt", kid.String())}
}
return key, *ckip, nil
} | [
"func",
"(",
"ckf",
"ComputedKeyFamily",
")",
"FindActiveEncryptionSubkey",
"(",
"kid",
"keybase1",
".",
"KID",
")",
"(",
"ret",
"GenericKey",
",",
"cki",
"ComputedKeyInfo",
",",
"err",
"error",
")",
"{",
"ckip",
",",
"err",
":=",
"ckf",
".",
"getCkiIfActive... | // FindActiveEncryptionSubkey takes a given KID and finds the corresponding
// active encryption subkey in the current key family. If for any reason it
// cannot find the key, it will return an error saying why. Otherwise, it will
// return the key. In this case either key is non-nil, or err is non-nil. | [
"FindActiveEncryptionSubkey",
"takes",
"a",
"given",
"KID",
"and",
"finds",
"the",
"corresponding",
"active",
"encryption",
"subkey",
"in",
"the",
"current",
"key",
"family",
".",
"If",
"for",
"any",
"reason",
"it",
"cannot",
"find",
"the",
"key",
"it",
"will"... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L558-L574 |
158,837 | keybase/client | go/libkb/keyfamily.go | TclToKeybaseTime | func TclToKeybaseTime(tcl TypedChainLink) *KeybaseTime {
return &KeybaseTime{
Unix: tcl.GetCTime().Unix(),
Chain: tcl.GetMerkleSeqno(),
}
} | go | func TclToKeybaseTime(tcl TypedChainLink) *KeybaseTime {
return &KeybaseTime{
Unix: tcl.GetCTime().Unix(),
Chain: tcl.GetMerkleSeqno(),
}
} | [
"func",
"TclToKeybaseTime",
"(",
"tcl",
"TypedChainLink",
")",
"*",
"KeybaseTime",
"{",
"return",
"&",
"KeybaseTime",
"{",
"Unix",
":",
"tcl",
".",
"GetCTime",
"(",
")",
".",
"Unix",
"(",
")",
",",
"Chain",
":",
"tcl",
".",
"GetMerkleSeqno",
"(",
")",
... | // TclToKeybaseTime turns a TypedChainLink into a KeybaseTime tuple, looking
// inside the chainlink for the Unix wallclock and the global MerkleChain seqno. | [
"TclToKeybaseTime",
"turns",
"a",
"TypedChainLink",
"into",
"a",
"KeybaseTime",
"tuple",
"looking",
"inside",
"the",
"chainlink",
"for",
"the",
"Unix",
"wallclock",
"and",
"the",
"global",
"MerkleChain",
"seqno",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L586-L591 |
158,838 | keybase/client | go/libkb/keyfamily.go | NowAsKeybaseTime | func NowAsKeybaseTime(seqno keybase1.Seqno) *KeybaseTime {
return &KeybaseTime{
Unix: time.Now().Unix(),
Chain: seqno,
}
} | go | func NowAsKeybaseTime(seqno keybase1.Seqno) *KeybaseTime {
return &KeybaseTime{
Unix: time.Now().Unix(),
Chain: seqno,
}
} | [
"func",
"NowAsKeybaseTime",
"(",
"seqno",
"keybase1",
".",
"Seqno",
")",
"*",
"KeybaseTime",
"{",
"return",
"&",
"KeybaseTime",
"{",
"Unix",
":",
"time",
".",
"Now",
"(",
")",
".",
"Unix",
"(",
")",
",",
"Chain",
":",
"seqno",
",",
"}",
"\n",
"}"
] | // NowAsKeybaseTime makes a representation of now. IF we don't know the MerkleTree
// chain seqno, just use 0 | [
"NowAsKeybaseTime",
"makes",
"a",
"representation",
"of",
"now",
".",
"IF",
"we",
"don",
"t",
"know",
"the",
"MerkleTree",
"chain",
"seqno",
"just",
"use",
"0"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L595-L600 |
158,839 | keybase/client | go/libkb/keyfamily.go | Delegate | func (ckf *ComputedKeyFamily) Delegate(tcl TypedChainLink) (err error) {
kid := tcl.GetDelegatedKid()
sigid := tcl.GetSigID()
tm := TclToKeybaseTime(tcl)
if kid.IsNil() {
debug.PrintStack()
return KeyFamilyError{fmt.Sprintf("Delegated KID is nil %T", tcl)}
}
if _, err := ckf.FindKeyWithKIDUnsafe(kid); err != nil {
return KeyFamilyError{fmt.Sprintf("Delegated KID %s is not in the key family", kid.String())}
}
mhm, err := tcl.GetMerkleHashMeta()
if err != nil {
return err
}
err = ckf.cki.Delegate(kid, tm, sigid, tcl.GetKID(), tcl.GetParentKid(),
tcl.GetPGPFullHash(), (tcl.GetRole() == DLGSibkey), tcl.GetCTime(), tcl.GetETime(),
mhm, tcl.GetFirstAppearedMerkleSeqnoUnverified(), tcl.ToSigChainLocation())
return
} | go | func (ckf *ComputedKeyFamily) Delegate(tcl TypedChainLink) (err error) {
kid := tcl.GetDelegatedKid()
sigid := tcl.GetSigID()
tm := TclToKeybaseTime(tcl)
if kid.IsNil() {
debug.PrintStack()
return KeyFamilyError{fmt.Sprintf("Delegated KID is nil %T", tcl)}
}
if _, err := ckf.FindKeyWithKIDUnsafe(kid); err != nil {
return KeyFamilyError{fmt.Sprintf("Delegated KID %s is not in the key family", kid.String())}
}
mhm, err := tcl.GetMerkleHashMeta()
if err != nil {
return err
}
err = ckf.cki.Delegate(kid, tm, sigid, tcl.GetKID(), tcl.GetParentKid(),
tcl.GetPGPFullHash(), (tcl.GetRole() == DLGSibkey), tcl.GetCTime(), tcl.GetETime(),
mhm, tcl.GetFirstAppearedMerkleSeqnoUnverified(), tcl.ToSigChainLocation())
return
} | [
"func",
"(",
"ckf",
"*",
"ComputedKeyFamily",
")",
"Delegate",
"(",
"tcl",
"TypedChainLink",
")",
"(",
"err",
"error",
")",
"{",
"kid",
":=",
"tcl",
".",
"GetDelegatedKid",
"(",
")",
"\n",
"sigid",
":=",
"tcl",
".",
"GetSigID",
"(",
")",
"\n",
"tm",
... | // Delegate performs a delegation to the key described in the given TypedChainLink.
// This maybe be a sub- or sibkey delegation. | [
"Delegate",
"performs",
"a",
"delegation",
"to",
"the",
"key",
"described",
"in",
"the",
"given",
"TypedChainLink",
".",
"This",
"maybe",
"be",
"a",
"sub",
"-",
"or",
"sibkey",
"delegation",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L604-L628 |
158,840 | keybase/client | go/libkb/keyfamily.go | Delegate | func (cki *ComputedKeyInfos) Delegate(kid keybase1.KID, tm *KeybaseTime, sigid keybase1.SigID, signingKid, parentKID keybase1.KID,
pgpHash string, isSibkey bool, ctime, etime time.Time,
merkleHashMeta keybase1.HashMeta, fau keybase1.Seqno,
dascl keybase1.SigChainLocation) (err error) {
cki.G().Log.Debug("ComputeKeyInfos#Delegate To %s with %s at sig %s", kid.String(), signingKid, sigid.ToDisplayString(true))
info, found := cki.Infos[kid]
etimeUnix := cki.G().HonorSigchainExpireTime(etime.Unix())
if !found {
newInfo := NewComputedKeyInfo(kid, false, isSibkey, KeyUncancelled, ctime.Unix(), etimeUnix, pgpHash)
newInfo.DelegatedAt = tm
info = &newInfo
cki.Infos[kid] = info
} else {
info.Status = KeyUncancelled
info.CTime = ctime.Unix()
info.ETime = etimeUnix
}
info.Delegations[sigid] = signingKid
info.DelegationsList = append(info.DelegationsList, Delegation{signingKid, sigid})
info.Sibkey = isSibkey
info.DelegatedAtHashMeta = merkleHashMeta.DeepCopy()
info.DelegatedAtSigChainLocation = dascl.DeepCopy()
info.FirstAppearedUnverified = fau
cki.Sigs[sigid] = info
// If it's a subkey, make a pointer from it to its parent,
// and also from its parent to it.
if parentKID.Exists() {
info.Parent = parentKID
if parent, found := cki.Infos[parentKID]; found {
parent.Subkey = kid
}
}
return
} | go | func (cki *ComputedKeyInfos) Delegate(kid keybase1.KID, tm *KeybaseTime, sigid keybase1.SigID, signingKid, parentKID keybase1.KID,
pgpHash string, isSibkey bool, ctime, etime time.Time,
merkleHashMeta keybase1.HashMeta, fau keybase1.Seqno,
dascl keybase1.SigChainLocation) (err error) {
cki.G().Log.Debug("ComputeKeyInfos#Delegate To %s with %s at sig %s", kid.String(), signingKid, sigid.ToDisplayString(true))
info, found := cki.Infos[kid]
etimeUnix := cki.G().HonorSigchainExpireTime(etime.Unix())
if !found {
newInfo := NewComputedKeyInfo(kid, false, isSibkey, KeyUncancelled, ctime.Unix(), etimeUnix, pgpHash)
newInfo.DelegatedAt = tm
info = &newInfo
cki.Infos[kid] = info
} else {
info.Status = KeyUncancelled
info.CTime = ctime.Unix()
info.ETime = etimeUnix
}
info.Delegations[sigid] = signingKid
info.DelegationsList = append(info.DelegationsList, Delegation{signingKid, sigid})
info.Sibkey = isSibkey
info.DelegatedAtHashMeta = merkleHashMeta.DeepCopy()
info.DelegatedAtSigChainLocation = dascl.DeepCopy()
info.FirstAppearedUnverified = fau
cki.Sigs[sigid] = info
// If it's a subkey, make a pointer from it to its parent,
// and also from its parent to it.
if parentKID.Exists() {
info.Parent = parentKID
if parent, found := cki.Infos[parentKID]; found {
parent.Subkey = kid
}
}
return
} | [
"func",
"(",
"cki",
"*",
"ComputedKeyInfos",
")",
"Delegate",
"(",
"kid",
"keybase1",
".",
"KID",
",",
"tm",
"*",
"KeybaseTime",
",",
"sigid",
"keybase1",
".",
"SigID",
",",
"signingKid",
",",
"parentKID",
"keybase1",
".",
"KID",
",",
"pgpHash",
"string",
... | // Delegate marks the given ComputedKeyInfos object that the given kid is now
// delegated, as of time tm, in sigid, as signed by signingKid, etc.
// fau = "FirstAppearedUnverified", a hint from the server that we're going to persist.
// dascl = "DelegatedAtSigChainLocation" | [
"Delegate",
"marks",
"the",
"given",
"ComputedKeyInfos",
"object",
"that",
"the",
"given",
"kid",
"is",
"now",
"delegated",
"as",
"of",
"time",
"tm",
"in",
"sigid",
"as",
"signed",
"by",
"signingKid",
"etc",
".",
"fau",
"=",
"FirstAppearedUnverified",
"a",
"... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L638-L674 |
158,841 | keybase/client | go/libkb/keyfamily.go | DelegatePerUserKey | func (cki *ComputedKeyInfos) DelegatePerUserKey(perUserKey keybase1.PerUserKey) (err error) {
if perUserKey.Gen <= 0 {
return fmt.Errorf("invalid per-user-key generation %v", perUserKey.Gen)
}
if perUserKey.Seqno == 0 {
return fmt.Errorf("invalid per-user-key seqno: %v", perUserKey.Seqno)
}
if perUserKey.SigKID.IsNil() {
return errors.New("nil per-user-key sig kid")
}
if perUserKey.EncKID.IsNil() {
return errors.New("nil per-user-key enc kid")
}
if perUserKey.SignedByKID.IsNil() {
return errors.New("nil per-user-key signed-by kid")
}
cki.PerUserKeys[keybase1.PerUserKeyGeneration(perUserKey.Gen)] = perUserKey
return nil
} | go | func (cki *ComputedKeyInfos) DelegatePerUserKey(perUserKey keybase1.PerUserKey) (err error) {
if perUserKey.Gen <= 0 {
return fmt.Errorf("invalid per-user-key generation %v", perUserKey.Gen)
}
if perUserKey.Seqno == 0 {
return fmt.Errorf("invalid per-user-key seqno: %v", perUserKey.Seqno)
}
if perUserKey.SigKID.IsNil() {
return errors.New("nil per-user-key sig kid")
}
if perUserKey.EncKID.IsNil() {
return errors.New("nil per-user-key enc kid")
}
if perUserKey.SignedByKID.IsNil() {
return errors.New("nil per-user-key signed-by kid")
}
cki.PerUserKeys[keybase1.PerUserKeyGeneration(perUserKey.Gen)] = perUserKey
return nil
} | [
"func",
"(",
"cki",
"*",
"ComputedKeyInfos",
")",
"DelegatePerUserKey",
"(",
"perUserKey",
"keybase1",
".",
"PerUserKey",
")",
"(",
"err",
"error",
")",
"{",
"if",
"perUserKey",
".",
"Gen",
"<=",
"0",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",... | // DelegatePerUserKey inserts the new per-user key into the list of known per-user keys. | [
"DelegatePerUserKey",
"inserts",
"the",
"new",
"per",
"-",
"user",
"key",
"into",
"the",
"list",
"of",
"known",
"per",
"-",
"user",
"keys",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L681-L699 |
158,842 | keybase/client | go/libkb/keyfamily.go | Revoke | func (ckf *ComputedKeyFamily) Revoke(tcl TypedChainLink) (err error) {
err = ckf.revokeSigs(tcl.GetRevocations(), tcl)
if err == nil {
err = ckf.revokeKids(tcl.GetRevokeKids(), tcl)
}
return err
} | go | func (ckf *ComputedKeyFamily) Revoke(tcl TypedChainLink) (err error) {
err = ckf.revokeSigs(tcl.GetRevocations(), tcl)
if err == nil {
err = ckf.revokeKids(tcl.GetRevokeKids(), tcl)
}
return err
} | [
"func",
"(",
"ckf",
"*",
"ComputedKeyFamily",
")",
"Revoke",
"(",
"tcl",
"TypedChainLink",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"ckf",
".",
"revokeSigs",
"(",
"tcl",
".",
"GetRevocations",
"(",
")",
",",
"tcl",
")",
"\n",
"if",
"err",
"=="... | // Revoke examines a TypeChainLink and applies any revocations in the link
// to the current ComputedKeyInfos. | [
"Revoke",
"examines",
"a",
"TypeChainLink",
"and",
"applies",
"any",
"revocations",
"in",
"the",
"link",
"to",
"the",
"current",
"ComputedKeyInfos",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L703-L709 |
158,843 | keybase/client | go/libkb/keyfamily.go | ClearActivePGPHash | func (ckf *ComputedKeyFamily) ClearActivePGPHash(kid keybase1.KID) {
if _, ok := ckf.cki.Infos[kid]; ok {
ckf.cki.Infos[kid].ActivePGPHash = ""
} else {
ckf.G().Log.Debug("| Skipped clearing active hash, since key was never delegated")
}
} | go | func (ckf *ComputedKeyFamily) ClearActivePGPHash(kid keybase1.KID) {
if _, ok := ckf.cki.Infos[kid]; ok {
ckf.cki.Infos[kid].ActivePGPHash = ""
} else {
ckf.G().Log.Debug("| Skipped clearing active hash, since key was never delegated")
}
} | [
"func",
"(",
"ckf",
"*",
"ComputedKeyFamily",
")",
"ClearActivePGPHash",
"(",
"kid",
"keybase1",
".",
"KID",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"ckf",
".",
"cki",
".",
"Infos",
"[",
"kid",
"]",
";",
"ok",
"{",
"ckf",
".",
"cki",
".",
"Infos",
... | // ClearActivePGPHash clears authoritative hash of PGP key, after a revoke. | [
"ClearActivePGPHash",
"clears",
"authoritative",
"hash",
"of",
"PGP",
"key",
"after",
"a",
"revoke",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L733-L739 |
158,844 | keybase/client | go/libkb/keyfamily.go | revokeSigs | func (ckf *ComputedKeyFamily) revokeSigs(sigs []keybase1.SigID, tcl TypedChainLink) error {
for _, s := range sigs {
if len(s) == 0 {
continue
}
if err := ckf.RevokeSig(s, tcl); err != nil {
return err
}
}
return nil
} | go | func (ckf *ComputedKeyFamily) revokeSigs(sigs []keybase1.SigID, tcl TypedChainLink) error {
for _, s := range sigs {
if len(s) == 0 {
continue
}
if err := ckf.RevokeSig(s, tcl); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"ckf",
"*",
"ComputedKeyFamily",
")",
"revokeSigs",
"(",
"sigs",
"[",
"]",
"keybase1",
".",
"SigID",
",",
"tcl",
"TypedChainLink",
")",
"error",
"{",
"for",
"_",
",",
"s",
":=",
"range",
"sigs",
"{",
"if",
"len",
"(",
"s",
")",
"==",
"... | // revokeSigs operates on the per-signature revocations in the given
// TypedChainLink and applies them accordingly. | [
"revokeSigs",
"operates",
"on",
"the",
"per",
"-",
"signature",
"revocations",
"in",
"the",
"given",
"TypedChainLink",
"and",
"applies",
"them",
"accordingly",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L743-L753 |
158,845 | keybase/client | go/libkb/keyfamily.go | revokeKids | func (ckf *ComputedKeyFamily) revokeKids(kids []keybase1.KID, tcl TypedChainLink) (err error) {
for _, k := range kids {
if k.Exists() {
if err = ckf.RevokeKid(k, tcl); err != nil {
return
}
}
}
return
} | go | func (ckf *ComputedKeyFamily) revokeKids(kids []keybase1.KID, tcl TypedChainLink) (err error) {
for _, k := range kids {
if k.Exists() {
if err = ckf.RevokeKid(k, tcl); err != nil {
return
}
}
}
return
} | [
"func",
"(",
"ckf",
"*",
"ComputedKeyFamily",
")",
"revokeKids",
"(",
"kids",
"[",
"]",
"keybase1",
".",
"KID",
",",
"tcl",
"TypedChainLink",
")",
"(",
"err",
"error",
")",
"{",
"for",
"_",
",",
"k",
":=",
"range",
"kids",
"{",
"if",
"k",
".",
"Exi... | // revokeKids operates on the per-kid revocations in the given
// TypedChainLink and applies them accordingly. | [
"revokeKids",
"operates",
"on",
"the",
"per",
"-",
"kid",
"revocations",
"in",
"the",
"given",
"TypedChainLink",
"and",
"applies",
"them",
"accordingly",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L757-L766 |
158,846 | keybase/client | go/libkb/keyfamily.go | FindKeybaseName | func (ckf ComputedKeyFamily) FindKeybaseName(s string) bool {
kem := KeybaseEmailAddress(s)
for kid := range ckf.kf.PGPKeySets {
if info, found := ckf.cki.Infos[kid]; !found {
continue
} else if info.Status != KeyUncancelled || !info.Sibkey {
continue
}
pgp := ckf.kf.PGPKeySets[kid].PermissivelyMergedKey
if pgp.FindEmail(kem) {
ckf.G().Log.Debug("| Found self-sig for %s in key ID: %s", s, kid)
return true
}
}
return false
} | go | func (ckf ComputedKeyFamily) FindKeybaseName(s string) bool {
kem := KeybaseEmailAddress(s)
for kid := range ckf.kf.PGPKeySets {
if info, found := ckf.cki.Infos[kid]; !found {
continue
} else if info.Status != KeyUncancelled || !info.Sibkey {
continue
}
pgp := ckf.kf.PGPKeySets[kid].PermissivelyMergedKey
if pgp.FindEmail(kem) {
ckf.G().Log.Debug("| Found self-sig for %s in key ID: %s", s, kid)
return true
}
}
return false
} | [
"func",
"(",
"ckf",
"ComputedKeyFamily",
")",
"FindKeybaseName",
"(",
"s",
"string",
")",
"bool",
"{",
"kem",
":=",
"KeybaseEmailAddress",
"(",
"s",
")",
"\n",
"for",
"kid",
":=",
"range",
"ckf",
".",
"kf",
".",
"PGPKeySets",
"{",
"if",
"info",
",",
"f... | // FindKeybaseName looks at all PGP keys in this key family that are active
// sibkeys to find a key with a signed identity of <name@keybase.io>. IF
// found return true, and otherwise false. | [
"FindKeybaseName",
"looks",
"at",
"all",
"PGP",
"keys",
"in",
"this",
"key",
"family",
"that",
"are",
"active",
"sibkeys",
"to",
"find",
"a",
"key",
"with",
"a",
"signed",
"identity",
"of",
"<name"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L823-L838 |
158,847 | keybase/client | go/libkb/keyfamily.go | LocalDelegate | func (kf *KeyFamily) LocalDelegate(key GenericKey) (err error) {
if pgp, ok := key.(*PGPKeyBundle); ok {
kid := pgp.GetKID()
kf.pgp2kid[pgp.GetFingerprint()] = kid
}
kf.SingleKeys[key.GetKID()] = key
return
} | go | func (kf *KeyFamily) LocalDelegate(key GenericKey) (err error) {
if pgp, ok := key.(*PGPKeyBundle); ok {
kid := pgp.GetKID()
kf.pgp2kid[pgp.GetFingerprint()] = kid
}
kf.SingleKeys[key.GetKID()] = key
return
} | [
"func",
"(",
"kf",
"*",
"KeyFamily",
")",
"LocalDelegate",
"(",
"key",
"GenericKey",
")",
"(",
"err",
"error",
")",
"{",
"if",
"pgp",
",",
"ok",
":=",
"key",
".",
"(",
"*",
"PGPKeyBundle",
")",
";",
"ok",
"{",
"kid",
":=",
"pgp",
".",
"GetKID",
"... | // LocalDelegate performs a local key delegation, without the server's permissions.
// We'll need to do this when a key is locally generated. | [
"LocalDelegate",
"performs",
"a",
"local",
"key",
"delegation",
"without",
"the",
"server",
"s",
"permissions",
".",
"We",
"ll",
"need",
"to",
"do",
"this",
"when",
"a",
"key",
"is",
"locally",
"generated",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L842-L849 |
158,848 | keybase/client | go/libkb/keyfamily.go | HasActiveKey | func (ckf ComputedKeyFamily) HasActiveKey() bool {
for kid := range ckf.kf.AllKIDs {
if ckf.GetKeyRole(kid) == DLGSibkey {
return true
}
}
return false
} | go | func (ckf ComputedKeyFamily) HasActiveKey() bool {
for kid := range ckf.kf.AllKIDs {
if ckf.GetKeyRole(kid) == DLGSibkey {
return true
}
}
return false
} | [
"func",
"(",
"ckf",
"ComputedKeyFamily",
")",
"HasActiveKey",
"(",
")",
"bool",
"{",
"for",
"kid",
":=",
"range",
"ckf",
".",
"kf",
".",
"AllKIDs",
"{",
"if",
"ckf",
".",
"GetKeyRole",
"(",
"kid",
")",
"==",
"DLGSibkey",
"{",
"return",
"true",
"\n",
... | // HasActiveKey returns if the given ComputeKeyFamily has any active keys.
// The key has to be in the server-given KeyFamily and also in our ComputedKeyFamily.
// The former check is so that we can handle the case nuked sigchains. | [
"HasActiveKey",
"returns",
"if",
"the",
"given",
"ComputeKeyFamily",
"has",
"any",
"active",
"keys",
".",
"The",
"key",
"has",
"to",
"be",
"in",
"the",
"server",
"-",
"given",
"KeyFamily",
"and",
"also",
"in",
"our",
"ComputedKeyFamily",
".",
"The",
"former"... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L959-L966 |
158,849 | keybase/client | go/libkb/keyfamily.go | GetActivePGPKeys | func (ckf ComputedKeyFamily) GetActivePGPKeys(sibkey bool) (ret []*PGPKeyBundle) {
for kid := range ckf.kf.PGPKeySets {
role := ckf.GetKeyRole(kid)
if (sibkey && role == DLGSibkey) || role != DLGNone {
if key, err := ckf.FindKeyWithKIDUnsafe(kid); err == nil {
ret = append(ret, key.(*PGPKeyBundle))
} else {
ckf.G().Log.Errorf("KID %s was in a KeyFamily's list of PGP keys, but the key doesn't exist: %s", kid, err)
}
}
}
return
} | go | func (ckf ComputedKeyFamily) GetActivePGPKeys(sibkey bool) (ret []*PGPKeyBundle) {
for kid := range ckf.kf.PGPKeySets {
role := ckf.GetKeyRole(kid)
if (sibkey && role == DLGSibkey) || role != DLGNone {
if key, err := ckf.FindKeyWithKIDUnsafe(kid); err == nil {
ret = append(ret, key.(*PGPKeyBundle))
} else {
ckf.G().Log.Errorf("KID %s was in a KeyFamily's list of PGP keys, but the key doesn't exist: %s", kid, err)
}
}
}
return
} | [
"func",
"(",
"ckf",
"ComputedKeyFamily",
")",
"GetActivePGPKeys",
"(",
"sibkey",
"bool",
")",
"(",
"ret",
"[",
"]",
"*",
"PGPKeyBundle",
")",
"{",
"for",
"kid",
":=",
"range",
"ckf",
".",
"kf",
".",
"PGPKeySets",
"{",
"role",
":=",
"ckf",
".",
"GetKeyR... | // GetActivePGPKeys gets the active PGP keys from the ComputedKeyFamily.
// If sibkey is False it will return all active PGP keys. Otherwise, it
// will return only the Sibkeys. Note the keys need to be non-canceled,
// and non-expired. | [
"GetActivePGPKeys",
"gets",
"the",
"active",
"PGP",
"keys",
"from",
"the",
"ComputedKeyFamily",
".",
"If",
"sibkey",
"is",
"False",
"it",
"will",
"return",
"all",
"active",
"PGP",
"keys",
".",
"Otherwise",
"it",
"will",
"return",
"only",
"the",
"Sibkeys",
".... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L972-L984 |
158,850 | keybase/client | go/libkb/keyfamily.go | UpdateDevices | func (ckf *ComputedKeyFamily) UpdateDevices(tcl TypedChainLink) (err error) {
var dobj *Device
if dobj = tcl.GetDevice(); dobj == nil {
ckf.G().VDL.Log(VLog1, "Short-circuit of UpdateDevices(); not a device link")
return
}
defer ckf.G().Trace("UpdateDevice", func() error { return err })()
did := dobj.ID
kid := dobj.Kid
ckf.G().Log.Debug("| Device ID=%s; KID=%s", did, kid.String())
var prevKid keybase1.KID
if existing, found := ckf.cki.Devices[did]; found {
ckf.G().Log.Debug("| merge with existing")
prevKid = existing.Kid
existing.Merge(dobj)
dobj = existing
} else {
ckf.G().Log.Debug("| New insert")
ckf.cki.Devices[did] = dobj
}
// If a KID is specified, we should clear out any previous KID from the
// KID->Device map. But if not, leave the map as it is. Later "device"
// blobs in the sigchain aren't required to repeat the KID every time.
if kid.IsValid() {
if prevKid.IsValid() {
ckf.G().Log.Debug("| Clear out old key")
delete(ckf.cki.KIDToDeviceID, prevKid)
}
ckf.cki.KIDToDeviceID[kid] = did
}
return
} | go | func (ckf *ComputedKeyFamily) UpdateDevices(tcl TypedChainLink) (err error) {
var dobj *Device
if dobj = tcl.GetDevice(); dobj == nil {
ckf.G().VDL.Log(VLog1, "Short-circuit of UpdateDevices(); not a device link")
return
}
defer ckf.G().Trace("UpdateDevice", func() error { return err })()
did := dobj.ID
kid := dobj.Kid
ckf.G().Log.Debug("| Device ID=%s; KID=%s", did, kid.String())
var prevKid keybase1.KID
if existing, found := ckf.cki.Devices[did]; found {
ckf.G().Log.Debug("| merge with existing")
prevKid = existing.Kid
existing.Merge(dobj)
dobj = existing
} else {
ckf.G().Log.Debug("| New insert")
ckf.cki.Devices[did] = dobj
}
// If a KID is specified, we should clear out any previous KID from the
// KID->Device map. But if not, leave the map as it is. Later "device"
// blobs in the sigchain aren't required to repeat the KID every time.
if kid.IsValid() {
if prevKid.IsValid() {
ckf.G().Log.Debug("| Clear out old key")
delete(ckf.cki.KIDToDeviceID, prevKid)
}
ckf.cki.KIDToDeviceID[kid] = did
}
return
} | [
"func",
"(",
"ckf",
"*",
"ComputedKeyFamily",
")",
"UpdateDevices",
"(",
"tcl",
"TypedChainLink",
")",
"(",
"err",
"error",
")",
"{",
"var",
"dobj",
"*",
"Device",
"\n",
"if",
"dobj",
"=",
"tcl",
".",
"GetDevice",
"(",
")",
";",
"dobj",
"==",
"nil",
... | // UpdateDevices takes the Device object from the given ChainLink
// and updates keys to reflects any device changes encoded therein. | [
"UpdateDevices",
"takes",
"the",
"Device",
"object",
"from",
"the",
"given",
"ChainLink",
"and",
"updates",
"keys",
"to",
"reflects",
"any",
"device",
"changes",
"encoded",
"therein",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L1049-L1087 |
158,851 | keybase/client | go/libkb/keyfamily.go | GetSibkeyForDevice | func (ckf *ComputedKeyFamily) GetSibkeyForDevice(did keybase1.DeviceID) (key GenericKey, err error) {
var kid keybase1.KID
kid, err = ckf.getSibkeyKidForDevice(did)
if kid.Exists() {
key, _, err = ckf.FindActiveSibkey(kid)
}
return
} | go | func (ckf *ComputedKeyFamily) GetSibkeyForDevice(did keybase1.DeviceID) (key GenericKey, err error) {
var kid keybase1.KID
kid, err = ckf.getSibkeyKidForDevice(did)
if kid.Exists() {
key, _, err = ckf.FindActiveSibkey(kid)
}
return
} | [
"func",
"(",
"ckf",
"*",
"ComputedKeyFamily",
")",
"GetSibkeyForDevice",
"(",
"did",
"keybase1",
".",
"DeviceID",
")",
"(",
"key",
"GenericKey",
",",
"err",
"error",
")",
"{",
"var",
"kid",
"keybase1",
".",
"KID",
"\n",
"kid",
",",
"err",
"=",
"ckf",
"... | // GetSibkeyForDevice gets the current per-device key for the given Device. Will
// return nil if one isn't found, and set err for a real error. The sibkey should
// be a signing key, not an encryption key of course. | [
"GetSibkeyForDevice",
"gets",
"the",
"current",
"per",
"-",
"device",
"key",
"for",
"the",
"given",
"Device",
".",
"Will",
"return",
"nil",
"if",
"one",
"isn",
"t",
"found",
"and",
"set",
"err",
"for",
"a",
"real",
"error",
".",
"The",
"sibkey",
"should"... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L1111-L1118 |
158,852 | keybase/client | go/libkb/keyfamily.go | GetCurrentDevice | func (ckf *ComputedKeyFamily) GetCurrentDevice(g *GlobalContext) (*Device, error) {
did := g.Env.GetDeviceID()
if did.IsNil() {
return nil, NotProvisionedError{}
}
dev, ok := ckf.cki.Devices[did]
if !ok {
return nil, NotFoundError{}
}
return dev, nil
} | go | func (ckf *ComputedKeyFamily) GetCurrentDevice(g *GlobalContext) (*Device, error) {
did := g.Env.GetDeviceID()
if did.IsNil() {
return nil, NotProvisionedError{}
}
dev, ok := ckf.cki.Devices[did]
if !ok {
return nil, NotFoundError{}
}
return dev, nil
} | [
"func",
"(",
"ckf",
"*",
"ComputedKeyFamily",
")",
"GetCurrentDevice",
"(",
"g",
"*",
"GlobalContext",
")",
"(",
"*",
"Device",
",",
"error",
")",
"{",
"did",
":=",
"g",
".",
"Env",
".",
"GetDeviceID",
"(",
")",
"\n",
"if",
"did",
".",
"IsNil",
"(",
... | // GetCurrentDevice returns the current device. | [
"GetCurrentDevice",
"returns",
"the",
"current",
"device",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L1121-L1133 |
158,853 | keybase/client | go/libkb/keyfamily.go | GetEncryptionSubkeyForDevice | func (ckf *ComputedKeyFamily) GetEncryptionSubkeyForDevice(did keybase1.DeviceID) (key GenericKey, err error) {
var kid keybase1.KID
if kid, err = ckf.getSibkeyKidForDevice(did); err != nil {
return
}
if kid.IsNil() {
return
}
if cki, found := ckf.cki.Infos[kid]; !found {
return
} else if !cki.Subkey.IsValid() {
return
} else {
key, _, err = ckf.FindActiveEncryptionSubkey(cki.Subkey)
}
return
} | go | func (ckf *ComputedKeyFamily) GetEncryptionSubkeyForDevice(did keybase1.DeviceID) (key GenericKey, err error) {
var kid keybase1.KID
if kid, err = ckf.getSibkeyKidForDevice(did); err != nil {
return
}
if kid.IsNil() {
return
}
if cki, found := ckf.cki.Infos[kid]; !found {
return
} else if !cki.Subkey.IsValid() {
return
} else {
key, _, err = ckf.FindActiveEncryptionSubkey(cki.Subkey)
}
return
} | [
"func",
"(",
"ckf",
"*",
"ComputedKeyFamily",
")",
"GetEncryptionSubkeyForDevice",
"(",
"did",
"keybase1",
".",
"DeviceID",
")",
"(",
"key",
"GenericKey",
",",
"err",
"error",
")",
"{",
"var",
"kid",
"keybase1",
".",
"KID",
"\n",
"if",
"kid",
",",
"err",
... | // GetEncryptionSubkeyForDevice gets the current encryption subkey for the given device. | [
"GetEncryptionSubkeyForDevice",
"gets",
"the",
"current",
"encryption",
"subkey",
"for",
"the",
"given",
"device",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L1136-L1152 |
158,854 | keybase/client | go/libkb/keyfamily.go | GetDeviceForKey | func (ckf *ComputedKeyFamily) GetDeviceForKey(key GenericKey) (*Device, error) {
return ckf.GetDeviceForKID(key.GetKID())
} | go | func (ckf *ComputedKeyFamily) GetDeviceForKey(key GenericKey) (*Device, error) {
return ckf.GetDeviceForKID(key.GetKID())
} | [
"func",
"(",
"ckf",
"*",
"ComputedKeyFamily",
")",
"GetDeviceForKey",
"(",
"key",
"GenericKey",
")",
"(",
"*",
"Device",
",",
"error",
")",
"{",
"return",
"ckf",
".",
"GetDeviceForKID",
"(",
"key",
".",
"GetKID",
"(",
")",
")",
"\n",
"}"
] | // GetDeviceForKey gets the device that this key is bound to, if any. | [
"GetDeviceForKey",
"gets",
"the",
"device",
"that",
"this",
"key",
"is",
"bound",
"to",
"if",
"any",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/keyfamily.go#L1167-L1169 |
158,855 | keybase/client | go/teams/sig.go | NewSubteamID | func NewSubteamID(public bool) keybase1.TeamID {
var useSuffix byte = keybase1.SUB_TEAMID_PRIVATE_SUFFIX
if public {
useSuffix = keybase1.SUB_TEAMID_PUBLIC_SUFFIX
}
idBytes, err := libkb.RandBytesWithSuffix(16, useSuffix)
if err != nil {
panic("RandBytes failed: " + err.Error())
}
return keybase1.TeamID(hex.EncodeToString(idBytes))
} | go | func NewSubteamID(public bool) keybase1.TeamID {
var useSuffix byte = keybase1.SUB_TEAMID_PRIVATE_SUFFIX
if public {
useSuffix = keybase1.SUB_TEAMID_PUBLIC_SUFFIX
}
idBytes, err := libkb.RandBytesWithSuffix(16, useSuffix)
if err != nil {
panic("RandBytes failed: " + err.Error())
}
return keybase1.TeamID(hex.EncodeToString(idBytes))
} | [
"func",
"NewSubteamID",
"(",
"public",
"bool",
")",
"keybase1",
".",
"TeamID",
"{",
"var",
"useSuffix",
"byte",
"=",
"keybase1",
".",
"SUB_TEAMID_PRIVATE_SUFFIX",
"\n",
"if",
"public",
"{",
"useSuffix",
"=",
"keybase1",
".",
"SUB_TEAMID_PUBLIC_SUFFIX",
"\n",
"}"... | // 15 random bytes, followed by the byte 0x25, encoded as hex | [
"15",
"random",
"bytes",
"followed",
"by",
"the",
"byte",
"0x25",
"encoded",
"as",
"hex"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/sig.go#L197-L207 |
158,856 | keybase/client | go/engine/device_keygen.go | NewDeviceKeygen | func NewDeviceKeygen(g *libkb.GlobalContext, args *DeviceKeygenArgs) *DeviceKeygen {
return &DeviceKeygen{
args: args,
Contextified: libkb.NewContextified(g),
}
} | go | func NewDeviceKeygen(g *libkb.GlobalContext, args *DeviceKeygenArgs) *DeviceKeygen {
return &DeviceKeygen{
args: args,
Contextified: libkb.NewContextified(g),
}
} | [
"func",
"NewDeviceKeygen",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"args",
"*",
"DeviceKeygenArgs",
")",
"*",
"DeviceKeygen",
"{",
"return",
"&",
"DeviceKeygen",
"{",
"args",
":",
"args",
",",
"Contextified",
":",
"libkb",
".",
"NewContextified",
... | // NewDeviceKeygen creates a DeviceKeygen engine. | [
"NewDeviceKeygen",
"creates",
"a",
"DeviceKeygen",
"engine",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/device_keygen.go#L69-L74 |
158,857 | keybase/client | go/engine/device_keygen.go | preparePerUserKeyBoxFromProvisioningKey | func (e *DeviceKeygen) preparePerUserKeyBoxFromProvisioningKey(m libkb.MetaContext) ([]keybase1.PerUserKeyBox, error) {
// Assuming this is a paperkey or self provision.
upak := e.args.Me.ExportToUserPlusAllKeys()
if len(upak.Base.PerUserKeys) == 0 {
m.Debug("DeviceKeygen skipping per-user-keys, none exist")
return nil, nil
}
pukring := e.args.PerUserKeyring
if pukring == nil {
return nil, errors.New("missing PerUserKeyring")
}
provisioningKey := m.ActiveDevice().ProvisioningKey(m)
var provisioningSigKey, provisioningEncKeyGeneric libkb.GenericKey
if provisioningKey != nil {
provisioningSigKey = provisioningKey.SigningKey()
provisioningEncKeyGeneric = provisioningKey.EncryptionKey()
}
if provisioningSigKey == nil && provisioningEncKeyGeneric == nil {
// GPG provisioning is not supported when the user has per-user-keys.
// This is the error that manifests. See CORE-4960
return nil, errors.New("missing provisioning key in login context")
}
if provisioningSigKey == nil {
return nil, errors.New("missing provisioning sig key")
}
if provisioningEncKeyGeneric == nil {
return nil, errors.New("missing provisioning enc key")
}
provisioningEncKey, ok := provisioningEncKeyGeneric.(libkb.NaclDHKeyPair)
if !ok {
return nil, errors.New("Unexpected encryption key type")
}
provisioningDeviceID, err := upak.GetDeviceID(provisioningSigKey.GetKID())
if err != nil {
return nil, err
}
err = pukring.SyncAsProvisioningKey(m, &upak, provisioningDeviceID, provisioningEncKey)
if err != nil {
return nil, err
}
if !pukring.HasAnyKeys() {
return nil, nil
}
pukBox, err := pukring.PrepareBoxForNewDevice(m,
e.EncryptionKey(), // receiver key: provisionee enc
provisioningEncKey, // sender key: provisioning key enc
)
return []keybase1.PerUserKeyBox{pukBox}, err
} | go | func (e *DeviceKeygen) preparePerUserKeyBoxFromProvisioningKey(m libkb.MetaContext) ([]keybase1.PerUserKeyBox, error) {
// Assuming this is a paperkey or self provision.
upak := e.args.Me.ExportToUserPlusAllKeys()
if len(upak.Base.PerUserKeys) == 0 {
m.Debug("DeviceKeygen skipping per-user-keys, none exist")
return nil, nil
}
pukring := e.args.PerUserKeyring
if pukring == nil {
return nil, errors.New("missing PerUserKeyring")
}
provisioningKey := m.ActiveDevice().ProvisioningKey(m)
var provisioningSigKey, provisioningEncKeyGeneric libkb.GenericKey
if provisioningKey != nil {
provisioningSigKey = provisioningKey.SigningKey()
provisioningEncKeyGeneric = provisioningKey.EncryptionKey()
}
if provisioningSigKey == nil && provisioningEncKeyGeneric == nil {
// GPG provisioning is not supported when the user has per-user-keys.
// This is the error that manifests. See CORE-4960
return nil, errors.New("missing provisioning key in login context")
}
if provisioningSigKey == nil {
return nil, errors.New("missing provisioning sig key")
}
if provisioningEncKeyGeneric == nil {
return nil, errors.New("missing provisioning enc key")
}
provisioningEncKey, ok := provisioningEncKeyGeneric.(libkb.NaclDHKeyPair)
if !ok {
return nil, errors.New("Unexpected encryption key type")
}
provisioningDeviceID, err := upak.GetDeviceID(provisioningSigKey.GetKID())
if err != nil {
return nil, err
}
err = pukring.SyncAsProvisioningKey(m, &upak, provisioningDeviceID, provisioningEncKey)
if err != nil {
return nil, err
}
if !pukring.HasAnyKeys() {
return nil, nil
}
pukBox, err := pukring.PrepareBoxForNewDevice(m,
e.EncryptionKey(), // receiver key: provisionee enc
provisioningEncKey, // sender key: provisioning key enc
)
return []keybase1.PerUserKeyBox{pukBox}, err
} | [
"func",
"(",
"e",
"*",
"DeviceKeygen",
")",
"preparePerUserKeyBoxFromProvisioningKey",
"(",
"m",
"libkb",
".",
"MetaContext",
")",
"(",
"[",
"]",
"keybase1",
".",
"PerUserKeyBox",
",",
"error",
")",
"{",
"// Assuming this is a paperkey or self provision.",
"upak",
"... | // Can return no boxes if there are no per-user-keys. | [
"Can",
"return",
"no",
"boxes",
"if",
"there",
"are",
"no",
"per",
"-",
"user",
"-",
"keys",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/device_keygen.go#L389-L442 |
158,858 | keybase/client | go/stellar/bundle/bundle.go | New | func New(secret stellar1.SecretKey, name string) (*stellar1.Bundle, error) {
secretKey, accountID, _, err := libkb.ParseStellarSecretKey(string(secret))
if err != nil {
return nil, err
}
return &stellar1.Bundle{
Revision: 1,
Accounts: []stellar1.BundleEntry{
newEntry(accountID, name, false, stellar1.AccountMode_USER),
},
AccountBundles: map[stellar1.AccountID]stellar1.AccountBundle{
accountID: newAccountBundle(accountID, secretKey),
},
}, nil
} | go | func New(secret stellar1.SecretKey, name string) (*stellar1.Bundle, error) {
secretKey, accountID, _, err := libkb.ParseStellarSecretKey(string(secret))
if err != nil {
return nil, err
}
return &stellar1.Bundle{
Revision: 1,
Accounts: []stellar1.BundleEntry{
newEntry(accountID, name, false, stellar1.AccountMode_USER),
},
AccountBundles: map[stellar1.AccountID]stellar1.AccountBundle{
accountID: newAccountBundle(accountID, secretKey),
},
}, nil
} | [
"func",
"New",
"(",
"secret",
"stellar1",
".",
"SecretKey",
",",
"name",
"string",
")",
"(",
"*",
"stellar1",
".",
"Bundle",
",",
"error",
")",
"{",
"secretKey",
",",
"accountID",
",",
"_",
",",
"err",
":=",
"libkb",
".",
"ParseStellarSecretKey",
"(",
... | // New creates a Bundle from an existing secret key. | [
"New",
"creates",
"a",
"Bundle",
"from",
"an",
"existing",
"secret",
"key",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/bundle/bundle.go#L13-L27 |
158,859 | keybase/client | go/stellar/bundle/bundle.go | NewInitial | func NewInitial(name string) (*stellar1.Bundle, error) {
full, err := keypair.Random()
if err != nil {
return nil, err
}
x, err := New(stellar1.SecretKey(full.Seed()), name)
if err != nil {
return nil, err
}
x.Accounts[0].IsPrimary = true
return x, nil
} | go | func NewInitial(name string) (*stellar1.Bundle, error) {
full, err := keypair.Random()
if err != nil {
return nil, err
}
x, err := New(stellar1.SecretKey(full.Seed()), name)
if err != nil {
return nil, err
}
x.Accounts[0].IsPrimary = true
return x, nil
} | [
"func",
"NewInitial",
"(",
"name",
"string",
")",
"(",
"*",
"stellar1",
".",
"Bundle",
",",
"error",
")",
"{",
"full",
",",
"err",
":=",
"keypair",
".",
"Random",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"... | // NewInitial creates a Bundle with a new random secret key. | [
"NewInitial",
"creates",
"a",
"Bundle",
"with",
"a",
"new",
"random",
"secret",
"key",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/bundle/bundle.go#L30-L44 |
158,860 | keybase/client | go/stellar/bundle/bundle.go | MakeMobileOnly | func MakeMobileOnly(a *stellar1.Bundle, accountID stellar1.AccountID) error {
var found bool
for i, account := range a.Accounts {
if account.AccountID == accountID {
if account.Mode == stellar1.AccountMode_MOBILE {
return ErrNoChangeNecessary
}
account.Mode = stellar1.AccountMode_MOBILE
a.Accounts[i] = account
found = true
break
}
}
if !found {
return libkb.NotFoundError{}
}
return nil
} | go | func MakeMobileOnly(a *stellar1.Bundle, accountID stellar1.AccountID) error {
var found bool
for i, account := range a.Accounts {
if account.AccountID == accountID {
if account.Mode == stellar1.AccountMode_MOBILE {
return ErrNoChangeNecessary
}
account.Mode = stellar1.AccountMode_MOBILE
a.Accounts[i] = account
found = true
break
}
}
if !found {
return libkb.NotFoundError{}
}
return nil
} | [
"func",
"MakeMobileOnly",
"(",
"a",
"*",
"stellar1",
".",
"Bundle",
",",
"accountID",
"stellar1",
".",
"AccountID",
")",
"error",
"{",
"var",
"found",
"bool",
"\n",
"for",
"i",
",",
"account",
":=",
"range",
"a",
".",
"Accounts",
"{",
"if",
"account",
... | // MakeMobileOnly transforms an account in a stellar1.Bundle into a mobile-only
// account. This advances the revision of the Bundle. If it's already mobile-only,
// this function will return ErrNoChangeNecessary. | [
"MakeMobileOnly",
"transforms",
"an",
"account",
"in",
"a",
"stellar1",
".",
"Bundle",
"into",
"a",
"mobile",
"-",
"only",
"account",
".",
"This",
"advances",
"the",
"revision",
"of",
"the",
"Bundle",
".",
"If",
"it",
"s",
"already",
"mobile",
"-",
"only",... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/bundle/bundle.go#L70-L87 |
158,861 | keybase/client | go/stellar/bundle/bundle.go | AccountWithSecret | func AccountWithSecret(bundle *stellar1.Bundle, accountID stellar1.AccountID) (*WithSecret, error) {
secret, ok := bundle.AccountBundles[accountID]
if !ok {
return nil, libkb.NotFoundError{}
}
// ugh
var found *stellar1.BundleEntry
for _, a := range bundle.Accounts {
if a.AccountID == accountID {
found = &a
break
}
}
if found == nil {
// this is bad: secret found but not visible portion
return nil, libkb.NotFoundError{}
}
return &WithSecret{
AccountID: found.AccountID,
Mode: found.Mode,
Name: found.Name,
Revision: found.AcctBundleRevision,
Signers: secret.Signers,
}, nil
} | go | func AccountWithSecret(bundle *stellar1.Bundle, accountID stellar1.AccountID) (*WithSecret, error) {
secret, ok := bundle.AccountBundles[accountID]
if !ok {
return nil, libkb.NotFoundError{}
}
// ugh
var found *stellar1.BundleEntry
for _, a := range bundle.Accounts {
if a.AccountID == accountID {
found = &a
break
}
}
if found == nil {
// this is bad: secret found but not visible portion
return nil, libkb.NotFoundError{}
}
return &WithSecret{
AccountID: found.AccountID,
Mode: found.Mode,
Name: found.Name,
Revision: found.AcctBundleRevision,
Signers: secret.Signers,
}, nil
} | [
"func",
"AccountWithSecret",
"(",
"bundle",
"*",
"stellar1",
".",
"Bundle",
",",
"accountID",
"stellar1",
".",
"AccountID",
")",
"(",
"*",
"WithSecret",
",",
"error",
")",
"{",
"secret",
",",
"ok",
":=",
"bundle",
".",
"AccountBundles",
"[",
"accountID",
"... | // AccountWithSecret finds an account in bundle and its associated secret
// and extracts them into a convenience type bundle.WithSecret.
// It will return libkb.NotFoundError if it can't find the secret or the
// account in the bundle. | [
"AccountWithSecret",
"finds",
"an",
"account",
"in",
"bundle",
"and",
"its",
"associated",
"secret",
"and",
"extracts",
"them",
"into",
"a",
"convenience",
"type",
"bundle",
".",
"WithSecret",
".",
"It",
"will",
"return",
"libkb",
".",
"NotFoundError",
"if",
"... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/bundle/bundle.go#L125-L149 |
158,862 | keybase/client | go/stellar/bundle/bundle.go | AdvanceBundle | func AdvanceBundle(prevBundle stellar1.Bundle) stellar1.Bundle {
nextBundle := prevBundle.DeepCopy()
nextBundle.Prev = nextBundle.OwnHash
nextBundle.OwnHash = nil
nextBundle.Revision++
return nextBundle
} | go | func AdvanceBundle(prevBundle stellar1.Bundle) stellar1.Bundle {
nextBundle := prevBundle.DeepCopy()
nextBundle.Prev = nextBundle.OwnHash
nextBundle.OwnHash = nil
nextBundle.Revision++
return nextBundle
} | [
"func",
"AdvanceBundle",
"(",
"prevBundle",
"stellar1",
".",
"Bundle",
")",
"stellar1",
".",
"Bundle",
"{",
"nextBundle",
":=",
"prevBundle",
".",
"DeepCopy",
"(",
")",
"\n",
"nextBundle",
".",
"Prev",
"=",
"nextBundle",
".",
"OwnHash",
"\n",
"nextBundle",
"... | // AdvanceBundle only advances the revisions and hashes on the Bundle
// and not on the accounts. This is useful for adding and removing accounts
// but not for changing them. | [
"AdvanceBundle",
"only",
"advances",
"the",
"revisions",
"and",
"hashes",
"on",
"the",
"Bundle",
"and",
"not",
"on",
"the",
"accounts",
".",
"This",
"is",
"useful",
"for",
"adding",
"and",
"removing",
"accounts",
"but",
"not",
"for",
"changing",
"them",
"."
... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/bundle/bundle.go#L154-L160 |
158,863 | keybase/client | go/stellar/bundle/bundle.go | AddAccount | func AddAccount(bundle *stellar1.Bundle, secretKey stellar1.SecretKey, name string, makePrimary bool) (err error) {
if bundle == nil {
return fmt.Errorf("nil bundle")
}
secretKey, accountID, _, err := libkb.ParseStellarSecretKey(string(secretKey))
if err != nil {
return err
}
if name == "" {
return fmt.Errorf("Name required for new account")
}
if makePrimary {
for i := range bundle.Accounts {
bundle.Accounts[i].IsPrimary = false
}
}
bundle.Accounts = append(bundle.Accounts, stellar1.BundleEntry{
AccountID: accountID,
Mode: stellar1.AccountMode_USER,
IsPrimary: makePrimary,
AcctBundleRevision: 1,
Name: name,
})
bundle.AccountBundles[accountID] = stellar1.AccountBundle{
AccountID: accountID,
Signers: []stellar1.SecretKey{secretKey},
}
return bundle.CheckInvariants()
} | go | func AddAccount(bundle *stellar1.Bundle, secretKey stellar1.SecretKey, name string, makePrimary bool) (err error) {
if bundle == nil {
return fmt.Errorf("nil bundle")
}
secretKey, accountID, _, err := libkb.ParseStellarSecretKey(string(secretKey))
if err != nil {
return err
}
if name == "" {
return fmt.Errorf("Name required for new account")
}
if makePrimary {
for i := range bundle.Accounts {
bundle.Accounts[i].IsPrimary = false
}
}
bundle.Accounts = append(bundle.Accounts, stellar1.BundleEntry{
AccountID: accountID,
Mode: stellar1.AccountMode_USER,
IsPrimary: makePrimary,
AcctBundleRevision: 1,
Name: name,
})
bundle.AccountBundles[accountID] = stellar1.AccountBundle{
AccountID: accountID,
Signers: []stellar1.SecretKey{secretKey},
}
return bundle.CheckInvariants()
} | [
"func",
"AddAccount",
"(",
"bundle",
"*",
"stellar1",
".",
"Bundle",
",",
"secretKey",
"stellar1",
".",
"SecretKey",
",",
"name",
"string",
",",
"makePrimary",
"bool",
")",
"(",
"err",
"error",
")",
"{",
"if",
"bundle",
"==",
"nil",
"{",
"return",
"fmt",... | // AddAccount adds an account to the bundle. Mutates `bundle`. | [
"AddAccount",
"adds",
"an",
"account",
"to",
"the",
"bundle",
".",
"Mutates",
"bundle",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/bundle/bundle.go#L187-L215 |
158,864 | keybase/client | go/stellar/bundle/bundle.go | CreateNewAccount | func CreateNewAccount(bundle *stellar1.Bundle, name string, makePrimary bool) (pub stellar1.AccountID, err error) {
accountID, masterKey, err := randomStellarKeypair()
if err != nil {
return pub, err
}
if err := AddAccount(bundle, masterKey, name, makePrimary); err != nil {
return pub, err
}
return accountID, nil
} | go | func CreateNewAccount(bundle *stellar1.Bundle, name string, makePrimary bool) (pub stellar1.AccountID, err error) {
accountID, masterKey, err := randomStellarKeypair()
if err != nil {
return pub, err
}
if err := AddAccount(bundle, masterKey, name, makePrimary); err != nil {
return pub, err
}
return accountID, nil
} | [
"func",
"CreateNewAccount",
"(",
"bundle",
"*",
"stellar1",
".",
"Bundle",
",",
"name",
"string",
",",
"makePrimary",
"bool",
")",
"(",
"pub",
"stellar1",
".",
"AccountID",
",",
"err",
"error",
")",
"{",
"accountID",
",",
"masterKey",
",",
"err",
":=",
"... | // CreateNewAccount generates a Stellar key pair and adds it to the
// bundle. Mutates `bundle`. | [
"CreateNewAccount",
"generates",
"a",
"Stellar",
"key",
"pair",
"and",
"adds",
"it",
"to",
"the",
"bundle",
".",
"Mutates",
"bundle",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/bundle/bundle.go#L219-L228 |
158,865 | keybase/client | go/chat/search/indexer.go | validBatch | func (idx *Indexer) validBatch(msgs []chat1.MessageUnboxed) bool {
if len(msgs) == 0 {
return false
}
for _, msg := range msgs {
switch msg.GetTopicType() {
case chat1.TopicType_CHAT:
return true
case chat1.TopicType_NONE:
continue
default:
return false
}
}
// if we only have TopicType_NONE, assume it's ok to return true so we
// document the seen ids properly.
return true
} | go | func (idx *Indexer) validBatch(msgs []chat1.MessageUnboxed) bool {
if len(msgs) == 0 {
return false
}
for _, msg := range msgs {
switch msg.GetTopicType() {
case chat1.TopicType_CHAT:
return true
case chat1.TopicType_NONE:
continue
default:
return false
}
}
// if we only have TopicType_NONE, assume it's ok to return true so we
// document the seen ids properly.
return true
} | [
"func",
"(",
"idx",
"*",
"Indexer",
")",
"validBatch",
"(",
"msgs",
"[",
"]",
"chat1",
".",
"MessageUnboxed",
")",
"bool",
"{",
"if",
"len",
"(",
"msgs",
")",
"==",
"0",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"msg",
":=",
"ra... | // validBatch verifies the topic type is CHAT | [
"validBatch",
"verifies",
"the",
"topic",
"type",
"is",
"CHAT"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/search/indexer.go#L207-L225 |
158,866 | keybase/client | go/chat/search/indexer.go | Search | func (idx *Indexer) Search(ctx context.Context, uid gregor1.UID, query, origQuery string,
opts chat1.SearchOpts, hitUICh chan chat1.ChatSearchInboxHit, indexUICh chan chat1.ChatSearchIndexStatus) (res *chat1.ChatSearchInboxResults, err error) {
defer idx.Trace(ctx, func() error { return err }, "Indexer.Search")()
defer func() {
// get a selective sync to run after the search completes even if we
// errored.
idx.PokeSync(ctx)
if hitUICh != nil {
close(hitUICh)
}
if indexUICh != nil {
close(indexUICh)
}
}()
if idx.G().GetEnv().GetDisableSearchIndexer() {
idx.Debug(ctx, "Search: Search indexer is disabled, results will be inaccurate.")
}
idx.CancelSync(ctx)
sess := newSearchSession(query, origQuery, uid, hitUICh, indexUICh, idx, opts)
return sess.run(ctx)
} | go | func (idx *Indexer) Search(ctx context.Context, uid gregor1.UID, query, origQuery string,
opts chat1.SearchOpts, hitUICh chan chat1.ChatSearchInboxHit, indexUICh chan chat1.ChatSearchIndexStatus) (res *chat1.ChatSearchInboxResults, err error) {
defer idx.Trace(ctx, func() error { return err }, "Indexer.Search")()
defer func() {
// get a selective sync to run after the search completes even if we
// errored.
idx.PokeSync(ctx)
if hitUICh != nil {
close(hitUICh)
}
if indexUICh != nil {
close(indexUICh)
}
}()
if idx.G().GetEnv().GetDisableSearchIndexer() {
idx.Debug(ctx, "Search: Search indexer is disabled, results will be inaccurate.")
}
idx.CancelSync(ctx)
sess := newSearchSession(query, origQuery, uid, hitUICh, indexUICh, idx, opts)
return sess.run(ctx)
} | [
"func",
"(",
"idx",
"*",
"Indexer",
")",
"Search",
"(",
"ctx",
"context",
".",
"Context",
",",
"uid",
"gregor1",
".",
"UID",
",",
"query",
",",
"origQuery",
"string",
",",
"opts",
"chat1",
".",
"SearchOpts",
",",
"hitUICh",
"chan",
"chat1",
".",
"ChatS... | // Search tokenizes the given query and finds the intersection of all matches
// for each token, returning matches. | [
"Search",
"tokenizes",
"the",
"given",
"query",
"and",
"finds",
"the",
"intersection",
"of",
"all",
"matches",
"for",
"each",
"token",
"returning",
"matches",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/search/indexer.go#L431-L453 |
158,867 | keybase/client | go/chat/search/indexer.go | SelectiveSync | func (idx *Indexer) SelectiveSync(ctx context.Context, uid gregor1.UID) (err error) {
defer idx.Trace(ctx, func() error { return err }, "SelectiveSync")()
convMap, err := idx.allConvs(ctx, uid, nil)
if err != nil {
return err
}
// make sure the most recently modified convs are fully indexed
convs := idx.convsByMTime(ctx, uid, convMap)
// number of batches of messages to fetch in total
numJobs := idx.maxSyncConvs
for _, conv := range convs {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
convID := conv.GetConvID()
md, err := idx.store.GetMetadata(ctx, uid, convID)
if err != nil {
idx.Debug(ctx, "SelectiveSync: Unable to get md for conv: %v, %v", convID, err)
continue
}
if md.FullyIndexed(conv.Conv) {
continue
}
completedJobs, err := idx.reindexConv(ctx, conv, uid, numJobs, nil)
if err != nil {
idx.Debug(ctx, "Unable to reindex conv: %v, %v", convID, err)
continue
} else if completedJobs == 0 {
continue
}
idx.Debug(ctx, "SelectiveSync: Indexed completed jobs %d", completedJobs)
numJobs -= completedJobs
if numJobs <= 0 {
break
}
}
return nil
} | go | func (idx *Indexer) SelectiveSync(ctx context.Context, uid gregor1.UID) (err error) {
defer idx.Trace(ctx, func() error { return err }, "SelectiveSync")()
convMap, err := idx.allConvs(ctx, uid, nil)
if err != nil {
return err
}
// make sure the most recently modified convs are fully indexed
convs := idx.convsByMTime(ctx, uid, convMap)
// number of batches of messages to fetch in total
numJobs := idx.maxSyncConvs
for _, conv := range convs {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
convID := conv.GetConvID()
md, err := idx.store.GetMetadata(ctx, uid, convID)
if err != nil {
idx.Debug(ctx, "SelectiveSync: Unable to get md for conv: %v, %v", convID, err)
continue
}
if md.FullyIndexed(conv.Conv) {
continue
}
completedJobs, err := idx.reindexConv(ctx, conv, uid, numJobs, nil)
if err != nil {
idx.Debug(ctx, "Unable to reindex conv: %v, %v", convID, err)
continue
} else if completedJobs == 0 {
continue
}
idx.Debug(ctx, "SelectiveSync: Indexed completed jobs %d", completedJobs)
numJobs -= completedJobs
if numJobs <= 0 {
break
}
}
return nil
} | [
"func",
"(",
"idx",
"*",
"Indexer",
")",
"SelectiveSync",
"(",
"ctx",
"context",
".",
"Context",
",",
"uid",
"gregor1",
".",
"UID",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"idx",
".",
"Trace",
"(",
"ctx",
",",
"func",
"(",
")",
"error",
"{",
... | // SelectiveSync queues up a small number of jobs on the background loader
// periodically so our index can cover all conversations. The number of jobs
// varies between desktop and mobile so mobile can be more conservative. | [
"SelectiveSync",
"queues",
"up",
"a",
"small",
"number",
"of",
"jobs",
"on",
"the",
"background",
"loader",
"periodically",
"so",
"our",
"index",
"can",
"cover",
"all",
"conversations",
".",
"The",
"number",
"of",
"jobs",
"varies",
"between",
"desktop",
"and",... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/search/indexer.go#L458-L500 |
158,868 | keybase/client | go/kbnm/hostmanifest/user.go | CurrentUser | func CurrentUser() (*UserPath, error) {
current, err := user.Current()
if err != nil {
return nil, err
}
u := &UserPath{
Admin: current.Uid == "0",
}
if !u.IsAdmin() {
u.Path = current.HomeDir
}
return u, nil
} | go | func CurrentUser() (*UserPath, error) {
current, err := user.Current()
if err != nil {
return nil, err
}
u := &UserPath{
Admin: current.Uid == "0",
}
if !u.IsAdmin() {
u.Path = current.HomeDir
}
return u, nil
} | [
"func",
"CurrentUser",
"(",
")",
"(",
"*",
"UserPath",
",",
"error",
")",
"{",
"current",
",",
"err",
":=",
"user",
".",
"Current",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"u",
":=",
"&",
"Us... | // CurrentUser returns a UserPath representing the current user. | [
"CurrentUser",
"returns",
"a",
"UserPath",
"representing",
"the",
"current",
"user",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbnm/hostmanifest/user.go#L28-L40 |
158,869 | keybase/client | go/kbfs/tlf/utils.go | SplitAndNormalizeTLFName | func SplitAndNormalizeTLFName(g *libkb.GlobalContext, name string, public bool) (
writerNames, readerNames []string,
extensionSuffix string, err error) {
names := strings.SplitN(name, TlfHandleExtensionSep, 2)
if len(names) > 2 {
return nil, nil, "", BadTLFNameError{name}
}
if len(names) > 1 {
extensionSuffix = names[1]
}
splitNames := strings.SplitN(names[0], ReaderSep, 3)
if len(splitNames) > 2 {
return nil, nil, "", BadTLFNameError{name}
}
writerNames = strings.Split(splitNames[0], ",")
if len(splitNames) > 1 {
readerNames = strings.Split(splitNames[1], ",")
}
hasPublic := len(readerNames) == 0
if public && !hasPublic {
// No public folder exists for this folder.
return nil, nil, "", NoSuchNameError{Name: name}
}
normalizedName, err := NormalizeNamesInTLF(g,
writerNames, readerNames, extensionSuffix)
if err != nil {
return nil, nil, "", err
}
if normalizedName != name {
return nil, nil, "", NameNotCanonical{name, normalizedName}
}
return writerNames, readerNames, strings.ToLower(extensionSuffix), nil
} | go | func SplitAndNormalizeTLFName(g *libkb.GlobalContext, name string, public bool) (
writerNames, readerNames []string,
extensionSuffix string, err error) {
names := strings.SplitN(name, TlfHandleExtensionSep, 2)
if len(names) > 2 {
return nil, nil, "", BadTLFNameError{name}
}
if len(names) > 1 {
extensionSuffix = names[1]
}
splitNames := strings.SplitN(names[0], ReaderSep, 3)
if len(splitNames) > 2 {
return nil, nil, "", BadTLFNameError{name}
}
writerNames = strings.Split(splitNames[0], ",")
if len(splitNames) > 1 {
readerNames = strings.Split(splitNames[1], ",")
}
hasPublic := len(readerNames) == 0
if public && !hasPublic {
// No public folder exists for this folder.
return nil, nil, "", NoSuchNameError{Name: name}
}
normalizedName, err := NormalizeNamesInTLF(g,
writerNames, readerNames, extensionSuffix)
if err != nil {
return nil, nil, "", err
}
if normalizedName != name {
return nil, nil, "", NameNotCanonical{name, normalizedName}
}
return writerNames, readerNames, strings.ToLower(extensionSuffix), nil
} | [
"func",
"SplitAndNormalizeTLFName",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"name",
"string",
",",
"public",
"bool",
")",
"(",
"writerNames",
",",
"readerNames",
"[",
"]",
"string",
",",
"extensionSuffix",
"string",
",",
"err",
"error",
")",
"{",
... | // SplitAndNormalizeTLFName returns separate lists of normalized
// writer and reader names, as well as the extension suffix, of the
// given `name`. | [
"SplitAndNormalizeTLFName",
"returns",
"separate",
"lists",
"of",
"normalized",
"writer",
"and",
"reader",
"names",
"as",
"well",
"as",
"the",
"extension",
"suffix",
"of",
"the",
"given",
"name",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/utils.go#L31-L69 |
158,870 | keybase/client | go/kbfs/tlf/utils.go | NormalizeNamesInTLF | func NormalizeNamesInTLF(g *libkb.GlobalContext, writerNames, readerNames []string,
extensionSuffix string) (string, error) {
sortedWriterNames := make([]string, len(writerNames))
var err error
for i, w := range writerNames {
sortedWriterNames[i], err = NormalizeAssertionOrName(g, w)
if err != nil {
return "", err
}
}
sort.Strings(sortedWriterNames)
normalizedName := strings.Join(sortedWriterNames, ",")
if len(readerNames) > 0 {
sortedReaderNames := make([]string, len(readerNames))
for i, r := range readerNames {
sortedReaderNames[i], err = NormalizeAssertionOrName(g, r)
if err != nil {
return "", err
}
}
sort.Strings(sortedReaderNames)
normalizedName += ReaderSep + strings.Join(sortedReaderNames, ",")
}
if len(extensionSuffix) != 0 {
// This *should* be normalized already but make sure. I can see not
// doing so might surprise a caller.
normalizedName += TlfHandleExtensionSep + strings.ToLower(extensionSuffix)
}
return normalizedName, nil
} | go | func NormalizeNamesInTLF(g *libkb.GlobalContext, writerNames, readerNames []string,
extensionSuffix string) (string, error) {
sortedWriterNames := make([]string, len(writerNames))
var err error
for i, w := range writerNames {
sortedWriterNames[i], err = NormalizeAssertionOrName(g, w)
if err != nil {
return "", err
}
}
sort.Strings(sortedWriterNames)
normalizedName := strings.Join(sortedWriterNames, ",")
if len(readerNames) > 0 {
sortedReaderNames := make([]string, len(readerNames))
for i, r := range readerNames {
sortedReaderNames[i], err = NormalizeAssertionOrName(g, r)
if err != nil {
return "", err
}
}
sort.Strings(sortedReaderNames)
normalizedName += ReaderSep + strings.Join(sortedReaderNames, ",")
}
if len(extensionSuffix) != 0 {
// This *should* be normalized already but make sure. I can see not
// doing so might surprise a caller.
normalizedName += TlfHandleExtensionSep + strings.ToLower(extensionSuffix)
}
return normalizedName, nil
} | [
"func",
"NormalizeNamesInTLF",
"(",
"g",
"*",
"libkb",
".",
"GlobalContext",
",",
"writerNames",
",",
"readerNames",
"[",
"]",
"string",
",",
"extensionSuffix",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"sortedWriterNames",
":=",
"make",
"(",
"["... | // NormalizeNamesInTLF takes a split TLF name and, without doing any
// resolutions or identify calls, normalizes all elements of the
// name. It then returns the normalized name. | [
"NormalizeNamesInTLF",
"takes",
"a",
"split",
"TLF",
"name",
"and",
"without",
"doing",
"any",
"resolutions",
"or",
"identify",
"calls",
"normalizes",
"all",
"elements",
"of",
"the",
"name",
".",
"It",
"then",
"returns",
"the",
"normalized",
"name",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/utils.go#L74-L104 |
158,871 | keybase/client | go/kbfs/tlf/utils.go | ToStatus | func (e NoSuchUserError) ToStatus() keybase1.Status {
return keybase1.Status{
Name: "NotFound",
Code: int(keybase1.StatusCode_SCNotFound),
Desc: e.Error(),
}
} | go | func (e NoSuchUserError) ToStatus() keybase1.Status {
return keybase1.Status{
Name: "NotFound",
Code: int(keybase1.StatusCode_SCNotFound),
Desc: e.Error(),
}
} | [
"func",
"(",
"e",
"NoSuchUserError",
")",
"ToStatus",
"(",
")",
"keybase1",
".",
"Status",
"{",
"return",
"keybase1",
".",
"Status",
"{",
"Name",
":",
"\"",
"\"",
",",
"Code",
":",
"int",
"(",
"keybase1",
".",
"StatusCode_SCNotFound",
")",
",",
"Desc",
... | // ToStatus implements the keybase1.ToStatusAble interface for NoSuchUserError | [
"ToStatus",
"implements",
"the",
"keybase1",
".",
"ToStatusAble",
"interface",
"for",
"NoSuchUserError"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlf/utils.go#L186-L192 |
158,872 | keybase/client | go/libkb/util_nix.go | SafeWriteToFile | func SafeWriteToFile(g SafeWriteLogger, t SafeWriter, mode os.FileMode) error {
return safeWriteToFileOnce(g, t, mode)
} | go | func SafeWriteToFile(g SafeWriteLogger, t SafeWriter, mode os.FileMode) error {
return safeWriteToFileOnce(g, t, mode)
} | [
"func",
"SafeWriteToFile",
"(",
"g",
"SafeWriteLogger",
",",
"t",
"SafeWriter",
",",
"mode",
"os",
".",
"FileMode",
")",
"error",
"{",
"return",
"safeWriteToFileOnce",
"(",
"g",
",",
"t",
",",
"mode",
")",
"\n",
"}"
] | // SafeWriteToFile is a pass-through to safeWriteToFileOnce on non-Windows. | [
"SafeWriteToFile",
"is",
"a",
"pass",
"-",
"through",
"to",
"safeWriteToFileOnce",
"on",
"non",
"-",
"Windows",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/util_nix.go#L55-L57 |
158,873 | keybase/client | go/engine/pgp_import_key.go | checkPregenPrivate | func (e *PGPKeyImportEngine) checkPregenPrivate() error {
if e.arg.Pregen == nil {
return nil
}
if e.arg.Pregen.HasSecretKey() || e.arg.GPGFallback {
return nil
}
return libkb.NoSecretKeyError{}
} | go | func (e *PGPKeyImportEngine) checkPregenPrivate() error {
if e.arg.Pregen == nil {
return nil
}
if e.arg.Pregen.HasSecretKey() || e.arg.GPGFallback {
return nil
}
return libkb.NoSecretKeyError{}
} | [
"func",
"(",
"e",
"*",
"PGPKeyImportEngine",
")",
"checkPregenPrivate",
"(",
")",
"error",
"{",
"if",
"e",
".",
"arg",
".",
"Pregen",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"e",
".",
"arg",
".",
"Pregen",
".",
"HasSecretKey",
"(",
... | // checkPregenPrivate makes sure that the pregenerated key is a
// private key. | [
"checkPregenPrivate",
"makes",
"sure",
"that",
"the",
"pregenerated",
"key",
"is",
"a",
"private",
"key",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/pgp_import_key.go#L140-L148 |
158,874 | keybase/client | go/engine/pgp_import_key.go | clonePGPKeyBundle | func clonePGPKeyBundle(bundle *libkb.PGPKeyBundle) (*libkb.PGPKeyBundle, error) {
var buf bytes.Buffer
if err := bundle.SerializePrivate(&buf); err != nil {
return nil, err
}
res, _, err := libkb.ReadOneKeyFromBytes(buf.Bytes())
if err != nil {
return nil, err
}
return res, nil
} | go | func clonePGPKeyBundle(bundle *libkb.PGPKeyBundle) (*libkb.PGPKeyBundle, error) {
var buf bytes.Buffer
if err := bundle.SerializePrivate(&buf); err != nil {
return nil, err
}
res, _, err := libkb.ReadOneKeyFromBytes(buf.Bytes())
if err != nil {
return nil, err
}
return res, nil
} | [
"func",
"clonePGPKeyBundle",
"(",
"bundle",
"*",
"libkb",
".",
"PGPKeyBundle",
")",
"(",
"*",
"libkb",
".",
"PGPKeyBundle",
",",
"error",
")",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"if",
"err",
":=",
"bundle",
".",
"SerializePrivate",
"(",
"&"... | // clonePGPKeyBundle returns an approximate deep copy of PGPKeyBundle
// by exporting and re-importing PGPKeyBundle. If PGP key contains
// something that is not supported by either go-crypto exporter or
// importer, that information will be lost. | [
"clonePGPKeyBundle",
"returns",
"an",
"approximate",
"deep",
"copy",
"of",
"PGPKeyBundle",
"by",
"exporting",
"and",
"re",
"-",
"importing",
"PGPKeyBundle",
".",
"If",
"PGP",
"key",
"contains",
"something",
"that",
"is",
"not",
"supported",
"by",
"either",
"go",... | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/pgp_import_key.go#L258-L268 |
158,875 | keybase/client | go/kbfs/libkbfs/modes.go | NewInitModeFromType | func NewInitModeFromType(t InitModeType) InitMode {
switch t {
case InitDefault:
return modeDefault{}
case InitMinimal:
return modeMinimal{}
case InitSingleOp:
return modeSingleOp{modeDefault{}}
case InitConstrained:
return modeConstrained{modeDefault{}}
case InitMemoryLimited:
return modeMemoryLimited{modeConstrained{modeDefault{}}}
default:
panic(fmt.Sprintf("Unknown mode: %s", t))
}
} | go | func NewInitModeFromType(t InitModeType) InitMode {
switch t {
case InitDefault:
return modeDefault{}
case InitMinimal:
return modeMinimal{}
case InitSingleOp:
return modeSingleOp{modeDefault{}}
case InitConstrained:
return modeConstrained{modeDefault{}}
case InitMemoryLimited:
return modeMemoryLimited{modeConstrained{modeDefault{}}}
default:
panic(fmt.Sprintf("Unknown mode: %s", t))
}
} | [
"func",
"NewInitModeFromType",
"(",
"t",
"InitModeType",
")",
"InitMode",
"{",
"switch",
"t",
"{",
"case",
"InitDefault",
":",
"return",
"modeDefault",
"{",
"}",
"\n",
"case",
"InitMinimal",
":",
"return",
"modeMinimal",
"{",
"}",
"\n",
"case",
"InitSingleOp",... | // NewInitModeFromType returns an InitMode object corresponding to the
// given type. | [
"NewInitModeFromType",
"returns",
"an",
"InitMode",
"object",
"corresponding",
"to",
"the",
"given",
"type",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/modes.go#L17-L32 |
158,876 | keybase/client | go/libkb/usercard_cache.go | NewUserCardCache | func NewUserCardCache(maxAge time.Duration) *UserCardCache {
c := &UserCardCache{
cache: ramcache.New(),
}
c.cache.MaxAge = maxAge
c.cache.TTL = maxAge
return c
} | go | func NewUserCardCache(maxAge time.Duration) *UserCardCache {
c := &UserCardCache{
cache: ramcache.New(),
}
c.cache.MaxAge = maxAge
c.cache.TTL = maxAge
return c
} | [
"func",
"NewUserCardCache",
"(",
"maxAge",
"time",
".",
"Duration",
")",
"*",
"UserCardCache",
"{",
"c",
":=",
"&",
"UserCardCache",
"{",
"cache",
":",
"ramcache",
".",
"New",
"(",
")",
",",
"}",
"\n",
"c",
".",
"cache",
".",
"MaxAge",
"=",
"maxAge",
... | // NewUserCardCache creates a UserCardCache. keybase1.UserCards will expire
// after maxAge. | [
"NewUserCardCache",
"creates",
"a",
"UserCardCache",
".",
"keybase1",
".",
"UserCards",
"will",
"expire",
"after",
"maxAge",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/usercard_cache.go#L19-L26 |
158,877 | keybase/client | go/libkb/usercard_cache.go | Get | func (c *UserCardCache) Get(uid keybase1.UID, useSession bool) (*keybase1.UserCard, error) {
v, err := c.cache.Get(c.key(uid, useSession))
if err != nil {
if err == ramcache.ErrNotFound {
return nil, nil
}
return nil, err
}
card, ok := v.(keybase1.UserCard)
if !ok {
return nil, fmt.Errorf("invalid type in cache: %T", v)
}
return &card, nil
} | go | func (c *UserCardCache) Get(uid keybase1.UID, useSession bool) (*keybase1.UserCard, error) {
v, err := c.cache.Get(c.key(uid, useSession))
if err != nil {
if err == ramcache.ErrNotFound {
return nil, nil
}
return nil, err
}
card, ok := v.(keybase1.UserCard)
if !ok {
return nil, fmt.Errorf("invalid type in cache: %T", v)
}
return &card, nil
} | [
"func",
"(",
"c",
"*",
"UserCardCache",
")",
"Get",
"(",
"uid",
"keybase1",
".",
"UID",
",",
"useSession",
"bool",
")",
"(",
"*",
"keybase1",
".",
"UserCard",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"c",
".",
"cache",
".",
"Get",
"(",
"c",... | // Get looks for a keybase1.UserCard for uid. It returns nil, nil if not found.
// useSession is set if the card is being looked up with a session. | [
"Get",
"looks",
"for",
"a",
"keybase1",
".",
"UserCard",
"for",
"uid",
".",
"It",
"returns",
"nil",
"nil",
"if",
"not",
"found",
".",
"useSession",
"is",
"set",
"if",
"the",
"card",
"is",
"being",
"looked",
"up",
"with",
"a",
"session",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/usercard_cache.go#L30-L43 |
158,878 | keybase/client | go/libkb/generickey.go | KeyMatchesQuery | func KeyMatchesQuery(key GenericKey, q string, exact bool) bool {
if key.GetKID().Match(q, exact) {
return true
}
return GetPGPFingerprintFromGenericKey(key).Match(q, exact)
} | go | func KeyMatchesQuery(key GenericKey, q string, exact bool) bool {
if key.GetKID().Match(q, exact) {
return true
}
return GetPGPFingerprintFromGenericKey(key).Match(q, exact)
} | [
"func",
"KeyMatchesQuery",
"(",
"key",
"GenericKey",
",",
"q",
"string",
",",
"exact",
"bool",
")",
"bool",
"{",
"if",
"key",
".",
"GetKID",
"(",
")",
".",
"Match",
"(",
"q",
",",
"exact",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"Get... | // Any valid key matches the empty string. | [
"Any",
"valid",
"key",
"matches",
"the",
"empty",
"string",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/generickey.go#L87-L92 |
158,879 | keybase/client | go/kbfs/libkey/key_bundle_cache_measured.go | NewKeyBundleCacheMeasured | func NewKeyBundleCacheMeasured(delegate kbfsmd.KeyBundleCache, r metrics.Registry) KeyBundleCacheMeasured {
getReaderBundleTimer := metrics.GetOrRegisterTimer("KeyBundleCache.GetTLFReaderKeyBundle", r)
putReaderBundleTimer := metrics.GetOrRegisterTimer("KeyBundleCache.PutTLFReaderKeyBundle", r)
getWriterBundleTimer := metrics.GetOrRegisterTimer("KeyBundleCache.GetTLFWriterKeyBundle", r)
putWriterBundleTimer := metrics.GetOrRegisterTimer("KeyBundleCache.PutTLFWriterKeyBundle", r)
hitReaderBundleCountMeter := metrics.GetOrRegisterMeter("KeyBundleCache.TLFReaderKeyBundleHitCount", r)
hitWriterBundleCountMeter := metrics.GetOrRegisterMeter("KeyBundleCache.TLFWriterKeyBundleHitCount", r)
attemptReaderBundleCountMeter := metrics.GetOrRegisterMeter("KeyBundleCache.TLFReaderKeyBundleAttemptCount", r)
attemptWriterBundleCountMeter := metrics.GetOrRegisterMeter("KeyBundleCache.TLFWriterKeyBundleAttemptCount", r)
return KeyBundleCacheMeasured{
delegate: delegate,
getReaderBundleTimer: getReaderBundleTimer,
getWriterBundleTimer: getWriterBundleTimer,
putReaderBundleTimer: putReaderBundleTimer,
putWriterBundleTimer: putWriterBundleTimer,
hitReaderBundleCountMeter: hitReaderBundleCountMeter,
hitWriterBundleCountMeter: hitWriterBundleCountMeter,
attemptReaderBundleCountMeter: attemptReaderBundleCountMeter,
attemptWriterBundleCountMeter: attemptWriterBundleCountMeter,
}
} | go | func NewKeyBundleCacheMeasured(delegate kbfsmd.KeyBundleCache, r metrics.Registry) KeyBundleCacheMeasured {
getReaderBundleTimer := metrics.GetOrRegisterTimer("KeyBundleCache.GetTLFReaderKeyBundle", r)
putReaderBundleTimer := metrics.GetOrRegisterTimer("KeyBundleCache.PutTLFReaderKeyBundle", r)
getWriterBundleTimer := metrics.GetOrRegisterTimer("KeyBundleCache.GetTLFWriterKeyBundle", r)
putWriterBundleTimer := metrics.GetOrRegisterTimer("KeyBundleCache.PutTLFWriterKeyBundle", r)
hitReaderBundleCountMeter := metrics.GetOrRegisterMeter("KeyBundleCache.TLFReaderKeyBundleHitCount", r)
hitWriterBundleCountMeter := metrics.GetOrRegisterMeter("KeyBundleCache.TLFWriterKeyBundleHitCount", r)
attemptReaderBundleCountMeter := metrics.GetOrRegisterMeter("KeyBundleCache.TLFReaderKeyBundleAttemptCount", r)
attemptWriterBundleCountMeter := metrics.GetOrRegisterMeter("KeyBundleCache.TLFWriterKeyBundleAttemptCount", r)
return KeyBundleCacheMeasured{
delegate: delegate,
getReaderBundleTimer: getReaderBundleTimer,
getWriterBundleTimer: getWriterBundleTimer,
putReaderBundleTimer: putReaderBundleTimer,
putWriterBundleTimer: putWriterBundleTimer,
hitReaderBundleCountMeter: hitReaderBundleCountMeter,
hitWriterBundleCountMeter: hitWriterBundleCountMeter,
attemptReaderBundleCountMeter: attemptReaderBundleCountMeter,
attemptWriterBundleCountMeter: attemptWriterBundleCountMeter,
}
} | [
"func",
"NewKeyBundleCacheMeasured",
"(",
"delegate",
"kbfsmd",
".",
"KeyBundleCache",
",",
"r",
"metrics",
".",
"Registry",
")",
"KeyBundleCacheMeasured",
"{",
"getReaderBundleTimer",
":=",
"metrics",
".",
"GetOrRegisterTimer",
"(",
"\"",
"\"",
",",
"r",
")",
"\n... | // NewKeyBundleCacheMeasured creates and returns a new KeyBundleCacheMeasured
// instance with the given delegate and registry. | [
"NewKeyBundleCacheMeasured",
"creates",
"and",
"returns",
"a",
"new",
"KeyBundleCacheMeasured",
"instance",
"with",
"the",
"given",
"delegate",
"and",
"registry",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkey/key_bundle_cache_measured.go#L30-L50 |
158,880 | keybase/client | go/kbfs/libkey/key_bundle_cache_measured.go | GetTLFReaderKeyBundle | func (b KeyBundleCacheMeasured) GetTLFReaderKeyBundle(
bundleID kbfsmd.TLFReaderKeyBundleID) (rkb *kbfsmd.TLFReaderKeyBundleV3, err error) {
b.attemptReaderBundleCountMeter.Mark(1)
b.getReaderBundleTimer.Time(func() {
rkb, err = b.delegate.GetTLFReaderKeyBundle(bundleID)
})
if err == nil && rkb != nil {
b.hitReaderBundleCountMeter.Mark(1)
}
return rkb, err
} | go | func (b KeyBundleCacheMeasured) GetTLFReaderKeyBundle(
bundleID kbfsmd.TLFReaderKeyBundleID) (rkb *kbfsmd.TLFReaderKeyBundleV3, err error) {
b.attemptReaderBundleCountMeter.Mark(1)
b.getReaderBundleTimer.Time(func() {
rkb, err = b.delegate.GetTLFReaderKeyBundle(bundleID)
})
if err == nil && rkb != nil {
b.hitReaderBundleCountMeter.Mark(1)
}
return rkb, err
} | [
"func",
"(",
"b",
"KeyBundleCacheMeasured",
")",
"GetTLFReaderKeyBundle",
"(",
"bundleID",
"kbfsmd",
".",
"TLFReaderKeyBundleID",
")",
"(",
"rkb",
"*",
"kbfsmd",
".",
"TLFReaderKeyBundleV3",
",",
"err",
"error",
")",
"{",
"b",
".",
"attemptReaderBundleCountMeter",
... | // GetTLFReaderKeyBundle implements the KeyBundleCache interface for
// KeyBundleCacheMeasured. | [
"GetTLFReaderKeyBundle",
"implements",
"the",
"KeyBundleCache",
"interface",
"for",
"KeyBundleCacheMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkey/key_bundle_cache_measured.go#L54-L64 |
158,881 | keybase/client | go/kbfs/libkey/key_bundle_cache_measured.go | GetTLFWriterKeyBundle | func (b KeyBundleCacheMeasured) GetTLFWriterKeyBundle(
bundleID kbfsmd.TLFWriterKeyBundleID) (wkb *kbfsmd.TLFWriterKeyBundleV3, err error) {
b.attemptWriterBundleCountMeter.Mark(1)
b.getWriterBundleTimer.Time(func() {
wkb, err = b.delegate.GetTLFWriterKeyBundle(bundleID)
})
if err == nil && wkb != nil {
b.hitWriterBundleCountMeter.Mark(1)
}
return wkb, err
} | go | func (b KeyBundleCacheMeasured) GetTLFWriterKeyBundle(
bundleID kbfsmd.TLFWriterKeyBundleID) (wkb *kbfsmd.TLFWriterKeyBundleV3, err error) {
b.attemptWriterBundleCountMeter.Mark(1)
b.getWriterBundleTimer.Time(func() {
wkb, err = b.delegate.GetTLFWriterKeyBundle(bundleID)
})
if err == nil && wkb != nil {
b.hitWriterBundleCountMeter.Mark(1)
}
return wkb, err
} | [
"func",
"(",
"b",
"KeyBundleCacheMeasured",
")",
"GetTLFWriterKeyBundle",
"(",
"bundleID",
"kbfsmd",
".",
"TLFWriterKeyBundleID",
")",
"(",
"wkb",
"*",
"kbfsmd",
".",
"TLFWriterKeyBundleV3",
",",
"err",
"error",
")",
"{",
"b",
".",
"attemptWriterBundleCountMeter",
... | // GetTLFWriterKeyBundle implements the KeyBundleCache interface for
// KeyBundleCacheMeasured. | [
"GetTLFWriterKeyBundle",
"implements",
"the",
"KeyBundleCache",
"interface",
"for",
"KeyBundleCacheMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkey/key_bundle_cache_measured.go#L68-L78 |
158,882 | keybase/client | go/kbfs/libkey/key_bundle_cache_measured.go | PutTLFReaderKeyBundle | func (b KeyBundleCacheMeasured) PutTLFReaderKeyBundle(
bundleID kbfsmd.TLFReaderKeyBundleID, rkb kbfsmd.TLFReaderKeyBundleV3) {
b.putReaderBundleTimer.Time(func() {
b.delegate.PutTLFReaderKeyBundle(bundleID, rkb)
})
} | go | func (b KeyBundleCacheMeasured) PutTLFReaderKeyBundle(
bundleID kbfsmd.TLFReaderKeyBundleID, rkb kbfsmd.TLFReaderKeyBundleV3) {
b.putReaderBundleTimer.Time(func() {
b.delegate.PutTLFReaderKeyBundle(bundleID, rkb)
})
} | [
"func",
"(",
"b",
"KeyBundleCacheMeasured",
")",
"PutTLFReaderKeyBundle",
"(",
"bundleID",
"kbfsmd",
".",
"TLFReaderKeyBundleID",
",",
"rkb",
"kbfsmd",
".",
"TLFReaderKeyBundleV3",
")",
"{",
"b",
".",
"putReaderBundleTimer",
".",
"Time",
"(",
"func",
"(",
")",
"... | // PutTLFReaderKeyBundle implements the KeyBundleCache interface for
// KeyBundleCacheMeasured. | [
"PutTLFReaderKeyBundle",
"implements",
"the",
"KeyBundleCache",
"interface",
"for",
"KeyBundleCacheMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkey/key_bundle_cache_measured.go#L82-L87 |
158,883 | keybase/client | go/kbfs/libkey/key_bundle_cache_measured.go | PutTLFWriterKeyBundle | func (b KeyBundleCacheMeasured) PutTLFWriterKeyBundle(
bundleID kbfsmd.TLFWriterKeyBundleID, wkb kbfsmd.TLFWriterKeyBundleV3) {
b.putWriterBundleTimer.Time(func() {
b.delegate.PutTLFWriterKeyBundle(bundleID, wkb)
})
} | go | func (b KeyBundleCacheMeasured) PutTLFWriterKeyBundle(
bundleID kbfsmd.TLFWriterKeyBundleID, wkb kbfsmd.TLFWriterKeyBundleV3) {
b.putWriterBundleTimer.Time(func() {
b.delegate.PutTLFWriterKeyBundle(bundleID, wkb)
})
} | [
"func",
"(",
"b",
"KeyBundleCacheMeasured",
")",
"PutTLFWriterKeyBundle",
"(",
"bundleID",
"kbfsmd",
".",
"TLFWriterKeyBundleID",
",",
"wkb",
"kbfsmd",
".",
"TLFWriterKeyBundleV3",
")",
"{",
"b",
".",
"putWriterBundleTimer",
".",
"Time",
"(",
"func",
"(",
")",
"... | // PutTLFWriterKeyBundle implements the KeyBundleCache interface for
// KeyBundleCacheMeasured. | [
"PutTLFWriterKeyBundle",
"implements",
"the",
"KeyBundleCache",
"interface",
"for",
"KeyBundleCacheMeasured",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkey/key_bundle_cache_measured.go#L91-L96 |
158,884 | keybase/client | go/kbfs/libdokan/user_edit_history.go | NewUserEditHistoryFile | func NewUserEditHistoryFile(folder *Folder) *SpecialReadFile {
return &SpecialReadFile{
read: func(ctx context.Context) ([]byte, time.Time, error) {
return libfs.GetEncodedUserEditHistory(ctx, folder.fs.config)
},
fs: folder.fs,
}
} | go | func NewUserEditHistoryFile(folder *Folder) *SpecialReadFile {
return &SpecialReadFile{
read: func(ctx context.Context) ([]byte, time.Time, error) {
return libfs.GetEncodedUserEditHistory(ctx, folder.fs.config)
},
fs: folder.fs,
}
} | [
"func",
"NewUserEditHistoryFile",
"(",
"folder",
"*",
"Folder",
")",
"*",
"SpecialReadFile",
"{",
"return",
"&",
"SpecialReadFile",
"{",
"read",
":",
"func",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"byte",
",",
"time",
".",
"Time",
","... | // NewUserEditHistoryFile returns a special read file that contains a text
// representation of the file edit history for the logged-in user. | [
"NewUserEditHistoryFile",
"returns",
"a",
"special",
"read",
"file",
"that",
"contains",
"a",
"text",
"representation",
"of",
"the",
"file",
"edit",
"history",
"for",
"the",
"logged",
"-",
"in",
"user",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libdokan/user_edit_history.go#L16-L23 |
158,885 | keybase/client | go/kbfs/libkbfs/crypto_client.go | Sign | func (c *CryptoClient) Sign(ctx context.Context, msg []byte) (
sigInfo kbfscrypto.SignatureInfo, err error) {
c.log.CDebugf(ctx, "Signing %d-byte message", len(msg))
defer func() {
c.deferLog.CDebugf(ctx, "Signed %d-byte message with %s: err=%+v", len(msg),
sigInfo, err)
}()
timer := c.logAboutTooLongUnlessCancelled(ctx, "SignED25519")
defer timer.Stop()
ed25519SigInfo, err := c.client.SignED25519(ctx, keybase1.SignED25519Arg{
Msg: msg,
Reason: "to use kbfs",
})
if err != nil {
return kbfscrypto.SignatureInfo{}, errors.WithStack(err)
}
return kbfscrypto.SignatureInfo{
Version: kbfscrypto.SigED25519,
Signature: ed25519SigInfo.Sig[:],
VerifyingKey: kbfscrypto.MakeVerifyingKey(kbcrypto.NaclSigningKeyPublic(ed25519SigInfo.PublicKey).GetKID()),
}, nil
} | go | func (c *CryptoClient) Sign(ctx context.Context, msg []byte) (
sigInfo kbfscrypto.SignatureInfo, err error) {
c.log.CDebugf(ctx, "Signing %d-byte message", len(msg))
defer func() {
c.deferLog.CDebugf(ctx, "Signed %d-byte message with %s: err=%+v", len(msg),
sigInfo, err)
}()
timer := c.logAboutTooLongUnlessCancelled(ctx, "SignED25519")
defer timer.Stop()
ed25519SigInfo, err := c.client.SignED25519(ctx, keybase1.SignED25519Arg{
Msg: msg,
Reason: "to use kbfs",
})
if err != nil {
return kbfscrypto.SignatureInfo{}, errors.WithStack(err)
}
return kbfscrypto.SignatureInfo{
Version: kbfscrypto.SigED25519,
Signature: ed25519SigInfo.Sig[:],
VerifyingKey: kbfscrypto.MakeVerifyingKey(kbcrypto.NaclSigningKeyPublic(ed25519SigInfo.PublicKey).GetKID()),
}, nil
} | [
"func",
"(",
"c",
"*",
"CryptoClient",
")",
"Sign",
"(",
"ctx",
"context",
".",
"Context",
",",
"msg",
"[",
"]",
"byte",
")",
"(",
"sigInfo",
"kbfscrypto",
".",
"SignatureInfo",
",",
"err",
"error",
")",
"{",
"c",
".",
"log",
".",
"CDebugf",
"(",
"... | // Sign implements the Crypto interface for CryptoClient. | [
"Sign",
"implements",
"the",
"Crypto",
"interface",
"for",
"CryptoClient",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/crypto_client.go#L44-L67 |
158,886 | keybase/client | go/kbfs/libkbfs/crypto_client.go | SignToString | func (c *CryptoClient) SignToString(ctx context.Context, msg []byte) (
signature string, err error) {
c.log.CDebugf(ctx, "Signing %d-byte message to string", len(msg))
defer func() {
c.deferLog.CDebugf(ctx, "Signed %d-byte message: err=%+v", len(msg), err)
}()
timer := c.logAboutTooLongUnlessCancelled(ctx, "SignToString")
defer timer.Stop()
signature, err = c.client.SignToString(ctx, keybase1.SignToStringArg{
Msg: msg,
Reason: "KBFS Authentication",
})
if err != nil {
return "", errors.WithStack(err)
}
return signature, nil
} | go | func (c *CryptoClient) SignToString(ctx context.Context, msg []byte) (
signature string, err error) {
c.log.CDebugf(ctx, "Signing %d-byte message to string", len(msg))
defer func() {
c.deferLog.CDebugf(ctx, "Signed %d-byte message: err=%+v", len(msg), err)
}()
timer := c.logAboutTooLongUnlessCancelled(ctx, "SignToString")
defer timer.Stop()
signature, err = c.client.SignToString(ctx, keybase1.SignToStringArg{
Msg: msg,
Reason: "KBFS Authentication",
})
if err != nil {
return "", errors.WithStack(err)
}
return signature, nil
} | [
"func",
"(",
"c",
"*",
"CryptoClient",
")",
"SignToString",
"(",
"ctx",
"context",
".",
"Context",
",",
"msg",
"[",
"]",
"byte",
")",
"(",
"signature",
"string",
",",
"err",
"error",
")",
"{",
"c",
".",
"log",
".",
"CDebugf",
"(",
"ctx",
",",
"\"",... | // SignToString implements the Crypto interface for CryptoClient. | [
"SignToString",
"implements",
"the",
"Crypto",
"interface",
"for",
"CryptoClient",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/crypto_client.go#L96-L113 |
158,887 | keybase/client | go/kbfs/libkbfs/crypto_client.go | DecryptTLFCryptKeyClientHalf | func (c *CryptoClient) DecryptTLFCryptKeyClientHalf(ctx context.Context,
publicKey kbfscrypto.TLFEphemeralPublicKey,
encryptedClientHalf kbfscrypto.EncryptedTLFCryptKeyClientHalf) (
clientHalf kbfscrypto.TLFCryptKeyClientHalf, err error) {
c.log.CDebugf(ctx, "Decrypting TLF client key half")
defer func() {
c.deferLog.CDebugf(ctx, "Decrypted TLF client key half: %+v",
err)
}()
encryptedData, nonce, err := c.prepareTLFCryptKeyClientHalf(
encryptedClientHalf)
if err != nil {
return kbfscrypto.TLFCryptKeyClientHalf{}, err
}
timer := c.logAboutTooLongUnlessCancelled(ctx, "UnboxBytes32")
defer timer.Stop()
decryptedClientHalf, err := c.client.UnboxBytes32(ctx, keybase1.UnboxBytes32Arg{
EncryptedBytes32: encryptedData,
Nonce: nonce,
PeersPublicKey: keybase1.BoxPublicKey(publicKey.Data()),
Reason: "to use kbfs",
})
if err != nil {
return kbfscrypto.TLFCryptKeyClientHalf{}, errors.WithStack(err)
}
return kbfscrypto.MakeTLFCryptKeyClientHalf(decryptedClientHalf), nil
} | go | func (c *CryptoClient) DecryptTLFCryptKeyClientHalf(ctx context.Context,
publicKey kbfscrypto.TLFEphemeralPublicKey,
encryptedClientHalf kbfscrypto.EncryptedTLFCryptKeyClientHalf) (
clientHalf kbfscrypto.TLFCryptKeyClientHalf, err error) {
c.log.CDebugf(ctx, "Decrypting TLF client key half")
defer func() {
c.deferLog.CDebugf(ctx, "Decrypted TLF client key half: %+v",
err)
}()
encryptedData, nonce, err := c.prepareTLFCryptKeyClientHalf(
encryptedClientHalf)
if err != nil {
return kbfscrypto.TLFCryptKeyClientHalf{}, err
}
timer := c.logAboutTooLongUnlessCancelled(ctx, "UnboxBytes32")
defer timer.Stop()
decryptedClientHalf, err := c.client.UnboxBytes32(ctx, keybase1.UnboxBytes32Arg{
EncryptedBytes32: encryptedData,
Nonce: nonce,
PeersPublicKey: keybase1.BoxPublicKey(publicKey.Data()),
Reason: "to use kbfs",
})
if err != nil {
return kbfscrypto.TLFCryptKeyClientHalf{}, errors.WithStack(err)
}
return kbfscrypto.MakeTLFCryptKeyClientHalf(decryptedClientHalf), nil
} | [
"func",
"(",
"c",
"*",
"CryptoClient",
")",
"DecryptTLFCryptKeyClientHalf",
"(",
"ctx",
"context",
".",
"Context",
",",
"publicKey",
"kbfscrypto",
".",
"TLFEphemeralPublicKey",
",",
"encryptedClientHalf",
"kbfscrypto",
".",
"EncryptedTLFCryptKeyClientHalf",
")",
"(",
... | // DecryptTLFCryptKeyClientHalf implements the Crypto interface for
// CryptoClient. | [
"DecryptTLFCryptKeyClientHalf",
"implements",
"the",
"Crypto",
"interface",
"for",
"CryptoClient",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/crypto_client.go#L144-L172 |
158,888 | keybase/client | go/kbfs/libkbfs/crypto_client.go | DecryptTLFCryptKeyClientHalfAny | func (c *CryptoClient) DecryptTLFCryptKeyClientHalfAny(ctx context.Context,
keys []EncryptedTLFCryptKeyClientAndEphemeral, promptPaper bool) (
clientHalf kbfscrypto.TLFCryptKeyClientHalf, index int, err error) {
c.log.CDebugf(ctx, "Decrypting TLF client key half with any key")
defer func() {
c.deferLog.CDebugf(ctx,
"Decrypted TLF client key half with any key: %+v",
err)
}()
if len(keys) == 0 {
return kbfscrypto.TLFCryptKeyClientHalf{}, -1,
errors.WithStack(NoKeysError{})
}
bundles := make([]keybase1.CiphertextBundle, 0, len(keys))
prepErrs := make([]error, 0, len(keys))
indexLookup := make([]int, 0, len(keys))
for i, k := range keys {
encryptedData, nonce, prepErr :=
c.prepareTLFCryptKeyClientHalf(k.ClientHalf)
if err != nil {
prepErrs = append(prepErrs, prepErr)
} else {
bundles = append(bundles, keybase1.CiphertextBundle{
Kid: k.PubKey.KID(),
Ciphertext: encryptedData,
Nonce: nonce,
PublicKey: keybase1.BoxPublicKey(k.EPubKey.Data()),
})
indexLookup = append(indexLookup, i)
}
}
if len(bundles) == 0 {
return kbfscrypto.TLFCryptKeyClientHalf{}, -1, prepErrs[0]
}
timer := c.logAboutTooLongUnlessCancelled(ctx, "UnboxBytes32Any")
defer timer.Stop()
res, err := c.client.UnboxBytes32Any(ctx, keybase1.UnboxBytes32AnyArg{
Bundles: bundles,
Reason: "to rekey for kbfs",
PromptPaper: promptPaper,
})
if err != nil {
return kbfscrypto.TLFCryptKeyClientHalf{}, -1,
errors.WithStack(err)
}
return kbfscrypto.MakeTLFCryptKeyClientHalf(res.Plaintext),
indexLookup[res.Index], nil
} | go | func (c *CryptoClient) DecryptTLFCryptKeyClientHalfAny(ctx context.Context,
keys []EncryptedTLFCryptKeyClientAndEphemeral, promptPaper bool) (
clientHalf kbfscrypto.TLFCryptKeyClientHalf, index int, err error) {
c.log.CDebugf(ctx, "Decrypting TLF client key half with any key")
defer func() {
c.deferLog.CDebugf(ctx,
"Decrypted TLF client key half with any key: %+v",
err)
}()
if len(keys) == 0 {
return kbfscrypto.TLFCryptKeyClientHalf{}, -1,
errors.WithStack(NoKeysError{})
}
bundles := make([]keybase1.CiphertextBundle, 0, len(keys))
prepErrs := make([]error, 0, len(keys))
indexLookup := make([]int, 0, len(keys))
for i, k := range keys {
encryptedData, nonce, prepErr :=
c.prepareTLFCryptKeyClientHalf(k.ClientHalf)
if err != nil {
prepErrs = append(prepErrs, prepErr)
} else {
bundles = append(bundles, keybase1.CiphertextBundle{
Kid: k.PubKey.KID(),
Ciphertext: encryptedData,
Nonce: nonce,
PublicKey: keybase1.BoxPublicKey(k.EPubKey.Data()),
})
indexLookup = append(indexLookup, i)
}
}
if len(bundles) == 0 {
return kbfscrypto.TLFCryptKeyClientHalf{}, -1, prepErrs[0]
}
timer := c.logAboutTooLongUnlessCancelled(ctx, "UnboxBytes32Any")
defer timer.Stop()
res, err := c.client.UnboxBytes32Any(ctx, keybase1.UnboxBytes32AnyArg{
Bundles: bundles,
Reason: "to rekey for kbfs",
PromptPaper: promptPaper,
})
if err != nil {
return kbfscrypto.TLFCryptKeyClientHalf{}, -1,
errors.WithStack(err)
}
return kbfscrypto.MakeTLFCryptKeyClientHalf(res.Plaintext),
indexLookup[res.Index], nil
} | [
"func",
"(",
"c",
"*",
"CryptoClient",
")",
"DecryptTLFCryptKeyClientHalfAny",
"(",
"ctx",
"context",
".",
"Context",
",",
"keys",
"[",
"]",
"EncryptedTLFCryptKeyClientAndEphemeral",
",",
"promptPaper",
"bool",
")",
"(",
"clientHalf",
"kbfscrypto",
".",
"TLFCryptKey... | // DecryptTLFCryptKeyClientHalfAny implements the Crypto interface for
// CryptoClient. | [
"DecryptTLFCryptKeyClientHalfAny",
"implements",
"the",
"Crypto",
"interface",
"for",
"CryptoClient",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/crypto_client.go#L176-L223 |
158,889 | keybase/client | go/kbfs/libkbfs/crypto_client.go | DecryptTeamMerkleLeaf | func (c *CryptoClient) DecryptTeamMerkleLeaf(
ctx context.Context, teamID keybase1.TeamID,
publicKey kbfscrypto.TLFEphemeralPublicKey,
encryptedMerkleLeaf kbfscrypto.EncryptedMerkleLeaf,
minKeyGen keybase1.PerTeamKeyGeneration) (decryptedData []byte, err error) {
c.log.CDebugf(ctx, "Decrypting team Merkle leaf")
defer func() {
c.deferLog.CDebugf(ctx, "Decrypted team Merkle leaf: %+v", err)
}()
nonce, err := kbfscrypto.PrepareMerkleLeaf(
encryptedMerkleLeaf)
if err != nil {
return nil, err
}
timer := c.logAboutTooLongUnlessCancelled(ctx, "DecryptTeamMerkleLeaf")
defer timer.Stop()
decryptedData, err = c.teamsClient.TryDecryptWithTeamKey(ctx,
keybase1.TryDecryptWithTeamKeyArg{
TeamID: teamID,
EncryptedData: encryptedMerkleLeaf.EncryptedData,
Nonce: nonce,
PeersPublicKey: keybase1.BoxPublicKey(publicKey.Data()),
MinGeneration: minKeyGen,
})
if err != nil {
return nil, errors.WithStack(err)
}
return decryptedData, nil
} | go | func (c *CryptoClient) DecryptTeamMerkleLeaf(
ctx context.Context, teamID keybase1.TeamID,
publicKey kbfscrypto.TLFEphemeralPublicKey,
encryptedMerkleLeaf kbfscrypto.EncryptedMerkleLeaf,
minKeyGen keybase1.PerTeamKeyGeneration) (decryptedData []byte, err error) {
c.log.CDebugf(ctx, "Decrypting team Merkle leaf")
defer func() {
c.deferLog.CDebugf(ctx, "Decrypted team Merkle leaf: %+v", err)
}()
nonce, err := kbfscrypto.PrepareMerkleLeaf(
encryptedMerkleLeaf)
if err != nil {
return nil, err
}
timer := c.logAboutTooLongUnlessCancelled(ctx, "DecryptTeamMerkleLeaf")
defer timer.Stop()
decryptedData, err = c.teamsClient.TryDecryptWithTeamKey(ctx,
keybase1.TryDecryptWithTeamKeyArg{
TeamID: teamID,
EncryptedData: encryptedMerkleLeaf.EncryptedData,
Nonce: nonce,
PeersPublicKey: keybase1.BoxPublicKey(publicKey.Data()),
MinGeneration: minKeyGen,
})
if err != nil {
return nil, errors.WithStack(err)
}
return decryptedData, nil
} | [
"func",
"(",
"c",
"*",
"CryptoClient",
")",
"DecryptTeamMerkleLeaf",
"(",
"ctx",
"context",
".",
"Context",
",",
"teamID",
"keybase1",
".",
"TeamID",
",",
"publicKey",
"kbfscrypto",
".",
"TLFEphemeralPublicKey",
",",
"encryptedMerkleLeaf",
"kbfscrypto",
".",
"Encr... | // DecryptTeamMerkleLeaf implements the Crypto interface for
// CryptoClient. | [
"DecryptTeamMerkleLeaf",
"implements",
"the",
"Crypto",
"interface",
"for",
"CryptoClient",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/crypto_client.go#L227-L256 |
158,890 | keybase/client | go/kbfs/kbfsblock/protocol_utils.go | MakeGetBlockArg | func MakeGetBlockArg(tlfID tlf.ID, id ID, context Context) keybase1.GetBlockArg {
return keybase1.GetBlockArg{
Bid: makeIDCombo(id, context),
Folder: tlfID.String(),
}
} | go | func MakeGetBlockArg(tlfID tlf.ID, id ID, context Context) keybase1.GetBlockArg {
return keybase1.GetBlockArg{
Bid: makeIDCombo(id, context),
Folder: tlfID.String(),
}
} | [
"func",
"MakeGetBlockArg",
"(",
"tlfID",
"tlf",
".",
"ID",
",",
"id",
"ID",
",",
"context",
"Context",
")",
"keybase1",
".",
"GetBlockArg",
"{",
"return",
"keybase1",
".",
"GetBlockArg",
"{",
"Bid",
":",
"makeIDCombo",
"(",
"id",
",",
"context",
")",
","... | // MakeGetBlockArg builds a keybase1.GetBlockArg from the given params. | [
"MakeGetBlockArg",
"builds",
"a",
"keybase1",
".",
"GetBlockArg",
"from",
"the",
"given",
"params",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/protocol_utils.go#L45-L50 |
158,891 | keybase/client | go/kbfs/kbfsblock/protocol_utils.go | ParseGetBlockRes | func ParseGetBlockRes(res keybase1.GetBlockRes, resErr error) (
buf []byte, serverHalf kbfscrypto.BlockCryptKeyServerHalf, err error) {
if resErr != nil {
return nil, kbfscrypto.BlockCryptKeyServerHalf{}, resErr
}
serverHalf, err = kbfscrypto.ParseBlockCryptKeyServerHalf(res.BlockKey)
if err != nil {
return nil, kbfscrypto.BlockCryptKeyServerHalf{}, err
}
return res.Buf, serverHalf, nil
} | go | func ParseGetBlockRes(res keybase1.GetBlockRes, resErr error) (
buf []byte, serverHalf kbfscrypto.BlockCryptKeyServerHalf, err error) {
if resErr != nil {
return nil, kbfscrypto.BlockCryptKeyServerHalf{}, resErr
}
serverHalf, err = kbfscrypto.ParseBlockCryptKeyServerHalf(res.BlockKey)
if err != nil {
return nil, kbfscrypto.BlockCryptKeyServerHalf{}, err
}
return res.Buf, serverHalf, nil
} | [
"func",
"ParseGetBlockRes",
"(",
"res",
"keybase1",
".",
"GetBlockRes",
",",
"resErr",
"error",
")",
"(",
"buf",
"[",
"]",
"byte",
",",
"serverHalf",
"kbfscrypto",
".",
"BlockCryptKeyServerHalf",
",",
"err",
"error",
")",
"{",
"if",
"resErr",
"!=",
"nil",
... | // ParseGetBlockRes parses the given keybase1.GetBlockRes into its
// components. | [
"ParseGetBlockRes",
"parses",
"the",
"given",
"keybase1",
".",
"GetBlockRes",
"into",
"its",
"components",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/protocol_utils.go#L54-L64 |
158,892 | keybase/client | go/kbfs/kbfsblock/protocol_utils.go | MakePutBlockArg | func MakePutBlockArg(tlfID tlf.ID, id ID,
bContext Context, buf []byte,
serverHalf kbfscrypto.BlockCryptKeyServerHalf) keybase1.PutBlockArg {
return keybase1.PutBlockArg{
Bid: makeIDCombo(id, bContext),
// BlockKey is misnamed -- it contains just the server
// half.
BlockKey: serverHalf.String(),
Folder: tlfID.String(),
Buf: buf,
}
} | go | func MakePutBlockArg(tlfID tlf.ID, id ID,
bContext Context, buf []byte,
serverHalf kbfscrypto.BlockCryptKeyServerHalf) keybase1.PutBlockArg {
return keybase1.PutBlockArg{
Bid: makeIDCombo(id, bContext),
// BlockKey is misnamed -- it contains just the server
// half.
BlockKey: serverHalf.String(),
Folder: tlfID.String(),
Buf: buf,
}
} | [
"func",
"MakePutBlockArg",
"(",
"tlfID",
"tlf",
".",
"ID",
",",
"id",
"ID",
",",
"bContext",
"Context",
",",
"buf",
"[",
"]",
"byte",
",",
"serverHalf",
"kbfscrypto",
".",
"BlockCryptKeyServerHalf",
")",
"keybase1",
".",
"PutBlockArg",
"{",
"return",
"keybas... | // MakePutBlockArg builds a keybase1.PutBlockArg from the given params. | [
"MakePutBlockArg",
"builds",
"a",
"keybase1",
".",
"PutBlockArg",
"from",
"the",
"given",
"params",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/protocol_utils.go#L67-L78 |
158,893 | keybase/client | go/kbfs/kbfsblock/protocol_utils.go | MakePutBlockAgainArg | func MakePutBlockAgainArg(tlfID tlf.ID, id ID,
bContext Context, buf []byte, serverHalf kbfscrypto.BlockCryptKeyServerHalf) keybase1.PutBlockAgainArg {
return keybase1.PutBlockAgainArg{
Ref: makeReference(id, bContext),
// BlockKey is misnamed -- it contains just the server
// half.
BlockKey: serverHalf.String(),
Folder: tlfID.String(),
Buf: buf,
}
} | go | func MakePutBlockAgainArg(tlfID tlf.ID, id ID,
bContext Context, buf []byte, serverHalf kbfscrypto.BlockCryptKeyServerHalf) keybase1.PutBlockAgainArg {
return keybase1.PutBlockAgainArg{
Ref: makeReference(id, bContext),
// BlockKey is misnamed -- it contains just the server
// half.
BlockKey: serverHalf.String(),
Folder: tlfID.String(),
Buf: buf,
}
} | [
"func",
"MakePutBlockAgainArg",
"(",
"tlfID",
"tlf",
".",
"ID",
",",
"id",
"ID",
",",
"bContext",
"Context",
",",
"buf",
"[",
"]",
"byte",
",",
"serverHalf",
"kbfscrypto",
".",
"BlockCryptKeyServerHalf",
")",
"keybase1",
".",
"PutBlockAgainArg",
"{",
"return",... | // MakePutBlockAgainArg builds a keybase1.PutBlockAgainArg from the
// given params. | [
"MakePutBlockAgainArg",
"builds",
"a",
"keybase1",
".",
"PutBlockAgainArg",
"from",
"the",
"given",
"params",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/protocol_utils.go#L82-L92 |
158,894 | keybase/client | go/kbfs/kbfsblock/protocol_utils.go | MakeAddReferenceArg | func MakeAddReferenceArg(tlfID tlf.ID, id ID, context Context) keybase1.AddReferenceArg {
return keybase1.AddReferenceArg{
Ref: makeReference(id, context),
Folder: tlfID.String(),
}
} | go | func MakeAddReferenceArg(tlfID tlf.ID, id ID, context Context) keybase1.AddReferenceArg {
return keybase1.AddReferenceArg{
Ref: makeReference(id, context),
Folder: tlfID.String(),
}
} | [
"func",
"MakeAddReferenceArg",
"(",
"tlfID",
"tlf",
".",
"ID",
",",
"id",
"ID",
",",
"context",
"Context",
")",
"keybase1",
".",
"AddReferenceArg",
"{",
"return",
"keybase1",
".",
"AddReferenceArg",
"{",
"Ref",
":",
"makeReference",
"(",
"id",
",",
"context"... | // MakeAddReferenceArg builds a keybase1.AddReferenceArg from the
// given params. | [
"MakeAddReferenceArg",
"builds",
"a",
"keybase1",
".",
"AddReferenceArg",
"from",
"the",
"given",
"params",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/protocol_utils.go#L96-L101 |
158,895 | keybase/client | go/kbfs/kbfsblock/protocol_utils.go | getNotDone | func getNotDone(all ContextMap, doneRefs map[ID]map[RefNonce]int) (
notDone []keybase1.BlockReference) {
for id, idContexts := range all {
for _, context := range idContexts {
if _, ok := doneRefs[id]; ok {
if _, ok1 := doneRefs[id][context.GetRefNonce()]; ok1 {
continue
}
}
ref := makeReference(id, context)
notDone = append(notDone, ref)
}
}
return notDone
} | go | func getNotDone(all ContextMap, doneRefs map[ID]map[RefNonce]int) (
notDone []keybase1.BlockReference) {
for id, idContexts := range all {
for _, context := range idContexts {
if _, ok := doneRefs[id]; ok {
if _, ok1 := doneRefs[id][context.GetRefNonce()]; ok1 {
continue
}
}
ref := makeReference(id, context)
notDone = append(notDone, ref)
}
}
return notDone
} | [
"func",
"getNotDone",
"(",
"all",
"ContextMap",
",",
"doneRefs",
"map",
"[",
"ID",
"]",
"map",
"[",
"RefNonce",
"]",
"int",
")",
"(",
"notDone",
"[",
"]",
"keybase1",
".",
"BlockReference",
")",
"{",
"for",
"id",
",",
"idContexts",
":=",
"range",
"all"... | // getNotDone returns the set of block references in "all" that do not
// yet appear in "results" | [
"getNotDone",
"returns",
"the",
"set",
"of",
"block",
"references",
"in",
"all",
"that",
"do",
"not",
"yet",
"appear",
"in",
"results"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/protocol_utils.go#L105-L119 |
158,896 | keybase/client | go/kbfs/kbfsblock/protocol_utils.go | BatchDowngradeReferences | func BatchDowngradeReferences(ctx context.Context, log logger.Logger,
tlfID tlf.ID, contexts ContextMap, archive bool,
server keybase1.BlockInterface) (
doneRefs map[ID]map[RefNonce]int, finalError error) {
doneRefs = make(map[ID]map[RefNonce]int)
notDone := getNotDone(contexts, doneRefs)
throttleErr := backoff.Retry(func() error {
var res keybase1.DowngradeReferenceRes
var err error
if archive {
res, err = server.ArchiveReferenceWithCount(ctx,
keybase1.ArchiveReferenceWithCountArg{
Refs: notDone,
Folder: tlfID.String(),
})
} else {
res, err = server.DelReferenceWithCount(ctx,
keybase1.DelReferenceWithCountArg{
Refs: notDone,
Folder: tlfID.String(),
})
}
// log errors
if err != nil {
log.CWarningf(ctx, "batchDowngradeReferences archive=%t sent=%v done=%v failedRef=%v err=%v",
archive, notDone, res.Completed, res.Failed, err)
} else {
log.CDebugf(ctx, "batchDowngradeReferences archive=%t notdone=%v all succeeded",
archive, notDone)
}
// update the set of completed reference
for _, ref := range res.Completed {
bid, err := IDFromString(ref.Ref.Bid.BlockHash)
if err != nil {
continue
}
nonces, ok := doneRefs[bid]
if !ok {
nonces = make(map[RefNonce]int)
doneRefs[bid] = nonces
}
nonces[RefNonce(ref.Ref.Nonce)] = ref.LiveCount
}
// update the list of references to downgrade
notDone = getNotDone(contexts, doneRefs)
//if context is cancelled, return immediately
select {
case <-ctx.Done():
finalError = ctx.Err()
return nil
default:
}
// check whether to backoff and retry
if err != nil {
// if error is of type throttle, retry
if IsThrottleError(err) {
return err
}
// non-throttle error, do not retry here
finalError = err
}
return nil
}, backoff.NewExponentialBackOff())
// if backoff has given up retrying, return error
if throttleErr != nil {
return doneRefs, throttleErr
}
if finalError == nil {
if len(notDone) != 0 {
log.CErrorf(ctx, "batchDowngradeReferences finished successfully with outstanding refs? all=%v done=%v notDone=%v\n", contexts, doneRefs, notDone)
return doneRefs,
errors.New("batchDowngradeReferences inconsistent result")
}
}
return doneRefs, finalError
} | go | func BatchDowngradeReferences(ctx context.Context, log logger.Logger,
tlfID tlf.ID, contexts ContextMap, archive bool,
server keybase1.BlockInterface) (
doneRefs map[ID]map[RefNonce]int, finalError error) {
doneRefs = make(map[ID]map[RefNonce]int)
notDone := getNotDone(contexts, doneRefs)
throttleErr := backoff.Retry(func() error {
var res keybase1.DowngradeReferenceRes
var err error
if archive {
res, err = server.ArchiveReferenceWithCount(ctx,
keybase1.ArchiveReferenceWithCountArg{
Refs: notDone,
Folder: tlfID.String(),
})
} else {
res, err = server.DelReferenceWithCount(ctx,
keybase1.DelReferenceWithCountArg{
Refs: notDone,
Folder: tlfID.String(),
})
}
// log errors
if err != nil {
log.CWarningf(ctx, "batchDowngradeReferences archive=%t sent=%v done=%v failedRef=%v err=%v",
archive, notDone, res.Completed, res.Failed, err)
} else {
log.CDebugf(ctx, "batchDowngradeReferences archive=%t notdone=%v all succeeded",
archive, notDone)
}
// update the set of completed reference
for _, ref := range res.Completed {
bid, err := IDFromString(ref.Ref.Bid.BlockHash)
if err != nil {
continue
}
nonces, ok := doneRefs[bid]
if !ok {
nonces = make(map[RefNonce]int)
doneRefs[bid] = nonces
}
nonces[RefNonce(ref.Ref.Nonce)] = ref.LiveCount
}
// update the list of references to downgrade
notDone = getNotDone(contexts, doneRefs)
//if context is cancelled, return immediately
select {
case <-ctx.Done():
finalError = ctx.Err()
return nil
default:
}
// check whether to backoff and retry
if err != nil {
// if error is of type throttle, retry
if IsThrottleError(err) {
return err
}
// non-throttle error, do not retry here
finalError = err
}
return nil
}, backoff.NewExponentialBackOff())
// if backoff has given up retrying, return error
if throttleErr != nil {
return doneRefs, throttleErr
}
if finalError == nil {
if len(notDone) != 0 {
log.CErrorf(ctx, "batchDowngradeReferences finished successfully with outstanding refs? all=%v done=%v notDone=%v\n", contexts, doneRefs, notDone)
return doneRefs,
errors.New("batchDowngradeReferences inconsistent result")
}
}
return doneRefs, finalError
} | [
"func",
"BatchDowngradeReferences",
"(",
"ctx",
"context",
".",
"Context",
",",
"log",
"logger",
".",
"Logger",
",",
"tlfID",
"tlf",
".",
"ID",
",",
"contexts",
"ContextMap",
",",
"archive",
"bool",
",",
"server",
"keybase1",
".",
"BlockInterface",
")",
"(",... | // BatchDowngradeReferences archives or deletes a batch of references,
// handling all batching and throttles. | [
"BatchDowngradeReferences",
"archives",
"or",
"deletes",
"a",
"batch",
"of",
"references",
"handling",
"all",
"batching",
"and",
"throttles",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/protocol_utils.go#L123-L205 |
158,897 | keybase/client | go/kbfs/kbfsblock/protocol_utils.go | GetLiveCounts | func GetLiveCounts(doneRefs map[ID]map[RefNonce]int) map[ID]int {
liveCounts := make(map[ID]int)
for id, nonces := range doneRefs {
for _, count := range nonces {
if existing, ok := liveCounts[id]; !ok || existing > count {
liveCounts[id] = count
}
}
}
return liveCounts
} | go | func GetLiveCounts(doneRefs map[ID]map[RefNonce]int) map[ID]int {
liveCounts := make(map[ID]int)
for id, nonces := range doneRefs {
for _, count := range nonces {
if existing, ok := liveCounts[id]; !ok || existing > count {
liveCounts[id] = count
}
}
}
return liveCounts
} | [
"func",
"GetLiveCounts",
"(",
"doneRefs",
"map",
"[",
"ID",
"]",
"map",
"[",
"RefNonce",
"]",
"int",
")",
"map",
"[",
"ID",
"]",
"int",
"{",
"liveCounts",
":=",
"make",
"(",
"map",
"[",
"ID",
"]",
"int",
")",
"\n",
"for",
"id",
",",
"nonces",
":=... | // GetLiveCounts computes the maximum live count for each ID over its
// RefNonces. | [
"GetLiveCounts",
"computes",
"the",
"maximum",
"live",
"count",
"for",
"each",
"ID",
"over",
"its",
"RefNonces",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsblock/protocol_utils.go#L209-L219 |
158,898 | keybase/client | go/chat/supersedes.go | transformDelete | func (t *basicSupersedesTransform) transformDelete(msg chat1.MessageUnboxed, superMsg chat1.MessageUnboxed) *chat1.MessageUnboxed {
mvalid := msg.Valid()
if !mvalid.IsEphemeral() {
return nil
}
explodedBy := superMsg.Valid().SenderUsername
mvalid.ClientHeader.EphemeralMetadata.ExplodedBy = &explodedBy
newMsg := chat1.NewMessageUnboxedWithValid(mvalid)
return &newMsg
} | go | func (t *basicSupersedesTransform) transformDelete(msg chat1.MessageUnboxed, superMsg chat1.MessageUnboxed) *chat1.MessageUnboxed {
mvalid := msg.Valid()
if !mvalid.IsEphemeral() {
return nil
}
explodedBy := superMsg.Valid().SenderUsername
mvalid.ClientHeader.EphemeralMetadata.ExplodedBy = &explodedBy
newMsg := chat1.NewMessageUnboxedWithValid(mvalid)
return &newMsg
} | [
"func",
"(",
"t",
"*",
"basicSupersedesTransform",
")",
"transformDelete",
"(",
"msg",
"chat1",
".",
"MessageUnboxed",
",",
"superMsg",
"chat1",
".",
"MessageUnboxed",
")",
"*",
"chat1",
".",
"MessageUnboxed",
"{",
"mvalid",
":=",
"msg",
".",
"Valid",
"(",
"... | // This is only relevant for ephemeralMessages that are deleted since we want
// these to show up in the gui as "explode now" | [
"This",
"is",
"only",
"relevant",
"for",
"ephemeralMessages",
"that",
"are",
"deleted",
"since",
"we",
"want",
"these",
"to",
"show",
"up",
"in",
"the",
"gui",
"as",
"explode",
"now"
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/supersedes.go#L48-L57 |
158,899 | keybase/client | go/tools/runquiet/runquiet.go | makeCmdLine | func makeCmdLine(args []string) string {
var s string
for _, v := range args {
if s != "" {
s += " "
}
s += syscall.EscapeArg(v)
}
return s
} | go | func makeCmdLine(args []string) string {
var s string
for _, v := range args {
if s != "" {
s += " "
}
s += syscall.EscapeArg(v)
}
return s
} | [
"func",
"makeCmdLine",
"(",
"args",
"[",
"]",
"string",
")",
"string",
"{",
"var",
"s",
"string",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"args",
"{",
"if",
"s",
"!=",
"\"",
"\"",
"{",
"s",
"+=",
"\"",
"\"",
"\n",
"}",
"\n",
"s",
"+=",
"sy... | // makeCmdLine builds a command line out of args by escaping "special"
// characters and joining the arguments with spaces. | [
"makeCmdLine",
"builds",
"a",
"command",
"line",
"out",
"of",
"args",
"by",
"escaping",
"special",
"characters",
"and",
"joining",
"the",
"arguments",
"with",
"spaces",
"."
] | b352622cd8cc94798cfacbcb56ada203c18e519e | https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/tools/runquiet/runquiet.go#L70-L79 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.