MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / InitNodeCryptoInfo

Method InitNodeCryptoInfo

proto/nodeinfo.go:189–200  ·  view source on GitHub ↗

InitNodeCryptoInfo generate Node asymmetric key pair and generate Node.NonceInfo. Node.ID = Node.NonceInfo.Hash.

(timeThreshold time.Duration)

Source from the content-addressed store, hash-verified

187// InitNodeCryptoInfo generate Node asymmetric key pair and generate Node.NonceInfo.
188// Node.ID = Node.NonceInfo.Hash.
189func (node *Node) InitNodeCryptoInfo(timeThreshold time.Duration) (err error) {
190 _, node.PublicKey, err = asymmetric.GenSecp256k1KeyPair()
191 if err != nil {
192 log.Error("failed to generate key pair")
193 }
194
195 nonce := asymmetric.GetPubKeyNonce(node.PublicKey, NewNodeIDDifficulty, timeThreshold, nil)
196 node.ID = NodeID(nonce.Hash.String())
197 node.Nonce = nonce.Nonce
198 log.Debugf("node: %#v", node)
199 return
200}
201
202// ToNodeID converts RawNodeID to NodeID.
203func (id *RawNodeID) ToNodeID() NodeID {

Callers 9

TestStartBP_CallRPCFunction · 0.95
TestDHTService_PingFunction · 0.95
TestEncPingFindNeighborFunction · 0.95
TestCaller_CallNodeFunction · 0.95
TestNewPersistentCallerFunction · 0.95

Calls 6

GenSecp256k1KeyPairFunction · 0.92
ErrorFunction · 0.92
GetPubKeyNonceFunction · 0.92
DebugfFunction · 0.92
NodeIDTypeAlias · 0.85
StringMethod · 0.45

Tested by 9

TestStartBP_CallRPCFunction · 0.76
TestDHTService_PingFunction · 0.76
TestEncPingFindNeighborFunction · 0.76
TestCaller_CallNodeFunction · 0.76
TestNewPersistentCallerFunction · 0.76