MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / GenerateMutualKey

Function GenerateMutualKey

cipher/diffiehellman/diffiehellmankeyexchange.go:23–25  ·  view source on GitHub ↗

GenerateMutualKey : generates a mutual key that can be used by only alice and bob mutualKey = (shareKey^prvKey)%primeNumber

(prvKey, shareKey int64)

Source from the content-addressed store, hash-verified

21// GenerateMutualKey : generates a mutual key that can be used by only alice and bob
22// mutualKey = (shareKey^prvKey)%primeNumber
23func GenerateMutualKey(prvKey, shareKey int64) int64 {
24 return modularExponentiation(shareKey, prvKey, primeNumber)
25}
26
27// r = (b^e)%mod
28func modularExponentiation(b, e, mod int64) int64 {

Callers 1

Calls 1

modularExponentiationFunction · 0.85

Tested by 1