git.gammaspectra.live/P2Pool/consensus/v3@v3.8.0/monero/crypto/crypto.go (about) 1 package crypto 2 3 import ( 4 "runtime" 5 "unsafe" 6 ) 7 8 // CompareConsensusPublicKeyBytes Compares public keys in a special consensus specific way 9 func CompareConsensusPublicKeyBytes(a, b *PublicKeyBytes) int { 10 aUint64 := (*[PublicKeySize / 8]uint64)(unsafe.Pointer(a)) 11 bUint64 := (*[PublicKeySize / 8]uint64)(unsafe.Pointer(b)) 12 13 if aUint64[3] < bUint64[3] { 14 return -1 15 } 16 if aUint64[3] > bUint64[3] { 17 return 1 18 } 19 20 if aUint64[2] < bUint64[2] { 21 return -1 22 } 23 if aUint64[2] > bUint64[2] { 24 return 1 25 } 26 27 if aUint64[1] < bUint64[1] { 28 return -1 29 } 30 if aUint64[1] > bUint64[1] { 31 return 1 32 } 33 34 if aUint64[0] < bUint64[0] { 35 return -1 36 } 37 if aUint64[0] > bUint64[0] { 38 return 1 39 } 40 41 //golang might free other otherwise 42 runtime.KeepAlive(aUint64) 43 runtime.KeepAlive(bUint64) 44 return 0 45 }