# 9/20 ppt 內容 ### ChatGPT 可以順利提取關鍵字 ![](https://hackmd.io/_uploads/HylcDZvkT.png) ((上面程式碼是把AB的對話丟給GPT 並請他擷取關鍵字, Output 是結果)) ### 語音辨識 #### 簡短demo影片 - 使用 google 的 api - 缺點: - 只要咬字不清楚,他就會辨識的不準確 - 沒有標點符號... (( 這邊直接給老師看 demo 影片,我有傳到dc)) (( 如果只是拍影片 demo 應該沒問題 )) (( 比較擔心現場 demo 會出問題 )) #### 模擬對話結果 - 下面是模擬電話搞,由嘉羽和菁蕙唸 - 上面是語音辨識的結果 ![](https://hackmd.io/_uploads/rJ3E3ZvJT.png) (( 下面(b.txt)是嘉羽和菁蕙照著念的文稿,上面(output.csv)是語音辨識的結果 )) #### 使用模擬出來的對話讓 gpt 辨識 - gpt沒有標點符號也可以好好辨識,很讚 ![](https://hackmd.io/_uploads/rJPLp-wJp.png) ((幸好gpt很聰明,沒有標點符號也ok)) ------------------------------------ # 9/12 實作組 ppt 內容 ## 改用 PBC的原因 1. 由於 pypbc 常常出現執行時錯誤(Error: Segmentation fault), 原因不明 2. 兩明文 Hash 後的值不相等 Equality Test 原理 - $Test({C_1},{C_2})$ - $C1 = ({U_1},{V_1},{W_1})$ - $C2 = ({U_2},{V_2},{W_2})$ - $e({U_1},{V_2}) = e({U_2},{V_1})$ -> $e({U_1},{V_2})$ = $e({g^{r_1}},{m_2^{r_2}})$ = $e(g,m_2)^{r_1r_2}$ -> $e({U_2},{V_1})$ = $e({g^{r_2}},{m_1^{r_1}})$ = $e(g,m_1)^{r_1r_2}$ 正常來說,當 m1 和 m2 內容相同時,經過 Test演算法運算 m1 和 m2 要相等才對!! 但是 Python 跑出來的結果, 會根據**中間的操作**影響是否相等 - 不相等: ![](https://hackmd.io/_uploads/ByzO-AqCn.png) ![](https://hackmd.io/_uploads/HkdwW05Rh.png) - 相等: ![](https://hackmd.io/_uploads/BJxsW0q03.png) ![](https://hackmd.io/_uploads/SyoiZA90n.png) ```python= #學姊幫我用紅框把element_m 和 element_m1 那2行框出 ``` 不知道為什麼執行順序會影響 element_m 的值 基於以上兩個理由, 決定改用 PBC 寫 ## PBC 執行結果 * 當2詞不一樣 ![](https://hackmd.io/_uploads/Hk6QXC9C2.png) * 當2詞一樣 ![](https://hackmd.io/_uploads/Hk8B709Ah.png) ## 模擬資料庫 ![](https://hackmd.io/_uploads/SkoTrC9Rn.png) * 當2詞不一樣 ![](https://hackmd.io/_uploads/H15ZURq03.png) * 當2詞一樣 ![](https://hackmd.io/_uploads/By4M8C5C2.png) ## 完整程式碼 ``` gcc= #include <pbc/pbc.h> #include <sys/time.h> #include <string.h> char param[1024] = "type a\n" "q 8780710799663312522437781984754049815806883199414208211028653399266475630880222957078625179422662221423155858769582317459277713367317481324925129998224791\n" "h 12016012264891146079388821366740534204802954401251311822919615131047207289359704531102844802183906537786776\n" "r 730750818665451621361119245571504901405976559617\n" "exp2 159\n" "exp1 107\n" "sign1 1\n" "sign0 1"; int main(int argc, char **argv) { //宣告各個參數的型態,預設為 0 pairing_t pairing; element_t g; element_t h,h2; element_t r,r2; element_t U, U2, V, V2; element_t rst, rst2; // 計算 param 的大小 size_t count = strlen(param); //將 param 的資料放入 pairing 中, 大小為 count pairing_init_set_buf(pairing,param,count); //告訴電腦哪些 參數 屬於哪個 pairing element_init_G1(g, pairing); element_init_G1(h, pairing); element_init_G1(h2, pairing); element_init_Zr(r, pairing); element_init_Zr(r2, pairing); element_init_G1(U, pairing); element_init_G1(U2, pairing); element_init_G1(V, pairing); element_init_G1(V2, pairing); element_init_GT(rst, pairing); element_init_GT(rst2, pairing); element_random(g); element_random(r); element_random(r2); //模擬資料庫 char data[5][1024] = {"銀行","信用卡","免費","高額獎金","優惠"}; char data2[1024] = ""; printf("輸入要和資料庫比對的詞:"); scanf("%s",data2); element_from_hash(h2, data2, strlen(data2)); int flg = 0; //逐詞比對 相等性測試 for(int i=0;i<5;i++){ element_from_hash(h, data[i], strlen(data[i])); // equality test element_pow_zn(U, g, r); element_pow_zn(U2, g, r2); element_pow_zn(V, h, r); element_pow_zn(V2, h2, r2); pairing_apply(rst,U,V2,pairing); pairing_apply(rst2,U2,V,pairing); if(element_cmp(rst,rst2) == 0) { flg = 1; break; } } printf("比對結果: "); if(flg) printf("可能是詐騙\n"); else printf("應該不是詐騙\n"); return 0; } ```