<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: KanakSasak</title>
    <description>The latest articles on DEV Community by KanakSasak (@kanaksasak).</description>
    <link>https://dev.to/kanaksasak</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F689464%2Fe68c0a30-151a-4a2d-82e0-4792af616bc7.jpeg</url>
      <title>DEV Community: KanakSasak</title>
      <link>https://dev.to/kanaksasak</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kanaksasak"/>
    <language>en</language>
    <item>
      <title>Searchable Symmetric Encryption (SSE) Basic Understanding In Go</title>
      <dc:creator>KanakSasak</dc:creator>
      <pubDate>Thu, 16 Feb 2023 08:40:07 +0000</pubDate>
      <link>https://dev.to/kanaksasak/searchable-symmetric-encryption-sse-basic-understanding-in-go-31f6</link>
      <guid>https://dev.to/kanaksasak/searchable-symmetric-encryption-sse-basic-understanding-in-go-31f6</guid>
      <description>&lt;p&gt;by KanakSasak&lt;br&gt;
The problem being discussed is how to search for a specific word, “W”, within a set of encrypted documents that are stored on an untrusted server. The documents are encrypted by the user, Alice, to protect them from the untrusted server, Bob. The documents are divided into “words” which can be any token, such as a 64-bit block or an English word, depending on the context. The goal is to design a scheme where the server can determine if a document contains the specific word “W” without learning any other information about the document. This is necessary because Alice may have a low-bandwidth connection to the server.&lt;br&gt;
There seem to be two types of approaches. The first method involves creating an index that lists all documents containing a specific word. The second method involves searching through the documents sequentially without using an index. The advantage of using an index is that it can be faster when working with large amounts of data, but the disadvantage is that it can take a lot of resources to store and update the index. Therefore, using an index is more appropriate for data that is mostly read and not often modified.&lt;br&gt;
Build the Simple Program Using Go or Run in this &lt;a href="https://goplay.tools/snippet/K0tyXGo6cZw" rel="noopener noreferrer"&gt;link&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import (
 "crypto/rand"
 "fmt"
 "log"
 "math"
 "math/big"
 "strconv"
 "strings"
)

func main() {
 plaintext := "Alice and Bob want to send message securely"
 fromIndexWord := strings.Index(plaintext, "message")
 toIndexWord := fromIndexWord + 7
 log.Println("Plain Text : ", plaintext)
 log.Println("Index Position : " + strconv.Itoa(fromIndexWord) + " to " + strconv.Itoa(toIndexWord) + "")
 log.Println("Index Word : ", plaintext[fromIndexWord:toIndexWord])
 log.Println("Index Word Length : ", len(plaintext[fromIndexWord:toIndexWord]))
 fmt.Println("-------------------------***-------------------------------")
 plainbin := binary(plaintext)
 log.Println("Binary :", plainbin)
 log.Println("Binary Length :", len(plainbin))
 log.Println("Plain Length :", len(plaintext))
 log.Println("Plain ASCII :", []byte(plaintext))
 fmt.Println("-------------------------***-------------------------------")

 keyplain, keybin, err := GenerateRandomString(len(plaintext))
 if err != nil {
  panic(err)
 }

 log.Println("Key in plain : ", keyplain)
 log.Println("Key in binary : ", keybin)
 log.Println("Key in binary length : ", len(keybin))
 log.Println("Key in plain length : ", len(keyplain))
 log.Println("key in ASCII : ", []byte(keyplain))
 log.Println("Index key Word : ", keyplain[fromIndexWord:toIndexWord])
 log.Println("Index key Length : ", len(keyplain[fromIndexWord:toIndexWord]))
 fmt.Println("-------------------------***-------------------------------")
 Titxt := produceTi(keyplain)
 TiBin := binary(Titxt)
 stringTI := Titxt

 log.Println("Ti ASCII : ", []byte(Titxt))
 log.Println("Ti in Plain : ", Titxt)
 log.Println("Ti length : ", len(Titxt))
 log.Println("Ti in binary : ", TiBin)
 log.Println("Ti in binary length : ", len(TiBin))
 log.Println("Index Ti Word : ", stringTI[fromIndexWord:toIndexWord])
 log.Println("Index Ti Length : ", len(stringTI[fromIndexWord:toIndexWord]))
 fmt.Println("-------------------------***-------------------------------")

 chiper := encryptStreamChiper(TiBin, plainbin)
 log.Println("Chiper : ", chiper)
 log.Println("Chiper in binary length : ", len(chiper))
 chiperdecode := binaryToText(chiper)
 log.Println("Chiper ASCII : ", []byte(chiperdecode))
 log.Println("Chiper text : ", chiperdecode)
 log.Println("Chiper text length: ", len(chiperdecode))
 log.Println("Index Chiper Word: ", chiperdecode[fromIndexWord:toIndexWord])
 log.Println("Index Chiper Length : ", len(chiperdecode[fromIndexWord:toIndexWord]))
 plain := decryptStreamChiper(TiBin, chiper)
 log.Println("Plain : ", plain)
 log.Println("Plain in binary length : ", len(plain))
 plaindecode := binaryToText(plain)
 log.Println("Plain ASCII : ", []byte(plaindecode))
 log.Println("Plain text : ", plaindecode)
 log.Println("Plain text length: ", len(plaindecode))

 if plain != plainbin {
  panic("failed to decrypt")
 }

 fmt.Println("-------------------------*** Start Scenario SSE ***-------------------------------")
 log.Println("Alice give Bob index word : ", plaintext[fromIndexWord:toIndexWord])
 log.Println("Alice give Bob index word position : from " + strconv.Itoa(fromIndexWord) + " to " + strconv.Itoa(toIndexWord) + "")
 prooftxt := proof(chiperdecode, plaintext[fromIndexWord:toIndexWord], fromIndexWord, toIndexWord)
 log.Println("Bob give Alice proof : ", prooftxt)
 log.Println("Alice compare proof : " + prooftxt + " and Ti : " + stringTI[fromIndexWord:toIndexWord] + "")
 if prooftxt != stringTI[fromIndexWord:toIndexWord] {
  panic("failed to proofing")
 } else {
  log.Println("Proofing Success!")
 }

}

func binary(s string) string {
 res := ""
 for _, c := range s {
  res = fmt.Sprintf("%s%.8b", res, c)
 }
 return res
}

func GenerateRandomString(n int) (string, string, error) {
 const letters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-"
 ret := make([]byte, n)
 for i := 0; i &amp;lt; n; i++ {
  num, err := rand.Int(rand.Reader, big.NewInt(int64(len(letters))))
  if err != nil {
   return "", "", err
  }
  ret[i] = letters[num.Int64()]
 }

 token := binary(string(ret))

 return string(ret), token, nil
}

func encryptStreamChiper(key string, message string) string {

 keyarr := []byte(key)
 messagearr := []byte(message)
 chipertxt := ""
 for i := 0; i &amp;lt; len(messagearr); i++ {
  ciphertmp := messagearr[i] ^ keyarr[i]
  chipertxt = fmt.Sprintf("%s%s", chipertxt, fmt.Sprint(ciphertmp))
 }
 return chipertxt

}

func produceTi(key string) string {
 keyarr := []byte(key) //convert to ASCII

 Ti := make([]byte, len(keyarr))

 for i := 0; i &amp;lt; len(keyarr); i++ {
  res := int(keyarr[i]) + 3
  copy(Ti[i:], string(int(res)))
 }

 return string(Ti)
}

func decryptStreamChiper(key string, chiper string) string {

 keyarr := []byte(key)
 chiperarr := []byte(chiper)
 plaintext := ""

 for i := 0; i &amp;lt; len(chiperarr); i++ {
  plaintexttmp := chiperarr[i] ^ keyarr[i]
  plaintext = fmt.Sprintf("%s%s", plaintext, fmt.Sprint(plaintexttmp))

 }

 return plaintext

}

func binaryToText(binarystring string) string {
 plaintext := ""
 n := 8
 for n &amp;lt;= len(binarystring) {
  lass := n - 8

  x := binarystring[lass:n]
  y, e := strconv.Atoi(x)
  if e != nil {
   panic(e)
  }
  plaintext = fmt.Sprintf("%s%s", plaintext, string(binaryToDecimal(y)))
  n += 8
 }

 return plaintext

}

func binaryToDecimal(num int) int {
 var remainder int
 index := 0
 decimalNum := 0
 for num != 0 {
  remainder = num % 10
  num = num / 10
  decimalNum = decimalNum + remainder*int(math.Pow(2, float64(index)))
  index++
 }
 return decimalNum
}

func proof(chiper string, word string, fromindex int, toindex int) string {
 chiperword := chiper[fromindex:toindex]
 wordarr := []byte(word)
 chiperwordarr := []byte(chiperword)
 prooftxt := make([]byte, len(wordarr))
 for i := 0; i &amp;lt; len(wordarr); i++ {
  plaintexttmp := chiperwordarr[i] ^ wordarr[i]
  copy(prooftxt[i:], string(int(plaintexttmp)))
 }

 return string(prooftxt)

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fog55zsd9yk317omsscan.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fog55zsd9yk317omsscan.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An additional pseudo-random function, which will be keyed independently of F . The main idea is to choose our keys as k[i] := fk’ (W[i]). We require that k’ be chosen uniformly randomly in K by Alice and never be revealed. Then, if Alice wish to allow Bob to search for the word W, she reveals fk’ (W) and W to him. This allows Bob to identify all the locations where W might occur, but reveals absolutely nothing on the locations i where W[i] != W. This attains our desired goal of controlled searching.&lt;/p&gt;

&lt;p&gt;Reference :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Dawn Xiaoding Song, Wagner, D., &amp;amp; Perrig, A. (2000). Practical techniques for searches on encrypted data. Proceeding 2000 IEEE Symposium on Security and Privacy. S&amp;amp;P 2000, 44–55. &lt;a href="https://doi.org/10.1109/SECPRI.2000.848445" rel="noopener noreferrer"&gt;https://doi.org/10.1109/SECPRI.2000.848445&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>cybersecurity</category>
      <category>crypto</category>
      <category>cryptography</category>
    </item>
    <item>
      <title>Blockchain Forensics</title>
      <dc:creator>KanakSasak</dc:creator>
      <pubDate>Thu, 16 Feb 2023 08:38:02 +0000</pubDate>
      <link>https://dev.to/kanaksasak/blockchain-forensics-cg3</link>
      <guid>https://dev.to/kanaksasak/blockchain-forensics-cg3</guid>
      <description>&lt;p&gt;by KanakSasak&lt;br&gt;
Blockchain forensics is a rapidly growing field that involves the application of forensic techniques to the analysis of blockchain technology and its associated data. Blockchain, the underlying technology of cryptocurrencies such as Bitcoin, is a decentralized, distributed ledger that allows for the secure and transparent recording of transactions. As the use of blockchain technology continues to expand, the need for forensic analysis of this data has become increasingly important.&lt;br&gt;
One key application of blockchain forensics is in the investigation of financial crimes, such as money laundering and terrorist financing. The transparent and immutable nature of blockchain data allows for tracing funds and identifying suspicious activity.In forensic investigation,digital evidence plays an increasingly important role that is expected to bridge persons with criminal activities [5].&lt;br&gt;
Based on research Mas’ud MHassan AShah W et al [4] the forensic over blockchain network has been formulated based on few forensic earlier. Fundamentally a digital forensic investigation process con-sists of Identification, Collection and Preservation, Exami-nation and Analysis[4]; and Presentation.. Researches papers are found to be related to blockchain foren-sic. Ten of 11 papers are discussing the identification of evidence in cryptocurrency environment, eight papers discussion collection and preservation process whereas four papers discussing on the examination and analysis process. Nonepaper discusses on the presentation process.&lt;br&gt;
In this paper we propose schema that do forensic in blockchain network but we handle it before the attack has been occured. We added new monitoring mechanism to detect and map the attack payload or malicious code that will be targeted the smartcontract vulnerability.&lt;br&gt;
Case Scenario&lt;br&gt;
From Figure 7 it is explained that attacker will send malicious payload or execute malicious code that can be vulnerable to smartcontract, but the transaction will go to blockchain security protocol to be monitored and do the risk assessment to the transaction, if the transaction suspect have the malicious code that can be affect the smartcontract the monitoring system will report to the blockchain security protocol to override the transaction or delete the transaction before it mined. When the attack occurred, it will be monitoring and track over the blockchain network. The malicious transaction in blockchain can be monitored using Misttrack platform.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BI9HfYN9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iwbeka5e7y0zqmyeegu6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BI9HfYN9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iwbeka5e7y0zqmyeegu6.png" alt="Image description" width="630" height="561"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next : Part 2&lt;/p&gt;

&lt;p&gt;Reference :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Lone, A. H., &amp;amp; Mir, R. N. (2018). Forensic-chain: Ethereum blockchain based digital forensics chain of custody. Sci. Pract. Cyber Secur. J, 1, 21–27.&lt;/li&gt;
&lt;li&gt;Lone, A. H., &amp;amp; Mir, R. N. (2019). Forensic-chain: Blockchain based digital forensics chain of custody with PoC in Hyperledger Composer. Digital investigation, 28, 44–55.&lt;/li&gt;
&lt;li&gt;Ahmad, L., Khanji, S., Iqbal, F., &amp;amp; Kamoun, F. (2020, August). Blockchain-based chain of custody: towards real-time tamper-proof evidence management. In Proceedings of the 15th international conference on availability, reliability and security (pp. 1–8).&lt;/li&gt;
&lt;li&gt;Mas’ud, M. Z., Hassan, A., Shah, W. Md., Abdul-Latip, S. F., Ahmad, R., Ariffin, A., &amp;amp; Yunos, Z. (2021). A Review of Digital Forensics Framework for Blockchain in Cryptocurrency Technology. 2021 3rd International Cyber Resilience Conference (CRC), 1–6. &lt;a href="https://doi.org/10.1109/CRC50527.2021.9392563"&gt;https://doi.org/10.1109/CRC50527.2021.9392563&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;S. Li, T. Qin and G. Min, “Blockchain-Based Digital Forensics Investigation Framework in the Internet of Things and Social Systems,” in IEEE Transactions on Computational Social Systems, vol. 6, no. 6, pp. 1433–1441, Dec. 2019, doi: 10.1109/TCSS.2019.2927431.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>forensics</category>
      <category>digitalforensics</category>
      <category>blockchain</category>
      <category>cybersecurity</category>
    </item>
  </channel>
</rss>
