follower.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. package main
  2. //#cgo CFLAGS: -fopenmp -O2
  3. //#cgo LDFLAGS: -lcrypto -lm -fopenmp
  4. //#include "../c/dpf.h"
  5. //#include "../c/okv.h"
  6. //#include "../c/dpf.c"
  7. //#include "../c/okv.c"
  8. import "C"
  9. //ssssssssssssss
  10. import (
  11. "2PPS/lib"
  12. "crypto/rand"
  13. "crypto/rsa"
  14. "crypto/sha256"
  15. "crypto/tls"
  16. "crypto/x509"
  17. "crypto/x509/pkix"
  18. "encoding/pem"
  19. "fmt"
  20. "math/big"
  21. "net"
  22. "strconv"
  23. "sync"
  24. "time"
  25. "unsafe"
  26. "golang.org/x/crypto/nacl/box"
  27. )
  28. const leader string = "127.0.0.1:4442"
  29. //needs to be changed at leader/follower/client at the same time
  30. const neededSubscriptions = 1
  31. //this stores all neccessary information for each client
  32. type clientKeys struct {
  33. SharedSecret [32]byte
  34. PirQuery [][]byte
  35. }
  36. //uses clients publicKey as key
  37. var clientData = make(map[[32]byte]clientKeys)
  38. var topicList []byte
  39. var topicAmount int
  40. var followerPrivateKey *[32]byte
  41. var followerPublicKey *[32]byte
  42. var leaderPublicKey *[32]byte
  43. var numThreads int = 12
  44. //has to be dividable by 32
  45. var dataLength int = 64
  46. var dbWriteSize int = 4
  47. var round int = 1
  48. var startTime time.Time
  49. var maxTimePerRound time.Duration = 5 * time.Second
  50. func main() {
  51. generatedPublicKey, generatedPrivateKey, err := box.GenerateKey(rand.Reader)
  52. if err != nil {
  53. panic(err)
  54. }
  55. followerPrivateKey = generatedPrivateKey
  56. followerPublicKey = generatedPublicKey
  57. /*
  58. if len(os.Args) != 4 {
  59. fmt.Println("try again: numThreads, dataLength, numRows")
  60. return
  61. }
  62. numThreads, _ = strconv.Atoi(os.Args[2])
  63. dataLength, _ = strconv.Atoi(os.Args[3])
  64. numRows, _ = strconv.Atoi(os.Args[4])
  65. */
  66. C.initializeServer(C.int(numThreads))
  67. followerConnectionPrivateKey, err := rsa.GenerateKey(rand.Reader, 2048)
  68. if err != nil {
  69. panic(err)
  70. }
  71. // Generate a pem block with the private key
  72. keyPem := pem.EncodeToMemory(&pem.Block{
  73. Type: "RSA PRIVATE KEY",
  74. Bytes: x509.MarshalPKCS1PrivateKey(followerConnectionPrivateKey),
  75. })
  76. tml := x509.Certificate{
  77. // you can add any attr that you need
  78. NotBefore: time.Now(),
  79. NotAfter: time.Now().AddDate(5, 0, 0),
  80. // you have to generate a different serial number each execution
  81. SerialNumber: big.NewInt(123123),
  82. Subject: pkix.Name{
  83. CommonName: "New Name",
  84. Organization: []string{"New Org."},
  85. },
  86. BasicConstraintsValid: true,
  87. }
  88. cert, err := x509.CreateCertificate(rand.Reader, &tml, &tml, &followerConnectionPrivateKey.PublicKey, followerConnectionPrivateKey)
  89. if err != nil {
  90. panic(err)
  91. }
  92. // Generate a pem block with the certificate
  93. certPem := pem.EncodeToMemory(&pem.Block{
  94. Type: "CERTIFICATE",
  95. Bytes: cert,
  96. })
  97. tlsCert, err := tls.X509KeyPair(certPem, keyPem)
  98. if err != nil {
  99. panic(err)
  100. }
  101. config := &tls.Config{Certificates: []tls.Certificate{tlsCert}}
  102. fmt.Println("start leader")
  103. //listens for leader
  104. lnLeader, err := tls.Listen("tcp", ":4443", config)
  105. if err != nil {
  106. panic(err)
  107. }
  108. defer lnLeader.Close()
  109. leaderConnection, err := lnLeader.Accept()
  110. if err != nil {
  111. panic(err)
  112. }
  113. //send publicKey to leader
  114. writeToConn(leaderConnection, followerPublicKey[:])
  115. //receives leader PublicKey
  116. var tmpLeaderPubKey [32]byte
  117. _, err = leaderConnection.Read(tmpLeaderPubKey[:])
  118. if err != nil {
  119. panic(err)
  120. }
  121. leaderPublicKey = &tmpLeaderPubKey
  122. //setup ends here
  123. //locks access to DB
  124. var m sync.Mutex
  125. wg := &sync.WaitGroup{}
  126. for {
  127. //phase1
  128. fmt.Println("phase1")
  129. //create write db for this round
  130. for i := 0; i < dbWriteSize; i++ {
  131. C.createDb(C.int(0), C.int(dataLength))
  132. }
  133. //receives the virtualAddresses
  134. virtualAddresses := make([]int, dbWriteSize+1)
  135. for i := 0; i <= dbWriteSize; i++ {
  136. virtualAddress := readFromConn(leaderConnection, 4)
  137. virtualAddresses[i] = byteToInt(virtualAddress)
  138. }
  139. for i := 0; i < numThreads; i++ {
  140. wg.Add(1)
  141. leaderConnection, err := lnLeader.Accept()
  142. if err != nil {
  143. panic(err)
  144. }
  145. leaderConnection.SetDeadline(time.Time{})
  146. startTime = time.Now()
  147. go phase1(i, leaderConnection, m, wg, virtualAddresses)
  148. }
  149. wg.Wait()
  150. //phase2
  151. fmt.Println("phase2")
  152. leaderConnection, err := lnLeader.Accept()
  153. if err != nil {
  154. panic(err)
  155. }
  156. leaderConnection.SetDeadline(time.Time{})
  157. phase2(leaderConnection)
  158. //phase3
  159. fmt.Println("phase3")
  160. if round == 1 {
  161. //addTestTweets()
  162. }
  163. //no tweets -> continue to phase 1 and mb get tweets
  164. topicList, topicAmount = lib.GetTopicList(0)
  165. if len(topicList) == 0 {
  166. continue
  167. }
  168. for i := 0; i < numThreads; i++ {
  169. wg.Add(1)
  170. leaderConnection, err := lnLeader.Accept()
  171. if err != nil {
  172. panic(err)
  173. }
  174. leaderConnection.SetDeadline(time.Time{})
  175. startTime = time.Now()
  176. go phase3(leaderConnection, wg)
  177. }
  178. wg.Wait()
  179. lib.CleanUpdbR(round)
  180. round++
  181. }
  182. }
  183. func phase1(id int, leaderWorkerConnection net.Conn, m sync.Mutex, wg *sync.WaitGroup, virtualAddresses []int) {
  184. gotClient := make([]byte, 1)
  185. for {
  186. gotClient = readFromConn(leaderWorkerConnection, 1)
  187. //this worker is done
  188. if gotClient[0] == 0 {
  189. wg.Done()
  190. return
  191. }
  192. //setup the worker-specific db
  193. dbSize := int(C.dbSize)
  194. db := make([][]byte, dbSize)
  195. for i := 0; i < dbSize; i++ {
  196. db[i] = make([]byte, int(C.db[i].dataSize))
  197. }
  198. //gets clients publicKey
  199. var clientPublicKey *[32]byte
  200. var tmpClientPublicKey [32]byte
  201. _, err := leaderWorkerConnection.Read(tmpClientPublicKey[:])
  202. if err != nil {
  203. panic(err)
  204. }
  205. clientPublicKey = &tmpClientPublicKey
  206. clientKeys := clientData[tmpClientPublicKey]
  207. clientKeys, pirQuery := handlePirQuery(clientKeys, leaderWorkerConnection, 0, tmpClientPublicKey, true)
  208. getSendVirtualAddress(pirQuery[0], virtualAddresses, clientKeys.SharedSecret, leaderWorkerConnection)
  209. clientData[*clientPublicKey] = clientKeys
  210. //gets dpfQuery from leader
  211. dpfLengthBytes := readFromConn(leaderWorkerConnection, 4)
  212. dpfLength := byteToInt(dpfLengthBytes)
  213. dpfQueryBEncrypted := make([]byte, dpfLength)
  214. dpfQueryBEncrypted = readFromConn(leaderWorkerConnection, dpfLength)
  215. //decrypt dpfQueryB for sorting into db
  216. var decryptNonce [24]byte
  217. copy(decryptNonce[:], dpfQueryBEncrypted[:24])
  218. dpfQueryB, ok := box.Open(nil, dpfQueryBEncrypted[24:], &decryptNonce, clientPublicKey, followerPrivateKey)
  219. if !ok {
  220. panic("dpfQueryB decryption not ok")
  221. }
  222. ds := int(C.db[0].dataSize)
  223. dataShareFollower := make([]byte, ds)
  224. pos := C.getUint128_t(C.int(virtualAddresses[dbWriteSize]))
  225. C.evalDPF(C.ctx[id], (*C.uchar)(&dpfQueryB[0]), pos, C.int(ds), (*C.uchar)(&dataShareFollower[0]))
  226. dataShareLeader := make([]byte, ds)
  227. writeToConn(leaderWorkerConnection, dataShareFollower)
  228. dataShareLeader = readFromConn(leaderWorkerConnection, ds)
  229. auditXOR := make([]byte, ds)
  230. passedAudit := true
  231. for i := 0; i < ds; i++ {
  232. auditXOR[i] = dataShareLeader[i] ^ dataShareFollower[i]
  233. //client tried to write to a position that is not a virtuallAddress
  234. if auditXOR[i] != 0 {
  235. passedAudit = false
  236. }
  237. }
  238. if passedAudit {
  239. //run dpf, xor into local db
  240. for i := 0; i < dbSize; i++ {
  241. ds := int(C.db[i].dataSize)
  242. dataShare := make([]byte, ds)
  243. pos := C.getUint128_t(C.int(virtualAddresses[i]))
  244. C.evalDPF(C.ctx[id], (*C.uchar)(&dpfQueryB[0]), pos, C.int(ds), (*C.uchar)(&dataShare[0]))
  245. for j := 0; j < ds; j++ {
  246. db[i][j] = db[i][j] ^ dataShare[j]
  247. }
  248. }
  249. //xor the worker's DB into the main DB
  250. for i := 0; i < dbSize; i++ {
  251. m.Lock()
  252. C.xorIn(C.int(i), (*C.uchar)(&db[i][0]))
  253. m.Unlock()
  254. }
  255. }
  256. }
  257. }
  258. func phase2(leaderWorkerConnection net.Conn) {
  259. //gets current seed
  260. seedFollower := make([]byte, 16)
  261. C.readSeed((*C.uchar)(&seedFollower[0]))
  262. //get data
  263. dbSize := int(C.dbSize)
  264. tmpdbFollower := make([][]byte, dbSize)
  265. for i := range tmpdbFollower {
  266. tmpdbFollower[i] = make([]byte, dataLength)
  267. }
  268. for i := 0; i < dbSize; i++ {
  269. C.readData(C.int(i), (*C.uchar)(&tmpdbFollower[i][0]))
  270. }
  271. //receive seed from leader
  272. seedLeader := readFromConn(leaderWorkerConnection, 16)
  273. //receive data from leader
  274. tmpdbLeader := make([][]byte, dbSize)
  275. for i := range tmpdbLeader {
  276. tmpdbLeader[i] = make([]byte, dataLength)
  277. }
  278. for i := 0; i < dbSize; i++ {
  279. tmpdbLeader[i] = readFromConn(leaderWorkerConnection, dataLength)
  280. }
  281. //writes seed to leader
  282. writeToConn(leaderWorkerConnection, seedFollower)
  283. //write data to leader
  284. for i := 0; i < dbSize; i++ {
  285. writeToConn(leaderWorkerConnection, tmpdbFollower[i])
  286. }
  287. //put together the db
  288. tmpdb := make([][]byte, dbSize)
  289. for i := range tmpdb {
  290. tmpdb[i] = make([]byte, dataLength)
  291. }
  292. //get own Ciphers
  293. ciphersFollowers := make([]*C.uchar, dbSize)
  294. for i := 0; i < dbSize; i++ {
  295. ciphersFollowers[i] = (*C.uchar)(C.malloc(16))
  296. }
  297. for i := 0; i < dbSize; i++ {
  298. C.getCipher(0, C.int(i), ciphersFollowers[i])
  299. }
  300. //receive ciphers from leader
  301. ciphersLeader := make([]byte, dbSize*16)
  302. for i := 0; i < dbSize; i++ {
  303. _, err := leaderWorkerConnection.Read(ciphersLeader[i*16:])
  304. if err != nil {
  305. panic(err)
  306. }
  307. }
  308. //send own Ciphers to leader
  309. for i := 0; i < dbSize; i++ {
  310. writeToConn(leaderWorkerConnection, C.GoBytes(unsafe.Pointer(ciphersFollowers[i]), 16))
  311. }
  312. //put in ciphers from leader
  313. for i := 0; i < dbSize; i++ {
  314. C.putCipher(0, C.int(i), (*C.uchar)(&ciphersLeader[i*16]))
  315. }
  316. for i := 0; i < dbSize; i++ {
  317. C.decryptRow(C.int(i), (*C.uchar)(&tmpdb[i][0]), (*C.uchar)(&tmpdbLeader[i][0]), (*C.uchar)(&tmpdbFollower[i][0]), (*C.uchar)(&seedLeader[0]), (*C.uchar)(&seedFollower[0]))
  318. }
  319. var tweets []lib.Tweet
  320. for i := 0; i < dbSize; i++ {
  321. //discard cover message
  322. if tmpdb[i][0] == 0 {
  323. continue
  324. } else {
  325. //reconstruct tweet
  326. var position int = 0
  327. var topics []string
  328. var topic string
  329. var text string
  330. for _, letter := range tmpdb[i] {
  331. if string(letter) == ";" {
  332. if topic != "" {
  333. topics = append(topics, topic)
  334. topic = ""
  335. }
  336. position++
  337. } else {
  338. if position == 0 {
  339. if string(letter) == "," {
  340. topics = append(topics, topic)
  341. topic = ""
  342. } else {
  343. topic = topic + string(letter)
  344. }
  345. } else if position == 1 {
  346. text = text + string(letter)
  347. }
  348. }
  349. }
  350. tweet := lib.Tweet{"", -1, topics, text, round}
  351. tweets = append(tweets, tweet)
  352. }
  353. }
  354. //fmt.Println("tweets recovered: ", tweets)
  355. //sort into read db
  356. lib.NewEntries(tweets, 0)
  357. //reset write db after the tweets were moved to read db
  358. C.resetDb()
  359. //gets current dbWriteSize from leader
  360. dbWriteSizeBytes := readFromConn(leaderWorkerConnection, 4)
  361. dbWriteSize = byteToInt(dbWriteSizeBytes)
  362. }
  363. func addTestTweets() {
  364. //creates test tweets
  365. tweets := make([]lib.Tweet, 5)
  366. for i := range tweets {
  367. j := i
  368. if i == 1 {
  369. j = 0
  370. }
  371. text := "Text " + strconv.Itoa(i)
  372. var topics []string
  373. topics = append(topics, "Topic "+strconv.Itoa(j))
  374. tweets[i] = lib.Tweet{"", -1, topics, text, i}
  375. }
  376. lib.NewEntries(tweets, 0)
  377. }
  378. func phase3(leaderWorkerConnection net.Conn, wg *sync.WaitGroup) {
  379. gotClient := make([]byte, 1)
  380. for {
  381. gotClient = readFromConn(leaderWorkerConnection, 1)
  382. //this worker is done
  383. if gotClient[0] == 0 {
  384. wg.Done()
  385. return
  386. }
  387. subPhase := readFromConn(leaderWorkerConnection, 1)
  388. var clientPublicKey [32]byte
  389. _, err := leaderWorkerConnection.Read(clientPublicKey[:])
  390. if err != nil {
  391. panic(err)
  392. }
  393. //gets the client data
  394. clientKeys := clientData[clientPublicKey]
  395. if subPhase[0] == 0 || subPhase[0] == 1 {
  396. clientKeys, _ = handlePirQuery(clientKeys, leaderWorkerConnection, int(subPhase[0]), clientPublicKey, false)
  397. }
  398. getSendTweets(clientKeys, nil, leaderWorkerConnection)
  399. wantsArchive := readFromConn(leaderWorkerConnection, 1)
  400. if wantsArchive[0] == 1 {
  401. _, archiveQuerys := handlePirQuery(clientKeys, leaderWorkerConnection, -1, clientPublicKey, false)
  402. getSendTweets(clientKeys, archiveQuerys, leaderWorkerConnection)
  403. }
  404. //saves clientKeys
  405. clientData[clientPublicKey] = clientKeys
  406. }
  407. }
  408. func getSendTweets(clientKeys clientKeys, archiveQuerys [][]byte, leaderWorkerConnection net.Conn) {
  409. tmpNeededSubscriptions := neededSubscriptions
  410. if archiveQuerys != nil {
  411. tmpNeededSubscriptions = len(archiveQuerys)
  412. }
  413. for i := 0; i < tmpNeededSubscriptions; i++ {
  414. //gets all requested tweets
  415. var tweets []byte
  416. if archiveQuerys == nil {
  417. tweets = lib.GetTweets(clientKeys.PirQuery[i], dataLength, 0)
  418. } else {
  419. tweets = lib.GetTweets(archiveQuerys[i], dataLength, 1)
  420. }
  421. //expand sharedSecret so it is of right length
  422. expandBy := len(tweets) / 32
  423. var expandedSharedSecret []byte
  424. for i := 0; i < expandBy; i++ {
  425. expandedSharedSecret = append(expandedSharedSecret, clientKeys.SharedSecret[:]...)
  426. }
  427. //Xor's sharedSecret with all tweets
  428. lib.Xor(expandedSharedSecret[:], tweets)
  429. lib.Xor(tweets, expandedSharedSecret[:])
  430. //sends tweets to leader
  431. tweetsLengthBytes := intToByte(len(tweets))
  432. writeToConn(leaderWorkerConnection, tweetsLengthBytes)
  433. writeToConn(leaderWorkerConnection, tweets)
  434. }
  435. }
  436. func handlePirQuery(clientKeys clientKeys, leaderWorkerConnection net.Conn, subPhase int, clientPublicKey [32]byte, doAuditing bool) (clientKeys, [][]byte) {
  437. archiveNeededSubscriptions := make([]byte, 4)
  438. if subPhase == -1 {
  439. archiveNeededSubscriptions = readFromConn(leaderWorkerConnection, 4)
  440. }
  441. //gets the msg length
  442. msgLengthBytes := readFromConn(leaderWorkerConnection, 4)
  443. msgLength := byteToInt(msgLengthBytes)
  444. //gets the message
  445. message := readFromConn(leaderWorkerConnection, msgLength)
  446. var decryptNonce [24]byte
  447. copy(decryptNonce[:], message[:24])
  448. decrypted, ok := box.Open(nil, message[24:], &decryptNonce, &clientPublicKey, followerPrivateKey)
  449. if !ok {
  450. panic("pirQuery decryption not ok")
  451. }
  452. //gets sharedSecret
  453. if subPhase == 0 {
  454. //bs!
  455. var newSharedSecret [32]byte
  456. for index := 0; index < 32; index++ {
  457. newSharedSecret[index] = decrypted[index]
  458. }
  459. clientKeys.SharedSecret = newSharedSecret
  460. decrypted = decrypted[32:]
  461. if doAuditing {
  462. result := make([][]byte, 1)
  463. result[0] = decrypted
  464. return clientKeys, result
  465. }
  466. //follower updates sharedSecret
  467. } else if subPhase == 1 {
  468. sharedSecret := clientKeys.SharedSecret
  469. sharedSecret = sha256.Sum256(sharedSecret[:])
  470. clientKeys.SharedSecret = sharedSecret
  471. }
  472. //follower expects pirQuery
  473. //transforms byteArray to ints of wanted topics
  474. tmpNeededSubscriptions := neededSubscriptions
  475. tmpTopicAmount := topicAmount
  476. if subPhase == -1 {
  477. tmpNeededSubscriptions = byteToInt(archiveNeededSubscriptions)
  478. _, tmpTopicAmount = lib.GetTopicList(1)
  479. }
  480. pirQueryFlattened := decrypted
  481. pirQuerys := make([][]byte, tmpNeededSubscriptions)
  482. for i := range pirQuerys {
  483. pirQuerys[i] = make([]byte, tmpTopicAmount)
  484. }
  485. for i := 0; i < tmpNeededSubscriptions; i++ {
  486. pirQuerys[i] = pirQueryFlattened[i*tmpTopicAmount : (i+1)*tmpTopicAmount]
  487. }
  488. //sets the pirQuery for the client in case whe are not archiving
  489. if subPhase != -1 {
  490. clientKeys.PirQuery = pirQuerys
  491. }
  492. return clientKeys, pirQuerys
  493. }
  494. func getSendVirtualAddress(pirQuery []byte, virtualAddresses []int, sharedSecret [32]byte, leaderWorkerConnection net.Conn) {
  495. //xores all requested addresses into virtuallAddress
  496. virtualAddress := make([]byte, 4)
  497. for index, num := range pirQuery {
  498. if num == 1 {
  499. currentAddress := intToByte(virtualAddresses[index])
  500. for i := 0; i < 4; i++ {
  501. virtualAddress[i] = virtualAddress[i] ^ currentAddress[i]
  502. }
  503. }
  504. }
  505. //xores the sharedSecret
  506. for i := 0; i < 4; i++ {
  507. virtualAddress[i] = virtualAddress[i] ^ sharedSecret[i]
  508. }
  509. writeToConn(leaderWorkerConnection, virtualAddress)
  510. }
  511. //sends the array to the connection
  512. func writeToConn(connection net.Conn, array []byte) {
  513. _, err := connection.Write(array)
  514. if err != nil {
  515. panic(err)
  516. }
  517. }
  518. //reads an array which is returned and of size "size" from the connection
  519. func readFromConn(connection net.Conn, size int) []byte {
  520. array := make([]byte, size)
  521. _, err := connection.Read(array)
  522. if err != nil {
  523. panic(err)
  524. }
  525. return array
  526. }
  527. func transformBytesToStringArray(topicsAsBytes []byte) []string {
  528. var topics []string
  529. var topic string
  530. var position int = 0
  531. for _, letter := range topicsAsBytes {
  532. if string(letter) == "," {
  533. topics[position] = topic
  534. topic = ""
  535. position++
  536. } else {
  537. topic = topic + string(letter)
  538. }
  539. }
  540. return topics
  541. }
  542. func byteToInt(myBytes []byte) (x int) {
  543. x = int(myBytes[3])<<24 + int(myBytes[2])<<16 + int(myBytes[1])<<8 + int(myBytes[0])
  544. return
  545. }
  546. func intToByte(myInt int) (retBytes []byte) {
  547. retBytes = make([]byte, 4)
  548. retBytes[3] = byte((myInt >> 24) & 0xff)
  549. retBytes[2] = byte((myInt >> 16) & 0xff)
  550. retBytes[1] = byte((myInt >> 8) & 0xff)
  551. retBytes[0] = byte(myInt & 0xff)
  552. return
  553. }