本文整理匯總了Golang中github.com/keybase/go-jsonw.Wrapper.AtPath方法的典型用法代碼示例。如果您正苦於以下問題:Golang Wrapper.AtPath方法的具體用法?Golang Wrapper.AtPath怎麽用?Golang Wrapper.AtPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/keybase/go-jsonw.Wrapper
的用法示例。
在下文中一共展示了Wrapper.AtPath方法的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: rememberDeviceInfo
// rememberDeviceInfo saves the device name and type in
// Kex2Provisioner for later use.
func (e *Kex2Provisioner) rememberDeviceInfo(jw *jsonw.Wrapper) error {
name, err := jw.AtPath("body.device.name").GetString()
if err != nil {
return err
}
e.provisioneeDeviceName = name
dtype, err := jw.AtPath("body.device.type").GetString()
if err != nil {
return err
}
e.provisioneeDeviceType = dtype
return nil
}
示例3: UnpackData
func (rc *RooterChecker) UnpackData(inp *jsonw.Wrapper) (string, ProofError) {
var status, post string
var err error
cf := keybase1.ProofStatus_CONTENT_FAILURE
inp.AtPath("status.name").GetStringVoid(&status, &err)
if err != nil {
return "", rc.contentMissing(err)
}
if status != "OK" {
var code int
inp.AtPath("status.code").GetIntVoid(&code, &err)
if err != nil {
return "", rc.contentMissing(err)
}
if code == SCNotFound {
return "", NewProofError(keybase1.ProofStatus_NOT_FOUND, status)
}
return "", NewProofError(cf, "Rooter: Non-OK status: %s", status)
}
inp.AtPath("toot.post").GetStringVoid(&post, &err)
if err != nil {
return "", rc.contentMissing(err)
}
return post, nil
}
示例4: NewMerkleRootFromJSON
func NewMerkleRootFromJSON(jw *jsonw.Wrapper, g *GlobalContext) (ret *MerkleRoot, err error) {
var seqno int64
var sigs *jsonw.Wrapper
var payloadJSONString string
var pj *jsonw.Wrapper
var fp PGPFingerprint
var rh, lurh NodeHash
var ctime int64
if sigs, err = jw.AtKey("sigs").ToDictionary(); err != nil {
return
}
if payloadJSONString, err = jw.AtKey("payload_json").GetString(); err != nil {
return
}
if pj, err = jsonw.Unmarshal([]byte(payloadJSONString)); err != nil {
return
}
GetPGPFingerprintVoid(pj.AtPath("body.key.fingerprint"), &fp, &err)
pj.AtPath("body.seqno").GetInt64Void(&seqno, &err)
GetNodeHashVoid(pj.AtPath("body.root"), &rh, &err)
lurh, _ = GetNodeHash(pj.AtPath("body.legacy_uid_root"))
pj.AtKey("ctime").GetInt64Void(&ctime, &err)
if err != nil {
return
}
ret = &MerkleRoot{
seqno: Seqno(seqno),
pgpFingerprint: fp,
sigs: sigs,
payloadJSONString: payloadJSONString,
payloadJSON: pj,
rootHash: rh,
legacyUIDRootHash: lurh,
ctime: ctime,
Contextified: NewContextified(g),
}
return
}