本文整理汇总了Golang中github.com/keybase/go-jsonw.NewNil函数的典型用法代码示例。如果您正苦于以下问题:Golang NewNil函数的具体用法?Golang NewNil怎么用?Golang NewNil使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewNil函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: SetNullAtPath
func (f *JSONConfigFile) SetNullAtPath(p string) (err error) {
existing := f.jw.AtPath(p)
if !existing.IsNil() || existing.Error() != nil {
err = f.jw.SetValueAtPath(p, jsonw.NewNil())
if err == nil {
return f.flush()
}
}
return
}
示例3: ToTrackingStatementSeqTail
func (u *User) ToTrackingStatementSeqTail() *jsonw.Wrapper {
mul := u.GetPublicChainTail()
if mul == nil {
return jsonw.NewNil()
}
ret := jsonw.NewDictionary()
ret.SetKey("sig_id", jsonw.NewString(mul.SigID.ToString(true)))
ret.SetKey("seqno", jsonw.NewInt(int(mul.Seqno)))
ret.SetKey("payload_hash", jsonw.NewString(mul.LinkID.String()))
return ret
}
示例4: ToJSON
func (arg KeySection) ToJSON() (*jsonw.Wrapper, error) {
ret := jsonw.NewDictionary()
ret.SetKey("kid", jsonw.NewString(arg.Key.GetKID().String()))
if arg.EldestKID != "" {
ret.SetKey("eldest_kid", jsonw.NewString(arg.EldestKID.String()))
}
if arg.ParentKID != "" {
ret.SetKey("parent_kid", jsonw.NewString(arg.ParentKID.String()))
}
if arg.HasRevSig {
var revSig *jsonw.Wrapper
if arg.RevSig != "" {
revSig = jsonw.NewString(arg.RevSig)
} else {
revSig = jsonw.NewNil()
}
ret.SetKey("reverse_sig", revSig)
}
if arg.SigningUser != nil {
ret.SetKey("host", jsonw.NewString(CanonicalHost))
ret.SetKey("uid", UIDWrapper(arg.SigningUser.GetUID()))
ret.SetKey("username", jsonw.NewString(arg.SigningUser.GetName()))
}
if pgp, ok := arg.Key.(*PGPKeyBundle); ok {
fingerprint := pgp.GetFingerprint()
ret.SetKey("fingerprint", jsonw.NewString(fingerprint.String()))
ret.SetKey("key_id", jsonw.NewString(fingerprint.ToKeyID()))
if arg.IncludePGPHash {
hash, err := pgp.FullHash()
if err != nil {
return nil, err
}
ret.SetKey("full_hash", jsonw.NewString(hash))
}
}
return ret, nil
}
示例5: 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
}
示例6: BaseToTrackingStatement
func (g *GenericChainLink) BaseToTrackingStatement(state keybase1.ProofState) *jsonw.Wrapper {
ret := jsonw.NewDictionary()
ret.SetKey("curr", jsonw.NewString(g.id.String()))
ret.SetKey("sig_id", jsonw.NewString(g.GetSigID().ToString(true)))
rkp := jsonw.NewDictionary()
ret.SetKey("remote_key_proof", rkp)
rkp.SetKey("state", jsonw.NewInt(int(state)))
prev := g.GetPrev()
var prevVal *jsonw.Wrapper
if prev == nil {
prevVal = jsonw.NewNil()
} else {
prevVal = jsonw.NewString(prev.String())
}
ret.SetKey("prev", prevVal)
ret.SetKey("ctime", jsonw.NewInt64(g.unpacked.ctime))
ret.SetKey("etime", jsonw.NewInt64(g.unpacked.etime))
return ret
}
示例7: VerifyReverseSig
// VerifyReverseSig checks a SibkeyChainLink's reverse signature using the ComputedKeyFamily provided.
func (s *SibkeyChainLink) VerifyReverseSig(ckf ComputedKeyFamily) (err error) {
var key GenericKey
if key, err = ckf.FindKeyWithKIDUnsafe(s.GetDelegatedKid()); err != nil {
return err
}
var p1, p2 []byte
if p1, _, err = key.VerifyStringAndExtract(s.reverseSig); err != nil {
err = ReverseSigError{fmt.Sprintf("Failed to verify/extract sig: %s", err)}
return
}
if p1, err = jsonw.Canonicalize(p1); err != nil {
err = ReverseSigError{fmt.Sprintf("Failed to canonicalize json: %s", err)}
return
}
// Null-out the reverse sig on the parent
path := "body.sibkey.reverse_sig"
s.payloadJSON.SetValueAtPath(path, jsonw.NewNil())
if p2, err = s.payloadJSON.Marshal(); err != nil {
err = ReverseSigError{fmt.Sprintf("Can't remarshal JSON statement: %s", err)}
return
}
eq := FastByteArrayEq(p1, p2)
s.payloadJSON.SetValueAtPath(path, jsonw.NewString(s.reverseSig))
if !eq {
err = ReverseSigError{fmt.Sprintf("JSON mismatch: %s != %s",
string(p1), string(p2))}
return
}
return
}
示例8: ToJsonw
func (k KID) ToJsonw() *jsonw.Wrapper {
if k.IsNil() {
return jsonw.NewNil()
}
return jsonw.NewString(string(k))
}