本文整理匯總了Golang中github.com/keybase/go-jsonw.Wrapper.SetValueAtPath方法的典型用法代碼示例。如果您正苦於以下問題:Golang Wrapper.SetValueAtPath方法的具體用法?Golang Wrapper.SetValueAtPath怎麽用?Golang Wrapper.SetValueAtPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/keybase/go-jsonw.Wrapper
的用法示例。
在下文中一共展示了Wrapper.SetValueAtPath方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: checkReverseSig
// checkReverseSig verifies that the reverse sig in jw is valid
// and matches jw.
func (e *Kex2Provisioner) checkReverseSig(jw *jsonw.Wrapper) error {
kid, err := jw.AtPath("body.sibkey.kid").GetString()
if err != nil {
return err
}
keypair, err := libkb.ImportKeypairFromKID(keybase1.KIDFromString(kid))
if err != nil {
return err
}
revsig, err := jw.AtPath("body.sibkey.reverse_sig").GetString()
if err != nil {
return err
}
// set reverse_sig to nil to verify it:
jw.SetValueAtPath("body.sibkey.reverse_sig", jsonw.NewNil())
msg, err := jw.Marshal()
if err != nil {
return err
}
_, err = keypair.VerifyString(revsig, msg)
if err != nil {
return err
}
// put reverse_sig back in
jw.SetValueAtPath("body.sibkey.reverse_sig", jsonw.NewString(revsig))
return nil
}
示例2: addDeviceSibkey
func (e *Kex2Provisionee) addDeviceSibkey(jw *jsonw.Wrapper) error {
if e.device.Description == nil {
e.G().Log.Debug("prompting for device name")
// TODO: get existing device names
arg := keybase1.PromptNewDeviceNameArg{}
name, err := e.ctx.ProvisionUI.PromptNewDeviceName(context.TODO(), arg)
if err != nil {
return err
}
e.device.Description = &name
e.G().Log.Debug("got device name: %q", name)
}
s := libkb.DeviceStatusActive
e.device.Status = &s
e.device.Kid = e.eddsa.GetKID()
dw, err := e.device.Export(libkb.SibkeyType)
if err != nil {
return err
}
jw.SetValueAtPath("body.device", dw)
if err = jw.SetValueAtPath("body.sibkey.kid", jsonw.NewString(e.eddsa.GetKID().String())); err != nil {
return err
}
return nil
}
示例3: reverseSig
func (e *Kex2Provisionee) reverseSig(jw *jsonw.Wrapper) error {
// need to set reverse_sig to nil before making reverse sig:
if err := jw.SetValueAtPath("body.sibkey.reverse_sig", jsonw.NewNil()); err != nil {
return err
}
sig, _, _, err := libkb.SignJSON(jw, e.eddsa)
if err != nil {
return err
}
// put the signature in reverse_sig
if err := jw.SetValueAtPath("body.sibkey.reverse_sig", jsonw.NewString(sig)); err != nil {
return err
}
return nil
}
示例4: addDeviceSibkey
func (e *Kex2Provisionee) addDeviceSibkey(jw *jsonw.Wrapper) error {
if e.device.Description == nil {
// need user to get existing device names
loadArg := libkb.NewLoadUserByNameArg(e.G(), e.username)
loadArg.LoginContext = e.ctx.LoginContext
user, err := libkb.LoadUser(loadArg)
if err != nil {
return err
}
existingDevices, err := user.DeviceNames()
if err != nil {
e.G().Log.Debug("proceeding despite error getting existing device names: %s", err)
}
e.G().Log.Debug("prompting for device name")
arg := keybase1.PromptNewDeviceNameArg{
ExistingDevices: existingDevices,
}
name, err := e.ctx.ProvisionUI.PromptNewDeviceName(context.TODO(), arg)
if err != nil {
return err
}
e.device.Description = &name
e.G().Log.Debug("got device name: %q", name)
}
s := libkb.DeviceStatusActive
e.device.Status = &s
e.device.Kid = e.eddsa.GetKID()
dw, err := e.device.Export(libkb.SibkeyType)
if err != nil {
return err
}
jw.SetValueAtPath("body.device", dw)
if err = jw.SetValueAtPath("body.sibkey.kid", jsonw.NewString(e.eddsa.GetKID().String())); err != nil {
return err
}
return nil
}