本文整理匯總了Golang中github.com/keybase/go-jsonw.Wrapper.Marshal方法的典型用法代碼示例。如果您正苦於以下問題:Golang Wrapper.Marshal方法的具體用法?Golang Wrapper.Marshal怎麽用?Golang Wrapper.Marshal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/keybase/go-jsonw.Wrapper
的用法示例。
在下文中一共展示了Wrapper.Marshal方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: Put
func (j *JSONLocalDb) Put(id DbKey, aliases []DbKey, val *jsonw.Wrapper) error {
bytes, err := val.Marshal()
if err == nil {
err = j.engine.Put(id, aliases, bytes)
}
return err
}
示例3: SignJSON
// SimpleSignJson marshals the given Json structure and then signs it.
func SignJSON(jw *jsonw.Wrapper, key GenericKey) (out string, id keybase1.SigID, lid LinkID, err error) {
var tmp []byte
if tmp, err = jw.Marshal(); err != nil {
return
}
out, id, err = key.SignToString(tmp)
lid = ComputeLinkID(tmp)
return
}