本文整理汇总了Golang中gx/ipfs/QmUWER4r4qMvaCnX5zREcfyiWN7cXN9g3a7fkRqNz8qWPP/go-libp2p-crypto.PrivKey.GetPublic方法的典型用法代码示例。如果您正苦于以下问题:Golang PrivKey.GetPublic方法的具体用法?Golang PrivKey.GetPublic怎么用?Golang PrivKey.GetPublic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gx/ipfs/QmUWER4r4qMvaCnX5zREcfyiWN7cXN9g3a7fkRqNz8qWPP/go-libp2p-crypto.PrivKey
的用法示例。
在下文中一共展示了PrivKey.GetPublic方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: publish
func publish(ctx context.Context, n *core.IpfsNode, k crypto.PrivKey, ref path.Path, opts *publishOpts) (*IpnsEntry, error) {
if opts.verifyExists {
// verify the path exists
_, err := core.Resolve(ctx, n, ref)
if err != nil {
return nil, err
}
}
eol := time.Now().Add(opts.pubValidTime)
err := n.Namesys.PublishWithEOL(ctx, k, ref, eol)
if err != nil {
return nil, err
}
hash, err := k.GetPublic().Hash()
if err != nil {
return nil, err
}
return &IpnsEntry{
Name: key.Key(hash).String(),
Value: ref.String(),
}, nil
}
示例2: PutRecordToRouting
func PutRecordToRouting(ctx context.Context, k ci.PrivKey, value path.Path, seqnum uint64, eol time.Time, r routing.IpfsRouting, id peer.ID) error {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
namekey, ipnskey := IpnsKeysForID(id)
entry, err := CreateRoutingEntryData(k, value, seqnum, eol)
if err != nil {
return err
}
ttl, ok := checkCtxTTL(ctx)
if ok {
entry.Ttl = proto.Uint64(uint64(ttl.Nanoseconds()))
}
errs := make(chan error, 2)
go func() {
errs <- PublishEntry(ctx, r, ipnskey, entry)
}()
go func() {
errs <- PublishPublicKey(ctx, r, namekey, k.GetPublic())
}()
err = waitOnErrChan(ctx, errs)
if err != nil {
return err
}
err = waitOnErrChan(ctx, errs)
if err != nil {
return err
}
return nil
}
示例3: MakePutRecord
// MakePutRecord creates and signs a dht record for the given key/value pair
func MakePutRecord(sk ci.PrivKey, key key.Key, value []byte, sign bool) (*pb.Record, error) {
record := new(pb.Record)
record.Key = proto.String(string(key))
record.Value = value
pkh, err := sk.GetPublic().Hash()
if err != nil {
return nil, err
}
record.Author = proto.String(string(pkh))
if sign {
blob := RecordBlobForSig(record)
sig, err := sk.Sign(blob)
if err != nil {
return nil, err
}
record.Signature = sig
}
return record, nil
}